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.
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.
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.
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.
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.