Skip to content

Commit

Permalink
[rustfmt] Run new 1.72.0 rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyr authored and dfrg committed Aug 25, 2023
1 parent 4c071e6 commit c8a9a8c
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 16 deletions.
2 changes: 1 addition & 1 deletion read-fonts/src/offset_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ where
/// error variant.
pub fn get(&self, idx: usize) -> Option<Result<T, ReadError>> {
let Some(offset) = self.offsets.get(idx) else {
return Some(Err(ReadError::InvalidCollectionIndex(idx as _)))
return Some(Err(ReadError::InvalidCollectionIndex(idx as _)));
};
offset.get().resolve_with_args(self.data, &self.args)
}
Expand Down
4 changes: 3 additions & 1 deletion read-fonts/src/tables/variations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ impl<'a> PackedPointNumbers<'a> {

let mut n_seen = 0;
while n_seen < n_points {
let Some((count, two_bytes)) = read_control_byte(&mut cursor) else { return n_bytes };
let Some((count, two_bytes)) = read_control_byte(&mut cursor) else {
return n_bytes;
};
let word_size = 1 + usize::from(two_bytes);
let run_size = word_size * count as usize;
n_bytes += run_size + 1; // plus the control byte;
Expand Down
12 changes: 9 additions & 3 deletions skrifa/src/charmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ pub struct Charmap<'a> {
impl<'a> Charmap<'a> {
/// Creates a new character map from the given font.
pub fn new(font: &impl TableProvider<'a>) -> Self {
let Ok(cmap) = font.cmap() else { return Default::default() };
let Ok(cmap) = font.cmap() else {
return Default::default();
};
let selection = MappingSelection::new(&cmap);
Self {
codepoint_subtable: selection
Expand Down Expand Up @@ -138,7 +140,9 @@ impl MappingIndex {
/// Finds the indices of the most suitable Unicode mapping tables in the
/// given font.
pub fn new<'a>(font: &impl TableProvider<'a>) -> Self {
let Ok(cmap) = font.cmap() else { return Default::default() };
let Ok(cmap) = font.cmap() else {
return Default::default();
};
MappingSelection::new(&cmap).mapping_index
}

Expand All @@ -147,7 +151,9 @@ impl MappingIndex {
///
/// The font should be the same as the one used to construct this object.
pub fn charmap<'a>(&self, font: &impl TableProvider<'a>) -> Charmap<'a> {
let Ok(cmap) = font.cmap() else { return Default::default() };
let Ok(cmap) = font.cmap() else {
return Default::default();
};
let records = cmap.encoding_records();
let data = cmap.offset_data();
Charmap {
Expand Down
4 changes: 2 additions & 2 deletions skrifa/src/scale/scaler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ impl<'a> ScalerBuilder<'a> {
return; // nop
}
let Ok(fvar) = font.fvar() else {
return; // nop
return; // nop
};
let Ok(axes) = fvar.axes() else {
return; // nop
return; // nop
};
let avar_mappings = font.avar().ok().map(|avar| avar.axis_segment_maps());
let axis_count = fvar.axis_count() as usize;
Expand Down
8 changes: 6 additions & 2 deletions write-fonts/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,9 @@ impl Graph {
// now everything but the links to the roots roots has been remapped;
// remap those, if needed
for root in roots.iter() {
let Some(new_id) = id_map.get(root) else { continue };
let Some(new_id) = id_map.get(root) else {
continue;
};
self.parents_invalid = true;
self.positions_invalid = true;
for (parent_id, len) in &self.nodes[new_id].parents {
Expand Down Expand Up @@ -842,7 +844,9 @@ impl Graph {
}

fn try_promoting_subtables(&mut self) {
let Some((can_promote, parent_id)) = self.get_promotable_subtables() else { return };
let Some((can_promote, parent_id)) = self.get_promotable_subtables() else {
return;
};
let to_promote = self.select_promotions_hb(&can_promote, parent_id);
log::info!(
"promoting {} of {} eligible subtables",
Expand Down
6 changes: 5 additions & 1 deletion write-fonts/src/tables/glyf/composite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,11 @@ mod tests {
let font = FontRef::new(font_test_data::VAZIRMATN_VAR).unwrap();
let loca = font.loca(None).unwrap();
let glyf = font.glyf().unwrap();
let read_glyf::Glyph::Composite(orig) = loca.get_glyf(GlyphId::new(2), &glyf).unwrap().unwrap() else { panic!("not a composite glyph") };
let read_glyf::Glyph::Composite(orig) =
loca.get_glyf(GlyphId::new(2), &glyf).unwrap().unwrap()
else {
panic!("not a composite glyph")
};

let bbox = Bbox {
x_min: orig.x_min(),
Expand Down
18 changes: 15 additions & 3 deletions write-fonts/src/tables/glyf/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,11 @@ mod tests {
let font = FontRef::new(font_test_data::SIMPLE_GLYF).unwrap();
let loca = font.loca(None).unwrap();
let glyf = font.glyf().unwrap();
let read_glyf::Glyph::Simple(orig) = loca.get_glyf(GlyphId::new(0), &glyf).unwrap().unwrap() else { panic!("not a simple glyph") };
let read_glyf::Glyph::Simple(orig) =
loca.get_glyf(GlyphId::new(0), &glyf).unwrap().unwrap()
else {
panic!("not a simple glyph")
};
let orig_bytes = orig.offset_data();

let ours = SimpleGlyph::from_table_ref(&orig);
Expand All @@ -688,7 +692,11 @@ mod tests {
let font = FontRef::new(font_test_data::SIMPLE_GLYF).unwrap();
let loca = font.loca(None).unwrap();
let glyf = font.glyf().unwrap();
let read_glyf::Glyph::Simple(orig) = loca.get_glyf(GlyphId::new(2), &glyf).unwrap().unwrap() else { panic!("not a simple glyph") };
let read_glyf::Glyph::Simple(orig) =
loca.get_glyf(GlyphId::new(2), &glyf).unwrap().unwrap()
else {
panic!("not a simple glyph")
};
let orig_bytes = orig.offset_data();

let bezpath = simple_glyph_to_bezpath(&orig);
Expand All @@ -710,7 +718,11 @@ mod tests {
let font = FontRef::new(font_test_data::VAZIRMATN_VAR).unwrap();
let loca = font.loca(None).unwrap();
let glyf = font.glyf().unwrap();
let read_glyf::Glyph::Simple(orig) = loca.get_glyf(GlyphId::new(1), &glyf).unwrap().unwrap() else { panic!("not a simple glyph") };
let read_glyf::Glyph::Simple(orig) =
loca.get_glyf(GlyphId::new(1), &glyf).unwrap().unwrap()
else {
panic!("not a simple glyph")
};
let orig_bytes = orig.offset_data();

let bezpath = simple_glyph_to_bezpath(&orig);
Expand Down
4 changes: 3 additions & 1 deletion write-fonts/src/tables/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ mod tests {
let axis_values = read.offset_to_axis_values().unwrap();
assert_eq!(axis_values.axis_value_offsets().len(), 2);
let value2 = axis_values.axis_values().get(1).unwrap();
let read_stat::AxisValue::Format1(value2) = value2 else { panic!("wrong format"); };
let read_stat::AxisValue::Format1(value2) = value2 else {
panic!("wrong format");
};
assert_eq!(value2.value_name_id(), NameId::new(261));
}
}
8 changes: 6 additions & 2 deletions write-fonts/src/tables/value_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,15 @@ mod tests {

let bytes = crate::dump_table(&a_table).unwrap();
let read_back = PairPosFormat2::read(bytes.as_slice().into()).unwrap();
let DeviceOrVariationIndex::VariationIndex(dev2) = read_back.class1_records[0].class2_records[0]
let DeviceOrVariationIndex::VariationIndex(dev2) = read_back.class1_records[0]
.class2_records[0]
.value_record2
.x_advance_device
.as_ref()
.unwrap() else { panic!("not a variation index") };
.unwrap()
else {
panic!("not a variation index")
};
assert_eq!(dev2.delta_set_outer_index, 0xaa);
}
}

0 comments on commit c8a9a8c

Please sign in to comment.