Two potentially easy to answer questions!

Hi guys!

Two things I’m struggling with at the moment are the following:

  • Stretching a background image to fit the entire screen of any device (original image doesn’t even fill whole screen).
  • I want to place a title text at the top of my screen but in a fancy like text. Is there a list of fonts I can choose from?

Thanks for any help you have! [import]uid: 35535 topic_id: 29296 reply_id: 329296[/import]

the total width of your screen is display.screenOriginX*2+display.contentWidth

the left X of your screen is display.screenOriginX

the total height of your screen is display.screenOriginY*2+display.contentHeight

the top Y of your screen is display.screenOriginY

so - xScale your image at (display.screenOriginX*2+display.contentWidth)/Image.width
yScale your image at (display.screenOriginY*2+display.contentHeight)/Image.height

and place it at display.screenOriginX, display.screenOriginY
[import]uid: 160496 topic_id: 29296 reply_id: 117789[/import]

The list of fonts available natively vary from android to iOS. You can us your own custom fonts(just use the search and there is a blog post that covers it) but really, for a title, I would just make a fancy image and use that. There are limits to how fancy you can make text look, even with custom fonts :slight_smile: [import]uid: 147305 topic_id: 29296 reply_id: 117799[/import]

I’ll follow up on the font comment that even in Android the fonts are going to vary. What you may find on the Kindle Fire won’t be the same as you will find on a Nook. There is probably also some variance between OS versions too.

You can get a list of fonts using this little block of code. I wrote a “GetInfo” app to dump this info on the device:

local v = {}  
v[1] = display.newText(system.getInfo("name"),0,0, "Helvetica", 18)  
v[2] = display.newText(system.getInfo("model"),0,0, "Helvetica", 18)  
v[3] = display.newText(system.getInfo("platformName"),0,0, "Helvetica", 18)  
v[4] = display.newText(system.getInfo("platformVersion"),0,0, "Helvetica", 18)  
v[5] = display.newText(system.getInfo("build"),0,0, "Helvetica", 18)  
  
for i = 1, #v do  
 v[i]:setReferencePoint(display.TopLeftReferencePoint)  
 v[i].y = i \* 20  
 v[i].x = 10  
end  
  
local fonts = native.getFontNames()  
  
local fontStr = {}  
local i = 1  
local col = 1  
local row = 1  
for k, v in pairs(fonts) do  
-- print(k,v)  
 fontStr[i] = display.newText(v,0,0,v,14)  
 fontStr[i]:setReferencePoint(display.TopLeftReferencePoint)  
 fontStr[i].y = row \* 18 + 128  
 fontStr[i].x = 10 + (col - 1) \* 290  
 col = col + 1  
 if col \> 2 then  
 col = 1  
 row = row + 1  
 end  
 i = i + 1  
end  

drop that in a main.lua, and build it for the device you are interested in.

WARNING… It will be really slow to load in the Corona simulator because it picks up all of your computer’s fonts and that’s a VERY VERY long list.

Now if want fancier fonts, go to a free font site, find a font you like that is free to use for commercial products and use it. [import]uid: 19626 topic_id: 29296 reply_id: 117878[/import]

I wonder if there are any “core” fonts that exist on every system. Like “Times Roman” or “Arial”? [import]uid: 160496 topic_id: 29296 reply_id: 117892[/import]

See this site:

http://iosfonts.com/ [import]uid: 19626 topic_id: 29296 reply_id: 117902[/import]