Add sans family and true small caps

This commit is contained in:
gloamxun committed 2026-10-19 12:52:53 +08:00
1 parent e44d4c8669
commit 337eaa1778
15 files changed
+628 -122

No files matched your search

+57
View File
@@ -279,3 +279,60 @@ C\hfill D\hfill E
assert!(d > 70.0 && d < 100.0, "middle hfill is not centered: {d}");
assert!(e > 150.0, "last hfill did not reach the right edge: {e}");
}
#[test]
fn sans_family_selects_the_sans_face() {
let source = r#"\documentclass{article}
\begin{document}
\setlength{\parindent}{0pt}
Serif text.
{\sffamily Sans family text.}
\textsf{Textsf sans} and {\sffamily\bfseries bold sans}.
\end{document}
"#;
let value = fresh_preview(source, "sans.tex");
assert_eq!(value["status"], "ok", "{}", value["message"]);
let svg = page_svg(&value, 0);
assert!(
svg.contains("font-family=\"TexrraSans\""),
"sans face missing"
);
assert!(
svg.contains("font-family=\"TexrraSerif\""),
"serif face missing"
);
assert!(svg.contains(">Sans</text>"), "sans text missing");
assert!(svg.contains("extsf"), "textsf text missing");
assert!(
svg.contains("font-family=\"TexrraSans\" font-size=\"3.8806\" font-weight=\"700\""),
"bold sans face missing"
);
}
#[test]
fn small_caps_uses_reduced_uppercase_glyphs() {
let source = r#"\documentclass{article}
\begin{document}
\setlength{\parindent}{0pt}
\textsc{Small Caps} and {\scshape mixed Case}.
\end{document}
"#;
let value = fresh_preview(source, "smallcaps.tex");
assert_eq!(value["status"], "ok", "{}", value["message"]);
let svg = page_svg(&value, 0);
assert!(
svg.contains(">MALL</text>"),
"lowercase letters were not uppercased"
);
assert!(!svg.contains("mall"), "small caps leaked lowercase glyphs");
assert!(
svg.contains("font-size=\"3.1750\""),
"small caps were not reduced to 80%"
);
assert!(
svg.contains("font-size=\"3.8806\""),
"full-size capitals should remain full-size"
);
}