Can anyone install this on an Android device and post some results?

Hi everyone!

I would like someone to install this android app and post a screenshot of it here.
Reason for this is that I want the font to be right.

Android apk:
http://d.pr/f/ApPO

-Oskar [import]uid: 24111 topic_id: 26833 reply_id: 326833[/import]

HI,

it’s not working, no bebas font only system font. [import]uid: 8303 topic_id: 26833 reply_id: 108913[/import]

Okay, thanks for testing!

What should the code look like to make it work?

Current code:

main.lua

io.output():setvbuf('no')  
print();print("");print()  
   
-- The main group  
mainGroup = display.newGroup()  
   
-- The main function  
local function main()  
  
 text1bg = display.newRect(50,50,200,75)  
 text1bg:setFillColor(255, 48, 14)  
 text1bg.x = display.contentWidth/2  
 text1bg.y = 60  
  
 text1 = display.newText("BebasNeue", 20,20,"BebasNeue", 50)  
 text2 = display.newText("Bebas Neue", 20,20,"Bebas Neue", 50)  
 text3 = display.newText("Bebas Neue.otf", 20,20,"Bebas Neue.otf", 50)  
 text4 = display.newText("BebasNeue.otf", 20,20,"BebasNeue.otf", 50)  
 text5 = display.newText("System.contentFont", 20, 20, system.contentFont, 50)  
  
 text1:setReferencePoint(display.CenterReferencePoint)  
 text1.x = display.contentWidth/2  
  
  
 text2:setReferencePoint(display.CenterReferencePoint)  
 text2.x = display.contentWidth/2  
 text2.y = text1.y + 100  
  
 text3:setReferencePoint(display.CenterReferencePoint)  
 text3.x = display.contentWidth/2  
 text3.y = text1.y + 200  
  
 text4:setReferencePoint(display.CenterReferencePoint)  
 text4.x = display.contentWidth/2  
 text4.y = text1.y + 300  
  
 text5:setReferencePoint(display.CenterReferencePoint)  
 text5.x = display.contentWidth/2  
 text5.y = text1.y + 400  
  
  
end  
   
main()  

build.settings

settings = {  
 orientation = {  
 default = "portrait",  
 supported =  
 {  
 "portrait", "portraitUpsideDown"  
 }  
 },  
  
 iphone = {  
 plist = {  
 UIAppFonts = {  
 "BebasNeue.otf",   
 },  
 UIApplicationExitsOnSuspend = false,  
 UIPrerenderedIcon = true,  
 CFBundleIconFile = "Icon.png",  
 CFBundleIconFiles = {  
 "Icon.png" ,   
 "Icon@2x.png" ,   
 "Icon-72.png" ,  
 "Icon-72@2x.png" ,  
 "Icon-Small-50.png" ,  
 "Icon-Small-50@2x.png" ,   
 "Icon-Small.png" ,   
 "Icon-Small@2x.png"  
 },  
 },  
 },  
  
 androidPermissions = {  
 "android.permission.INTERNET"  
 },  
  
 android = {  
 plist = {  
 UIAppFonts = {  
 "BebasNeue.otf"  
 }  
 },  
 },  
  
  
}  

Font name is BebasNeue.otf and it’s in the same folder.

-Oskar [import]uid: 24111 topic_id: 26833 reply_id: 108918[/import]

Uploaded a new one:
http://d.pr/f/ex3n
-Oskar [import]uid: 24111 topic_id: 26833 reply_id: 108919[/import]

Oskar,

You need to first look up the font name as it is seem by the OS. For this you should use the “native.getFontNames()” function and look through the list of fonts returned by this functions. If this contains your font (it should if your build.settings is correct and font file is present in the project folder), then pass that font handle to the display.newText() function.

Below is a sample code which I use to load custom fonts. I think I found this code somewhere in these forums but can’t recall where. Works for me on iOS.

The point to note here is, the font name might be different in iOS and Android. So try passing different keywords to this function. Maybe “Bebas”, “bebas”, “Neue”, “neue” etc. Case might matter.

-- Tries to find the specified font. 'keyword' is used as a substring search keyword to look up  
-- in the fonts available on the system. If found, returns the system recognized font name. Otherwise  
-- returns nil  
function findFont(keyword)  
 local fonts = native.getFontNames()  
 local count, found\_count = 0, 0  
 for i,fontname in ipairs(fonts) do  
 count = count+1  
 j, k = string.find(fontname, keyword)   
 if (j ~= nil) then  
 found\_count = found\_count + 1  
 print("found font: " .. fontname)  
 return fontname  
 end  
 end  
  
 print(keyword .. ": font not found")  
 return nil  
end  

HTH
Kapil [import]uid: 135671 topic_id: 26833 reply_id: 108923[/import]

kapil,

