Using Fonts

I’ve downloaded from Google the PT Serif font, which comes as 4 tff files. I’ve placed these files in my project folder and coded them as such:
serifFont = { text = “”, font = “PTSerif-Regular.tff”, fontSize = 12, align = “left” }
serifFontBold = { text = “”, font = “PTSerif-Bold.tff”, fontSize = 12, align = “left” }
serifFontItalic = { text = “”, font = “PTSerif-Italic.tff”, fontSize = 12, align = “left” }

Here’s the problem I’m running into. When I call the font as Text options, only the regular style is displayed.
entryTexts[lineIndex] = display.newText( serifFont ) – This displays with the regular style.

entryTexts[lineIndex] = display.newText( serifFontItalic ) – This also displays with the regular style, even though the option is for italic.

However, when I don’t call the regular or bold style, JUST the italic style, then it does display in italics.

Am I going about this wrong? I’ve done a lot of searching, but have basically come to the conclusion that even though people asked these questions back in '12, font styles are still a pain in '20.

@scottabroughton - in your post, you use this line…

entryTexts[lineIndex] = display.newText( serifFontItalic )

What does the entire line look like? You can’t just pass the fontName into display.newText without telling it what you want to display and where. Right?

Assuming that you did include some text and a location. I would hope that you were incrementing the lineIndex. Also, I think that the actual font names should end in .ttf, not .tff.

It is EXTREMELY common to have problems using downloaded fonts, especially if they are in the same family.

My usual fix is to, open the font in a font editor and edit the font info. Make sure the ‘Font Family’ has the same value as ‘Full Name’.

  1. Using this editor:,
  2. You can load your fonts, then click Settings -> Font Info,
  3. Then copy Full Name’s value and paste it into ‘Font Family’,
  4. Then click confirm,
  5. Then click the ‘ttf’ button to download the modified file, and finally
  6. Use that file in your game.

At the end of the day, each font must have a unique name to ensure it will get looked up properly.

Here is a sample show the ‘issue’ and the ‘fixed’ results:




Sorry for not posting enough of the code. Of course I have additional lines that set the .text and .x properties. The text displays for me, it just doesn’t use the italic font I’ve specified. It defaults to the regular style of the font family.

Yeah, the .tff was a typo in my post, not in the code. And yes, I increment the lineIndex.

The text displays fine, in the correct location. The problem is that, although I want to use the italics style of the font, it defaults to the regular style of the font family. IOW, it only allows me to use one style of the font family in my app, even though I’ve separated them in different font options names and have included all the ttf files in my app folder.

Can you provide me with two lines of code? 1 line that loads the font into the proper variable and another line that displays the text?

Sure. I’m not having trouble with the lineIndex or what I assign to the .text property. But because I use the regular style of this font, when I try to use the italics style, it defaults to the regular style.

serifFontItalic = { text = “”, font = “PTSerif-Italic.ttf”, fontSize = 12, align = “left” }
entryTexts[lineIndex] = display.newText( serifFontItalic )
entryTexts[lineIndex].text = parts[lang][entryTable[entryIndex].speech]

Thank you! Your explanation and fonts have helped me fix my font family problem. I imagined the fonts from the same family all needed different names (not just file names), but I didn’t know how to go about it. I have another font that I’ll be doing the same.