Click the links below to explore the different sections of our site. If you have any questions about our products or services, don't hesitate to contact us.
Following are a number of links to pages that might interest you as a visitor of this web site.
copyright © 2005-07 by Mark Schonewille & Economy-x-Talk

Economy-x-Talk - Sample Scripts

AltFont Docs

Documentation included with AltFont.





altFont is an external. That means it's a separate file from RunRev or the engine. Just like altBrowser, altFont must be loaded in order to work. The external filename for altFont on Windows is "altFont.dll", and the one for Mac OSX is "altFont.bundle"

When the Demo runs the first time it will automatically install the external for your platform in the same folder as Revolution (unless you're using an older version of MacOSX - then you'll need to manually download it from the site). This way it works automatically with the Demo. If you want to use it with any of your other stacks, it should work correctly as long as you: (assuming your stack name is "myStack"

set the externals of stack "myStack" to "altFont.dll" &cr& "altFont.bundle"
then save it. Close it. And Open it.

Explanation:
In order to load an external in a standalone, you need to set the externals property of a stack to the filepath where the external is expected to be found. As said, when running with the IDE, you can expect the external to be found in the Revolution folder, so it's a good idea to keep it in the same folder as your standalone as well. Please check the docs on the standalone builder for more information on this topic.
Instructions AltFont has only 2 commands:

XLOAD_FONT

XUNLOAD_FONT

It will return an error in the result if a problem occurred trying to access the font.

Font path names may be different from the font name, so if you need to get the newly loaded font name, you'll have to do it by script as neither Windows nor Mac's API returns this info.

Here's a simple script that does just that (it's also in the script of the Load Font button:

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

  put the fontnames into tNewList
  if the number of lines in tNewList = tNumOfFonts +1 then
    put diffLists(tOldList,tNewList) into tFontName

    answer information "Font successfully loaded: " & tFontName

  else

    answer information "Problem loading font." &cr& \
        "This could be because it is already loaded, or the file is not of correct type!"
  end if
end mouseUp

function diffLists pOldList,pNewList
  set the wholematches to true
  repeat with x = the number of lines in pNewList down to 1
    if line x of pNewList is not among the lines of pOldList then return line x of pNewList
  end repeat
end diffLists

Embedding Fonts in Your Stacks You can embed fonts in your stacks by creating custom properties consisting of the binary data of the font. Then when you first start your app, on Startup you check to see if the file exists, and if not you save the binary data (the font file) to the folder of the app.

Here's how to do it. Create 2 buttons: SuckUp and SpitOut.

Script of btn SuckUp:

on mouseUp
  answer file "Choose a font to embed:"
  if it is emtpy then exit to top
  suckUp it
end mouseUp

Script of btn SpitOut:

on mouseUp
  answer folder "Folder to store font:"
  if it is empty then exit to top
  spitOut it
end mouseUp

Now in the Card script:

on suckUp pFilePath
  set itemDel to "/"
  set the uFileName of this card to last item of pFilePath
  set the uEmbeddedFile of this card to URL ("binfile:" & pFilePath)
end suckUp

on spitOut pFolderPath
  put the uFileName of this card into tFileName
  put pFolderPath &"/"& tFileName into tFilePath
  put the uEmbeddedFile of this card into URL ("binfile:" & tFilePath)
end spitOut


It's that simple! You can now SuckUp a binary file, then SpitOut it. Of course, you can also always just ship your standalone with the external and the fonts as individual files.





Keep this extensive resource of tutorials and samples on-line! Support RunRev.info!
Yes, this script is useful. I make a donation and choose freely how much I want to donate on-line (PayPal). Click here if you want to make a donation in dollars.This script has not (completely) solved my problem and I want Economy-x-Talk to take care of it. Let me contact you.
Copyright©2002-2008 by Mark Schonewille, Nijmegen, the Netherlands. This web site is in no way affiliated with Runtime Revolution Ltd., but we do recommend the Revolution development platform.