Issue with incorrect fonts

I’ve got a project with a simple main.lua (below) and a fonts folder with the Roboto font in bold, italic and regular. The loop in main.lua should create text objects with a font style corresponding to the input string. Unfortunately there is a mismatch, as in the picture below. There’s nothing coming up in the console, so I’m at a loss as to what the problem could be. I would appreciate any suggestions, thank you.


local fontStyles = {"regular", "bold", "italic"}

local function randomStyle() 
	return fontStyles[math.random(1,3)]

for i = 1, 9 do
	local style = randomStyle()
	local font = "fonts/Roboto-"
	local text = display.newText({text = style, font = font, fontSize = 22})
	text.anchorX = 0
	text.y = i*30


Bug (229.1 KB)

I am using Roboto in one of my projects, but my Font Filenames are Capitalized.


Hope this helps.

  1. If you have Roboto Fonts installed in your system you may be getting a name lookup conflict. - Suggestion. If using custom fonts, use fonts not installed in system if you can. If you can’t avoid it, use files with exactly the same name as those used to install the font(s). See #2 below.

  2. Renaming the files may cause issues. Go with original font-file names as downloaded.

  3. You’re missing the “.ttf” in the filenames so I suspect it is trying to find a known/installed font that matches the name.

See modified version of your example (especially mod2):

Thanks for the replies. I tried a bunch of different fonts (with original names and .ttf extension), but kept running into the same problem. It works fine with Light, Medium, and Black, but not with Regular, Bold, and Italic. The one small clue I’ve noticed so far is that the first one is always right, and if the next one is the same style, it will be right too, and so on until the style changes. I’ll continue investigating tomorrow, and let you know if I find anything.