TeX in C
Explore TeX with modern c compiler.
fonts.h
浏览该文件的文档.
1 #pragma once
2 #ifndef FONTS_H
4 #define FONTS_H
5 #include <stdio.h> // FILE
6 #include "global.h" // [macro] qi, qo; [const] UMAXOF, static_assert
7 #include "tex_constant.h" // [const] FONT_MAX, FONT_MEM_SIZE, FONT_BASE, MIN_QUARTER_WORD, MAX_HALF_WORD
8 #include "str.h"
9 #include "dump.h" // [macro]
10 // [fonts], dviout, tex
11 
12 
20 enum CharTag {
24  EXT_TAG
25 };
26 
30 
38 };
39 
41 #define opbyte(x) (x.b2)
42 #define rembyte(x) (x.b3)
43 
45 #define stopflag qi(128)
47 #define kernflag qi(128)
48 #define skipbyte(x) x.b0
49 #define nextchar(x) x.b1
50 
52 #define charexists(x) ((x).b0>MIN_QUARTER_WORD)
53 #define chartag(x) ((qo((x).b2)) % 4)
54 
56 #define heightdepth(x) qo(x.b1)
57 
59 #define ligkernstart(x, y) (ligkernbase[(x)] + rembyte(y))
61 #define ligkernrestart(x, y) \
62  (ligkernbase[(x)] + opbyte(y) * 256 + rembyte(y) - kernbaseoffset + 32768L)
63 // #define lig_kern_start(x) (lig_kern_base[x]+rem_byte)
64 
66 #define NON_CHAR 256
68 #define nonaddress 0
70 #define kernbaseoffset 32768
71 
73 #define param(x, y) (fontinfo[(x) + parambase[y]].sc)
74 #define slant(x) param(SLANT_CODE,x) /* slant to the right, per unit distance upward}*/
75 #define space(x) param(SPACE_CODE,x) /* NORMAL space between words}*/
76 #define spacestretch(x) param(SPACE_STRETCH_CODE,x) /* stretch between words}*/
77 #define spaceshrink(x) param(SPACE_SHRINK_CODE,x) /* shrink between words}*/
78 #define xheight(x) param(X_HEIGHT_CODE,x) /* one ex}*/
79 #define quad(x) param(QUAD_CODE,x) /* one em}*/
80 #define extraspace(x) param(EXTRA_SPACE_CODE,x) /* additional space at end of sentence}*/
81 
83 #define badtfm 11
84 
86 #define exttop(x) x.b0 /* |top| piece in a recipe */
87 #define extmid(x) x.b1 /* |mid| piece in a recipe */
88 #define extbot(x) x.b2 /* |bot| piece in a recipe */
89 #define extrep(x) x.b3 /* |rep| piece in a recipe */
90 
93 static_assert(FONT_BASE == 0, "FONT_BASE == 0");
94 static_assert(UMAXOF(InternalFontNumber) >= FONT_MAX,
95  "InternalFontNumber = [FONT_BASE, FONT_MAX] = [0, 75]"); // end group S539x582_P196x213
97 
98 
100 extern Boolean fontused[FONT_MAX + 1];
101 
102 // [fonts], dviout, printout, tex
106 
107 // [fonts], tex
108 typedef Pointer FontIndex; // #548: [0, FONT_MEM_SIZE] = [0, 200000]
109 static_assert(UMAXOF(FontIndex) >= FONT_MEM_SIZE,
110  "FontIndex = [0, FONT_MEM_SIZE] = [0, 200000]");
118 extern void fonts_init_once(void);
119 
120 extern int fonts_undump();
121 extern void fonts_dump();
123 extern void set_hyphenchar(InternalFontNumber x, Integer c);
125 extern void set_skewchar(InternalFontNumber x, Integer c);
126 
127 extern InternalFontNumber
129 extern void scanfontident(void);
130 extern void findfontdimen(Boolean writing);
131 extern void charwarning(InternalFontNumber f, EightBits c);
133 
134 extern FontIndex fmemptr;
135 extern MemoryWord fontinfo[FONT_MEM_SIZE + 1];
136 extern FontIndex fontparams[FONT_MAX + 1];
137 extern EightBits fontbc[FONT_MAX + 1];
138 extern EightBits fontec[FONT_MAX + 1];
139 extern Pointer fontglue[FONT_MAX + 1];
140 extern FontIndex bcharlabel[FONT_MAX + 1];
141 extern Integer fontbchar[FONT_MAX + 1];
142 extern Integer fontfalsebchar[FONT_MAX + 1];
143 extern Integer ligkernbase[FONT_MAX + 1]; // texmac
144 extern Integer extenbase[FONT_MAX + 1];
145 extern Integer parambase[FONT_MAX + 1];
146 
148 
149 extern void font_init();
150 
151 #endif // #ifndef FONTS_H
Pointer FontIndex
Definition: fonts.h:108
#define UMAXOF(t)
取无符号类型的最大值
Definition: global_macros.h:9
uint32_t HalfWord
[p43#113]: HalfWord(16=>32) .
Definition: tex_types.h:127
#define FONT_MAX
[#11] maximum internal font number.
Definition: tex_constant.h:82
#define FONT_BASE
[#12] smallest internal font number.
Definition: tex_constant.h:133
#define FONT_MEM_SIZE
[#11] number of words of fontinfo for all fonts.
Definition: tex_constant.h:87
UChar EightBits
[#25]: EightBits::UChar(8) = [0, 255]
Definition: tex_types.h:98
uint_fast32_t StrNumber
Definition: str.h:73
FourQuarters charinfo(InternalFontNumber f, EightBits p)
Definition: fonts.c:82
Integer get_hyphenchar(InternalFontNumber x)
Definition: fonts.c:75
StrNumber get_fontname(InternalFontNumber x)
Definition: fonts.c:79
TFMParamVal
[p200#547]
Definition: fonts.h:28
Integer ligkernbase[FONT_MAX+1]
base addresses for ligature/kerning programs.
Definition: fonts.c:60
MemoryWord fontinfo[FONT_MEM_SIZE+1]
the big collection of font data
Definition: fonts.c:25
void fonts_dump()
[#1320] Dump the font information.
Definition: fonts.c:161
Integer extenbase[FONT_MAX+1]
base addresses for extensible recipes.
Definition: fonts.c:64
EightBits fontec[FONT_MAX+1]
ending (largest) character code.
Definition: fonts.c:36
FourQuarters nullcharacter
Definition: fonts.c:69
FourQuarters get_fontcheck(InternalFontNumber x)
Definition: fonts.c:80
Integer get_skewchar(InternalFontNumber x)
Definition: fonts.c:73
void font_init()
[#551, #556]
Definition: fonts.c:107
HalfWord newcharacter(InternalFontNumber f, EightBits c)
[#582]
Definition: fonts.c:982
void fonts_init_once(void)
[#552] TeX always knows at least one font, namely the null font.
Definition: fonts.c:125
int fonts_undump()
[#1321] Undump the font information.
Definition: fonts.c:229
Integer parambase[FONT_MAX+1]
base addresses for font parameters.
Definition: fonts.c:66
InternalFontNumber readfontinfo(Pointer u, StrNumber nom, StrNumber aire, Scaled s)
[p205#560]: input a TFM file.
Definition: fonts.c:309
Scaled charkern(InternalFontNumber x, FourQuarters y)
Definition: fonts.c:102
Scaled charheight(InternalFontNumber x, Integer y)
Definition: fonts.c:94
Scaled charitalic(InternalFontNumber x, FourQuarters y)
Definition: fonts.c:90
InternalFontNumber fontptr
largest internal font number in use
Definition: fonts.c:27
EightBits fontbc[FONT_MAX+1]
beginning (smallest) character code
Definition: fonts.c:35
FontIndex fmemptr
first unused word of font info
Definition: fonts.c:26
Scaled chardepth(InternalFontNumber x, Integer y)
Definition: fonts.c:98
Boolean fontused[FONT_MAX+1]
has a character from this font actually appeared in the output?
Definition: fonts.c:40
Scaled charwidth(InternalFontNumber x, FourQuarters y)
Definition: fonts.c:86
void findfontdimen(Boolean writing)
[#578] sets cur_val to font_info location.
Definition: fonts.c:914
UChar InternalFontNumber
[#548]: [FONT_BASE, FONT_MAX] = [0, 75]
Definition: fonts.h:92
void charwarning(InternalFontNumber f, EightBits c)
[#581]
Definition: fonts.c:970
void set_skewchar(InternalFontNumber x, Integer c)
Definition: fonts.c:74
Integer fontbchar[FONT_MAX+1]
right boundary character, non char if there is none.
Definition: fonts.c:47
FontIndex fontparams[FONT_MAX+1]
how many font parameters are present
Definition: fonts.c:32
FontIndex bcharlabel[FONT_MAX+1]
start of lig kern program for left boundary character, non address if there is none.
Definition: fonts.c:45
void set_hyphenchar(InternalFontNumber x, Integer c)
Definition: fonts.c:76
Integer fontfalsebchar[FONT_MAX+1]
font bchar if it doesn’t exist in the font, otherwise non char.
Definition: fonts.c:49
CharTag
[p198#544]: tag field in a char_info_word that explain how to interpret the remainder field.
Definition: fonts.h:20
Scaled get_fontdsize(InternalFontNumber x)
Definition: fonts.c:78
Scaled get_fontsize(InternalFontNumber x)
Definition: fonts.c:77
Pointer fontglue[FONT_MAX+1]
glue specification for interword space, null if not allocated.
Definition: fonts.c:38
void scanfontident(void)
[#577] Declare procedures that scan font-related stuff.
Definition: fonts.c:884
@ SPACE_SHRINK_CODE
Definition: fonts.h:34
@ SPACE_STRETCH_CODE
Definition: fonts.h:33
@ QUAD_CODE
Definition: fonts.h:36
@ TFM_PARAM_MISSING
TeX sets the missing parameters to zero
Definition: fonts.h:29
@ X_HEIGHT_CODE
Definition: fonts.h:35
@ SPACE_CODE
Definition: fonts.h:32
@ SLANT_CODE
Definition: fonts.h:31
@ EXTRA_SPACE_CODE
Definition: fonts.h:37
@ LIST_TAG
character has a successor in a charlist
Definition: fonts.h:23
@ NO_TAG
vanilla character
Definition: fonts.h:21
@ EXT_TAG
character is extensible
Definition: fonts.h:24
@ LIG_TAG
character has a ligature/kerning program
Definition: fonts.h:22
[p43#113]: FourQuarters(64) .
Definition: tex_types.h:159
int64_t Integer
Integer(64) =
Definition: tex_types.h:42
Integer Scaled
[p38#101]: Scaled::Integer(64) = we need Pascal's Integer(32/64), dependent upon the bit size of the...
Definition: tex_types.h:106
size_t Pointer
Pointer::size_t(64), a flag or a location in mem or eqtb.
Definition: tex_types.h:45
bool Boolean
布尔类型定义
Definition: tex_types.h:11
uint8_t UChar
UChar(8) = [0, 255]
Definition: tex_types.h:38
[p43#113]: MemoryWord(64) .
Definition: tex_types.h:164