Skip to main content
Participant
September 2, 2022
Answered

Cannot change in text field the .textFont to serif font

  • September 2, 2022
  • 2 replies
  • 311 views

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 has been closed for replies.
Correct answer bebarth

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
September 3, 2022

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

...

@+

 

Legend
September 2, 2022

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.