Reputation: 2921
I am working on a printer driver sample. In this sample i am hooking to DrvTextOut() call. when the call back is called i get the text as Glyph indices. i want to convert these Glyph indices to Unicode character.
please let me know how to convert it.
Upvotes: 1
Views: 2659
Reputation: 138960
If you mean you need to handle the case where STROBJ->flAccel has SO_GLYPHINDEX_TEXTOUT set, then see this answer here from Microsoft's Bobby Mattappally:
http://www.winvistatips.com/glyph-handles-drvtextout-t183048.html
There is not always a 1:1 mapping between glyph indices and character codes and vice versa. This is expecially true with international character sets like Hebrew, Arabic etc.
So once you get this as SO_GLYPHINDEX_TEXTOUT, your driver should handle the glyph itself instead of trying to convert it back to Unicode.
Upvotes: 1
Reputation: 477150
In general the answer is "you cannot". In PDFs, for instance, you might have an embedded character map that lets you look up the characters corresponding to the glyphs (e.g. if you used the cmap package with pdfLaTeX to make the the PDF), but glyphs are private to a font, and there may be many glyphs that get used for the same character and vice versa, thanks to the magic of the GSUB tables.
If you're really desperate and have access to the font in question, you could try to build a character map yourself from the font file, but you better know which font you are currently looking at.
Edit: I think your question is tagged poorly; are you referring to this function? Perhaps the FONTOBJ structure that you already own exposes some sort of character map of the font, I wouldn't know.
Upvotes: 1