freemint / fvdi

fVDI fork with additional fixes and drivers.
https://fvdi.sourceforge.io
7 stars 6 forks source link

Set correct full font name and postscript name for scalable fonts #24

Closed chrisridd closed 2 years ago

chrisridd commented 2 years ago

Concatenating the family_name and style_name produces incorrect results for some fonts. We get better results by asking Freetype for the underlying TT_NAMEID names.

e.g.

family_name style_name TT_NAME_ID_FULL_NAME
Palatino Linotype Regular Palatino Linotype
Franklin Gothic Book Regular Franklin Gothic Book
Franklin Gothic Medium Regular Franklin Gothic Medium
DejaVu Sans Mono Book Deja Vu Sans Mono

Papyrus seems to do a better job with this patch than it does with NVDI. e.g. with NVDI you get one face called "Franklin Gothic" with styles "Regular" and "Regular". You get another face with the same name with styles "Italic" and "Italic". You get a face called "Palatino Linoty" and another face called "Palatino Linotype". Rather strange.

Querying TT_NAME_ID_PS_NAME gives us correct values for the vqt_fontheader() fh_sfntn field. The vqt_fontheader() copyright etc fields can now be filled in using the new code, though they seem a bit inessential.

Most TT_NAMEID values come back as Unicode even though they're generally ASCII, so there's a quick and dirty conversion. macOS has some fonts from Apple using Mac Roman encoded names, so convert those too. Note NVDI completely ignores those Apple fonts.

chrisridd commented 2 years ago

The algorithm in ft2_font_id() still uses family_name and style_name. Changing it to use TT_NAME_ID_UNIQUE_ID might give more "unique" results, but it would break compatibility for documents which used the older font ids. Not worthwhile IMO.