75 lines
14 KiB
Plaintext
75 lines
14 KiB
Plaintext
Medley MEDLEYFONTFORMAT
|
||
2
|
||
|
||
4
|
||
|
||
1
|
||
|
||
MEDLEYFONTFORMAT
|
||
1
|
||
|
||
4
|
||
|
||
By: Ron Kaplan
|
||
This document last edited on April 6, 2026.
|
||
Introduction
|
||
This file implement a new Medley-specific file format for storing the information contained in an arbitrary FONTDESCRIPTOR data structure, and for reading that information into a FONTDESCRIPTOR equivalent to the original. The original can be assembled and constructed from any sources for any device, modified in memory, and then saved in the standard medleyfont format. There is information in the file for all of the character sets of the font (up to the font's MAXCHARSET), including NIL entries for character sets that are not yet instantiated in the font descriptor. The individual character sets are indexed for rapid retrieval. Reading makes use of only forward-pointing SETFILEPTRs so does not depend on random access.
|
||
Writing and reading
|
||
The function MEDLEYFONT.WRITE.FONT writes the information in an in-memory FONTDESCRIPTOR to a file, and MEDLEYFONT.READ.FONT retrieves that information.
|
||
(MEDLEYFONT.WRITE.FONT FONT FILE OTHERFONTPROPS NOINDIRECTS) [Function]
|
||
FONT is either a FONTDESCRIPTOR a FONTSPEC. Enough information is written to FILE so that MEDLEYFONT.READ.FONT can reconstitute the in-core properties of the designated FONT. The information for all of FONT's current character sets will be written. It is expected that a medleyfont will be complete for character sets and characters within character sets, as determined by COMPLETE.FONT and the specifications of the FONTCOERCIONS and CHARCOERCIONS font-device properties. But the format records the fact that some character sets in the font descriptor may not yet be instantiated. These are distinguished from character sets that are known to be empty and are instantiated as the slug charsetinfo.
|
||
If FILE is not provided, the name of the file will be constructed from the properties of FONT. By default it will be stored in a MEDLEYDIR subdirectory of the form fonts>medley[device]s> with an extension of the form MEDLEY[device]FONT. That subdirectory and extension are included respectively in DISPLAYFONTDIRECTORIES and DISPLAYFONTEXTENSIONS. Similar subdirectories and extensions are set up for other devices (e.g. fonts/medleypostscript/fonts).
|
||
Thus, the file name produced by (MEDLEYFONT.WRITE.FONT '(CLASSIC 8)) will be [MEDLEYDIR]> fonts>medleydisplayfonts>CLASSIC08-MRR.MEDLEYDISPLAYFONT.
|
||
OTHERFONTPROPS can be specified as a note or other information to be written on the file for later retrieval.
|
||
The coercion process in the constuction of Medley font descriptors records the fact that some character sets are exactly identical to the same character sets in other fonts. Thus there may be only one true source for all of the Japanese Kanji character sets, but other fonts may appear to have those characters by virtue of an indirect pointer. The Medley fontfile for a font with such an indirect will store that indirect relationship as the FONTSPEC of the source font, with the benefit of a substantial reduction in file size. The downside is that the source font must be accessible at when such a character set is read in. If NOINDIRECTS is true, that dependency is avoided by copying into the file the full specification of an indirect character set.
|
||
(MEDLEYFONT.READ.FONT FILE CHARSETS NOERROR) [Function]
|
||
The information for CHARSETS character sets will be read from FILE into a new in-core FONTDESCRIPTOR. If CHARSETS is ALL, information for all character sets on FILE will be installed. If NIL, then only the font fields will be filled in, with no character sets (not even 0) instantiated.
|
||
Character sets that are not designated by CHARSETS will be represented by NIL in the resulting font, indicating that they have not yet been instantiated. The information for indirect character sets will be retrieved from a font-file in the same directory as FILE.
|
||
If FONT is provided as a FONTSPEC, the standard filename corresponding to that specification will be read.
|
||
If NOERROR, MEDLEYFONT.READ.FONT returns NIL if a font cannot be read from the indicated file.
|
||
(MEDLEYFONT.FILENAME FILE DIRECTORY EXTENSION) [Function]
|
||
Returns a fully specified Medley font file name for FILE, a string, litatom, or FONTSPEC. If FILE is a FONTSPEC it is first translated to a standard name for that specification, with values for the directory and extension taken from DIRECTORY and/or EXTENSION, if provided, or from the FONTDEVICEPROP properties of its device. DIRECTORY and EXTENSION also provide default s if FILE is a string or atom.
|
||
Integration with current FONT interface
|
||
(MEDLEYFONT.FILEP FILE) [Function]
|
||
Returns NIL if FILE is not a medley-font file or a stream open on a medley-font file, otherwise returns a list (fullname date version otherfontprops), where fullfilename is the fullname of the file, date is the date that the file was written, version is the version-number of the medleyfont format (currently 0), and otherfontprops is the value of OTHERFONTPROPS, if any were specified when the file was created. If FILE is a stream open at the beginning of a medley-font file, the stream is left open and positioned just after its header information.
|
||
MEDLEYFONT.FILEP is used to distinguish medley-font files from display and hardcopy font files with legacy formats when FONTCREATE requests information about a font or character set.
|
||
(MEDLEYFONT.GETCHARSET STREAM CHARSET FONT DIRECTORY) [Function]
|
||
This is how medley-format files are linked into the current font-loading interface: it is called from \READCHARSET when the priority list of directories and extensions lands on a medley-format file.
|
||
This returns the CHARSETINFO data structure for CHARSET from a medley-font file. If STREAM is an input stream, it is assumed that it is positioned (e.g. by MEDLEYFONT.FILEP) just after the header information. If STREAM is a file name, that file is opened, processed, and closed.
|
||
If the information for CHARSET is stored indirectly as a different (family size face rotation) FONTSPEC, its CHARSETINFO is retrieved by calling \READCHARSET recursively to find a file that matches those parameters.
|
||
Acces to file properties
|
||
The following functions provide information about the contents of a medley-font file:
|
||
(MEDLEYFONT.CHARSET? FILE CHARSET) [Function]
|
||
Returns CHARSET if FILE contain information about CHARSET, otherwise NIL. Causes an error if FILE is not a medley-font file.
|
||
(MEDLEYFONT.GETFILEPROP FILE PROP) [Function]
|
||
Returns the value of property PROP for the medley-font file FILE. PROP currently can be one of
|
||
DATE Returns the date that FILE was written.
|
||
OTHERPROPS Returns the OTHERFONTPROPS if provided when FILE was written.
|
||
FONTPROPS Returns a list of the FONTDESCRIPTOR field-values of the font written in FILE.
|
||
CHARSETS Returns the numbers of the character sets written in FILE.
|
||
Internal primitives
|
||
Finally, the following internal functions are the primitives used for writing and reading the font information.An item is written as a property-list pair consisting of a label and the item's data.
|
||
(MEDLEYFONT.WRITE.ITEM STREAM LABEL ITEM EVENIFNIL TYPE BLOCKNELTS) [Function]
|
||
Writes the data for ITEM on the open medley-font STREAM prefixed by LABEL. Unless EVENIFNIL, nothing will be written if ITEM is NIL. The type of the item (atom, number, array, list) is usually inferred from its Lisp datatype, but optional TYPE can be provided to override the inferred type. In particular, if TYPE is ALIST or PLIST, the data is written in a more compact form than it would be for a more general list. Type can also be specified as PRINT, in which case the data is written by PRIN2 and read by READ, without any other overhead. If ITEM is not one of the recognized types (e.g. an instance of a user-defined datatype), the fallback is to write it out with HPRINT.
|
||
The optional BLOCKNELTS is relevant only for arrayblocks. An arrayblock may have more physical words than an algorithm actually makes use of. If BLOCKNELTS is provided, it specifies the number of logically necessary words that are to be written on the stream. Otherwise, the possibly greater number of physical words will be written. (Note: currently it is assumed that the elements of all blocks contain 16-bit binary-word data; that can be changed.)
|
||
(MEDLEYFONT.READ.ITEM STREAM LABEL?) [Function]
|
||
Returns data for the item written at the current file position of STREAM. If LABEL? is specified, an error is generated if the label of the item is different from LABEL?. If the labels match, the value is the item's data. If LABEL? is not provided, the label in the file is not checked and the value is a (label data) pair.
|
||
(MEDLEYFONT.PEEK.ITEM STREAM LABEL?) [Function]
|
||
Reads and advances over the item written at the current file position of STREAM. That item is returned as if MEDLEYFONT.READ.ITEM had been called. But the item is also saved as a STREAM property so the next call to MEDLEYFONT.READ.ITEM will also return that item without further advancing the stream.
|
||
|
||
|
||
|