Open TheGS opened 8 years ago
I dont understand, was there a problem with utf8? This what hummus is expecting
Code in hummus translates utf8 to lists of UCS2 codepoints anyway (in several places in PDFUsedFont, etc.) before calling FreeTypeFaceWrapper::GetGlyphsForUnicodeText() itself, and we wanted some extra control over the output to do our own vertical glyph substitutions, and our own font fallback, etc. before calling Tj() with a glyph mapping list. Calling Tj() with a utf8 string, calls PDFUsedFont::TranslateStringToGlyphs() , which calls UnicodeString::FromUTF8(), and then calls FreeTypeFaceWrapper::GetGlyphsForUnicodeText(). The point of this issue is that the glyph given for a Unicode character by FreeTypeType1Wrapper::GetGlyphForUnicodeChar() is simply the character code itself if the font has a private encoding, and the issue with this is that the private encoding is not necessarily Unicode, and for older fonts, may be limited to 256 entries
Yeah. Sounds like what I did when I wrote a ps engine back when. Tell you the truth I got bored doing it again for PDF-writer, so I relied on free type to do the job, and provided the direct glyph access for whomever is not happy. I think that's as far as I go. Let's leave this open so that others can see the solution that you used. Thank you
We convert to strings of UCS2 codepoints and call FreeTypeFaceWrapper::GetGlyphsForUnicodeText() regardless of the font, and the implementation of FreeTypeType1Wrapper::GetGlyphForUnicodeChar() wasn't actually getting the desired glyph for Type 1 fonts, nor was it reporting if the font did not have a glyph for the given character. Our solution was to convert the UCS2 codepoint to a Postscript glyph name, check that the type 1 font provided a charstring for that glyph name, and then look up the glyph number for the glyph name in the font's private encoding. This let us use the same input to display text as we would for any TrueType or OpenType font, and also let us determine if we needed to switch to a different font (if the original font didn't provide the needed glyph). Sorry, I don't have code to share at the moment. We created our map of UCS2 to Postscript glyph names using data from here: https://github.com/adobe-type-tools/agl-aglfn/