1
0
mirror of synced 2026-01-12 00:42:56 +00:00
Interlisp.medley/docs/internal/MEDLEYFONTFORMAT.TEDIT
rmkaplan 82fc95ce18
rmk122--Next round on fonts and MCCS (#2280)
* A revision to the font, Unicode, Tedit, and other modules to implement the MCCS character coding as the standard for internal text strings.  MCCS is a variant of XCCS with arrows switched with circumflex/underscore and $ switched with currency, and allows for additional code assignments over time. :MCCS replaces :XCCS as the default external format, especially for source files.  The file XCCS is removed in favor of the file MCCS, which includes the XCCS external format for backward compatibility.

* This includes a single Medley-font formatted font file for each of the family/size/face display fonts.  The glyph assignments correspond to the MCCS character encoding (except for fonts with idiosyncratic encodings--Hippo, Symbol).  All charsets from legacy font files are included in each file, and the character sets and glyphs in each file have also been extended by offline coercion from related families (e.g. Glyphs not in legacy Terminal are taken from legacy Modern). There should be fewer black boxes, and character-display shouldn't change when you switch fonts.

* The Unicode mapping tables have been redefined to set up correspondences between Unicode and MCCS, not XCCS.  Separate XCCS to/from MCCS mapping functions are provided in the file MCCS; they are no longer included in INTERPRESS.

* TEDIT converts characters in legacy fonts to their new MCCS codes as it reads formatted files, marks the file as MCCS compatible and preserves the new codes on writing.

* Default keyboard assignments produce the MCCS uparrow and leftarrow for shift-6 and shift-hyphen, use Function-6 for circumflex and Function-10 for underscore.

See documentation in FONTCODECHANGES.TEDIT MCCS.TEDIT MEDLEYFONTFORMAT.TEDIT in docs/internal, and library/UNICODE.TEDIT.
2025-10-20 17:17:34 -07:00

72 lines
12 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 MEDLEYFONTFORMAT
2
4
1
MEDLEYFONTFORMAT
1
4
By: Ron Kaplan
This document last edited on May 25, 2025.
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. A single character set can be stored in a medleyfont file, but several or all of the character sets for a given font can be stored in one file. In that case 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 CHARSETNOS OTHERFONTPROPS) [Function]
FONT is either a FONTDESCRIPTOR or the typical list specification of a font. Enough information is written to FILE so that MEDLEYFONT.READ.FONT can reconstitute the in-core properties of FONT. The information for all of FONT's current character sets will be written if CHARSETNOS is not provided or is ALL, otherwise the information about just the specified 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.
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). If CHARSETNOS specifies a single character set (e.g. 0), that will be indicated by appending -C followed by the charset number to the name of the file, according to the old conventions Otherwise the default file name will have no character set indicator.
Thus, the file name produced by (MEDLEYFONT.WRITE.FONT '(CLASSIC 8)) will be<62><65>
<EFBFBD> [MEDLEYDIR]> fonts>medleydisplayfonts>CLASSIC08-MRR.MEDLEYDISPLAYFONT.<2E><>
<EFBFBD>For (MEDLEYFONT.WRITE.FONT '(CLASSIC 8) NIL 0) the name will be<62><65>
<EFBFBD> [MEDLEYDIR]fonts>medleydisplayfonts>CLASSIC08-MRR-C0.MEDLEYDISPLAYFONT.
Finally, OTHERFONTPROPS can be specified as a note or other information to be written on the file for later retrieval.
(MEDLEYFONT.READ.FONT FILE CHARSETNOS FONT) [Function]
The information for CHARSETNOS character sets will be read from FILE into an in-core FONTDESCRIPTOR. If FONT is provided and specifies a font descriptor, that object will be modified. Otherwise a new descriptor will be created and returned. If CHARSETNOS is not provided, information for all character sets on FILE will be installed.
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) [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.
(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> $<01>T5<01>$<01>T4<01> $<01>5*<01>$0T2<01>$T4<01>$<01>1<01>$1<00><00>8$1<00><00>8$1<00><00>8$J<01>$<01> PAGEHEADING RUNNINGHEAD
/MODERN
(CHARPROPS (COLOR . BLACK))0CLASSIC
(CHARPROPS (COLOR . BLACK))/MODERN
(CHARPROPS (COLOR . BLACK))2 HELVETICA
(CHARPROPS (COLOR . BLACK))/MODERN
(CHARPROPS (COLOR . BLACK))1TERMINAL
(CHARPROPS (COLOR . BLACK))/MODERN(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* <02><00># jI, PRm
<00>L FAO ` 
"$<00>
8( ](CU<00><00> <00>0<00>=<00>W
 %  

0
 L?<00>+ 

 uCj}<00>

{
,
 BP8]
 IdtDATE:j<><6A><EFBFBD><1D>z<>