Add Fraktur letters, infix fractions and middle delimiters
- bundle eufm10 (TFM + Type1), add the MathFraktur face and map \mathfrak
onto it, including PDF embedding and width lookup;
- parse TeX's infix fractions (\over, \atop, \choose, \brace,
\brack, \overwithdelims, \atopwithdelims): the rest of the current
row becomes the denominator, ar records whether a rule is drawn, and the
painter no longer emits parentheses (a \frac painter bug) and only draws
the bar for \over forms;
- add MathAtom::Middle, size top-level middle delimiters with the enclosing
\left/\right group through the CMEX size classes, and paint
SizedDelimiter at its selected size instead of the base glyph;
- skip the parser's '\u{0}' math spaces before \big, \middle,
\left and the withdelims delimiters, so \big ( parses like \big(.
560 workspace tests (381 route-D unit).
This commit is contained in:
1 parent
cb40cc4634
commit
8c42f2de2f
10 files changed
+499
-72
No files matched your search
@@ -16,7 +16,7 @@ use crate::cmr10::Cmr10Metrics;
|
||||
use crate::render::{DisplayItem, DisplayList, FontFace};
|
||||
use crate::type1::Type1Font;
|
||||
|
||||
const FACE_COUNT: usize = 10;
|
||||
const FACE_COUNT: usize = 11;
|
||||
|
||||
fn deflate(bytes: &[u8]) -> Vec<u8> {
|
||||
let mut encoder = ZlibEncoder::new(Vec::new(), Compression::default());
|
||||
@@ -92,6 +92,12 @@ static FULL_FACES: [PdfFace; FACE_COUNT] = [
|
||||
italic_angle: 0,
|
||||
font: OnceLock::new(),
|
||||
},
|
||||
PdfFace {
|
||||
bytes: include_bytes!("../../../assets/fonts-subset/LiberationSerif-Regular.ttf"),
|
||||
base: "LiberationSerif-MathFraktur",
|
||||
italic_angle: 0,
|
||||
font: OnceLock::new(),
|
||||
},
|
||||
];
|
||||
|
||||
static MIN_FACES: [PdfFace; FACE_COUNT] = [
|
||||
@@ -155,6 +161,12 @@ static MIN_FACES: [PdfFace; FACE_COUNT] = [
|
||||
italic_angle: 0,
|
||||
font: OnceLock::new(),
|
||||
},
|
||||
PdfFace {
|
||||
bytes: include_bytes!("../../../assets/fonts-subset-min/LiberationSerif-Regular.ttf"),
|
||||
base: "LiberationSerif-MathFraktur",
|
||||
italic_angle: 0,
|
||||
font: OnceLock::new(),
|
||||
},
|
||||
];
|
||||
|
||||
fn minimal_text_char(ch: char) -> bool {
|
||||
@@ -287,6 +299,7 @@ fn font_resource(font: FontFace) -> &'static str {
|
||||
FontFace::MathSymbol => "F8",
|
||||
FontFace::MathExtension => "F9",
|
||||
FontFace::MathBlackboard => "F10",
|
||||
FontFace::MathFraktur => "F11",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,6 +325,7 @@ fn type1_bytes(slot: usize) -> Option<&'static [u8]> {
|
||||
Some(include_bytes!("../../../assets/fonts/cmsy10.pfb")),
|
||||
Some(include_bytes!("../../../assets/fonts/cmex10.pfb")),
|
||||
Some(include_bytes!("../../../assets/fonts/msbm10.pfb")),
|
||||
Some(include_bytes!("../../../assets/fonts/eufm10.pfb")),
|
||||
];
|
||||
PFBS[slot]
|
||||
}
|
||||
@@ -967,6 +981,22 @@ mod type1_pdf_tests {
|
||||
assert!(text.contains("(\\101)"), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mathfrak_letters_embed_eufm10() {
|
||||
let mut list = hello_list();
|
||||
list.items[0] = DisplayItem::Text {
|
||||
x: 0,
|
||||
y: 800_000,
|
||||
size: 655_360,
|
||||
text: "A".to_string(),
|
||||
font: FontFace::MathFraktur,
|
||||
};
|
||||
let pdf = write(&[list]);
|
||||
let text = String::from_utf8_lossy(&pdf);
|
||||
assert!(text.contains("/BaseFont /EUFM10"), "{text}");
|
||||
assert!(text.contains("(\\101)"), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mathcal_letters_embed_cmsy10() {
|
||||
let mut list = hello_list();
|
||||
|
||||
Reference in new issue
Block a user