Loading fonts?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Loading fonts?

Post by peter.s » Sun Aug 31, 2008 4:57 pm

Hi there,

I am using about four "unusual" fonts in the text fields of my media presentation stack. I use these fonts on practically every card in the stack and substacks.

All the fonts are OTF, so they should be Windows and Mac friendly and the final standalone will run off a DVD - so it wants to be cross platform compatible.

What is the best way to load these fonts?

I've been reading about revFontLoad, but I'm not sure how to apply it... do I load it on opening the main stack? There by making the font's available to all subsequent stacks... all the time?

And - Can I load all four fonts at the same time?

Any advice will be helpful.

P

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

Post by Klaus » Tue Sep 02, 2008 8:22 am

Hi Peter,

did you check the Rev example stack?

You find it here:
Rev App folder/Resources/Examples/Font Loading Sampler.rev


Best

Klaus

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Post by peter.s » Tue Sep 02, 2008 9:23 am

Hi there Klaus,

I have checked out the Rev example stack... but I just don't get it. I'm not sure what the stack is supposed to do? There is no explanation on what the example is for and I can't find anything useful in the manual either.

I want my stack to access four fonts I have stored in a font folder, in the default folder of my standalone - so that my text fields display the text how I intend them to. I want the stack to just use the fonts without prompting the user to set anything up... surely this is possible?

Is it something like:

on openStack
revfontload "/FontFolder/font-1.otf, font-2.otf"
end openStack


I am aware that the answers are probably right under my nose, but sometimes I find it difficult to get my head around this program.

All the best,

Peter

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

Post by Klaus » Tue Sep 02, 2008 9:50 am

Hi Peter,

you are almost there :-)

The "revfontload" external apparently only accepts one font at a time, so will have to:

Code: Select all

on openStack 
  revfontload "/FontFolder/font-1.otf" 
  revfontload "/FontFolder/font-2.otf" 
### etc for all your fonts...
end openStack
That's it.
Don't forget to "revfontunload" all your fonts on quit/closestack!


Best

Klaus


P.S:
Sorry, just had a look at the example stack, and yes, that's a bit crappy ;-)

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Post by peter.s » Tue Sep 02, 2008 1:34 pm

Hi Klaus,

Thanks for the tip...

I have used the revfontload (and unload) as you suggested, on two stacks which use my desired fonts - but now I am experiencing a crash every time I open one of these two stacks.

I tested a standalone on another computer. One stack crashed immediately and the other worked alright... for a while... but then crashed.

Then I ran my Rev file which now frequently crashes either on opening the stack, or on opening cards within the stack. If I disable revfontload in the scripts, it becomes stable again.

I checked the location of the Font folder, which seems fine (as the test on the other computer verified it was being used), so I am thinking that loading four fonts might be too much?! What do you think? Any ideas?

Cheers,

Peter

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

Post by Klaus » Tue Sep 02, 2008 1:51 pm

Hi Peter,

hmm, very strange...

I have only been working with ONE font to load so far and did not experience any problems.

You said you had problems when you open your stacks, right?
You could try to check first if your custom fonts are already available before you load them.

Something like:

Code: Select all

...
if lineoffset("You font name here",the fontnames) = 0 then
  ## NOT the filename! Check for the name that will appear in the fontmenu!
  revloadfont ...
end if
...
Know what I mean?
Then check if that helps.

If not you should write a mail to "support@runrev.com" since that might be a bug.


Best

Klaus

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Post by peter.s » Tue Sep 02, 2008 2:52 pm

Yeah Klaus, I think I get it.

Is it something like:- If "Arial" is not in the list of fonts, then revfontload "Arial" ... Right ??

Just to get my understanding right, what you suggest should look like this?

if lineoffset ("Bauhaus Std", the fontnames) = 0
revfontload "fonts/BauhausStd-Light.otf"

Complete with brackets?

P

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

Post by Klaus » Tue Sep 02, 2008 3:04 pm

Hi Peter,

yes, but with "then" and "end if" :-)

Code: Select all

if lineoffset("Bauhaus Std", the fontnames) = 0 then
 revfontload "fonts/BauhausStd-Light.otf"
end if
And for all of your fonts.


Best from germany

Klaus

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Post by peter.s » Tue Sep 02, 2008 3:19 pm

Hi Klaus,

Thank you so much... yet again! It seems you have a habit of helping me out... and it is much appreciated.

My initial tests prove to be stable.

I discovered I needed to do the same for unloading too - as I experienced crashes closing the stack with a general unload list on closestack.

So I think all is well.

I hope the weather is good in Germany, it's stinking hot here in Cambodia!

Peter

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

Post by Klaus » Tue Sep 02, 2008 5:55 pm

Hi Peter,

the kudos goes to my mom (RIP) and her excellent education ;-)
Glad it is working for you now.

Nevertheless, Rev should not crash in these cases!

