Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fuzzer-found issues (Part 1) #126

Merged
merged 14 commits into from
Jul 15, 2024
Merged
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ unicode-properties = { version = "0.1.0", default-features = false, features = [
unicode-script = "0.5.2"

[dependencies.ttf-parser]
version = "0.24.0"
git = "https://github.com/RazrFalcon/ttf-parser"
rev = "85c1ff2"
default-features = false
features = [
"opentype-layout",
Expand Down
2 changes: 1 addition & 1 deletion scripts/gen-indic-table.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
0x109B: 'SM',
0x109C: 'SM',

0x104B: 'PLACEHOLDER',
0x104A: 'PLACEHOLDER',
}

position_overrides = {
Expand Down
2 changes: 0 additions & 2 deletions scripts/gen-shaping-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
# Resource exhaustion tests with large outputs
"morx_34_001",
"morx_36_001",
# ttf-parser uses different rounding, not a bug
"fallback_positioning_001",
# Requires support for the ltag table.
"macos_002",
# Custom MacOS test. A shortened version of `macos_013`, but with `--show-flags`.
Expand Down
20 changes: 19 additions & 1 deletion scripts/gen-unicode-norm-table.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
URL = 'https://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt'
FILE_NAME = 'UnicodeData.txt'

EXCLUSIONS_URL = 'https://www.unicode.org/Public/draft/UCD/ucd/CompositionExclusions.txt'
EXCLUSIONS_FILE_NAME = 'CompositionExclusions.txt'


def hex_to_char_rs(c):
return f"'\\u{{{c}}}'"
Expand All @@ -14,6 +17,20 @@ def hex_to_char_rs(c):
if not os.path.exists(FILE_NAME):
urllib.request.urlretrieve(URL, FILE_NAME)

if not os.path.exists(EXCLUSIONS_FILE_NAME):
urllib.request.urlretrieve(EXCLUSIONS_URL, EXCLUSIONS_FILE_NAME)

exclusions = set()

with open(EXCLUSIONS_FILE_NAME) as f:
import re
pattern = re.compile(r'^([0-9a-fA-F]+)\s+#\s+(.*)$')

for line in f:
match = pattern.match(line.strip())
if match:
exclusions.add(match.group(1))


print('// WARNING: this file was generated by ../scripts/gen-unicode-norm-table.py')
print()
Expand Down Expand Up @@ -76,6 +93,7 @@ def hex_to_char_rs(c):
assert len(pairs) == len(needles)

for pair in pairs:
print(f' ({pair[0]}, {hex_to_char_rs(pair[1])}),')
if pair[1] not in exclusions:
print(f' ({pair[0]}, {hex_to_char_rs(pair[1])}),')

print('];')
1 change: 1 addition & 0 deletions src/hb/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ impl hb_buffer_t {
let pos: Vec<hb_glyph_info_t> = bytemuck::cast_vec(core::mem::take(&mut self.pos));
self.pos = info;
self.info = pos;
self.have_separate_output = false;
}

self.len = self.out_len;
Expand Down
6 changes: 5 additions & 1 deletion src/hb/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ impl<'a> hb_font_t<'a> {
return ret;
}

let bbox = self.ttfp_face.glyph_bounding_box(glyph);
let mut bbox = None;

if let Some(glyf) = self.ttfp_face.tables().glyf {
bbox = glyf.bbox(glyph);
}

// See https://github.com/RazrFalcon/rustybuzz/pull/98#issuecomment-1948430785
if self.ttfp_face.tables().glyf.is_some() && bbox.is_none() {
Expand Down
9 changes: 3 additions & 6 deletions src/hb/ot_layout_gsubgpos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,16 +1182,13 @@ pub mod OT {

if has_glyph_classes {
props &= GlyphPropsFlags::PRESERVE.bits();
props =
(props & !GlyphPropsFlags::CLASS_MASK.bits()) | self.face.glyph_props(glyph_id);
cur.set_glyph_props(props | self.face.glyph_props(glyph_id));
} else if !class_guess.is_empty() {
props &= GlyphPropsFlags::PRESERVE.bits();
props = (props & !GlyphPropsFlags::CLASS_MASK.bits()) | class_guess.bits();
cur.set_glyph_props(props | class_guess.bits());
} else {
props = props & !GlyphPropsFlags::CLASS_MASK.bits();
cur.set_glyph_props(props);
}

cur.set_glyph_props(props);
}

pub fn replace_glyph(&mut self, glyph_id: GlyphId) {
Expand Down
4 changes: 4 additions & 0 deletions src/hb/ot_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,10 @@ fn map_glyphs_fast(buffer: &mut hb_buffer_t) {
for info in &mut buffer.info[..len] {
info.glyph_id = info.glyph_index();
}

for info in &mut buffer.out_info_mut()[..len] {
info.glyph_id = info.glyph_index();
}
}

fn hb_synthesize_glyph_classes(buffer: &mut hb_buffer_t) {
Expand Down
598 changes: 334 additions & 264 deletions src/hb/ot_shaper_indic_machine.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/hb/ot_shaper_indic_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use OT_MR as _OT_MR; /* 1 chars; MR */
use OT_MW as _OT_MW; /* 2 chars; MW */
use OT_MY as _OT_MY; /* 3 chars; MY */
use OT_N as _OT_N; /* 17 chars; N */
use OT_PLACEHOLDER as _OT_GB; /* 164 chars; PLACEHOLDER */
use OT_PLACEHOLDER as _OT_GB; /* 165 chars; PLACEHOLDER */
use OT_PT as _OT_PT; /* 8 chars; PT */
use OT_Ra as _OT_R; /* 14 chars; Ra */
use OT_Repha as _OT_Rf; /* 1 chars; Repha */
Expand All @@ -44,7 +44,7 @@ use POS_ABOVE_C as _POS_T; /* 22 chars; ABOVE_C */
use POS_AFTER_MAIN as _POS_A; /* 3 chars; AFTER_MAIN */
use POS_AFTER_POST as _POS_AP; /* 50 chars; AFTER_POST */
use POS_AFTER_SUB as _POS_AS; /* 51 chars; AFTER_SUB */
use POS_BASE_C as _POS_C; /* 832 chars; BASE_C */
use POS_BASE_C as _POS_C; /* 833 chars; BASE_C */
use POS_BEFORE_SUB as _POS_BS; /* 25 chars; BEFORE_SUB */
use POS_BELOW_C as _POS_B; /* 13 chars; BELOW_C */
use POS_END as _POS_X; /* 71 chars; END */
Expand Down Expand Up @@ -257,7 +257,7 @@ const TABLE: &[(SyllabicCategory, MatraCategory)] = &[
/* 1030 */(_OT_VB,_POS_B),(_OT_VL,_POS_L),(_OT_A,_POS_SM),(_OT_VA,_POS_T),(_OT_VA,_POS_T),(_OT_VA,_POS_T),(_OT_A,_POS_SM), (_OT_N,_POS_X),
/* 1038 */(_OT_SM,_POS_SM), (_OT_H,_POS_X),(_OT_As,_POS_X),(_OT_MY,_POS_X),(_OT_MR,_POS_X),(_OT_MW,_POS_X),(_OT_MH,_POS_X), (_OT_C,_POS_C),
/* 1040 */(_OT_GB,_POS_C),(_OT_GB,_POS_C),(_OT_GB,_POS_C),(_OT_GB,_POS_C),(_OT_GB,_POS_C),(_OT_GB,_POS_C),(_OT_GB,_POS_C),(_OT_GB,_POS_C),
/* 1048 */(_OT_GB,_POS_C),(_OT_GB,_POS_C), (_OT_X,_POS_X),(_OT_GB,_POS_C), (_OT_X,_POS_X), (_OT_X,_POS_X), (_OT_C,_POS_C), (_OT_X,_POS_X),
/* 1048 */(_OT_GB,_POS_C),(_OT_GB,_POS_C),(_OT_GB,_POS_C),(_OT_GB,_POS_C), (_OT_X,_POS_X), (_OT_X,_POS_X), (_OT_C,_POS_C), (_OT_X,_POS_X),
/* 1050 */ (_OT_C,_POS_C), (_OT_C,_POS_C), (_OT_V,_POS_C), (_OT_V,_POS_C), (_OT_V,_POS_C), (_OT_V,_POS_C),(_OT_VR,_POS_R),(_OT_VR,_POS_R),
/* 1058 */(_OT_VB,_POS_B),(_OT_VB,_POS_B), (_OT_R,_POS_C), (_OT_C,_POS_C), (_OT_C,_POS_C), (_OT_C,_POS_C),(_OT_MY,_POS_X),(_OT_MY,_POS_X),
/* 1060 */(_OT_ML,_POS_X), (_OT_C,_POS_C),(_OT_VR,_POS_R),(_OT_PT,_POS_X),(_OT_PT,_POS_X), (_OT_C,_POS_C), (_OT_C,_POS_C),(_OT_VR,_POS_R),
Expand Down
Loading
Loading