Embedding fonts anomalies

Shari shari at gypsyware.com
Sun Nov 16 14:07:58 EST 2008


>Do you have a sample stack that show
>the approach that you described?

No, but here's the code I am using, and it appears to be working:

on loadGameFonts
   global gameFonts
   # gameFonts is the folder that holds several custom fonts
   set the directory to gameFonts
   put the files into fileList
   filter fileList with "*.ttf" # delete all non-ttf-font files
   repeat for each line x in fileList
     put gameFonts & "/" & x into theFont
     revFontLoad theFont
   end repeat

# now all the fonts are loaded and can be used in Rev
# in case a font doesn't load for whatever reason,
# cycle thru the fonts as a heirarchy, setting the font
# of the stack to firstChoice, secondChoice, thirdChoice, etc.

   # set font heirarchy using the name of the font as
   # it appears in the fontNames, as the fontNames may contain
   # several variations of a font and I want a very specific variation,
   # I put the full, unedited name of the font I want
   # The following is an example, these are not the actual fonts I used
   # The dash-number will set the font size as each font may require a
   # different font size to give a similar size result

   put "Arial-20,Trebuchet Bold-18,Goudy Old Style-24,Big 
Caslon-20,Lucida Bright-18" into tit

   set the wholeMatches to true
   # so that it doesn't match plain old "Trebuchet" to "Trebuchet Bold"
   repeat for each item x in tit
     set the itemDel to "-"
     if item 1 of x is among the lines of the fontNames then
       set the textFont of stack "nameOfMainStack" to \
           item 1 of x
       set the textSize of stack "nameOfMainStack" to \
           item 2 of x
       exit repeat
     end if
     set the itemDel to comma
   end repeat

# none of the fields have a font set so they will use the font of the 
stack itself

# the only issue needing to be resolved is that you cannot set the 
line height of a stack
# so if you want that to change depending on the font chosen, you'll need to
# do some sort of handler to change the line height of each specific 
field based on
# the font

end loadGameFonts
-- 
   Dogs and bears, sports and cars, and patriots t-shirts
   http://www.villagetshirts.com
  WlND0WS and MAClNT0SH shareware games
  http://www.gypsyware.com



More information about the use-livecode mailing list