Setting a custom font on Android

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Monox18
Posts: 118
Joined: Tue Nov 25, 2014 9:48 pm
Location: Deggendorf, Germany

Setting a custom font on Android

Post by Monox18 » Thu Feb 14, 2019 8:00 pm

Hello!

I'm following the lesson to set up a custom password font:
https://revolution.screenstepslive.com/ ... word-field

but I get an error "Can't load font file". So, it works in the IDE and Windows standalone but not in Android. Any help?

My code is on a preOpenStack handler and I added the PasswordEntry.ttf file on the standalone settings "Copy Files". The file is on the same folder as the stack.

Code: Select all

on preOpenStack
   local theFontFile, theError
   set the itemdelimiter to slash
   put the effective filename of this stack into theFontFile
   delete the last item of theFontFile
   put theFontFile & "/PasswordEntry.ttf" into theFontFile
   start using font file theFontFile
   put the result into theError
   if theError is not empty then
      answer "Error loading password font:" &cr& theError & "."
   end if
end preOpenStack
Monox
Developing a Cyber Physical System.
https://www.monoxware.com/

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Setting a custom font on Android

Post by AxWald » Fri Feb 15, 2019 8:25 am

Hi,

putting the .ttf into a "fonts" folder next to your stack & referring it in the "Copy Files" section of the SA settings as "fonts/*" is all that's needed. It ends in "YourApp.apk/assets/fonts/" then.

The font is available for your app this way as if it was installed on the machine.
The same works for .ogg ("sounds folder).

So you can skip the "Loading The Font" section of the tutorial (in case of Android), it's of no use here. Just having the .ttf in the appropriate folder does the job for you already ;-)

Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

Monox18
Posts: 118
Joined: Tue Nov 25, 2014 9:48 pm
Location: Deggendorf, Germany

Re: Setting a custom font on Android

Post by Monox18 » Mon Feb 18, 2019 9:59 pm

Thanks AxWald. Your suggestion worked.
Monox
Developing a Cyber Physical System.
https://www.monoxware.com/

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”