mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-28 03:37:00 -06:00
Renderer tests: the Arabic alternate-glyph tests take the font lock
`tests_alternate`'s Arabic tests look up installed fonts by name (`FontDb::face`), which loads each one into the global database and so changes its generation, without `tests_fontchange::adding_fonts()`. When that lands in the first frame of `tests_charstroke::character_stroke_outlines_are_kept_between_frames`, the second frame lays the type out again and expands the stroke again, and the test fails (3 runs in 30 on macOS, where Arial and Geeza Pro are installed; where no Arabic font is, those tests return early and nothing changes). They now hold the lock, and its documentation says looking up an installed font counts as changing the fonts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
committed by
bflatastic
co-authored by
Claude Opus 5.5
parent
b998ae623c
commit
31b653b70f
@@ -80,6 +80,8 @@ fn glyphs(t: &vectorcraft_doc::text::TextObject) -> Vec<(usize, usize, u32)> {
|
||||
/// required shaping, not alternates, so ordinary Arabic text shows no pink.
|
||||
#[test]
|
||||
fn arabic_joining_forms_are_not_alternates() {
|
||||
// Looking up an installed font loads it, which changes the fonts.
|
||||
let _adding = crate::tests_fontchange::adding_fonts();
|
||||
let Some(style) = arabic_style("arabic_joining_forms_are_not_alternates") else { return };
|
||||
let t = text("خلطة مبتكرة من اللومي الحساوي", style);
|
||||
// The words are shaped: most glyphs are not their letter's cmap glyph.
|
||||
@@ -90,6 +92,8 @@ fn arabic_joining_forms_are_not_alternates() {
|
||||
/// #394: the lam-alef ligature is required (`rlig`), so it isn't highlighted either.
|
||||
#[test]
|
||||
fn lam_alef_is_not_an_alternate() {
|
||||
// Looking up an installed font loads it, which changes the fonts.
|
||||
let _adding = crate::tests_fontchange::adding_fonts();
|
||||
let Some(style) = arabic_style("lam_alef_is_not_an_alternate") else { return };
|
||||
for s in ["لا", "سلام", "الاسم"] {
|
||||
assert_eq!(alternates(&text(s, style.clone())), 0, "{s}");
|
||||
@@ -100,6 +104,8 @@ fn lam_alef_is_not_an_alternate() {
|
||||
/// discretionary alternate…) is highlighted on the glyphs it changes, and only on those.
|
||||
#[test]
|
||||
fn optional_features_on_arabic_flag_only_the_glyphs_they_change() {
|
||||
// Looking up an installed font loads it, which changes the fonts.
|
||||
let _adding = crate::tests_fontchange::adding_fonts();
|
||||
let db = vectorcraft_text::FontDb::global();
|
||||
let s = "خلطة مبتكرة من اللومي الحساوي";
|
||||
// Arabic fonts that may have optional features; the first installed one with a feature that
|
||||
|
||||
@@ -9,8 +9,10 @@ use vectorcraft_geom::Point;
|
||||
|
||||
use super::*;
|
||||
|
||||
/// Taken to add fonts. Renderers lay type out again when the fonts change, so tests of what they
|
||||
/// keep between frames hold it shared ([`fonts_steady`]) and the tests here hold it alone.
|
||||
/// Taken to add fonts, or to look up an installed one by name (`FontDb::face` loads it, which
|
||||
/// changes the fonts too). Renderers lay type out again when the fonts change, so tests of what
|
||||
/// they keep between frames hold it shared ([`fonts_steady`]) and the tests that change the fonts
|
||||
/// hold it alone ([`adding_fonts`]).
|
||||
static FONTS: RwLock<()> = RwLock::new(());
|
||||
|
||||
/// No fonts are added by these tests until the guard is dropped.
|
||||
|
||||
Reference in New Issue
Block a user