Page 1 of 1

Using different font for special characters

Posted: Thu Apr 06, 2017 10:59 am
by ckabstein
Hi all,

We are using a truetype font for PDF output that doesn't support all Unicode entities, meaning it cannot display   for non-breaking thin spaces.

I have tried to use a different font for this case, but it seems that this doesn't work properly.

For example, the PDF output I get:

test&#202f;test test - i. e. the word "test" in the middle still uses the different font. Can this be solved, or do we need to switch to a different font - which is the last option really?

What I did to achieve this:
In font-mappings.xml, I added a new physical font element:

Code: Select all


<physical-font char-set="Spaces">
<font-face>Arial Unicode MS, NotoSans</font-face>
</physical-font>
And in fop.xconf, I even embedded the font:

Code: Select all

  <font kerning="yes" embed-url="Arial/ARIALUNI.TTF">
<font-triplet name="Arial" style="normal" weight="normal"></font-triplet>
</font>
I also customized the l18n files, for example, in de_DE.xml, I added:

Code: Select all


 <alphabet char-set="Spaces">
<!-- Non-breaking space -->
<character>&#xA0;</character>
<!-- Non-breaking thin space -->
<character>&#x202f;</character>
</alphabet>
I think I'm heading in the right direction, but somehow I'm at a dead end now.
Could you help me, please?

Thanks,
Chris

Re: Using different font for special characters

Posted: Thu Apr 06, 2017 4:06 pm
by Radu
Hi Chris,

Honestly we have never tried this on our side. What you're doing looks like the right thing to do. So you have "de-DE" set as xml:lang on all topics and maps, right?
If you set the "clean.temp" param in the transformation to "no", then look at the generated "topic.fo" from the transformation temporary files folder does your customization seem to be taken into account?
How about if instead of trying to define those particular ranges, you could have defined for your entire content a sequence of font families in which the arial unicode would have been the fallback font? Something like:

Code: Select all

 <font-face>YourCoolTTFFont, Arial Unicode MS</font-face>
in this way glyphs missed by the regular font would be caught and displayed by Arial Unicode MS (if installed on the system).

Regards,
Radu

Re: Using different font for special characters

Posted: Mon Apr 10, 2017 4:26 pm
by ckabstein
Hi Radu,

I've tried out several things now and checked the topic.fo file. It seems like my customizations are ignored.

The topic.fo file doesn't show any additional inline elements with font-family attributes, but the PDF shows the output that I've already mentioned. The standard unicode &#xA0; looks OK in the output, but shows no inline elements with font-family attributes. The unicode for thin non-breaking spaces (&#x202f;) is replaced by a box in Text mode.

If I add the entities to one of the default sections in the font-mappings.xml file, the topic.fo file shows additional inline elements with font-family attributes, but in Text mode, for the thin non-breaking spaces entity, I see a box again, and the other non-breaking space looks OK. In the PDF output, the "box" entity isn't inserted at all, though. Oddly enough, the unicode fonts that I've tried out in this case, don't seem to know &#x202f;.

Is there anything else that I could try?

Thanks,
Christina

Re: Using different font for special characters

Posted: Mon Apr 10, 2017 4:33 pm
by Radu
Hi Christina,

I'm not sure. If you want at some point you could share with us the PDF customization (support@oxygenxml.com) and we could try to find some time to look into it.
You mentioned at some point:
but in Text mode, for the thin non-breaking spaces entity, I see a box again
The way in which Oxygen renders the characters is controlled by our Preferences->Fonts page so it is not related to the publishing font-mappings changes you are making.

Regards,
Radu

Re: Using different font for special characters

Posted: Mon Apr 24, 2017 12:51 pm
by ckabstein
Hi Radu,

any update on this one? I've sent a support request.

Best,
Christina

Re: Using different font for special characters

Posted: Mon Apr 24, 2017 10:53 pm
by Radu
Hi,

Thanks for the samples.
Adding my investigation here for completeness:
I started looking a little bit into this problem.
I have a simple XSL-FO file which has this particular "Narrow No-break
Space" in its contents. I tried setting any type of font-family to the
fo:root (for example font-family="serif") but I still cannot get this to
render properly with Apache FOP, that "#" shows up.
I published the same XSL-FO with the commercial RenderX XEP and it can
render without any problems this particular character.
So I think that Apache FOP has a particular problem with this character,
looks like a bug.

Regards,
Radu

Re: Using different font for special characters

Posted: Tue Apr 25, 2017 11:17 am
by ckabstein
Thanks, Radu.

So maybe we should think about a different font then.

Best,
Christina

Re: Using different font for special characters

Posted: Tue Apr 25, 2017 9:06 pm
by Radu
Hi Christina,

As I mentioned in my previous post using a different font did not seem to help, for me it looked like a problem in the open source FO processor we use by default. Maybe for comparison you should try to download a trial version for a commercial FO processor like Antenna House or XEP and try to produce PDF from Oxygen using one of them:

https://www.oxygenxml.com/doc/versions/ ... shing.html

Regards,
Radu

Re: Using different font for special characters

Posted: Wed Apr 26, 2017 4:26 pm
by ckabstein
Hi Radu,

Thanks for your advice, and I will look into Antenna House and XEP once I get the chance.
Nevertheless, I have checked out Noto Sans by Google as the default font, without defining another physical-font char-set, and that seems to do the trick for now. I haven't tested all characters yet, but it's looking good, until other issues appear from out of nowhere. Unfortunately, that font doesn't provide enough variation, only regular, bold, bold-italic, and bold-regular. It would be great to find a unicode truetype font that provides at least also a medium style. One day, hopefully. :-)

Christina