Short: Example code for using outline fonts Author: matsp888@yahoo.com (Mats Peterson) Uploader: matsp888 yahoo com (Mats Peterson) Type: dev/src Version: 1.15 Replaces: dev/src/BulletExamples.lha Architecture: m68k-amigaos >= 2.0.4 Distribution: Aminet Here's some interesting example code dealing with Compugraphic outline fonts and the Bullet font scaling engine from the 1992 Amiga Mail Vol. 2 article collection. I have modified the code to compile cleanly with SAS/C 6.58 and to use pragmas and direct library calls rather than calling the stub routines in amiga.lib. I have modified the programs to open a new screen. The viewport modes, bit depth, and background and foreground colors can be set with the `V=VPModeID', `B=BitDepth' and `C=Colors' command line keywords. The `V=VPModeID' keyword expects a hexadecimal value. I have included a small utility called `ListVPModes' that displays a list of available viewport modes that have a name, and their IDs. The `C=Colors' keyword expects a six character long hexadecimal value that defines the background and foreground color RGB triplets. For example, `fff000' sets a white background and black foreground. The default viewport modes, bit depth and colors are taken from the Workbench screen. I have improved `View' somewhat: - The program supports UCS-2 and UCS-4 encoded text files (use the U=UCS command line keyword with 2 or 4 as the value). The Bullet font scaling engine is limited to 16-bit code points, though. - The point size is interpreted as centipoints. So, to set e.g. 14.75 points, enter 1475. - The leading (distance between baselines) can be set in percent of the point size (default 120). - The descender (the portion of a glyph that extends below the baseline) can be set in percent of the point size (default 25). I wish there would be a way to calculate the descender automatically, but that seems to take using diskfont.library and OpenDiskFont(). I have made the `ViewDiskfont' program mentioned below display some data about the font, among them the descender percentage. - Kerning can optionally be disabled with the N=NoKern command line switch. - Kerning of whitespace can optionally be enabled with the `S=SpcKern' command line switch. It's not widely used, however, and it might look cramped at times. - Tabular (non-proportional) figures can optionally be enabled with the `T=TabFigs' command line switch. - The tracking (letter-spacing) can be adjusted with the `R=Tracking' command line keyword. The value is percent of the point size, either positive or negative. - Whitespace characters are handled properly. - The text scrolls up when it reaches the bottom of the window, rather than the whole window being cleared. - The output of the text can be paused/resumed with the Space key, or ended with the `q' key. - The program waits for the user to click the close gadget rather than closing the window immediately at the end of the displayed file. I have added a small program called `ViewChars', that lets you view a range of Unicode characters. The `StartCode' and `EndCode' command line arguments are expected to be hexadecimal values. Characters with no glyph and no width are represented by a white square (U+25A1). The default range is from U+0021 to U+007E inclusive. For relatively logical reasons this program doesn't make use of any kerning information. The statement about the point size being interpreted as centipoints goes for `ViewChars' and `Rotate' as well. Outline fonts are supported by diskfont.library in AmigaOS 2.04 (V37) and up, unfortunately the Text() function doesn't seem to make use of any kerning information in the font, so if kerning adjustment is desired it will be necessary to use the Bullet engine directly, and blit to the raster ourselves, which is also done in the example programs. I have included an additional program called `ViewDiskfont' that displays a text string with a chosen font using diskfont.library and the Text() function for demonstrational purposes. Please note that if you change the XDPI or YDPI command line argument between invocations, it will be necessary to use `avail flush' in order to clear any previously generated font bitmaps from memory. New in v1.15 ------------ - In `View', whitespace kerning is now once again disabled by default. It's not widely used, and it might look somewhat cramped at times. Reintroduced the `S=SpcKern' command line switch, which now enables whitespace kerning in general. - In `View.c', removed the SPCKERN preprocessor macro. New in v1.14 ------------ - In `View', the "diagnostic" `S=SpcKern' command line switch has been removed. - In `View.c', added a SPCKERN preprocessor macro that replaces the command line switch mentioned above. Also renamed the DEBUG preprocessor macro to DISPKERN. New in v1.13 ------------ - In `View', whitespace kerning is now re-enabled, but only when the second character in a kerning pair is a non-whitespace character. The main issue in the past was that sometimes (such as with the figure `1') extra kerning was added to a glyph when whitespace was the second character in a pair, and this kerning value would also propagate to each succeeding whitespace character. The `S=SpcKern' switch now merely acts as a diagnostic feature to show the incorrect whitespace kerning in these isolated cases. New in v1.12 ------------ - The point size for `View', `ViewChars' and `Rotate' is now interpreted as centipoints. So, to set e.g. 14.75 points, enter 1475. - In `View', the tracking (letter-spacing) can now be adjusted with the `R=Tracking' command line keyword. The value is percent of the point size, either positive or negative. - In `View.c', checking for a NULL string pointer was not done before calling StrToLong(). Fixed. New in v1.11 ------------ - In `View', added a `T=TabFigs' command line switch to enable tabular (non-proportional) figures. New in v1.10 ------------ - Due to more problems with the kerning of whitespace than just the figure `1' case mentioned below, I've decided to disable it altogether by default. Not using whitespace kerning is not uncommon, though. Most programs I've seen, both on the Amiga platform and otherwise, don't use it. It can be enabled with the `S=SpcKern' command line switch if desired. - The `O=OneKern' switch has been removed. New in v1.9 ----------- - In the `View' program, kerning between the figure `1' and whitespace is now disabled by default, since it's rather wonky with several fonts for some reason. This kerning can be enabled with the `O=OneKern' command line switch. As an example of the bad kerning, run `View' with the sample file `Text/BadKern' using the `O=OneKern' switch. New in v1.8 ----------- - In `View.c', simplified the code for processing UCS-2 and UCS-4 encoded text. - In 'View.c' and 'ViewChars.c', ScrollRaster() is now used to scroll the text in the window up, rather than using RectFill() to clear the whole window. - In `View.c' and `ViewChars.c', the output of the text can be paused/resumed with the Space key, or ended with the 'q' key. - New file `input.c' that handles IDCMP input. New in v1.7 ----------- - Corrected a typo in README; the default code point range in `ViewChars' begins at U+0021, not U+0020. - Moved the opening of the screen and the window to `window.c'. - The programs now make the newly opened screen use the video modes of the Workbench screen by default, rather than blindly assuming HiRes (640 horizontal pixels). - New command line keywords `V=VPModeID', `B=BitDepth' and `C=Colors'. - A small utility called `ListVPModes' has been included that lists available viewport modes that have a name, and their IDs. - The `I=Interlace' command line switch has been removed. - In `View' and `ViewChars' the descender (the portion of a glyph that extends below the baseline) can now be set. I wish there would be a way to calculate the descender automatically, but that seems to take using diskfont.library and OpenDiskFont(). I have made the `ViewDiskfont' program display some data about the font, among them the descender percentage. - In View.c and ViewChars.c, RectFill() painted over the borders. Fixed. - Moved the BumpRev revision files to `src/rev'. New in v1.6 ----------- - In `ViewChars', the `StartCode' and `EndCode' command line arguments are now expected to be hexadecimal values. It's more natural to use hexadecimal when dealing with Unicode code points after all. New in v1.5 ----------- - The sample text files `SampleTextUCS2' and `SampleTextUCS4' in the `Text' subdirectory stated that the ff, fi, fl and ffl ligatures are located in the Arabic Presentation Forms-A Unicode block. We need to get historical here. The Bullet engine was written at a time when the Unicode standard was at version 1.0, and these ligatures are in fact located in the Unicode 1.0 Private Use Area (U+E800-U+FDFF). New in v1.4 ----------- - Moved the source code to a `src' subdirectory. - Added a command line argument to `View' to set the leading (distance between baselines) in percent of the point size (default 120). - `View' now supports UCS-2 and UCS-4 encoded text files. - Added a small program called `ViewChars' that lets you view a range of Unicode characters. - The programs can now be run from Workbench, although you won't be able to provide any command line arguments. The default text file for `View' is `Text/SampleText'. - Now letting the menu bar be visible when opening the window of a program. - Corrected a statement concerning `ViewDiskfont' in README regarding the need to use `avail flush' when changing the command line arguments. It only concerns the XDPI and YDPI values. - Moved the sample text files to a `Text' subdirectory. - Added icons to various files. New in v1.3 ----------- - Now using BumpRev to manage revisions. This should have been done earlier. - Added a note in README about diskfont.library and the Text() function seemingly not supporting any kerning information in the font. Also included an additional program called `ViewDiskfont' that displays a text string with a chosen font using diskfont.library and the Text() function for demonstrational purposes. New in v1.2 ----------- - The programs now open a new screen. - New command line switches: `N=NoKern' disables kerning (only applicable to `View'), and `I=Interlace' sets interlaced video. - The opened window is now made active by using the WA_Activate tag in OpenWindowTags() in BulletMain.c and BulletMainFile.c. - In View.c, RectFill() didn't fill the whole window. Fixed. - In View.c, obtain the width of whitespace characters with ObtainInfo() and the OT_WidthList tag, rather than just using 1/4 em as the width. Also adjust the kerning of whitespace.