Parse cmr10 TFM metrics for route-D math
This commit is contained in:
1 parent
84e2e9cadb
commit
f909e8199c
4 files changed
+314
-37
No files matched your search
@@ -199,11 +199,15 @@ pub fn delimiter_scale(body: &MathBox) -> f64 {
|
||||
/// Lay out a math atom at the current style size.
|
||||
pub fn layout_math(atom: &MathAtom, font: &Cmr10Metrics) -> MathBox {
|
||||
match atom {
|
||||
MathAtom::Symbol(character) => MathBox {
|
||||
width: font.width(*character),
|
||||
height: 7 * 65_536,
|
||||
depth: 2 * 65_536,
|
||||
},
|
||||
MathAtom::Symbol(character) => {
|
||||
let height = font.height(*character);
|
||||
let depth = font.depth(*character);
|
||||
MathBox {
|
||||
width: font.width(*character),
|
||||
height: if height > 0 { height } else { 7 * 65_536 },
|
||||
depth: if depth > 0 { depth } else { 2 * 65_536 },
|
||||
}
|
||||
}
|
||||
MathAtom::Space(width) => MathBox {
|
||||
width: *width,
|
||||
height: 0,
|
||||
@@ -1595,6 +1599,15 @@ mod tests {
|
||||
assert!(underlined.depth > plain.depth);
|
||||
assert_eq!(underlined.height, plain.height);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn glyph_height_comes_from_the_tfm() {
|
||||
let font = Cmr10Metrics::default();
|
||||
let box_ = layout_math(&parse_math("A"), &font);
|
||||
assert_eq!(box_.height, font.height('A'));
|
||||
let g = layout_math(&parse_math("g"), &font);
|
||||
assert_eq!(g.depth, font.depth('g'));
|
||||
}
|
||||
#[test]
|
||||
fn math_text_uses_upright_character_widths() {
|
||||
let font = Cmr10Metrics::default();
|
||||
|
||||
Reference in new issue
Block a user