2 tfm.hh -- declare Tex_font_metric
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Jan Nieuwenhuizen <janneke@gnu.org>
15 #include "lily-proto.hh"
20 /* A character code. Perhaps someday we will allow for 16-bit
21 character codes, but for now we are restricted to 256 characters per
22 font (like TeX and PostScript). */
23 typedef unsigned char Char_code;
25 /* Used in file formats. */
26 typedef int Byte_count;
28 /* The restriction to 256 characters in a TFM file is part of the file
29 format, so this number should only be changed in the (very unlikely)
30 event that the file format changes. */
33 /* Fontwide information. All real values are in printer's points:
34 72.27 points = 1 inch. */
36 /* TFM_MIN_DESIGNSIZE <= designsize < TFM_MAX_DESIGNSIZE. */
37 #define TFM_MIN_DESIGNSIZE 1.0
38 #define TFM_MAX_DESIGNSIZE 2048
40 /* The maximum number of global font parameters we allow. */
41 #define TFM_MAX_FONTDIMENS 30
43 /* The maximum length of a codingscheme string. */
44 #define TFM_MAX_CODINGSCHEME_LENGTH 39
46 /* Define symbolic names for the numbers of the parameters we
47 recognize. Some numbers have more than one name. */
48 #define TFM_SLANT_PARAMETER 1
49 #define TFM_SPACE_PARAMETER 2
50 #define TFM_STRETCH_PARAMETER 3
51 #define TFM_SHRINK_PARAMETER 4
52 #define TFM_XHEIGHT_PARAMETER 5
53 #define TFM_QUAD_PARAMETER 6
54 #define TFM_EXTRASPACE_PARAMETER 7
55 #define TFM_NUM1_PARAMETER 8
56 #define TFM_NUM2_PARAMETER 9
57 #define TFM_NUM3_PARAMETER 10
58 #define TFM_DENOM1_PARAMETER 11
59 #define TFM_DENOM2_PARAMETER 12
60 #define TFM_SUP1_PARAMETER 13
61 #define TFM_SUP2_PARAMETER 14
62 #define TFM_SUP3_PARAMETER 15
63 #define TFM_SUB1_PARAMETER 16
64 #define TFM_SUB2_PARAMETER 17
65 #define TFM_SUPDROP_PARAMETER 18
66 #define TFM_SUBDROP_PARAMETER 19
67 #define TFM_DELIM1_PARAMETER 20
68 #define TFM_DELIM2_PARAMETER 21
69 #define TFM_AXISHEIGHT_PARAMETER 22
70 #define TFM_DEFAULTRULETHICKNESS_PARAMETER 8
71 #define TFM_BIGOPSPACING1_PARAMETER 9
72 #define TFM_BIGOPSPACING2_PARAMETER 10
73 #define TFM_BIGOPSPACING3_PARAMETER 11
74 #define TFM_BIGOPSPACING4_PARAMETER 12
75 #define TFM_BIGOPSPACING5_PARAMETER 13
77 /* These are not in any of the standard TeX fonts, but the information
78 is useful nevertheless. */
79 #define TFM_LEADINGHEIGHT_PARAMETER 23
80 #define TFM_LEADINGDEPTH_PARAMETER 24
81 #define TFM_FONTSIZE_PARAMETER 25
82 #define TFM_VERSION_PARAMETER 26
86 Byte_count char_info_pos;
88 Byte_count height_pos;
90 Byte_count italic_correction_pos;
91 Byte_count lig_kern_pos;
93 unsigned param_word_count;
98 Char_code first_charcode, last_charcode;
101 String coding_scheme;
102 unsigned parameter_count;
103 // Real parameters [Tex_font_metric::MAX_FONTDIMENS];
104 Real parameters [TFM_MAX_FONTDIMENS];
107 /* When typesetting, the current character + `character' leads to
108 `ligature'. The TFM format was extended in 1990 to allow for more
109 complicated ligatures than this, but we do not make those
117 /* Similarly for kerns. */
124 struct Tex_font_char_metric
128 Real width_, height_, depth_, italic_correction_;
129 Fix width_fix_, height_fix_, depth_fix_, italic_correction_fix_;
130 Array<Tfm_kern> kern_arr_;
131 Array<Tfm_ligature> ligature_arr_;
134 Tex_font_char_metric ();
138 class Tex_font_metric
142 Tex_font_char_metric find_ascii (int ascii, bool warn=true) const;
149 void read_file (String name);
151 Array<Tex_font_char_metric> char_metrics_;
152 Array<int> ascii_to_metric_idx_;
155 Real get_U32_fix_f (Binary_source_file* input);
156 Real get_U32_fix_scaled_f (Binary_source_file* input);
157 String get_bcpl_str (Binary_source_file* input);
158 void read_header (Binary_source_file* input);
159 void read_params (Binary_source_file* input);
160 void read_char_metrics (Binary_source_file* input);
161 Tex_font_char_metric read_char_metric (Binary_source_file* input, Char_code code);
162 Tex_font_char_metric read_char (Binary_source_file* input);
163 void read_lig_kern_program (Binary_source_file* input, Array <Tfm_ligature>* ligature_arr_p, Array <Tfm_kern>* kern_arr_p);