1
0
mirror of synced 2026-01-12 00:42:56 +00:00
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

59 lines
9.6 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 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 MCCS 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 those with source encoding either > 0xFFFF or with a low byte = 0xFF, as well as those with a width (escapement) = 0 and a bitmap (image) width = 0. 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
(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))tK(TEDIT-FONTCLASS 0 (HELVETICA 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))/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
., A 

 8V
 )$
!

 
 
  "C
N
 4"g=<00>    <00>"<01>
B &ta'
  
"+<00>p(((CHARENCODING . MCCS)))PROPS:#DATE:j<><6A><EFBFBD><00>z<EFBFBD>