Unable to add/apply custom fonts to Document Template

2
Hi,   I migrated an application from Mx 7.23.5 to Mx8.7. This application is using document templates to generate PDFs for official documents in several languages, including the likes of Polish and Hungarian. For these languages, some of the special characters now suddenly appear as ‘#’. Investigation revealed that in Mx8.7 I suddenly don’t have Arial anymore as a font and Mx using Helvetica instead (Courier and Times are ugly and mess up the entire layout) I tried adding Arial as a custom font using the description from Mendix : https://docs.mendix.com/refguide/style I tried this both on the resources folder (as suggested) and when that did not work, on the runtime/lib folder of the Mendix version. Both actions resulted in exactly no change at all. The font did not become available in my modeler. The font was not applied when I set it as custom styling on a label. Simply put, the fonts are not recognised and I am left with no option to generate my PDFs. Release notes don’t suggest this to be addressed in later versions.    Any help would be greatly appreciated.   Kind regards,
asked
4 answers
2

Have you been able to get this to work, because we are currently running into the same issue. It seems that the custom fonts are not applied, even when adding the embedding-mode=”full” part. are the triplet names required to equal the actual font names, or can this just be anything as long as the name matches?

Edit: Seems i was to quick, i found out why it was not working for me, the renderer seems to lower case your triplet names, but only runtime. e.g. if you use font-family:Arial in your document template it will search for a font-triplet with the name arial. Or in my case i was looking for Klavika RG, setting the loglevels to trace gave me the following warning:

Font "klavika rg,normal,400" not found. Substituting with "any,normal,400".

To fix this i simply changed the font-triplet name to lower case in my fop.xconf. While i am not sure on what the documentation of fop states of using triplet names capital letters, it feels kinda buggy to lower-case just the input.

answered
2

I can confirm that embedding fonts used to work in the past. I doubt that Mendix made any changes to this functionality recently.

You can find a fully configured example using “arial” in this blog post
https://www.notion.so/gajduk/Generating-PDF-A-compliant-documents-01ff7b8462e0404eac21b178784cae7d

Maybe you can compare the two and see what is the difference? a
 

 

answered
1

I followed  the documentation, but the key to get this working seems to be in the embedding-mode attribute as also stated in the blog post.

 

<font kerning="yes" embed-url="arial.ttf" embedding-mode="full">

          <font-triplet name="arial" style="normal" weight="normal"/>

          <font-triplet name="arialMT" style="normal" weight="normal"/>

        </font>

 

answered
1

 

 

Thanks, after spending lots of time R&D to make PDF display Chinese font, instead of ‘###’.

This is the result in PDF:

 

Additional Note:
Changing the Default Log Level from ‘Info’ → ‘Trace’ (allow me to understand regarding how Mendix read the font-triplet name (eg. lower-case “arial unicode ms”, instead of “Arial Unicode MS”)

 

fyi, you will need to copy the "original fop.xconf”, and paste into your resource.
 →  “yourproject-main\resource\”

 

File path: ...yourproject-main\resources\fop.xconf

<font kerning="yes" embed-url="arial-unicode-ms.ttf" embedding-mode="full">
	<font-triplet name="arial unicode ms" style="normal" weight="normal"/>
</font>

 

Overview on how I apply the “arial unicode ms” to diplay Chinese word

you need to download the “Arial Unicode MS” from the internet, and then rename the file to “arial-unicode-ms.ttf” (easier to use this name)

answered