I have a little function which I can call with several fonts in order of preference, similar to how you’d do it in CSS, and the function will fallback to a system font if it can’t find any of the included fonts.
[code]
appSetFont( {'FooFont', 'BarFont', 'Helvetica'} )
function appSetFont(fontNames)
fontNames = misc.toTable(fontNames)
app.defaultFont = nil
if fontNames ~= nil then
local availableFontNames = native.getFontNames()
for i = 1, #fontNames do
if misc.inArray(availableFontNames, fontNames[i]) then
app.defaultFont = fontNames[i]
break
end
end
end
if app.defaultFont == nil then app.defaultFont = native.systemFontBold end
end
[snip]
function inArray(array, value)
local is = false
for i, thisValue in ipairs(array) do
if thisValue == value then is = true; break end
end
return is
end
[/code]
[import]uid: 10284 topic_id: 14122 reply_id: 52764[/import]