Skip to content

Commit 7453381

Browse files
committed
Use original ttf-parser
1 parent f60011d commit 7453381

File tree

2 files changed

+37
-26
lines changed

2 files changed

+37
-26
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ unicode-script = "0.5.2"
2323
libm = { version = "0.2.2", optional = true }
2424

2525
[dependencies.ttf-parser]
26-
git = "https://github.com/LaurenzV/ttf-parser"
26+
version = "0.20.0"
2727
default-features = false
2828
features = [
2929
"opentype-layout",

src/ot/position.rs

+36-25
Original file line numberDiff line numberDiff line change
@@ -183,64 +183,63 @@ impl Apply for PairAdjustment<'_> {
183183
let second_glyph_index = iter.index();
184184
let second_glyph = ctx.buffer.info[second_glyph_index].as_glyph();
185185

186-
let finish = |ctx: &mut ApplyContext, len2| {
186+
let finish = |ctx: &mut ApplyContext, has_record2| {
187187
ctx.buffer.idx = second_glyph_index;
188188

189-
if len2 != 0 {
189+
if has_record2 {
190190
ctx.buffer.idx += 1;
191191
}
192192

193193
Some(())
194194
};
195195

196-
let boring = |ctx: &mut ApplyContext, len2| {
196+
let boring = |ctx: &mut ApplyContext, has_record2| {
197197
ctx.buffer
198198
.unsafe_to_concat(Some(ctx.buffer.idx), Some(second_glyph_index + 1));
199-
finish(ctx, len2)
199+
finish(ctx, has_record2)
200200
};
201201

202-
let success = |ctx: &mut ApplyContext, flag1, flag2, len2| {
202+
let success = |ctx: &mut ApplyContext, flag1, flag2, has_record2| {
203203
if flag1 || flag2 {
204204
ctx.buffer
205205
.unsafe_to_break(Some(ctx.buffer.idx), Some(second_glyph_index + 1));
206-
finish(ctx, len2)
206+
finish(ctx, has_record2)
207207
} else {
208-
boring(ctx, len2)
208+
boring(ctx, has_record2)
209209
}
210210
};
211211

212-
let bail = |ctx: &mut ApplyContext, records: (ValueRecord, ValueRecord), len2| {
212+
let bail = |ctx: &mut ApplyContext, records: (ValueRecord, ValueRecord)| {
213213
let flag1 = records.0.apply(ctx, ctx.buffer.idx);
214214
let flag2 = records.1.apply(ctx, second_glyph_index);
215215

216-
success(ctx, flag1, flag2, len2)
216+
let has_record2 = !records.1.is_empty();
217+
success(ctx, flag1, flag2, has_record2)
217218
};
218219

219-
let (records, len2) = match self {
220-
Self::Format1 { sets, .. } => (
221-
sets.get(first_glyph_coverage_index)?.get(second_glyph)?,
222-
sets.value_format_flags().1.len(),
223-
),
220+
let records = match self {
221+
Self::Format1 { sets, .. } => {
222+
sets.get(first_glyph_coverage_index)?.get(second_glyph)?
223+
}
224224
Self::Format2 {
225225
classes, matrix, ..
226226
} => {
227227
let classes = (classes.0.get(first_glyph), classes.1.get(second_glyph));
228228

229-
if classes.0 >= matrix.counts().0 || classes.1 >= matrix.counts().1 {
230-
ctx.buffer
231-
.unsafe_to_concat(Some(ctx.buffer.idx), Some(iter.index() + 1));
232-
return None;
233-
}
234-
235-
let records = matrix.get(classes)?;
236-
let flags = matrix.value_format_flags();
237-
let len2 = flags.1.len();
229+
let records = match matrix.get(classes) {
230+
Some(v) => v,
231+
None => {
232+
ctx.buffer
233+
.unsafe_to_concat(Some(ctx.buffer.idx), Some(iter.index() + 1));
234+
return None;
235+
}
236+
};
238237

239-
return bail(ctx, records, len2);
238+
return bail(ctx, records);
240239
}
241240
};
242241

243-
bail(ctx, records, len2)
242+
bail(ctx, records)
244243
}
245244
}
246245

@@ -545,11 +544,23 @@ impl Apply for MarkToMarkAdjustment<'_> {
545544
}
546545

547546
trait ValueRecordExt {
547+
fn is_empty(&self) -> bool;
548548
fn apply(&self, ctx: &mut ApplyContext, idx: usize) -> bool;
549549
fn apply_to_pos(&self, ctx: &mut ApplyContext, pos: &mut GlyphPosition) -> bool;
550550
}
551551

552552
impl ValueRecordExt for ValueRecord<'_> {
553+
fn is_empty(&self) -> bool {
554+
self.x_placement == 0
555+
&& self.y_placement == 0
556+
&& self.x_advance == 0
557+
&& self.y_advance == 0
558+
&& self.x_placement_device.is_none()
559+
&& self.y_placement_device.is_none()
560+
&& self.x_advance_device.is_none()
561+
&& self.y_advance_device.is_none()
562+
}
563+
553564
fn apply(&self, ctx: &mut ApplyContext, idx: usize) -> bool {
554565
let mut pos = ctx.buffer.pos[idx];
555566
let worked = self.apply_to_pos(ctx, &mut pos);

0 commit comments

Comments
 (0)