Skip to content

Commit

Permalink
Merge pull request #484 from googlefonts/new-kurbo
Browse files Browse the repository at this point in the history
use BezPath::reverse_subpaths() from latest kurbo
  • Loading branch information
anthrotype authored Oct 4, 2023
2 parents 7faf178 + c9f06ed commit c230306
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ env_logger = "0.10.0"

parking_lot = "0.12.1"

fea-rs = "0.17.0"
fea-rs = "0.18.0"
font-types = { version = "0.4.0", features = ["serde"] }
read-fonts = "0.11.2"
write-fonts = { version = "0.16.0", features = ["serde"] }
skrifa = "0.10.1"
read-fonts = "0.12.0"
write-fonts = { version = "0.17.0", features = ["serde"] }
skrifa = "0.11.0"

bitflags = "2.0"
chrono = { version = "0.4.24", features = ["serde"] }
filetime = "0.2.18"
indexmap = "1.9.2"
kurbo = { version = "0.9.4", features = ["serde"] }
kurbo = { version = "0.10.2", features = ["serde"] }
ordered-float = { version = "4.1.0", features = ["serde"] }
smol_str = { version = "0.1.24", features = ["serde"] }
quick-xml = { version = "0.29.0", features = ["serialize"] }
Expand Down
16 changes: 2 additions & 14 deletions fontir/src/glyph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use fontdrasil::{
use kurbo::Affine;
use log::{debug, log_enabled, trace};
use ordered_float::OrderedFloat;
use write_fonts::pens::{write_to_pen, BezPathPen, ReverseContourPen};

use crate::{
coords::NormalizedLocation,
Expand Down Expand Up @@ -210,13 +209,7 @@ fn convert_components_to_contours(context: &Context, original: &Glyph) -> Result

// See https://github.com/googlefonts/ufo2ft/blob/dd738cdcddf61cce2a744d1cafab5c9b33e92dd4/Lib/ufo2ft/util.py#L205
if component.transform.determinant() < 0.0 {
let mut bez_pen = BezPathPen::new();
let mut rev_pen = ReverseContourPen::new(&mut bez_pen);
write_to_pen(&contour, &mut rev_pen);
rev_pen
.flush()
.map_err(|e| WorkError::ContourReversalError(format!("{e:?}")))?;
inst.contours.push(bez_pen.into_inner());
inst.contours.push(contour.reverse_subpaths());
} else {
inst.contours.push(contour);
}
Expand Down Expand Up @@ -444,7 +437,6 @@ mod tests {
use font_types::Tag;
use fontdrasil::{orchestration::Access, types::GlyphName};
use kurbo::{Affine, BezPath};
use write_fonts::pens::{write_to_pen, BezPathPen, ReverseContourPen};

use crate::{
coords::{NormalizedCoord, NormalizedLocation},
Expand Down Expand Up @@ -778,13 +770,9 @@ mod tests {

// what we should get back is the contour with the_neg applied, reversed because
// the_neg is notoriously negative in determinant
let mut bez_pen = BezPathPen::new();
let mut rev_pen = ReverseContourPen::new(&mut bez_pen);
let mut expected = contour();
expected.apply_affine(the_neg);
write_to_pen(&expected, &mut rev_pen);
rev_pen.flush().unwrap();
let expected = bez_pen.into_inner().to_svg();
let expected = expected.reverse_subpaths().to_svg();

assert_eq!(
vec![expected],
Expand Down

0 comments on commit c230306

Please sign in to comment.