Thu 31 Aug 2017 07:54:56 AM UTC, comment #2:
While I am not familiar with the internals of the PDF or Postscript format, PDFium uses the Adobe Glyph List for a reverse lookup heuristic from glyph IDs in a PDF to map back to a unicode char sequence. See https://github.com/adobe-type-tools/agl-specification
AFAIK, PDFs can have aggressively subsetted fonts, only storing a minimal, sparse glyph set, and may lose any similarity with the CMAPs of the original font used when creating the PDF document.
In PDFium, this is done through FXFT_unicode_from_adobe_name and FXFT_adobe_name_from_unicode functions in
https://cs.chromium.org/chromium/src/third_party/pdfium/core/fxge/freetype/fx_freetype.cpp?sq=package:chromium&l=56
These lookup functions make use of FreeType's ft_adobe_glyph_list structure, as well as the ft_get_adobe_glyph_index lookup function from pstables.h.
By contrast, FT_Get_Name_Index retrieves a glyph ID for a glyph name for a specific font, FT_Get_Glyph_Name performs a glyph id lookup given a glyph name. However, neither of these functions attempt to map back to a unicode codepoint sequence. That's why they are not suitable for this specific mapping purpose in PDFium.
PDFium would benefit if the optimized Adobe Glyph List information that FreeType stores would be externally available.
Thanks in advance if there would be any volunteer considering to expose such an API.
|