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

[IFT] track design space intersection size in IntersectionInfo. #1268

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions font-test-data/src/ift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,15 @@ pub fn features_and_design_space_format2() -> BeBuffer {
0x02BC_0000u32, // end = 700

(Tag::new(b"wdth")), // tag = wdth
0x0u32, // start = 0
0x8000, // end = 0
0x0u32, // start = 0.0
0x8000u32, // end = 0.5

(Tag::new(b"wdth")), // tag = wdth
0x0002_0000, // start = 2.0
0x0002_8000, // end = 2.5
0x0002_0000u32, // start = 2.0
0x0002_8000u32, // end = 2.5

5u16, // bias = 5
0b00001101, 0b00000011, 0b00110001 // codepoints = [5..22]
[0b00001101, 0b00000011, 0b00110001u8] // codepoints = [5..22]
};

let offset = buffer.offset_for("entries[0]") as u32;
Expand Down
21 changes: 12 additions & 9 deletions fuzz/fuzz_targets/fuzz_ift_patch_group.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#![no_main]
//! Fuzzes the incremental_font_transfer patch_group.rs API

use std::{
collections::{BTreeSet, HashMap, HashSet},
ops::RangeInclusive,
};
use std::collections::{BTreeSet, HashMap, HashSet};

use font_types::Fixed;
use incremental_font_transfer::{
patch_group::{PatchGroup, UriStatus},
patchmap::SubsetDefinition,
};
use libfuzzer_sys::{arbitrary, fuzz_target};
use read_fonts::{collections::IntSet, types::Tag};
use read_fonts::{
collections::{IntSet, RangeSet},
types::Tag,
};
use skrifa::FontRef;
use write_fonts::FontBuilder;

Expand All @@ -25,7 +26,7 @@ struct FuzzInput {
// Parts of the target subset definition.
codepoints: HashSet<u32>,
features: HashSet<u32>,
design_space: HashMap<u32, Vec<(f64, f64)>>,
design_space: HashMap<u32, Vec<(i32, i32)>>,

// Patches
patches: HashMap<String, Vec<u8>>,
Expand All @@ -51,12 +52,14 @@ impl FuzzInput {
let feature_tags: BTreeSet<Tag> =
self.features.iter().copied().map(Tag::from_u32).collect();

let design_space: HashMap<Tag, Vec<RangeInclusive<f64>>> = self
let design_space: HashMap<Tag, RangeSet<Fixed>> = self
.design_space
.iter()
.map(|(tag, v)| {
let v: Vec<RangeInclusive<f64>> =
v.iter().map(|(start, end)| *start..=*end).collect();
let v: RangeSet<Fixed> = v
.iter()
.map(|(start, end)| Fixed::from_i32(*start)..=Fixed::from_i32(*end))
.collect();
(Tag::from_u32(*tag), v)
})
.collect();
Expand Down
Loading