Custom Fonts

Hi, I'm trying to add a custom font to my app, and I keep getting a warning that says 'Could not load font: "Segment14". Using default font'.

In my main.lua I have the following code:

1
2
3
4
5
6
7
8
9
local fonts = native.getFontNames()
fontname = ""
 
for i, v in ipairs (fonts) do
        if string.find(v, "egment", 1, true) then
                fontname = v            
        end
end
print ("font = " .. fontname)

@slicedpan, I do not know why the Segment14 font is not working for you, but instead of just dumping it to the console, I modified it a bit to view all the fonts available on the computer or the device

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
local fonts = native.getFontNames()
 
local scr = require("scrollview")
--local scroll = display.newGroup()
local scroll = scr.new()
 
local i,v, counter, text
 
for i,v in pairs(fonts) do
        
        text = display.newText(scroll, v,10,i*30,v,40)
                text:scale(0.5,0.5)
                text:setReferencePoint(display.TopLeftReferencePoint)
                text.x=10
                text.y = i*30
                
                --if i > 100 then break end
end
views:1613 update:2011/9/29 9:22:17
corona forums © 2003-2011