1
0
mirror of synced 2026-03-03 02:17:57 +00:00
Files
Interlisp.medley/lispusers/READ-BDF.TEDIT
Matt Heffron a8a427597f Significant restructuring:
Removed WRITE-BDF-TO-DISPLAYFONT-FILE (i.e., no STRIKE format files).
No multiple-values returned. Instead, use LIST when appropriate.
BDF-TO-CHARSETINFO is now IDEMPOTENT w.r.t. the GLYPHS.
Move resolution and defaulting of FAMILY, FACE, SIZE, ROTATION, DEVICE from WRITE-BDF-TO-MEDLEYDISPLAYFONT-FILE to BDF-TO-FONTDESCRIPTOR.
Keep the MCCS chars present BITMAP in the BDF-FONT structure, instead of needing to schlepping it around separately.
Abstracted testing/setting the MCCS chars present bits to CHAR-PRESENT-BIT (mimicking BITMAPBIT).
Added COUNT-MCHARS to know how many MCCS chars are marked in the BITMAP as present.
READ-BDF now handles when UTOMCODE? returns multiple mappings, and creates the appropriate duplicate GLYPHS with different MCCS char codes.
READ-GLYPH doesn't create an empty BITMAP for spacing glyphs.

Use font code changes:
Set (CHARSETINFO CHARSETNO).
Set (FONTDESCRIPTOR FONTSLUGWIDTH).
2025-11-30 17:46:12 -08:00

73 lines
12 KiB
Plaintext
Raw 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 November 30, 2025.
INTRODUCTION
This module defines functions to read BDF format font files, and then to write MEDLEYDISPLAYFONT files containing the glyphs from the source BDF file. In normal use, these font files will have remapped the glyphs from their Unicode encoding to Medley's MCCS encoding. All newly created symbols in this module are in the BDF package.
FUNCTIONS
(READ-BDF PATH &KEY :VERBOSE :MCCS-ONLY :EXTERNAL-FORMAT) [Function]
READ-BDF reads and parses the BDF file specified by PATH. (The parameter PATH is required and it does not default the extension of the filename.) This returns he first is a BDF-FONT structure containg all of the glyphs contained in the file, unless :MCCS-ONLY is non-NIL, in which case it will contain only the glyphs which correspond to valid MCCS characters.
The :VERBOSE keyword parameter enables display of some summary information about the BDF-FONT structure created.
The :EXTERNAL-FORMAT specifies the character encoding of the BDF file itself. This can be any value acceptable to use with the CL:OPEN or IL:OPENSTREAM functions. (At least one linux utility writes BDF files as ISO8859/1, so that is the default for this parameter.) If :VERBOSE is non-NIL, then at, its completion, 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.)
(BUILD-COMPOSITE BASE-FONT &REST FILL-FROM) [Function]
BUILD-COMPOSITE builds a single BDF-FONT structure instance from a sequence of BDF fonts. Either BDF-FONT instances, or paths to .bdf files (either as strings or PATHNAME instances). BASE-FONT may be a LISTP, in which case BASE-FONT will be set to (FIRST BASE-FONT), and FILL-FROM will be set to the list created by (APPEND (REST BASE-FONT) FILL-FROM).
If BASE-FONT is a BDF-FONT instance, it will be modified. If it designates a file, then a new BDF-FONT instance will be created. If either BASE-FONT or any entry on FILL-FROM is not one of: a BDF-FONT instance, a string, or a PATHNAME instance, an error will be raiseed.
The building of the composite BDF-FONT procedes as follows. The BASE-FONT is loaded by READ-BDF if necessary. The BITMAP created by READ-BDF from the BASE-FONT and stored in the BDF-FONT structure is . This has a bit for every possible MCCS character. Each entry on FILL-FROM in turn is loaded by READ-BDF if necessary, then each glyph present in that BDF-FONT is checked, using the BDF-FONT-MCHAR-PRESENT of BASE-FONT (a BITMAP), to see if it is already present in the BASE-FONT. If it is not, that glyph is pushed onto the list of glyphs in the BASE-FONT and the corresponding bit is set in the BITMAP.
(WRITE-BDF-TO-MEDLEYDISPLAYFONT-FILE BDFONT DEST-DIR &KEY :FAMILY :SIZE :FACE :ROTATION :DEVICE) [Function]
WRITE-BDF-TO-MEDLEYDISPLAYFONT-FILE writes one MEDLEYDISPLAYFONT file from BDFONT containing each MCCS character set which contains glyphs mapped into it. BDFONT must be of a BDF-FONT structure. The file will be written into the provided DEST-DIR path. BDFONT and DEST-DIR must be provided.
:FAMILY, :SIZE, :FACE, :ROTATION, and :DEVICE correspond to the same arguments to IL:FONTCREATE. WRITE-BDF-TO-MEDLEYDISPLAYFONT-FILE will attempt to get default values from the information in the BDF-FONT. (See the description of :VERBOSE output of READ-BDF, above.) FAMILY may be a list of values as for IL:FONTCREATE, in which case unspecified values for :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 each of the values will be used if no values were specified. If :DEVICE is either T or NIL, then :DEVICE is taken as DISPLAY.
WRITE-BDF-TO-MEDLEYDISPLAYFONT-FILE returns a list of three values. The full pathname of the file written, the IL:FONTDESCRIPTOR containing the mapped character sets, the list of character sets contained in the BDF-FONT structure which were actually written to the file.
NOTES
ÿÿïfÿ The names of the three entry point functions, READ-BDF, BUILD-COMPOSITE, and WRITE-BDF-TO-MEDLEYDISPLAYFONT-FILE, are the only symbols exported from the BDF package, all others are internal to that package.
ÿÿïfÿ Using a FAMILY name that contains any digits, either explicitly, or from the information in the 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.
ÿÿïfÿ It is recommended that the DEST-DIR path provided to the function WRITE-BDF-TO-MEDLEYDISPLAYFONT-FILE 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.
ÿÿïfÿ For BDF files containing a large number of glyphs, 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 È$ T5 È$ T5È$ÈT4È$È7äÈ$äÈ1È$1ŠŠ8$1ŠŠ8$JÈ$È PAGEHEADING RUNNINGHEAD/MODERN
(CHARPROPS (COLOR . BLACK)).GACHA
(CHARPROPS (COLOR . BLACK))/MODERN
(CHARPROPS (COLOR . BLACK))/MODERN
(CHARPROPS (COLOR . BLACK))/MODERN
(CHARPROPS (COLOR . BLACK))/MODERN
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MRR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MRR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MIR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MRR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MIR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MIR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MRR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MRR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MRR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MIR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MRR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MIR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MIR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MRR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))qH(TEDIT-FONTCLASS 0 (MODERN 10 MRR 0) NIL NIL (POSTSCRIPT NIL) (PDF NIL))
(CHARPROPS (COLOR . BLACK))/MODERN
(CHARPROPS (COLOR . BLACK))/MODERN
(CHARPROPS (COLOR . BLACK))2 HELVETICA
(CHARPROPS (COLOR . BLACK))/MODERN (CHARPROPS (COLOR . BLACK))/MODERN(CHARPROPS (COLOR . BLACK))3
TIMESROMAN$(CHARPROPS (COLOR . BLACK))
 
 HRULE.GETFN HRULE.GETFN HRULE.GETFN   HRULE.GETFN HRULE.GETFN./ B 


  4`& fI
 2 1&é    9N    2   R&  H 7 k /1 4 D 1%
   
% #(JM 

4#@ T Œ  #&ca&
  
#+ªp6Á(((CHARENCODING . MCCS)))PROPS:#DATE:jö'W