stb icon indicating copy to clipboard operation
stb copied to clipboard

support wingding.ttf font in stb_truetype

Open nothings opened this issue 3 years ago • 5 comments

Discussed in https://github.com/nothings/stb/discussions/1282

Originally posted by Jony01 January 31, 2022 I've trouble with initialisation of some fonts by function stbtt_InitFont which return zero

List of unopenable font on my windows:

"Bookshelf Symbol 7" "Marlett" "MS Outlook" "MS Reference Specialty" "MT Extra" "Symbol" "Webdings" "Wingdings 2" "Wingdings 3" "Wingdings" fonts.zip

Rest 270 true type fonts works fine.

Is there some restriction why I can't open this fonts?

image

nothings avatar Jan 31 '22 18:01 nothings

All of the fonts in fonts.zip are "symbol" fonts which use a microsoft-specific mapping system from character identifiers (which aren't Unicode) to determine how to draw it. Because it's not unicode stb_truetype doesn't support it. I'm not sure why this has never come up before, given how long stb_truetype has been out.

To fix it, we need to add support for cmap platformID=3 (Miicrosoft) encodingID = 0 (symbol font). Should probably make the logic first check for a non-symbol encoding, only check for 3/0 if it doesn't find a regular one first.

nothings avatar Jan 31 '22 18:01 nothings

You should fix it so that you can specify what encoding you want and does not have to be Unicode. (For compatibility purpose, Unicode can be selected by default, but please to fix it to allow the caller to override the choice of encoding, e.g. by adding a separate function for this purpose)

zzo38 avatar Aug 29 '22 00:08 zzo38

You should fix it so that you can specify what encoding you want and does not have to be Unicode. (For compatibility purpose, Unicode can be selected by default, but please to fix it to allow the caller to override the choice of encoding, e.g. by adding a separate function for this purpose)

I don't think there are enough fonts with multiple encodings for this to be worth doing. Just doing Unicode if available, then whatever the font supplies if not, should address all known fonts.

nothings avatar Aug 29 '22 00:08 nothings

I don't know if any fonts do have multiple encodings, but I would have wanted full support if they do, and full support for whatever encodings the font has even if they are not Unicode (even if it also has Unicode, too). I know, because I would want to support non-Unicode fonts (even if they use an encoding which stb_truetype does not recognize even in its enum lists). Possibly some encodings might have only some characters (this potentially includes Unicode), and the caller might want to work with specific encodings if they are available.

Also, is there the possibility of making pure monochrome bitmaps?

zzo38 avatar Aug 29 '22 02:08 zzo38

It doesn't make sense to add API complexity for a feature that no known fonts require.

There are no plans to support bitmapped fonts.

nothings avatar Aug 29 '22 02:08 nothings