Pin isolated ligature evaluators to licensed Noto Sans fixture

This commit is contained in:
2026-09-13 04:31:01 -07:00
parent 11c605f917
commit 4c9bc87e4e
6 changed files with 172 additions and 11 deletions
@@ -1,4 +1,5 @@
//! Unwired, unexecuted field-layout falsifiers. Paragraph is an independent
//! Unwired field-layout falsifiers. Execution evidence is recorded in the harness.
//! Paragraph is an independent
//! shaping oracle; it never invokes the candidate normalization/extraction.
use super::*;
use iced::advanced::{
@@ -6,6 +7,41 @@ use iced::advanced::{
text::{Paragraph as _, Text as ParagraphText, Wrapping},
};
// The two ligature tests run alone in fresh processes. Clearing host faces is
// deliberate: a system-installed Noto Sans with another version must not win.
const LIGATURE_FONT: &[u8] = include_bytes!("fixtures/NotoSans-Regular.ttf");
fn isolated_ligature_style(shaping: Shaping) -> Style {
let mut fonts = graphics_text::font_system().write().unwrap();
let ids: Vec<_> = fonts.raw().db().faces().map(|face| face.id).collect();
for id in ids {
fonts.raw().db_mut().remove_face(id);
}
fonts.load_font(std::borrow::Cow::Borrowed(LIGATURE_FONT));
assert_eq!(fonts.raw().db().len(), 1);
Style {
font: Font::with_name("Noto Sans"),
shaping,
..Style::default()
}
}
fn assert_ligature_fixture_face(oracle: &Paragraph) {
let mut fonts = graphics_text::font_system().write().unwrap();
let mut count = 0;
for glyph in oracle.buffer().layout_runs().flat_map(|run| run.glyphs) {
assert_eq!(
fonts.raw().db().with_face_data(glyph.font_id, |bytes, index| {
index == 0 && bytes == LIGATURE_FONT
}),
Some(true),
"the actual shaped face must be the byte-pinned fixture"
);
count += 1;
}
assert!(count > 0, "font identity cannot pass on an empty paragraph");
}
fn paragraph(text: &str, zoom: f32, style: Style) -> Paragraph {
Paragraph::with_text(ParagraphText {
content: text,
@@ -259,13 +295,12 @@ fn positive_notdef_advance_is_unresolved_not_covered_or_truncated() {
}
#[test]
#[ignore = "replaces global fonts; run only this exact test in a fresh process"]
fn advanced_ligature_partial_field_uses_whole_shared_cluster_not_fraction() {
let source = "ffi";
let style = Style {
shaping: Shaping::Advanced,
..Style::default()
};
let style = isolated_ligature_style(Shaping::Advanced);
let oracle = paragraph(source, 1., style);
assert_ligature_fixture_face(&oracle);
let run = oracle.buffer().layout_runs().next().unwrap();
let glyph = run
.glyphs
@@ -287,6 +322,7 @@ fn advanced_ligature_partial_field_uses_whole_shared_cluster_not_fraction() {
field.rectangles.iter().map(|rect| rect.width).sum::<f32>(),
expected.width
);
assert_complete_boxes(&field.rectangles, vec![expected]);
assert!(field.unresolved.is_empty());
}
@@ -565,16 +601,24 @@ fn field_lookup_4096_scalars_and_combining_heavy_full_coverage() {
}
#[test]
#[ignore = "replaces global fonts; run only this exact test in a fresh process"]
fn auto_ascii_to_ellipsis_advanced_transition_uses_final_buffer() {
let style = Style {
shaping: Shaping::Auto,
..Style::default()
};
let style = isolated_ligature_style(Shaping::Auto);
let source = "ffi office assessment";
assert_eq!(
graphics_text::to_shaping(style.shaping, source),
graphics_text::cosmic_text::Shaping::Basic
);
let basic = paragraph(source, 1., style);
assert_ligature_fixture_face(&basic);
let initial_clusters: Vec<_> = basic
.buffer()
.layout_runs()
.flat_map(|run| run.glyphs)
.filter(|glyph| glyph.start < 3)
.map(|glyph| (glyph.start, glyph.end))
.collect();
assert_eq!(initial_clusters, vec![(0, 1), (1, 2), (2, 3)]);
let (session, label) = resolve(
source,
paragraph("ffi office…", 1., style).min_width(),
@@ -587,6 +631,7 @@ fn auto_ascii_to_ellipsis_advanced_transition_uses_final_buffer() {
graphics_text::cosmic_text::Shaping::Advanced
);
let oracle = paragraph(&label.displayed, 1., style);
assert_ligature_fixture_face(&oracle);
let run = oracle.buffer().layout_runs().next().unwrap();
let first = run
.glyphs
@@ -603,6 +648,7 @@ fn auto_ascii_to_ellipsis_advanced_transition_uses_final_buffer() {
.iter()
.any(|rect| rect.x == first.x && rect.width == first.w)
);
assert_complete_boxes(&field.rectangles, paragraph_boxes(&oracle, &[0..3], 1.));
}
#[test]
@@ -0,0 +1 @@
* -text -whitespace
@@ -0,0 +1,93 @@
Copyright 2012 Google Inc. All Rights Reserved.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,15 @@
# Isolated ligature font fixture
NotoSans-Regular.ttf and NotoSans-LICENSE are copied byte for byte from the fonts/ directory of the pinned cosmic-text 0.15.0 package. The font is unmodified and licensed under SIL Open Font License 1.1; retain the adjacent complete copyright/license file when redistributing it.
- Package VCS commit: c82ee1c5b5b8032e91eaff1cb34294b538727a7d (from .cargo_vcs_info.json).
- Package checksum in this workspace Cargo.lock: 173852283a9a57a3cbe365d86e74dc428a09c50421477d5ad6fe9d9509e37737.
- Upstream font: https://github.com/pop-os/cosmic-text/blob/c82ee1c5b5b8032e91eaff1cb34294b538727a7d/fonts/NotoSans-Regular.ttf
- Upstream license: https://github.com/pop-os/cosmic-text/blob/c82ee1c5b5b8032e91eaff1cb34294b538727a7d/fonts/NotoSans-LICENSE
- The pinned upstream Git LFS pointer independently reports the identical SHA-256 and 556216-byte size; the fixture contains the actual font, not the pointer.
- Font bytes: 556216; SHA-256: 2ec33f84606cbaa0a1a944488e14f97faf2f6a25ecdd8354f5358f06da13c7d9.
- License bytes: 4351; SHA-256: 5ec4347054089def6904da61d04f0360968f9ef36634b1fe007a5b6ec2f7aa96.
Static cmap/GSUB inspection found f glyph 73 and i glyph 76, with ffi [73,73,76] substituted by glyph 1654 in lookup 39 under the standard liga feature. This is a fixture-selection check, not runtime shaping evidence. Iced's bundled Fira Sans was rejected for these unchanged ffi assertions because its corresponding lookup is under discretionary dlig, which these tests do not enable.
Both consumers are ignored by default and must each run as the sole exact test in a fresh process. Their test-only setup removes host font faces before loading this fixture, then verifies every actual oracle glyph resolves to these exact bytes and face index zero. The fixture therefore does not depend on an installed font with the same family name. The original positive nonzero ffi-cluster preconditions remain mandatory. Nothing selects this font for the product or changes the production label algorithm.
@@ -12,9 +12,15 @@ The relevant pinned sources are `iced_graphics 0.14.0/src/text.rs:202–256` (me
## Font and execution limitations
These fixtures use the installed system default font selection; they do **not** pin font bytes. The strong ligature, supported-glyph, shared-cluster and bidi preconditions must fail visibly if the local font environment cannot exercise the intended case. RTL cases print resolved font IDs, PostScript names and family records from the actual Paragraph. Font IDs are process-local and these names are diagnostic metadata, not a portable content hash. No global font mutation or new dependency is introduced. A missing precondition is an evaluator/environment finding, not proof that field geometry passed.
At source 11c605f9170eae461913410f83f333e9314714a5, the isolated harness compiled and its default-test diagnostic reported 21 passed, two failed and two ignored. The intended first listing accidentally executed tests; a later literal listing reported all 25. A separate serial normal run reproduced the same two failures before either reached field_layout: the host font did not meet the tests' exact ffi-cluster preconditions. No actual face identity was captured for those failed cases, so the failure must not be attributed to a guessed family. Parent-owned closed runner receipts are the execution authority; this note does not turn the failed diagnostic into a passing gate.
There are twelve normal field tests and one ignored diagnostic in the new module; all remain **UNEXECUTED** at this handoff. Existing label evaluators are retained. Because the parent module remains unwired, ordinary desktop listing does not include these tests until an explicitly isolated evaluator harness wires it. Formatting and `git diff --check` are source checks only, not compilation or execution evidence.
The correction uses an unmodified, byte-pinned Noto Sans fixture from cosmic-text 0.15.0 for exactly those two tests; see [fixture source, hashes and license](../../../crates/oa-desktop/src/behavior/scenario_label/fixtures/README.md). Standard liga contains the required ffi substitution. Each test verifies the actual Paragraph face bytes and retains its positive nonzero ffi-cluster precondition. The partial-field case compares the complete shared rectangle; the Auto case also requires three initial Basic clusters followed by the actual Advanced final-buffer rectangle set. Neither infers successful geometry merely from a shaping enum.
The two fixture-loading tests are ignored by default because their isolated setup replaces the global font database. Run each as the sole exact test in a fresh process: --ignored --exact <actual-listed-name> --nocapture --test-threads=1. Do not run all ignored tests together. This prevents ordinary/default parallel test execution from invalidating render sessions. Their leaf names are advanced_ligature_partial_field_uses_whole_shared_cluster_not_fraction and auto_ascii_to_ellipsis_advanced_transition_uses_final_buffer. The existing font-load invalidation test remains separately isolated.
Other cases retain installed system-font selection and explicit font/cluster/coverage preconditions. RTL font IDs, PostScript names and family records are diagnostic metadata, not portable content hashes. No new dependency or production font policy is introduced. A missing precondition remains an evaluator/environment finding, not a geometry pass.
After this correction the field module contains ten normal tests and three ignored tests (two isolated ligature cases plus the lookup diagnostic). Across the parent label module the intended inventory remains 25, now 21 normal and four ignored. The corrected source is **UNEXECUTED** at handoff. The parent module remains unwired; ordinary desktop listing does not include it without the isolated evaluator harness. Source review is not compilation or execution evidence.
## Optional bounded lookup diagnostic