Page 1 of 2

Custom fonts with a standalone

Posted: Mon Dec 01, 2014 8:35 pm
by adventuresofgreg
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

Re: Custom fonts with a standalone

Posted: Mon Dec 01, 2014 9:05 pm
by Klaus
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

Re: Custom fonts with a standalone

Posted: Mon Dec 01, 2014 9:11 pm
by adventuresofgreg
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

Re: Custom fonts with a standalone

Posted: Mon Dec 01, 2014 9:31 pm
by Klaus
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

Re: Custom fonts with a standalone

Posted: Mon Dec 01, 2014 9:47 pm
by adventuresofgreg
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

Re: Custom fonts with a standalone

Posted: Mon Dec 01, 2014 10:58 pm
by Klaus
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

Re: Custom fonts with a standalone

Posted: Wed Feb 14, 2024 4:05 pm
by cmhjon
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 :)

Re: Custom fonts with a standalone

Posted: Wed Feb 14, 2024 4:29 pm
by Klaus
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

Re: Custom fonts with a standalone

Posted: Wed Feb 14, 2024 4:38 pm
by cmhjon
Outstanding!

Thank you so much!
Jon :)

Re: Custom fonts with a standalone

Posted: Wed Feb 14, 2024 4:40 pm
by stam
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...

Re: Custom fonts with a standalone

Posted: Wed Feb 14, 2024 5:00 pm
by cmhjon
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

Re: Custom fonts with a standalone

Posted: Wed Feb 14, 2024 5:03 pm
by stam
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

Re: Custom fonts with a standalone

Posted: Wed Feb 14, 2024 5:09 pm
by Klaus
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:

Re: Custom fonts with a standalone

Posted: Wed Feb 14, 2024 5:11 pm
by Klaus
Yes, what stam wrote, this has not changed in the last 10 years.

Re: Custom fonts with a standalone

Posted: Wed Feb 14, 2024 5:35 pm
by Klaus
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... :)