font_metrics.dart
4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
class FontMetrics {
double get cssEmPerMu => quad / 18;
final double slant; // sigma1
final double space; // sigma2
final double stretch; // sigma3
final double shrink; // sigma4
final double xHeight; // sigma5
final double quad; // sigma6
final double extraSpace; // sigma7
final double num1; // sigma8
final double num2; // sigma9
final double num3; // sigma10
final double denom1; // sigma11
final double denom2; // sigma12
final double sup1; // sigma13
final double sup2; // sigma14
final double sup3; // sigma15
final double sub1; // sigma16
final double sub2; // sigma17
final double supDrop; // sigma18
final double subDrop; // sigma19
final double delim1; // sigma20
final double delim2; // sigma21
final double axisHeight; // sigma22
// These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
// they correspond to the font parameters of the extension fonts (family 3).
// See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
// match cmex7, we'd use cmex7.tfm values for script and scriptscript
// values.
final double defaultRuleThickness; // xi8; cmex7: 0.049
final double bigOpSpacing1; // xi9
final double bigOpSpacing2; // xi10
final double bigOpSpacing3; // xi11
final double bigOpSpacing4; // xi12; cmex7: 0.611
final double bigOpSpacing5; // xi13; cmex7: 0.143
// The \sqrt rule width is taken from the height of the surd character.
// Since we use the same font at all sizes, this thickness doesn't scale.
final double sqrtRuleThickness;
// This value determines how large a pt is, for metrics which are defined
// in terms of pts.
// This value is also used in katex.less; if you change it make sure the
// values match.
final double ptPerEm;
// The space between adjacent `|` columns in an array definition. From
// `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
final double doubleRuleSep;
// The width of separator lines in {array} environments. From
// `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm.
final double arrayRuleWidth; // Two values from LaTeX source2e:
final double fboxsep; // 3 pt / ptPerEm
final double fboxrule; // 0.4 pt / ptPerEm
const FontMetrics({
required this.slant,
required this.space,
required this.stretch,
required this.shrink,
required this.xHeight,
required this.quad,
required this.extraSpace,
required this.num1,
required this.num2,
required this.num3,
required this.denom1,
required this.denom2,
required this.sup1,
required this.sup2,
required this.sup3,
required this.sub1,
required this.sub2,
required this.supDrop,
required this.subDrop,
required this.delim1,
required this.delim2,
required this.axisHeight,
required this.defaultRuleThickness,
required this.bigOpSpacing1,
required this.bigOpSpacing2,
required this.bigOpSpacing3,
required this.bigOpSpacing4,
required this.bigOpSpacing5,
required this.sqrtRuleThickness,
required this.ptPerEm,
required this.doubleRuleSep,
required this.arrayRuleWidth,
required this.fboxsep,
required this.fboxrule,
});
static FontMetrics? fromMap(Map<String, double> map) {
try {
return FontMetrics(
slant: map['slant']!,
space: map['space']!,
stretch: map['stretch']!,
shrink: map['shrink']!,
xHeight: map['xHeight']!,
quad: map['quad']!,
extraSpace: map['extraSpace']!,
num1: map['num1']!,
num2: map['num2']!,
num3: map['num3']!,
denom1: map['denom1']!,
denom2: map['denom2']!,
sup1: map['sup1']!,
sup2: map['sup2']!,
sup3: map['sup3']!,
sub1: map['sub1']!,
sub2: map['sub2']!,
supDrop: map['supDrop']!,
subDrop: map['subDrop']!,
delim1: map['delim1']!,
delim2: map['delim2']!,
axisHeight: map['axisHeight']!,
defaultRuleThickness: map['defaultRuleThickness']!,
bigOpSpacing1: map['bigOpSpacing1']!,
bigOpSpacing2: map['bigOpSpacing2']!,
bigOpSpacing3: map['bigOpSpacing3']!,
bigOpSpacing4: map['bigOpSpacing4']!,
bigOpSpacing5: map['bigOpSpacing5']!,
sqrtRuleThickness: map['sqrtRuleThickness']!,
ptPerEm: map['ptPerEm']!,
doubleRuleSep: map['doubleRuleSep']!,
arrayRuleWidth: map['arrayRuleWidth']!,
fboxsep: map['fboxsep']!,
fboxrule: map['fboxrule']!,
);
} on Error {
return null;
}
}
}