Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] request-font

From: carl::cybercraft::co::nz at: 18-Jan-2003 15:18

Hi List, The font requester and related scripts that Gregg Irwin and I have been slowly working on have reached beta stage and have been added to the reboltech library. The idea is that you have two scripts: One that's specifically for your OS and which creates a text-file of the font-names on your system. This only needs to be run once. (Though running it again would be necessary to keep the text-file up-to-date when the fonts on your system are changed.) And another that creates the request-font function and loads the font-names data. (Having this script launched from your user.r is the obvious way to run it.) The above would then make the request-font function available to all the View scripts you ran. Well, that's the short version anyway. This is the longer one... To test this, you'll need to get the two scripts (see below) - the request-font.r script and the get-fonts-[OS-type].r script that matches your OS. (Only available for Windows and Amiga so far - it's your job, List, should you choose to accept it, to write the scripts for the other OSs View supports;) These two scripts should be downloaded and placed in the same directory, (I'd suggest making one called fonts or similar in your View home directory), as request-font.r needs to find the text-file (called fonts-data.txt) that the get-fonts[OS-type].r script creates. (Now read the scripts' headers, just in case I'm forgetting something here...) After doing the above, first run the get-fonts[OS-type].r script. This saves in the fonts-data.txt file a list of objects containing font data. (Just the fonts' names at the moment, but they're stored in objects in case other data needs to be added in the future.) Note that as these scripts are seeking information about the fonts on your system you'll probably get requests to access files outside your View directory. Say yes to this if you trust these scripts... If all goes well you can then run request-font.r. Do this from the View console as the script creates the request-font function which you'll then be able to test. And this is where the scripts are... http://www.reboltech.com/library/scripts/request-font.r http://www.reboltech.com/library/scripts/get-fonts-windows.r http://www.reboltech.com/library/scripts/get-fonts-amiga.r Gregg wrote the get-fonts-windows.r script and I the other two. Thanks must also go to Phil Bevan for some useful bug-spotting. Plus this is the post that got this under way... http://www.escribe.com/internet/rebol/m25079.html (a very long time ago, Gregg;) Now some questions: I make no great claims for the code or interface in font-request, but I'd like to know if I've chosen a good set of refinements for it and if the defaults are sensible ones. Getting those right from the start will make writing alternatives less of a hassle. This is what I decided on...
>> ? request-font
USAGE: REQUEST-FONT /title title-line /name font-name /style font-style /size font-size /color font-color /font font-obj /text string /effects /keep /multi DESCRIPTION: Requests a font-name and optional settings. Returns a font-object. If more than one font is selected the objects name will contain a block of names. With /style, /size and /color, 'keep may be given to keep the previous settings. This allows you to place the style, size and color fields in the requester without forcing them to have a specific value. REQUEST-FONT is a function value. REFINEMENTS: /title -- Change heading on request. title-line -- Title line of request. (Type: string) /name font-name -- Font name. Default is font-sans-serif. (Type: string block) /style font-style -- (Type: word block none) /size font-size -- (Type: integer none) /color font-color -- (Type: tuple word) /font font-obj -- Supply a font object. (Type: object) /text string -- Supply example text. (Type: string) /effects -- Allow editing of offset, space, align, valign, shadow and colors. /keep -- Keep previous settings and results. /multi -- Allow more than one font name to be selected. I thought about having an update button in the requester, (that'd run get-fonts[OS-type].r), but decided against it in the end, though I'm still in two minds whether it should be in or not. We've also thought about having an installer for this too. A good idea or not, in that it'd mean request-font.r would have to be included with each OS-specific script, making updating it a bit of a pain. And that's it for now. (Be much easier if RT would just add a font-requester to View of course, but they haven't yet, so...:) -- Carl Read