Custom fonts with a standalone

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Custom fonts with a standalone

Post by adventuresofgreg » Mon Dec 01, 2014 8:35 pm

Hello: I would like to bundle some fonts with my standalone, but don't want to make the user install them into his/her WIndows or Mac system. I know I can do this with an iOS standalone, but I'd like to be able to do it with my WIndows and Mac standalones. Is there a way to do this?

Thanks
Greg

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Custom fonts with a standalone

Post by Klaus » Mon Dec 01, 2014 9:05 pm

Hi Greg,

if I remember right, you only need to add your fonts via the "Copy files" tab in the standalone
builder settings and they will be automatically availavble on iOS!
Worth a try! :D


Best

Klaus

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: Custom fonts with a standalone

Post by adventuresofgreg » Mon Dec 01, 2014 9:11 pm

Hi Klaus. I'm not interested in iOS. I would like the fonts to be available in the Windows or Mac standalone - even if those fonts are not system fonts

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Custom fonts with a standalone

Post by Klaus » Mon Dec 01, 2014 9:31 pm

Hi Greg,

oops, sorry, my fault!

OK, add the font files via the standalone builder "Copy files" and then you can "start using" them!
Check the entry "start using font file..." in the dictionary.

Basically you do something like this in the preopenstack script:
...
put specialfolderpath("engine") & "/A nice font.ttf" into tFont
start using font file tFont
## same for all other fonts...
...

When closing the stanadlone simply "stop using font file ...",
but maybe the fonts will be unloaded at at that point anyway :D


Best

Klaus

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: Custom fonts with a standalone

Post by adventuresofgreg » Mon Dec 01, 2014 9:47 pm

Great Klaus. I'll give that a try. Is there anyway to BUILD the font files INTO the standalone? currently after building the standalone this way, the font files appear as separate files. It would be nice to have them bundled in with the .exe if possible

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Custom fonts with a standalone

Post by Klaus » Mon Dec 01, 2014 10:58 pm

Hi Greg,

hmm, you could store the font files into custom properties of the stack,
but in any case you need to write them to the end users hd to be able
to use them, sorry!

Maybe "spit them out" into the temp directory -> specialfolderpath("temporary"),
start using them from there and delete them on quit?


Best

Klaus

cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Re: Custom fonts with a standalone

Post by cmhjon » Wed Feb 14, 2024 4:05 pm

Klaus wrote:
Mon Dec 01, 2014 9:31 pm
Basically you do something like this in the preopenstack script:
...
put specialfolderpath("engine") & "/A nice font.ttf" into tFont
start using font file tFont
## same for all other fonts...
...
Best
Klaus
Hi Klaus,

I have the same question and since this thread is almost 10 years old, I thought I would see if anything has changed? In my case, my app will only be compiled for macOS and Windows. My app uses a custom font. Ideally, I would like to have the font "embedded" within the app/exe so the user does not have to install it.

If I use the commands shown above, does 'put specialfolderpath("engine") & "/A nice font.ttf' work for Mac AND Windows or would the folder path location be different between macOS and Windows?

Best regards,
Jon :)

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Custom fonts with a standalone

Post by Klaus » Wed Feb 14, 2024 4:29 pm

Hi Jon,

you're lucky, I'm still alive! :-D

-> specialfolderpath("engine") is not the right folder, this only works on mobile, but is not recommended.

Use -> specialfolderpath("resources") instead, that is where all the files will reside that you add to
your runtime in the Standalone Application setting via "Copy files". This will work on ALL platforms!

Best

Klaus

cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Re: Custom fonts with a standalone

Post by cmhjon » Wed Feb 14, 2024 4:38 pm

Outstanding!

Thank you so much!
Jon :)

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Custom fonts with a standalone

Post by stam » Wed Feb 14, 2024 4:40 pm

Yep this works 100%
I had done exactly this for an early app in my workplace (desktop only mind you). That was a for a silly font where all glyphs were bullet points (used for a password field) - however I now just use unicode for that.

I'll be honest, I never understood why specialFolderPath("engine") is used - there probably is a use-case for it, but not one I've found. SpecialFolderPath("resources") does exactly what I need it to and is unambiguous...

cmhjon
Posts: 175
Joined: Tue Aug 04, 2015 11:55 am

Re: Custom fonts with a standalone

Post by cmhjon » Wed Feb 14, 2024 5:00 pm

Hmmmm. Maybe I spoke too fast. After doing everything, what I get for the Windows standalone is the .exe along with an empty 'Externals' folder the font file and when I open the app, the font doesn't display correctly.

What am I doing wrong?

Thank you,
Jon

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Custom fonts with a standalone

Post by stam » Wed Feb 14, 2024 5:03 pm

Have you added the font file via Copy Files in the Standalone Application Settings'?
Files should appear in the app folder it generates on Windows or in the equivalent folder inside the Mac app bundle.

Can't quite test on Windows right now, but I would expect the font file to appear in the same folder as the app, not the externals folder. The app folder should be what you get with specialFolderPath("resources"), so if your font file is there, you can access with

Code: Select all

on preOpenStack
   start using font file (specialFolderPath("resources") & "/my-special-font.ttf")
end preOpenStack
For mobile I believe you need to do more (modify the pList with font family name etc), but don't quote me on that...

Stam
Last edited by stam on Wed Feb 14, 2024 5:09 pm, edited 1 time in total.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Custom fonts with a standalone

Post by Klaus » Wed Feb 14, 2024 5:09 pm

stam wrote:
Wed Feb 14, 2024 4:40 pm
I'll be honest, I never understood why specialFolderPath("engine") is used - there probably is a use-case for it, but not one I've found. SpecialFolderPath("resources") does exactly what I need it to and is unambiguous...
specialFolderPath("engine") was used BEFORE LC introduced specialFolderPath("resources") and some users still got not used to that! :-)
After doing everything, what I get for the Windows standalone is the .exe along with an empty 'Externals' folder the font file and when I open the app, the font doesn't display correctly.
So your fonts are not present in the resulting folder with the standalone
although you added them in the STAB (Standalone Application Settings)? :shock:

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Custom fonts with a standalone

Post by Klaus » Wed Feb 14, 2024 5:11 pm

Yes, what stam wrote, this has not changed in the last 10 years.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Custom fonts with a standalone

Post by Klaus » Wed Feb 14, 2024 5:35 pm

stam wrote:
Wed Feb 14, 2024 5:03 pm
...
For mobile I believe you need to do more (modify the pList with font family name etc), but don't quote me on that...
Nope, according to the docs you only need to add the fonts in the STAB, no additional coding required.
Never tested however... :)

Post Reply

Return to “Talking LiveCode”