Embedded font


#1

I've got code to load an embedded font using the createSystemTypefaceFor() function, which works fine on OSX and Linux.

However, the very same code and font file do not create the expected font, on Windows.

I suspect that the problem has to do with me using an OTF font.  In any event, the code looks like:

Typeface::Ptr tface = Typeface::createSystemTypefaceFor(fntdata->buf, fntdata->len);
Font *f = new Font(tface);

(clearly, 'fntdata' is my own buffer class, but that's not important).

The font which I'm using is "Quicksand Light" from here: http://www.fontsquirrel.com/fonts/quicksand


#2

On Windows some stupidity in the win32 font functions mean that the embedded ones can only be loaded from simple TTF formats - search the code for TTFNameExtractor if you want a fuller explanation of why that is...


#3

Oy.  I saw that, but hoped (!) that I could use OTF fonts.  After all, Windows does allow them and know how to use them.

OK, for now it's a "note" for my users, just like the inability to play MP3 encoded audio (though OGG is fine)


#4

There's a nice 'libotf' library, but it's GPL...


#5

Well, if you can figure out some hacky (but not too hacky!) code to the TTFNameExtractor stuff that can pull the correct name out of your file, it should work, and I'd be happy to add that!


#6

ok, it may be worth my time, since no-otf is a pretty big restriction these days.


#7

The problem is something else, because the ttf code in fact does give the correct font name.

'otfinfo -i' says:


Family:              Quicksand
Subfamily:           Light
Full name:           Quicksand Light
PostScript name:     Quicksand-Light
Version:             1.002
Unique ID:           AndrewPaglinawan: Quicksand Italic: 2008
Designer:            Andrew Paglinawan
Designer URL:        www.andrewpaglinawan.com
Manufacturer:        Andrew Paglinawan
Trademark:           Quicksand Bold is a trademark of the Andrew Paglinawan.
Copyright:           Copyright (c) 2011, Andrew Paglinawan (www.andrewpaglinawan.com), with Reserved Font Name "Quicksand".
License URL:         http://scripts.sil.org/OFL
License Description: This Font Software is licensed under the SIL Open Font License, Version 1.1. This license is available with a FAQ at: http://scripts.sil.org/OFL
Vendor ID:           pyrs

and the ttf info code says 'Quicksand Light'


#8

So... any clues?


#9

If the name's correct and the win32 function fails to load it then no, I'm afraid I've no more clues!


#10

Could it possibly be a 'leading or trailing whitespace' problem?


#11

Seems unlikely. Is there any leading or trailing whitespace?


#12

Not that I can see.


#13

I have just discovered the same problem lol

However, I have been able to use the specific typeface I wanted using http://onlinefontconverter.com/ to convert the font file from OTF to TTF.