Skip to content

[t1cid] Improve cid_get_cid_from_glyph_index().

This is a proposal to separate the part loading the FD number and the offsets in the cid_load_glyph() as a separated function, cid_compute_fd_and_offsets(), and use it in cid_get_cid_from_glyph_index(), to exclude the CID without valid entry. This patch only cares for the conventional process with no incremental loading feature. As discussed in the mailing list (the thread "ftdump can show the CID registry, ordering, and supplement?", and the thread "any small software to test the incremental loading feature?" ), I didn't implement the corresponding part for the incremental loading because of the lack of the testing code and the pragmatic use cases.

Currently, get_cid_from_glyph_index() is a dummy function that returns the passed glyph index as the corresponding CID. The basic algorithm is correct but does not check the requested CID points to finite glyph data. Like some cmap in TrueType fonts use a GID 0xFFFF to mean that the glyph is unavailable, some CID-keyed fonts use an invalid fd number (and 0-byte glyph data) to represent the lack of the glyph data. By using cid_compute_fd_and_offsets(), such cases can be detected before processing the loaded glyph data. As a result, FT_Get_CID_From_Glyph_Index() can work the samely for subset CIDFontType 0 fonts and subset CFF fonts.

The modified ftdump to compare the time between FT_Glyph_Load() and improved FT_Get_CID_From_Glyph_Index() is here: https://gitlab.freedesktop.org/mpsuzuki/ft2demos-mps-wip/-/commits/test-t1cid-separate-loaders-of-fd-offsets

"ftdump -c" uses FT_Get_CID_From_Glyph_Index() only, and "ftdump -c -L" uses FT_Glyph_Load() additionally. The profiled data are attached here; profiled data of "ftdump -c WadaGo-Bold" and profile data of "ftdump -c -L WadaGo-Bold". The time of "ftdump -c -L" is 1.03sec, but that of "ftdump -c" is < 0.01sec. Most of the time for "ftdump -c -L" is spent in the cf2_xxx functions; therefore, the introduction of cid_compute_fd_and_offsets() improves FT_Get_CID_From_Glyph_Index() well without recognizable slowdown.

Merge request reports