Pin isolated ligature evaluators to licensed Noto Sans fixture
This commit is contained in:
@@ -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.
|
||||
Binary file not shown.
@@ -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.
|
||||
Reference in New Issue
Block a user