Skip to content

Commit

Permalink
Update copy indices implementation to match spec changes in w3c/IFT#252
Browse files Browse the repository at this point in the history
Copy indices becomes child indices. Intersection is now based on the intersection of the child entries instead of forming a union of the child entry subset definitions.
  • Loading branch information
garretrieger committed Feb 5, 2025
1 parent ec75c7d commit 63e7121
Show file tree
Hide file tree
Showing 9 changed files with 233 additions and 139 deletions.
2 changes: 1 addition & 1 deletion font-codegen/src/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl Fields {
.find(|fld| &fld.name == name)
.map(|fld| match &fld.typ {
FieldType::Scalar { typ } => typ,
_ => panic!("not a scalar field: {:?}", &fld.typ),
_ => panic!("not a scalar field"),
})
.or_else(|| {
self.read_args.as_ref().and_then(|args| {
Expand Down
8 changes: 4 additions & 4 deletions font-codegen/src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ pub(crate) enum CountTransform {
/// Number of bytes to hold a bitmap with max value N
MaxValueBitmapLen,
/// requires exactly one arg. Get the count from the $arg1.try_into::<usize>().
CustomCount,
Custom,
}

/// Attributes for specifying how to compile a field
Expand Down Expand Up @@ -1467,7 +1467,7 @@ static TRANSFORM_IDENTS: &[(CountTransform, &str)] = &[
),
(CountTransform::BitmapLen, "bitmap_len"),
(CountTransform::MaxValueBitmapLen, "max_value_bitmap_len"),
(CountTransform::CustomCount, "custom"),
(CountTransform::Custom, "custom"),
];

impl FromStr for CountTransform {
Expand Down Expand Up @@ -1504,7 +1504,7 @@ impl CountTransform {
CountTransform::ItemVariationDataLen => 3,
CountTransform::BitmapLen => 1,
CountTransform::MaxValueBitmapLen => 1,
CountTransform::CustomCount => 1,
CountTransform::Custom => 1,
}
}
}
Expand Down Expand Up @@ -1659,7 +1659,7 @@ impl Count {
(CountTransform::MaxValueBitmapLen, [a]) => {
quote!(transforms::max_value_bitmap_len(#a))
}
(CountTransform::CustomCount, [a]) => {
(CountTransform::Custom, [a]) => {
quote!(transforms::custom_count(#a))
}
_ => unreachable!("validated before now"),
Expand Down
40 changes: 20 additions & 20 deletions font-test-data/src/ift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ pub fn features_and_design_space_format2() -> BeBuffer {
buffer
}

pub fn copy_indices_format2() -> BeBuffer {
pub fn child_indices_format2() -> BeBuffer {
let mut buffer = be_buffer! {
2u8, // format

Expand Down Expand Up @@ -347,33 +347,33 @@ pub fn copy_indices_format2() -> BeBuffer {
0x0064_0000, // end = 100

// Entry id = 5
{0b00000010u8: "entries[4]"}, // format = COPY_INDICES
1u8, // copy count
(Uint24::new(0)), // copy
{0b00000010u8: "entries[4]"}, // format = CHILD_INDICES
1u8, // child count
(Uint24::new(0)), // child[0] = 0

// Entry id = 6
{0b00000010u8: "entries[5]"}, // format = COPY_INDICES
1u8, // copy count
(Uint24::new(2)), // copy
{0b00000010u8: "entries[5]"}, // format = CHILD_INDICES
1u8, // child count
(Uint24::new(2)), // child

// Entry id = 7
{0b00000010u8: "entries[6]"}, // format = COPY_INDICES
4u8, // copy count
(Uint24::new(3)), // copy[0]
(Uint24::new(2)), // copy[1]
(Uint24::new(1)), // copy[2]
(Uint24::new(0)), // copy[3]
{0b00000010u8: "entries[6]"}, // format = CHILD_INDICES
{4u8: "entries[6]_child_count"}, // child count
(Uint24::new(3)), // child[0] = 3
(Uint24::new(2)), // child[1] = 2
(Uint24::new(1)), // child[2] = 1
(Uint24::new(0)), // child[3] = 0

// Entry id = 8
{0b00000010u8: "entries[7]"}, // format = COPY_INDICES
2u8, // copy count
(Uint24::new(4)), // copy[0]
(Uint24::new(5)), // copy[1]
{0b00000010u8: "entries[7]"}, // format = CHILD_INDICES
2u8, // child count
(Uint24::new(4)), // child[0] = 4
(Uint24::new(5)), // child[1] = 5

// Entry id = 9
{0b00100010u8: "entries[8]"}, // format = CODEPOINT_BIT_2 | COPY_INDICES
1u8, // copy count
(Uint24::new(0)), // copy[0]
{0b00100010u8: "entries[8]"}, // format = CODEPOINT_BIT_2 | CHILD_INDICES
1u8, // child count
(Uint24::new(0)), // chil[0] = 0
100u16, // bias
[0b00001101, 0b00000011, 0b00110001u8] // codepoints = [100..117]
};
Expand Down
2 changes: 1 addition & 1 deletion incremental-font-transfer/src/patch_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ mod tests {
let s = SubsetDefinition::codepoints([5].into_iter().collect());
let g = PatchGroup::select_next_patches(font.clone(), &s);

assert!(g.is_err());
assert!(g.is_err(), "did not fail as expected.");
if let Err(err) = g {
assert_eq!(ReadError::ValidationError, err);
}
Expand Down
Loading

0 comments on commit 63e7121

Please sign in to comment.