Skip to content

Commit fb8d0aa

Browse files
committed
Assign maxp data when interjecting TTF with skrifa
1 parent 03f50a8 commit fb8d0aa

5 files changed

Lines changed: 32 additions & 24 deletions

File tree

src/cff2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::borrow::Cow;
77
pub fn subset(ctx: &mut Context) -> crate::Result<()> {
88
let mut maxp_data = MaxpData::default();
99

10-
let result = glyf::subset_with(ctx, |old_gid, ctx| {
10+
glyf::subset_with(ctx, |old_gid, ctx| {
1111
let data = match &ctx.interjector {
1212
// We reject CFF2 fonts earlier if `variable-fonts` feature is not enabled.
1313
Interjector::Dummy(_) => unreachable!(),
@@ -18,8 +18,8 @@ pub fn subset(ctx: &mut Context) -> crate::Result<()> {
1818
};
1919

2020
Ok(data)
21-
});
21+
})?;
2222

2323
ctx.custom_maxp_data = Some(maxp_data);
24-
result
24+
Ok(())
2525
}

src/glyf.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ pub fn closure(face: &Face, glyph_remapper: &mut GlyphRemapper) -> Result<()> {
4747

4848
pub fn subset(ctx: &mut Context) -> Result<()> {
4949
let table = Table::new(&ctx.face).ok_or(MalformedFont)?;
50-
let mut _maxp = MaxpData::default();
50+
51+
#[allow(unused_mut)]
52+
let mut maxp_data = MaxpData::default();
5153

5254
subset_with(ctx, |old_gid, ctx| {
5355
let data = match &ctx.interjector {
@@ -56,12 +58,18 @@ pub fn subset(ctx: &mut Context) -> Result<()> {
5658
}
5759
#[cfg(feature = "variable-fonts")]
5860
Interjector::Skrifa(s) => {
59-
Cow::Owned(s.glyph_data(&mut _maxp, old_gid).ok_or(MalformedFont)?)
61+
Cow::Owned(s.glyph_data(&mut maxp_data, old_gid).ok_or(MalformedFont)?)
6062
}
6163
};
6264

6365
Ok(data)
64-
})
66+
})?;
67+
68+
if ctx.interjector.is_skrifa() {
69+
ctx.custom_maxp_data = Some(maxp_data);
70+
}
71+
72+
Ok(())
6573
}
6674

6775
pub(crate) fn subset_with<'a>(

tests/ttx/NotoSans-Regular_var_1.ttx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<!-- Most of this table will be recalculated by the compiler -->
2424
<tableVersion value="1.0"/>
2525
<fontRevision value="2.013"/>
26-
<checkSumAdjustment value="0xf8bea5c9"/>
26+
<checkSumAdjustment value="0xf902a8a3"/>
2727
<magicNumber value="0x5f0f3cf5"/>
2828
<flags value="00000000 00000011"/>
2929
<unitsPerEm value="1000"/>
@@ -64,18 +64,18 @@
6464
<!-- Most of this table will be recalculated by the compiler -->
6565
<tableVersion value="0x10000"/>
6666
<numGlyphs value="14"/>
67-
<maxPoints value="273"/>
68-
<maxContours value="24"/>
69-
<maxCompositePoints value="143"/>
70-
<maxCompositeContours value="8"/>
67+
<maxPoints value="51"/>
68+
<maxContours value="2"/>
69+
<maxCompositePoints value="0"/>
70+
<maxCompositeContours value="0"/>
7171
<maxZones value="1"/>
7272
<maxTwilightPoints value="0"/>
7373
<maxStorage value="0"/>
7474
<maxFunctionDefs value="0"/>
7575
<maxInstructionDefs value="0"/>
7676
<maxStackElements value="0"/>
7777
<maxSizeOfInstructions value="0"/>
78-
<maxComponentElements value="4"/>
78+
<maxComponentElements value="0"/>
7979
<maxComponentDepth value="1"/>
8080
</maxp>
8181

tests/ttx/NotoSans-Regular_var_2.ttx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<!-- Most of this table will be recalculated by the compiler -->
2424
<tableVersion value="1.0"/>
2525
<fontRevision value="2.013"/>
26-
<checkSumAdjustment value="0xe1c0756b"/>
26+
<checkSumAdjustment value="0xe2047845"/>
2727
<magicNumber value="0x5f0f3cf5"/>
2828
<flags value="00000000 00000011"/>
2929
<unitsPerEm value="1000"/>
@@ -64,18 +64,18 @@
6464
<!-- Most of this table will be recalculated by the compiler -->
6565
<tableVersion value="0x10000"/>
6666
<numGlyphs value="14"/>
67-
<maxPoints value="273"/>
68-
<maxContours value="24"/>
69-
<maxCompositePoints value="143"/>
70-
<maxCompositeContours value="8"/>
67+
<maxPoints value="51"/>
68+
<maxContours value="2"/>
69+
<maxCompositePoints value="0"/>
70+
<maxCompositeContours value="0"/>
7171
<maxZones value="1"/>
7272
<maxTwilightPoints value="0"/>
7373
<maxStorage value="0"/>
7474
<maxFunctionDefs value="0"/>
7575
<maxInstructionDefs value="0"/>
7676
<maxStackElements value="0"/>
7777
<maxSizeOfInstructions value="0"/>
78-
<maxComponentElements value="4"/>
78+
<maxComponentElements value="0"/>
7979
<maxComponentDepth value="1"/>
8080
</maxp>
8181

tests/ttx/NotoSans-Regular_var_3.ttx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<!-- Most of this table will be recalculated by the compiler -->
2424
<tableVersion value="1.0"/>
2525
<fontRevision value="2.013"/>
26-
<checkSumAdjustment value="0xec15e09b"/>
26+
<checkSumAdjustment value="0xec59e375"/>
2727
<magicNumber value="0x5f0f3cf5"/>
2828
<flags value="00000000 00000011"/>
2929
<unitsPerEm value="1000"/>
@@ -64,18 +64,18 @@
6464
<!-- Most of this table will be recalculated by the compiler -->
6565
<tableVersion value="0x10000"/>
6666
<numGlyphs value="14"/>
67-
<maxPoints value="273"/>
68-
<maxContours value="24"/>
69-
<maxCompositePoints value="143"/>
70-
<maxCompositeContours value="8"/>
67+
<maxPoints value="51"/>
68+
<maxContours value="2"/>
69+
<maxCompositePoints value="0"/>
70+
<maxCompositeContours value="0"/>
7171
<maxZones value="1"/>
7272
<maxTwilightPoints value="0"/>
7373
<maxStorage value="0"/>
7474
<maxFunctionDefs value="0"/>
7575
<maxInstructionDefs value="0"/>
7676
<maxStackElements value="0"/>
7777
<maxSizeOfInstructions value="0"/>
78-
<maxComponentElements value="4"/>
78+
<maxComponentElements value="0"/>
7979
<maxComponentDepth value="1"/>
8080
</maxp>
8181

0 commit comments

Comments
 (0)