altFont: Load a font

Adrian Williams adrian at clubtype.co.uk
Tue Nov 28 14:06:47 EST 2006


Hello,

I recently purchased altFont and using the
buttons that came with the DEMO stack all works fine,
using altFont to embed a font in my app.

I have been able to "SuckUp" the font in the IDE.
"SpitOut" the font from the button's custom prop. into the default 
Folder.
Now all I want to do is "Load a font" from the default Folder!
Simple enough if a clicked button presents the User with a dialog
to navigate the the font, but I don't want the User to have to do that.
Why should they.
I know where the font is sitting - its in the default Folder.
So how can I replace the code below with something triggered by the 
card script
to load the font automatically rather than the button...

--snippet of code
on mouseUp
   answer file "choose a ttf file to load"
   if it is empty then exit to top
   put the fontNames into tOldList
   put the number of lines in tOldList into tNumOfFonts

   --> ONLY COMMAND FOR LOADING
   XLOAD_FONT it
   put the result into tResult
   if tResult is not empty then
     answer warning tResult
     exit to top
   end if
--etc. etc

I did get a solution from the altFont author Chris Bohnert, but it 
lacked
enough comment for this newbie to understand how to use uFileName and
uEmbeddedFile and where to put the script...
> Adrian,
>
> The code you're using is very dangerously relying on the value of 'it'
> remaining stable between the call to Answer file and the call to 
> XLOAD_FONT.
>
> I'd leave your 'suck up' button in place (hiding it when you ship)
> and do the following to load the font.  The 'suck up' button sets the
> uFileName custom prop and uEmbeddedFile.
>
> put the uFileName of this card into tFilePath
> --if you need to append a subdir struct into the path you can do it 
> now with
> put "./mysubdir/" & tFilePath into tFilePath
> put the uEmbeddedFile of this card into URL("binfile:" & tFilePath )
>
> if there is a file tFilePath then
>   XLOAD_FONT tFilePath
> else
>   answer information "Font missing"
> end if

Any guidance would be appreciated,
Thanks,
Adrian
______________________
Club Type
http://www.clubtype.co.uk
adrian at clubtype.co.uk


More information about the use-livecode mailing list