Integrate fonts in software

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

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Integrate fonts in software

Post by Klaus » Tue Nov 20, 2018 11:58 am

AHA, so the font is NOT in -> specialfolderpath("resources") but in -> specialfolderpath("resources) & /"resources/"! :-D

Either do not create and use a subfolder named "resources"* by yourself, my advice, or provide the correct path to the font:
...
put specialfolderpath("resources") & "/resources/TerminalDosis-Medium.ttf" into tFontFile
...

*This folder will be created automatically by LC when creating the Mac standalone application package!

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Re: Integrate fonts in software

Post by AlessioForconi » Tue Nov 20, 2018 12:42 pm

Klaus wrote:
Tue Nov 20, 2018 11:58 am
AHA, so the font is NOT in -> specialfolderpath("resources") but in -> specialfolderpath("resources) & /"resources/"! :-D

Either do not create and use a subfolder named "resources"* by yourself, my advice, or provide the correct path to the font:
...
put specialfolderpath("resources") & "/resources/TerminalDosis-Medium.ttf" into tFontFile
...

*This folder will be created automatically by LC when creating the Mac standalone application package!
If I understood correctly ...

I set this way, that is, I have included the font file indicating it from the folder where the executable is, without creating the resources folder.

Screenshot_111.png


Now the error no longer appears, but it does not load the font, or rather it is only about the OS X virtual machine, but not on Linux and Windows.

I forgot that I also set the font in question on the stack at the design stage.


The resources folder is not created when LC creating the Mac standalone application package but the font file is copied as I have indicated it, ie in the same folder as the executable.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Integrate fonts in software

Post by Klaus » Tue Nov 20, 2018 1:15 pm

Hi Alessio,

your screen looks fine now.
And you use -> specialfolderpath("resources") & "/TerminalDosis-Medium.ttf"
Right? If yes, sorry, no idea why the font does not load.
The resources folder is not created when LC creating the Mac standalone application package but the font file is copied as I have indicated it, ie in the same folder as the executable.
this is not true! Did you take a look into the application package?
See screenshot:
mac_app_package_contents.jpg
Everything you add via the "Copy files" tab in the STAB Settings, will get copied to the "Resources" folder, which gets created during the compilation inside of the app package, and can be accessed with that specialfolderpath("resources") which LC nicely maps to whatever folder Apple is requiring today for this kind of "resources".

Some years ago everything went into the "MacOS" folder a.k.a. specialfolderpath("engine") but then Apple changed it mind again and LC now takes care of that.


Best

Klaus

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Integrate fonts in software

Post by bogs » Tue Nov 20, 2018 2:48 pm

I'm not positive, since I never actually used this method, but I think you have to check this
Selection_001.png
Copy files...?
after adding the files, don't you? I could be way off though.
Image

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Integrate fonts in software

Post by Klaus » Tue Nov 20, 2018 3:21 pm

bogs wrote:
Tue Nov 20, 2018 2:48 pm
I could be way off though.
And you are in fact! :D

Check page 513 in the "User Guide" (of LC 9):
...
Copy Referenced Files:
Loops over all image and player objects in stacks and copies any files referenced in the fileName property of these objects into the standalone. Then automatically sets the fileName property to reference these files in the standalone using referenced file paths.
...

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Integrate fonts in software

Post by bogs » Tue Nov 20, 2018 4:26 pm

Klaus wrote:
Tue Nov 20, 2018 3:21 pm
bogs wrote:
Tue Nov 20, 2018 2:48 pm
I could be way off though.
And you are in fact! :D
No surprise there :D
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Integrate fonts in software

Post by jacque » Tue Nov 20, 2018 5:13 pm

To test, put in a temporary line of script "answer the fontnames" and see what it says. Sometimes the font name is different than the file name.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Re: Integrate fonts in software

Post by AlessioForconi » Sat Nov 24, 2018 7:58 am

jacque wrote:
Tue Nov 20, 2018 5:13 pm
To test, put in a temporary line of script "answer the fontnames" and see what it says. Sometimes the font name is different than the file name.
The result of "answer the fontnames" is this

Screenshot_112.png

The file is this

Screenshot_114.png

And in the code I use this

Code: Select all

on preOpenStack
   ##answer the fontnames
   put specialfolderpath("resources") & "/TerminalDosis-Medium.ttf" into tFontFile
   start using font file tFontFile
   ## Do so for every font you have included
   if the result <> EMPTY then
      answer specialfolderpathspecialfolderpath("resources")
      answer "non è stato possibile caricare il Font selezionato:" & CR & the result
   end if
   ## if there is an error -> the result will not be EMPTY
end preOpenStack

SparkOut
Posts: 2946
Joined: Sun Sep 23, 2007 4:58 pm

Re: Integrate fonts in software

Post by SparkOut » Sat Nov 24, 2018 9:27 am

TerminalDosis-Medium.ttf <> Terminal Dosis Medium


Use the name listed under the fontNames when you "start using"

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Re: Integrate fonts in software

Post by AlessioForconi » Sat Nov 24, 2018 6:13 pm

SparkOut wrote:
Sat Nov 24, 2018 9:27 am
TerminalDosis-Medium.ttf <> Terminal Dosis Medium


Use the name listed under the fontNames when you "start using"
And the extension? "answer the fontnames" does not indicate it

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Integrate fonts in software

Post by Klaus » Sat Nov 24, 2018 7:19 pm

Hi Alessio,

the name of a font in "the fontnames" (and every font menu in other applications), may be NOT the same as the filename of the font, as you can see here.

I guess you have installed this font on your machine and alreadfy set the font of some of your fields to that font, right? If yes, the you do not do anything but "start using font file...", that's it!

If not, what do you want to use the font for?


Best

Klaus

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Re: Integrate fonts in software

Post by AlessioForconi » Sat Nov 24, 2018 7:28 pm

Klaus wrote:
Sat Nov 24, 2018 7:19 pm
Hi Alessio,

the name of a font in "the fontnames" (and every font menu in other applications), may be NOT the same as the filename of the font, as you can see here.

I guess you have installed this font on your machine and alreadfy set the font of some of your fields to that font, right? If yes, the you do not do anything but "start using font file...", that's it!

If not, what do you want to use the font for?


Best

Klaus
Yes, I set that font at the stack level and in the individual fields, if necessary, I set different sizes.
Obviously the font is installed on the computer.
What should I do for "start using font file ..."?

Doing some tests on virtual machines I noticed that on that OS X is however correctly used while on those Linux and Windows does not work. The font is not installed on any of the three.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Integrate fonts in software

Post by Klaus » Sat Nov 24, 2018 7:38 pm

"start using font file ..." is all you need to do!
This will install the font file with that name on the target machine, but the font can only be used inside of LC.

Since it works on a Mac, it generally works, no idea why it doesn't on Win and Linux.
Do you get any errors on these platforms?

Please post your script again, here is an error:

Code: Select all

on preOpenStack
   ##answer the fontnames
   put specialfolderpath("resources") & "/TerminalDosis-Medium.ttf" into tFontFile
   start using font file tFontFile
   ## Do so for every font you have included
   if the result <> EMPTY then

     ### HERE! One specialfolderpath too much :-)
      answer specialfolderpathspecialfolderpath("resources")
    ### HERE!
      answer "non è stato possibile caricare il Font selezionato:" & CR & the result
   end if
   ## if there is an error -> the result will not be EMPTY
end preOpenStack

AlessioForconi
Posts: 90
Joined: Sun Feb 15, 2015 2:51 pm

Re: Integrate fonts in software

Post by AlessioForconi » Sun Nov 25, 2018 8:15 am

Hi Klaus

I already corrected the mistake, I had seen it too.
Both on Windows and on Linux I do not get any errors, simply do not use the font.

Code: Select all

on preOpenStack
   ##answer the fontnames
   put specialfolderpath("resources") & "/TerminalDosis-Medium.ttf" into tFontFile
   start using font file tFontFile
   ## Do so for every font you have included
   if the result <> EMPTY then
      answer specialfolder("resources")
      answer "Non è stato possibile caricare il Font selezionato:" & CR & the result
   end if
   ## if there is an error -> the result will not be EMPTY
end preOpenStack
I checked again, as you can see from the screenshot the instruction
put specialfolderpath ("resources") & "/TerminalDosis-Medium.ttf" into tFontFile
it does not create the resources folder but simply copies the font file that I have indicated in the Copy files of Standalone Application Setting

Screenshot_116.png
Screenshot_117.png

SparkOut
Posts: 2946
Joined: Sun Sep 23, 2007 4:58 pm

Re: Integrate fonts in software

Post by SparkOut » Sun Nov 25, 2018 10:19 am

Try adding "globally" to the command

Code: Select all

start using font file tFontFile globally 
If that works (or even if not?) then I wonder whether it might be a regression of bug 19981 https://quality.livecode.com/show_bug.cgi?id=19981

Post Reply