Weather in germania is wet but still warm, but it looks like sommer is gone for this year :(

Please send some heat quickly :D


Best

Klaus

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Tue Sep 02, 2008 7:12 pm

It is warm at your place Klaus? Seems I live too far up in the north then. *sigh*

As for unloading the fonts (just a wild guess though). I guess it might be problematic if you try to unload a font you have not explicitly loaded. E.g someone has bauhaus.otf in his regular system font folder and coincidently you unload it without having it loaded. What would be worth a try is storing all fonts you did load in a variable and unload them before quitting the app. Something like this might work

Code: Select all

local sAllFonts

on loadMyFonts
  repeat for each item theFont in "fontabc,fontdef,fontxyz"
  -- replace with real fontnames
    if theFont is not among the lines of the fontNames then
      revfontload ("path/to/font/folder/"&theFont&".otf")
      put theFont&cr after sAllFonts
    end if
  end repeat
  delete char -1 of sAllFonts
  -- clean up last cr
end loadMyFonts

on unloadMyFonts
  repeat for each line theFont in sAllFonts
    revfontunload ("path/to/font/folder/"&theFont&".otf")
  end repeat
  delete variable sAllFonts
end unloadMyFonts
Just a guess that this will work though.

Best,

Malte

[edited because of being stupid]

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Post by peter.s » Wed Sep 03, 2008 11:02 am

Hi Malte,

This is a good point you are making. I don't want to go around upsetting people's font files.

I will study your script a bit more then give it a try. You may hear from me again if I run into any trouble.

Cheers,

Peter

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Post by peter.s » Fri Sep 12, 2008 7:29 am

My font load issue is still not resolved. If anyone is willing to advise - I would be very appreciative.

I did not attempt the script above suggested by Malte because I couldn't get my head around substituting the listed font names with the "real" font names and therefore didn't understand how the script would work...

So I stuck with the original idea which seems (although messy) more simpler:

on OpenStack
if lineoffset ("Arcana GMM Std", the fontnames) = 0 then
revFontLoad "Fonts/ArcanaGMMStd-Manuscript.otf"
end if
if lineoffset ("Bauhaus Std", the fontnames) = 0 then
revFontLoad "Fonts/BauhausStd-Light.otf"
end if
if lineoffset ("Myriad Pro", the fontnames) = 0 then
revFontLoad "Fonts/MyriadPro-Regular.otf"
end if
if lineoffset ("Myriad Pro", the fontnames) = 0 then
revFontLoad "Fonts/MyriadPro-Semibold.otf"
end if
end OpenStack



When I open the standalone on a PC (I work on a Mac) Arcana and Myriad - regular load alright, but Bauhaus and Myriad - semibold do not load.

This tells me that something is working. The app can find the fonts but doesn't like (for some reason) Bauhaus & Myriad - semibold.

Also, the PC seems to ignore my margin settings.

I haven't been able to see what it does on another Mac yet.

Any ideas? Anybody?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Sep 12, 2008 8:51 am

Hi Peter

Could you check the result after executing the revFontLoad command?

Code: Select all

on OpenStack
  put empty into rslt
  if lineoffset ("Arcana GMM Std", the fontnames) = 0 then
    revFontLoad "Fonts/ArcanaGMMStd-Manuscript.otf"
    put the result & cr after rslt
  end if
  if lineoffset ("Bauhaus Std", the fontnames) = 0 then
    revFontLoad "Fonts/BauhausStd-Light.otf"
     put the result & cr after rslt
  end if
  if lineoffset ("Myriad Pro", the fontnames) = 0 then
    revFontLoad "Fonts/MyriadPro-Regular.otf"
    put the result & cr after rslt
  end if
  if lineoffset ("Myriad Pro", the fontnames) = 0 then
    revFontLoad "Fonts/MyriadPro-Semibold.otf"
    put the result & cr after rslt
  end if
  put rslt
end OpenStack 
What does the message box contain after you run this code?

Some fonts are simply incompatible with the revFontExternal. If you don't get this to work, you simply will have to accept it. I hope there is another reason, though. Are you sure that none of the fonts are already in the fonts folder of your operating system?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Post by peter.s » Fri Sep 12, 2008 9:46 am

Hi Mark,

I have used the script, and a message box comes up, but it is empty. I have never used the Message Box before - so I'm not sure where we're going with it.

But - Seeing as I have all these fonts installed in my OS, I experimented with disabling a couple of them. First, I made sure I provided a Font folder (with the 4 fonts in question) in the default folder before disabling the fonts from my OS.
This is what I found.

If I disable Bauhaus it makes little difference. In the field, Bauhaus is substituted by another font and the message box comes up empty.

If I also disable Arcana, Revolution crashes on opening the stack. Enabling the font in the OS restores stability.

I do not need the user to interact with the text I am trying to provide - so if there is any way of "embedding" the fonts, that may be a better way to handle this?

Cheers,

Peter

Post Reply