1
0
mirror of synced 2026-01-13 15:37:38 +00:00
Interlisp.medley/lispusers/READ-BDF.TEDIT
Matt Heffron 39ebd40da4
READ-BDF: Handle newly encountered cases in BDF files. (#2108)
* Better handling of a glyph with ENCODING of -1. 
I treat it as the _slug_ glyph, instead of the _default_ of a solid block.

* Handle scrambled bitmaps issue #2109.
Glyphs with zero width bitmap *and* zero advance (_escapement_) caused miscalculated glyph offsets into the CHARSETINFO bitmap.

* Allow and ignore COMMENT lines preceding the STARTFONT line.
Add error checking for extracting font FAMILY, SIZE, FACE, etc. from the BDF-FONT object.
Add recommendation to documentation to write the DISPLAYFONT files to a directory separate from the system's IL:DISPLAYFONTDIRECTORIES locations.

* Account for glyphs with a negative initial offset.

* Add VERBOSE optional parameter to READ-BDF to report font internal FAMILY, FACE, etc.
Change &OPTIONAL parameters of WRITE-BDF-TO-DISPLAYFONT-FILES to &KEY to simplify calling. (No need to remember the order.)
Add CHAR-SETS and WRITE-UNMAPPED parameters to WRITE-BDF-TO-DISPLAYFONT-FILES to allow some level of control of which DISPLAYFONT files are written.
Updated documentation, and added warning note about font's FAMILY containing any digits.
2025-04-28 11:40:08 -07:00

58 lines
9.4 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Medley READ-BDF
2
4
1
READ-BDF
1
4
By: Matt Heffron (heffron@alumni.caltech.edu)
This document last edited on April 26, 2025.
INTRODUCTION
This module defines functions to read BDF format font files, and then to write DISPLAYFONT files containing the glyphs from the source BDF file. In normal use, these DISPLAYFONT files will have remapped the glyphs from their Unicode encoding to Medley's XCCS encoding. All newly created symbols in this module are in the BDF package.
FUNCTIONS
(BDF:READ-BDF PATH &OPTIONAL VERBOSE) [Function]
BDF:READ-BDF reads and parses the BDF file specified by PATH. (It is required and does not default the extension of the filename.) This returns a BDF::BDF-FONT structure containg all of the glyphs contained in the file. If VERBOSE is non-NIL, then at, its completion, BDF:READ-BDF will print the full internal font name, and the values of the Family, Size, Weight, Slant, and Expansion as determined from the parsed BDF file. (Collectively, Weight, Slant, and Expansion comprise the font FACE. See the IRM 27.12, Fonts, for further description.)
(BDF:WRITE-BDF-TO-DISPLAYFONT-FILES BDFONT DEST-DIR &KEY FAMILY SIZE FACE ROTATION DEVICE CHAR-SETS MAP-UNKNOWN-TO-PRIVATE WRITE-UNMAPPED RAW-UNICODE-MAPPING) [Function]
BDF:WRITE-BDF-TO-DISPLAYFONT-FILES writes DISPLAYFONT files from BDFONT for each XCCS character set which contains glyphs mapped into it. BDFONT must be of a BDF::BDF-FONT structure. The files will be written into the corresponding sub-directory of DEST-DIR by character set number. BDFONT and DEST-DIR must be provided.
FAMILY, SIZE, FACE, ROTATION, and DEVICE correspond to the same arguments to IL:FONTCREATE. BDF:WRITE-BDF-TO-DISPLAYFONT-FILES will attempt to get default values from the information in the BDF::BDF-FONT. (See the description of VERBOSE output of BDF:READ-BDF, above.) FAMILY may be a list of values as for IL:FONTCREATE, in which case SIZE FACE ROTATION and DEVICE are taken from the FAMILY list. FAMILY may also be an IL:FONTDESCRIPTOR, again as for IL:FONTCREATE, in this case the values will be used if no values were specified or found in the BDF::BDF-FONT.
CHAR-SETS specifies which character sets, if present, should have the corresponding DISPLAYFONT files written. It is either a single character set number (integer from 0 to 255), a list of character set numbers, T meaning all character sets, or NIL meaning only character set 0. The default is T.
MAP-UNKNOWN-TO-PRIVATE selects how glyphs (character codes) which are present in the BDF file but do not map into XCCS should be handled. If non-NIL, then those will be mapped into the private range of the XCCS encoding space, and the corresponding DISPLAYFONT files will be written. If MAP-UNKNOWN-TO-PRIVATE is NIL (the default), then, if WRITE-UNMAPPED is non-NIL, they will be written, with their BDF (Unicode) encoding, into a parallel set of DISPLAYFONT files with "-UNMAPPED" appended to the FAMILY part of the file name.
RAW-UNICODE-MAPPING, if non-NIL, overrides the mapping of character codes from the BDF file (Unicode) encoding to XCCS encoding, and just writes the DISPLAYFONT files according to the BDF file encoding for the glyphs. It will prefix the FAMILY part of the file name with "RAW-". This defaults to NIL.
BDF:WRITE-BDF-TO-DISPLAYFONT-FILES returns five values (not a list of five values). The IL:FONTDESCRIPTOR of the mapped character sets, the list of character sets with DISPLAYFONT files actually written, the IL:FONTDESCRIPTOR of the unmapped character sets, the list of the unmapped character sets with DISPLAYFONT files actually written, the list of BDF::GLYPH instances which could not be mapped. Specifically, those glyphs which have no mapping into XCCS and with source encoding either > 0xFFFF or with a low byte = 0xFF. These glyphs are never written to DISPLAYFONT files.
NOTES
<EFBFBD><EFBFBD><00>f<EFBFBD> The names of the two entry point functions, READ-BDF and WRITE-BDF-TO-DISPLAYFONT-FILES, are the only symbols exported from the BDF package, all others are internal to that package.
<EFBFBD><EFBFBD><00>f<EFBFBD> Using a FAMILY name that contains any digits, either explicitly or from the information in the BDF::BDF-FONT, is strongly discouraged. This is likely to result in fonts which cannot be located by the standard font search process (e.g., TEdit), although they can be created explicitly using IL:FONTCREATE.
<EFBFBD><EFBFBD><00>f<EFBFBD> It is recommended that DEST-DIR provided to BDF:WRITE-BDF-TO-DISPLAYFONT-FILES be a different location than those on the standard value of IL:DISPLAYFONTDIRECTORIES. This will protect your files from possible loss when newer releases of Medley are installed. You may (in your personal INIT file) add your DEST-DIR location to the IL:DISPLAYFONTDIRECTORIES list to enable the normal font finding process to locate your fonts.
<EFBFBD><EFBFBD><00>f<EFBFBD> For BDF files containing a large number of glyphs, BDF:READ-BDF can take quite a while and use a lot of memory. For example, READ-BDF of gnu unifont-16.0.02.bdf with 57086 glyphs, took 72 seconds, and allocated 1.3 million FIXP and 3.3 million ONED-ARRAY.)
(SEQUENCE NIL NIL (0 0 0 0) ((PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "" "") STARTINGPAGE# 1) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "" "")) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (ALTERNATE NIL NIL (0 0 0 0) ((PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "" "")) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "" "")) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (PAGE NIL (PAPERSIZE Letter FOLIOINFO (ARABIC "" "")) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO (ARABIC "" "")) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL)))))))
1$5 <01>$ T5 <01>$ T5<01>$<01>T4<01>$<01>7<00><01>$<00><01>1<01>$1<00><00>8$1<00><00>8$J<01>$<01> PAGEHEADING RUNNINGHEAD*MODERN
((\TEDIT.COLOR BLACK)))GACHA
((\TEDIT.COLOR BLACK))*MODERN
((\TEDIT.COLOR BLACK))*MODERN
((\TEDIT.COLOR BLACK))*MODERN
((\TEDIT.COLOR BLACK))*MODERN
((\TEDIT.COLOR BLACK))vR(TEDIT-FONTCLASS 0 (MODERN 10) NIL NIL (POSTSCRIPT (MODERN 10)) (PDF (MODERN 10)))
((\TEDIT.COLOR BLACK))[(TEDIT-FONTCLASS 0 (HELVETICA 10) NIL NIL (POSTSCRIPT (HELVETICA 10)) (PDF (HELVETICA 10)))
((\TEDIT.COLOR BLACK))<00>^(TEDIT-FONTCLASS 0 (MODERN 10 MIR) NIL NIL (POSTSCRIPT (MODERN 10 MIR)) (PDF (MODERN 10 MIR)))
((\TEDIT.COLOR BLACK))<00>^(TEDIT-FONTCLASS 0 (MODERN 10 MIR) NIL NIL (POSTSCRIPT (MODERN 10 MIR)) (PDF (MODERN 10 MIR)))
((\TEDIT.COLOR BLACK))*MODERN
((\TEDIT.COLOR BLACK))- HELVETICA
((\TEDIT.COLOR BLACK))*MODERN ((\TEDIT.COLOR BLACK))*MODERN((\TEDIT.COLOR BLACK)).
TIMESROMAN$((\TEDIT.COLOR BLACK))
 
 HRULE.GETFN HRULE.GETFN HRULE.GETFN
  HRULE.GETFN
 HRULE.GETFN
., A 

 8V
 )$
!

 
 
  "C
N
 4"g=<00>    <00>" &t<00>
  
"+<00>pDATE:iր<69><13><00>z<EFBFBD>