Skip to main content
Participant
Sep 2, 2022 5:38 AM UTC
Answered

Cannot change in text field the .textFont to serif font

Hello,

I am generating PDF with LuaLaTeX engine.

In my code I embed the following JavaScript command to change the font in text filed:

this.getField('fldname').textFont = 'fntname';

When the fntname is set to a sans-serif font name, like Calibri (on Windows), this command changes the font, but when it is set to a serif font name, like Times New Roman (on Windows), this command do nothing.

What is the difference between serif and sans-serif fonts in text fields?

This topic is closed to new replies. Start a new post to keep the conversation going.
bebarth
bebarthCorrect answer
Community Expert
Sep 3, 2022 4:01 PM UTC

To know the exact writing of the font you must use, set the field with the right font and type in the console:

console.println(this.getField("fldname").textFont);

For "Times New Roman" you will get: TimesNewRoman

For "Courier Std Bold Italic" you will get: CourierStd-BoldOblique

...

@+

 

2 replies

bebarth
Community Expert
bebarthCommunity ExpertCorrect answer
Community Expert
Sep 3, 2022 4:01 PM UTC

To know the exact writing of the font you must use, set the field with the right font and type in the console:

console.println(this.getField("fldname").textFont);

For "Times New Roman" you will get: TimesNewRoman

For "Courier Std Bold Italic" you will get: CourierStd-BoldOblique

...

@+

 

Translate
Legend
Sep 2, 2022 7:35 AM UTC

You're probably using the wrong name. The internal font name is sometimes luckily the name you see in a font menu, mostly not. Read under "Use of arbitrary fonts" in the JS API Reference for how to obtain the true name to use.

Translate