Thanks for your help but I’ve already tried that and it only finds BebasNeue, which is the one I use.
My code works perfectly on iOS but not on Android. :confused:
Can the native.getFontNames() show different lists on simulator and device?

-Oskar [import]uid: 24111 topic_id: 26833 reply_id: 108925[/import]

Yes it can show different lists on simulator and device. That is why it is a good idea to search through the list at runtime rather than hard-code the font name. You could try to print out the actual list on device and see it in the log in XCode (iOS) or LogCat (Android).

Kapil [import]uid: 135671 topic_id: 26833 reply_id: 108927[/import]

Okay, can you run this through LogCat or tell me how where I can get it and how to use it?
http://d.pr/f/rMHx
-Oskar [import]uid: 24111 topic_id: 26833 reply_id: 108928[/import]

Hi,

I had some custom font issues but found a working solution:
https://developer.anscamobile.com/forum/2010/09/30/embedding-custom-fonts

Note though that some fonts don’t just play along with Corona/Android/iOS.

Matias [import]uid: 46570 topic_id: 26833 reply_id: 108929[/import]

matias,

Thanks! Tried this and uploaded a new file, can you or someone else here try it out?

http://d.pr/f/G0SG
-Oskar [import]uid: 24111 topic_id: 26833 reply_id: 108930[/import]

as I know you should avoid OTF fonts and use ttf instead. [import]uid: 8303 topic_id: 26833 reply_id: 108932[/import]

Logcat output:

[text]
I/Corona ( 4397): DroidSerif-Regular
I/Corona ( 4397): DroidSerif-Italic
I/Corona ( 4397): DroidSerif-BoldItalic
I/Corona ( 4397): DroidSerif-Bold
I/Corona ( 4397): DroidSansThai
I/Corona ( 4397): DroidSansMono
I/Corona ( 4397): DroidSansHebrew
I/Corona ( 4397): DroidSansFallback
I/Corona ( 4397): DroidSansArabic
I/Corona ( 4397): DroidSans
I/Corona ( 4397): DroidSans-Bold
I/Corona ( 4397): Clockopia
I/Corona ( 4397): AndroidClock_Solid
I/Corona ( 4397): AndroidClock_Highlight
I/Corona ( 4397): AndroidClock
[/text] [import]uid: 135671 topic_id: 26833 reply_id: 108933[/import]

kapil, thanks for helping :slight_smile:

Where can I get Logcat and how do I use it?
New build:
http://d.pr/f/6K5j

-Oskar [import]uid: 24111 topic_id: 26833 reply_id: 108934[/import]

Have you tried any other font file? Try something else or a TTF font to rule out that issue.

Kapil [import]uid: 135671 topic_id: 26833 reply_id: 108935[/import]

For logcat, you have to install the Android SDK first. Then run “adb” which is basically the command line tool to interact with your android device from your PC/Mac host. On my linux host I run:
> ./adb logcat

That starts the log dump on the terminal.

[import]uid: 135671 topic_id: 26833 reply_id: 108936[/import]

Another comment is that I don’t think native.getFontNames() returns custom fonts as those are the fonts installed to the OS. My recollection is that my custom font never showed in native.getFontNames().

There is a free app called aLogCat for Android that allows you read the logs. So you can run app, switch to aLogCat and see the Corona terminal output. Easier than settings up Android SDK remote debugging. [import]uid: 46570 topic_id: 26833 reply_id: 108937[/import]

kapil,

Well it works on iOS.
Where do I get the Android SDK?

-Oskar [import]uid: 24111 topic_id: 26833 reply_id: 108938[/import]

Same result, still no Bebas font:
I/Corona ( 4667): DroidSerif-Regular
I/Corona ( 4667): DroidSerif-Italic
I/Corona ( 4667): DroidSerif-BoldItalic
I/Corona ( 4667): DroidSerif-Bold
I/Corona ( 4667): DroidSansThai
I/Corona ( 4667): DroidSansMono
I/Corona ( 4667): DroidSansHebrew
I/Corona ( 4667): DroidSansFallback
I/Corona ( 4667): DroidSansArabic
I/Corona ( 4667): DroidSans
I/Corona ( 4667): DroidSans-Bold
I/Corona ( 4667): Clockopia
I/Corona ( 4667): AndroidClock_Solid
I/Corona ( 4667): AndroidClock_Highlight
I/Corona ( 4667): AndroidClock
[import]uid: 135671 topic_id: 26833 reply_id: 108939[/import]

http://developer.android.com/sdk/index.html
[import]uid: 135671 topic_id: 26833 reply_id: 108940[/import]

Here is one last try, then I’m out of ideas :confused:

http://d.pr/f/DxQ0

-Oskar [import]uid: 24111 topic_id: 26833 reply_id: 108943[/import]