Skip to content
This repository has been archived by the owner on May 20, 2022. It is now read-only.

Remove overlap result not the best #70

Open
ctrlcctrlv opened this issue Jan 21, 2022 · 2 comments
Open

Remove overlap result not the best #70

ctrlcctrlv opened this issue Jan 21, 2022 · 2 comments

Comments

@ctrlcctrlv
Copy link
Sponsor

image
Input was FRBAmericanCursive-400-Regular.zip

…it's fast and wrong though, as opposed to slow and wrong as fontmake often is (though not this wrong)!

@ctrlcctrlv
Copy link
Sponsor Author

Strangely the contours are still in the TTF, just wrong winding direction. I wonder, is this yet another manifestation of @MatthewBlanchard's Skia bug?

@ctrlcctrlv
Copy link
Sponsor Author

Just an update. This is what it looks like post-№497140 (@MatthewBlanchard—Changed aswinding to use the signed area of the polygon defined by the contour's control points instead of the derivative of the left edge to determine winding direction.)

image
image

Much better, but not perfect.

To achieve this result I applied this patch to @simoncozens code:

diff --git a/crates/fonttools-cli/src/bin/ttf-remove-overlap.rs b/crates/fonttools-cli/src/bin/ttf-remove-overlap.rs
index d402dbb..53bd5e1 100644
--- a/crates/fonttools-cli/src/bin/ttf-remove-overlap.rs
+++ b/crates/fonttools-cli/src/bin/ttf-remove-overlap.rs
@@ -1,8 +1,7 @@
 use fonttools::tables::glyf::{Glyph, Point};
-use fonttools::tag;
 use fonttools_cli::{open_font, read_args, save_font};
 
-use skia_safe::{simplify, Path};
+use skia_safe::{Path, PathOp};
 
 fn remove_overlap(g: &mut Glyph) {
     if g.has_components() || g.is_empty() {
@@ -46,7 +45,7 @@ fn remove_overlap(g: &mut Glyph) {
         }
         path.close();
     }
-    if let Some(newpath) = simplify(&path) {
+    if let Some(Some(newpath)) = path.op(&path, PathOp::Union).map(|p| p.as_winding()) {
         g.contours = skia_to_glyf(newpath);
     }
 }

And compiled as:

SKIA_USE_SYSTEM_LIBRARIES=1 SKIA_LIBRARY_SEARCH_PATH=/opt/lib/ SKIA_SOURCE_DIR=$PWD/../../../rust-skia/skia-bindings/skia/ SKIA_BUILD_DEFINES="`cat /opt/lib/skia-defines.txt`" cargo -vvv build --release

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant