Skip to content

Commit 577da49

Browse files
committed
Move to the latest released version of Skrifa instead of a git dep
1 parent 0632a67 commit 577da49

File tree

10 files changed

+27
-21
lines changed

10 files changed

+27
-21
lines changed

Cargo.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ unicode-bidi-mirroring = "0.3.0"
2020
unicode-ccc = "0.3.0"
2121
unicode-properties = { version = "0.1.0", default-features = false, features = ["general-category"] }
2222
unicode-script = "0.5.2"
23-
# Use git rev to handle 'true' font header
24-
# TODO: replace with read-fonts
25-
skrifa = { git = "https://github.com/googlefonts/fontations", rev = "2eb4b1c" }
23+
24+
skrifa = "0.20" # TODO: read-fonts instead
2625
wasmi = { version = "0.34.0", optional = true }
2726
log = "0.4.22"
2827

src/hb/buffer.rs

+7
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,19 @@ impl hb_glyph_info_t {
204204
GlyphId(self.glyph_id as u16)
205205
}
206206

207+
// TODO: delete me and my bad u16 assumptions
207208
#[inline]
208209
pub(crate) fn as_skrifa_glyph(&self) -> skrifa::GlyphId {
209210
debug_assert!(self.glyph_id <= u32::from(u16::MAX));
210211
(self.glyph_id as u16).into()
211212
}
212213

214+
#[inline]
215+
pub(crate) fn as_skrifa_glyph16(&self) -> skrifa::GlyphId16 {
216+
debug_assert!(self.glyph_id <= u32::from(u16::MAX));
217+
(self.glyph_id as u16).into()
218+
}
219+
213220
// Var allocation: unicode_props
214221
// Used during the entire shaping process to store unicode properties
215222

src/hb/face.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,15 @@ impl<'a> hb_font_t<'a> {
133133
}
134134

135135
pub(crate) fn get_nominal_glyph(&self, c: u32) -> Option<GlyphId> {
136-
self.font.nominal_glyph(c).map(|gid| GlyphId(gid.to_u16()))
136+
self.font
137+
.nominal_glyph(c)
138+
.map(|gid| GlyphId(gid.to_u32() as u16)) // TODO: remove as u16 when fully on read-fonts GlyphId
137139
}
138140

139141
pub(crate) fn glyph_variation_index(&self, c: char, vs: char) -> Option<GlyphId> {
140142
self.font
141143
.nominal_variant_glyph(c as u32, vs as u32)
142-
.map(|gid| GlyphId(gid.to_u16()))
144+
.map(|gid| GlyphId(gid.to_u32() as u16)) // TODO: remove as u16 when fully on read-fonts GlyphId
143145
}
144146

145147
pub(crate) fn glyph_h_advance(&self, glyph: GlyphId) -> i32 {

src/hb/fonta/font.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use skrifa::{
1111
},
1212
ReadError, TableProvider,
1313
},
14-
GlyphId, MetadataProvider,
14+
GlyphId,
1515
};
1616
use ttf_parser::NormalizedCoordinate;
1717

src/hb/fonta/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ pub mod ot;
33
mod font;
44
mod set_digest;
55

6-
use set_digest::SetDigest;
7-
86
pub use font::Font;

src/hb/fonta/ot/contextual.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn match_class<'a>(
5959
|glyph, value| {
6060
class_def
6161
.as_ref()
62-
.map(|class_def| class_def.get(skrifa::GlyphId::from(glyph.0)) == value)
62+
.map(|class_def| class_def.get(skrifa::GlyphId16::new(glyph.0)) == value)
6363
.unwrap_or(false)
6464
}
6565
}
@@ -69,7 +69,7 @@ impl Apply for ChainedSequenceContextFormat2<'_> {
6969
let backtrack_classes = self.backtrack_class_def().ok();
7070
let input_classes = self.input_class_def().ok();
7171
let lookahead_classes = self.lookahead_class_def().ok();
72-
let glyph = skrifa::GlyphId::from(ctx.buffer.cur(0).as_glyph().0);
72+
let glyph = ctx.buffer.cur(0).as_skrifa_glyph16();
7373
self.coverage().ok()?.get(glyph)?;
7474
let index = input_classes.as_ref()?.get(glyph) as usize;
7575
let set = self.chained_class_seq_rule_sets().get(index)?.ok()?;
@@ -223,7 +223,7 @@ trait ToU16: Copy {
223223
fn to_u16(self) -> u16;
224224
}
225225

226-
impl ToU16 for BigEndian<skrifa::GlyphId> {
226+
impl ToU16 for BigEndian<skrifa::GlyphId16> {
227227
fn to_u16(self) -> u16 {
228228
self.get().to_u16()
229229
}

src/hb/fonta/ot/gpos/pair.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::hb::ot_layout_gpos_table::ValueRecordExt;
22
use crate::hb::ot_layout_gsubgpos::OT::hb_ot_apply_context_t;
33
use crate::hb::ot_layout_gsubgpos::{skipping_iterator_t, Apply};
4-
use skrifa::raw::tables::gpos::{PairPosFormat1, PairPosFormat2, PairSet, PairValueRecord};
4+
use skrifa::raw::tables::gpos::{PairPosFormat1, PairPosFormat2, PairValueRecord};
55
use skrifa::raw::FontData;
66

77
use super::Value;
@@ -104,7 +104,7 @@ fn find_second_glyph<'a>(
104104
while lo < hi {
105105
let mid = (lo + hi) / 2;
106106
let record_offset = set_offset + 2 + mid * record_size;
107-
let glyph_id = base_data.read_at::<skrifa::GlyphId>(record_offset).ok()?;
107+
let glyph_id = base_data.read_at::<skrifa::GlyphId16>(record_offset).ok()?;
108108
if glyph_id < second_glyph {
109109
lo = mid + 1
110110
} else if glyph_id > second_glyph {
@@ -119,7 +119,7 @@ fn find_second_glyph<'a>(
119119

120120
impl Apply for PairPosFormat2<'_> {
121121
fn apply(&self, ctx: &mut hb_ot_apply_context_t) -> Option<()> {
122-
let first_glyph = ctx.buffer.cur(0).as_skrifa_glyph();
122+
let first_glyph = ctx.buffer.cur(0).as_skrifa_glyph16();
123123
self.coverage().ok()?.get(first_glyph)?;
124124

125125
let mut iter = skipping_iterator_t::new(ctx, ctx.buffer.idx, false);
@@ -132,7 +132,7 @@ impl Apply for PairPosFormat2<'_> {
132132
}
133133

134134
let second_glyph_index = iter.index();
135-
let second_glyph = ctx.buffer.info[second_glyph_index].as_skrifa_glyph();
135+
let second_glyph = ctx.buffer.info[second_glyph_index].as_skrifa_glyph16();
136136

137137
let finish = |ctx: &mut hb_ot_apply_context_t, iter_index: &mut usize, has_record2| {
138138
if has_record2 {

src/hb/fonta/ot/gsub/multiple.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ impl WouldApply for MultipleSubstFormat1<'_> {
2020

2121
impl Apply for MultipleSubstFormat1<'_> {
2222
fn apply(&self, ctx: &mut hb_ot_apply_context_t) -> Option<()> {
23-
let glyph = ctx.buffer.cur(0).as_glyph().0;
24-
let index = self.coverage().ok()?.get(skrifa::GlyphId::new(glyph))? as usize;
23+
let gid = ctx.buffer.cur(0).as_skrifa_glyph16();
24+
let index = self.coverage().ok()?.get(gid)? as usize;
2525
let substs = self.sequences().get(index).ok()?.substitute_glyph_ids();
2626
match substs.len() {
2727
// Spec disallows this, but Uniscribe allows it.

src/hb/fonta/ot/gsub/single.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ use ttf_parser::GlyphId;
55

66
impl WouldApply for SingleSubstFormat1<'_> {
77
fn would_apply(&self, ctx: &WouldApplyContext) -> bool {
8+
let gid = skrifa::GlyphId::from(ctx.glyphs[0].0);
89
ctx.glyphs.len() == 1
910
&& self
1011
.coverage()
11-
.map(|cov| cov.get(ctx.glyphs[0].0.into()).is_some())
12+
.map(|cov| cov.get(gid).is_some())
1213
.unwrap_or_default()
1314
}
1415
}
1516

1617
impl Apply for SingleSubstFormat1<'_> {
1718
fn apply(&self, ctx: &mut hb_ot_apply_context_t) -> Option<()> {
18-
let glyph = ctx.buffer.cur(0).as_skrifa_glyph();
19+
let glyph = ctx.buffer.cur(0).as_skrifa_glyph16();
1920
self.coverage().ok()?.get(glyph)?;
2021
let subst = (glyph.to_u16() as i32 + self.delta_glyph_id() as i32) as u16;
2122
ctx.replace_glyph(GlyphId(subst));

src/hb/fonta/ot/lookup_cache.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::hb::set_digest::{hb_set_digest_ext, hb_set_digest_t};
22

3-
use super::super::SetDigest;
43
use alloc::vec::Vec;
54
use core::ops::Range;
65
use skrifa::raw::{
@@ -146,7 +145,7 @@ impl LookupCache {
146145
let lookup_flag = lookup.lookup_flag();
147146
entry.props = u32::from(lookup.lookup_flag().to_bits());
148147
if lookup_flag.to_bits() & LookupFlag::USE_MARK_FILTERING_SET.to_bits() != 0 {
149-
entry.props |= u32::from(lookup.mark_filtering_set()) << 16;
148+
entry.props |= (lookup.mark_filtering_set().unwrap_or_default() as u32) << 16;
150149
}
151150
entry.is_rtl = lookup_flag.to_bits() & LookupFlag::RIGHT_TO_LEFT.to_bits() != 0;
152151
if data.is_subst {

0 commit comments

Comments
 (0)