Forum How do I...?

Glyph fallback

rsands
Hi

I think this one has been queried a few times. We are testing unicode support and some font files that we are importing from google dont have certain unicode characters and as such princexml is replacing them with "?" - we have the font-family set to "Abeezee, Arial" - its not trying to fallback to the arial font which does contain the unicode glyph. Is this correct that its not trying the second font? Or am I missing something?

Thanks

Richard
mikeday
It should definitely be using the second font. Which Unicode character is involved? Perhaps it is not in Arial, either. There is a separate font called "Arial Unicode MS" which has a wider character range, if you have it installed.
rsands
The one causing problems is this: http://www.fileformat.info/info/unicode/char/062f/index.htm

Will test now with "Arial Unicode MS" and see where we get to. Is there a way to have a setting for fallback like @prince-glyph-fallback { font: "Arial Unicode MS"; }

This will automate the fallback as such so we dont have to manually set css
rsands
Sorry forgot to mention this is <svg> data we are using so the full code is:

<text style="font-family: 'ABeeZee', 'Arial';font-style: italic;font-weight: ;" text-anchor="middle" y="20" x="184.917843389" text-wrap="" text-wrap-width="369.835686778" text-wrap-x="184.917843389" text-wrap-y="20" text-wrap-line-height="83.33333333333334" text-wrap-caption="بنده" fill="#000000" font-size="83.33333333333334px" text-wrap-dimension="contentDimension"><tspan y="83.33333333333334" x="184.917843389">بنده</tspan></text>
mikeday
Okay this is an Arabic character. Different platforms have different fonts that support Arabic. For example, Times New Roman supports Arabic on Linux and Windows, but not on MacOS X.

Prince includes a fonts.css file in the style directory of the installation. This defines the default serif and sans-serif font families. You can add @font-face rules to this if you wish to use specific fonts. On Windows platforms, it already includes Arial Unicode MS as a last resort font.
rsands
its running on centos 6.6 and msttcorefonts is installed. I tried setting all the font-family inline css to Times New Roman but still get the ? and times new roman should support that?
rsands
Am i correct in saying the system will try use the font-family CSS fonts list first...if they all fail it will then try the prince sans-serif and serif fallback fonts and then as a last resort replace it with a "?" ?

So if i was to get a unicode fallback font and set @font-face serif and sans-serif to that i could make sure it finds it?
mikeday
Yes, that is correct. Make sure to put the @font-face rule near the top of fonts.css, so it is lower priority than the other rules.

I will check the situation with Times New Roman and Arabic.
mikeday
When I checked this document it worked for me on Ubuntu:
<p style="font-family: Times New Roman">&#x62f;</p>
<p style="font-family: Arial">&#x62f;</p>

Perhaps different versions of the Microsoft Core Fonts are getting installed.

Edited by mikeday

rsands
Would it be due to the fact we arent passing the uni code itself in and just the letter?
rsands
Strange...by putting this in the <head> section it fixed the problem and started to work

@font-face {
font-family: sans-serif;
src: local('Times New Roman')
}

@font-face {
font-family: serif;
src: local('Times New Roman')
}

Even despite that being inside of the fonts.css file that ships with the install. even putting times new roman as the css style it was broke. Pity dont know what was causing the problem though
mikeday
That should not make a difference, it all gets turned into the same code point underneath.

Which msttcorefonts package did you install? I can't seem to find it with yum on CentOS 6.
mikeday
Now that is very very strange.
rsands
I have version 2.0.1 installed - even setting it to Arial in the head fixes it...getting stranger lol
mikeday
Are there any other style sheets or declarations involved? Can you recreate the behaviour with a very simple document?
rsands
There is a few @import happening from google fonts. I will debug using the svg and trying without @font-face in the head to see if it does a fallback as it was meant to. Will let you know tomorrow on this test :)

Great help as usual, unreal service!