Pregunta

I have a Qt 4.8 app with it's front end UI all done via QML in a QDeclarativeView.

On the (original) Linux version of the app, there are a couple of fonts it uses in QML in Text items via specifying

font.family: "ReykjavikOne OT AGauge"

or

font.family: "ReykjavikOne OT CGauge"

and these work as expected (the CGauge one is a sort of fat, bold version).

However, on the Mac port, both these seem to fall back to some ugly default fallback sans font. But using

font.family: "ReykjavikOne OT"

does get the "AGauge".

On the Linux system, fc-list | grep ReykjavikOne gets me

/usr/share/fonts/opentype/ReykjavikOneCGaugeItalic.otf: ReykjavikOne OT,ReykjavikOne OT CGaugeItalic:style=CGaugeItalic
/usr/share/fonts/opentype/ReykjavikOneCGauge.otf: ReykjavikOne OT,ReykjavikOne OT CGauge:style=CGauge
/usr/share/fonts/opentype/ReykjavikOneAGauge.otf: ReykjavikOne OT,ReykjavikOne OT AGauge:style=AGauge
/usr/share/fonts/opentype/ReykjavikOneAGaugeItalic.otf: ReykjavikOne OT,ReykjavikOne OT AGaugeItalic:style=AGaugeItalic

and on the Mac, FontBook shows the 4 styles listed as sub items under a single "ReykjavikOne OT" entry. The CGauge font seems to be perfectly usable in other apps on the Mac, so I'm assuming this is an issue peculiar to Qt/QML.

There just doesn't seem to be any QML Text/font mechanism (at least, not one I can discover) by which I can select a font style with style name "CGauge". Messing around with bold/font-weight just seems to get me a bolder AGauge, or the default font.

Much the same applies to QML RichText content too. Text with <style></style> elements containing font-family: 'ReykjavikOne OT CGauge' work fine on Linux, but on Mac it reverts to the fallback font and 'ReykjavikOne OT' is the best can be done, obtaining the AGauge. (Adding a font-weight: bold; does get a bold AGauge, but CGauge is noticeably fatter).

Both Mac and Linux (Debian/Wheezy) systems have the fonts installed from the same .otf files.

What's my best hope to work round this issue and get the CGauge style of the font to display on the Mac as intended? (NB I'm a novice when it comes to fonts, and Macs).

¿Fue útil?

Solución

I'm afraid the core problem is the font metadata. The AGauge/CGauge bits should never have leaked in the font face name. While many font editors let font authors put pretty much any string they want in the face (style) field, in practice there are strict rules to respect if you want applications to make sense of them.

A few years ago Microsoft got serious about using css-like styling for its apps and got bitten by all the fonts with inventive naming out there. So they wrote strict guidelines about what could actually work in apps, with buy-in from Adobe and other major font players (Note that Microsoft is co-maintainer of the OpenType spec and uniscribe is pretty much the reference OpenType engine). Your font does not respect those guidelines

Please read the Microsoft whitepaper. It describes the kinds of font naming Microsoft manages to salvage, the heuristics used, and the canonical names the heuristics produce. A good font will not hit those heuristics because its naming will already use the canonical forms and need no correction. A bad font will at best have its naming silently corrected on a Microsoft platform. On other platforms such as Linux or OSX there will be no correction so wild naming will produce wild results, including the failures you hit.

https://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-components-postattachments/00-02-24-90-36/WPF-Font-Selection-Model.pdf http://blogs.adobe.com/typblography/typotechnica2007/Font%20names.pdf

For example, your fontconfig output shows ReykjavikOneCGauge.otf is declaring either ReykjavikOne OT or ReykjavikOne OT CGauge (in that priority order) as family names, and CGauge as face name. According to the Microsoft whitepaper CGauge is not a valid face name so the font should have used ReykjavikOne OT CGauge as family name, and build a face name from the appropriate WWS (Weight Width Slope) qualifiers. Unfortunately for you, it declares ReykjavikOne OT (without CGauge) as primary name, and CGauge as useless face name.

Note that older software does not read those new Opentype naming fields, so regardless of what the author puts there, it may sort of work as long as your font stack is ancient enough.

Otros consejos

I managed to work round this by opening the ReykjavikOneCGauge.otf file in fontforge on the Debian system, changing any mention of the font name / font family name to ReykjavikCGauge, of which this font is the "normal" style, regenerating a new ReykjavikCGauge.otf and installing that on the Debian and Mac systems. On the Mac it now shows up as a completely separate font from the original ones, and using font-family: ReykjavikCGauge can now access it as expected.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top