From 14494010970ddeb5f824efee69ff4346c29b5051 Mon Sep 17 00:00:00 2001 From: be5invis Date: Mon, 14 Dec 2015 04:38:37 +0800 Subject: [PATCH] Improved outline simplification subpass. --- glyphs/letters-unified-basic.aki | 4 ++-- glyphs/letters-unified-extended.aki | 11 ++++++----- pass1-cleanup.py | 13 ++++++++----- pass3-features.py | 4 +++- support/spirokit.aki | 13 +++++++------ 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/glyphs/letters-unified-basic.aki b/glyphs/letters-unified-basic.aki index 1d30029..8dd74d6 100644 --- a/glyphs/letters-unified-basic.aki +++ b/glyphs/letters-unified-basic.aki @@ -1225,7 +1225,7 @@ symbol-block 'p' assign-unicode 'p' include pMarks - include : OBarLeftShape + include : tagged 'bowl' : OBarLeftShape include : VBarLeft SB DESCENDER XH if SLAB : begin include : LeftwardTopSerif SB XH SIDEJUT @@ -2591,7 +2591,7 @@ symbol-block 't' local center : MIDDLE - TBALANCE - HALFSTROKE * CORRECTION_HX local hookx (center + (WIDTH - SB * 2) * 0.8 - OXHOOK + TAILADJX * globalTransform.yx) local turn : [mix center hookx 0.5] + CORRECTION_OMIDS - local smb : (turn - center) * 1.2 + local smb : Math.max HOOK ((turn - center) * 1.2) local g : dispiro widths.lhs diff --git a/glyphs/letters-unified-extended.aki b/glyphs/letters-unified-extended.aki index 23afe52..871ca1c 100644 --- a/glyphs/letters-unified-extended.aki +++ b/glyphs/letters-unified-extended.aki @@ -205,7 +205,7 @@ symbol-block 'epsilon and cyrze' include : dispiro widths.lhs g4 RIGHTSB (top - [fallback hook SHOOK]) - hookstart top + hookstart (top - O) g4 (SB + OXE) (top - sma) arcvh flat MIDDLE (midy - (fine - HALFSTROKE)) [widths.heading fine 0 RIGHTWARD] @@ -213,7 +213,7 @@ symbol-block 'epsilon and cyrze' include : dispiro widths.rhs g4 RIGHTSB [fallback hook SHOOK] - hookstart 0 + hookstart O g4 (SB + OXE) smb arcvh flat MIDDLE (midy + (fine - HALFSTROKE)) [widths.heading 0 fine RIGHTWARD] @@ -238,7 +238,7 @@ symbol-block 'epsilon and cyrze' include : dispiro widths.rhs g4 SB (top - [fallback hook SHOOK]) - hookstart top + hookstart (top - O) g4 (RIGHTSB - OXE) (top - smb) arcvh flat MIDDLE (midy - (fine - HALFSTROKE)) [widths.heading 0 fine LEFTWARD] @@ -246,7 +246,7 @@ symbol-block 'epsilon and cyrze' include : dispiro widths.lhs g4 SB [fallback hook SHOOK] - hookstart 0 + hookstart O g4 (RIGHTSB - OXE) sma arcvh flat MIDDLE (midy + (fine - HALFSTROKE)) [widths.heading fine 0 LEFTWARD] @@ -303,7 +303,7 @@ symbol-block 'zeta and xi' local ybar : mix 0 CAP 0.55 include : dispiro widths.rhs - g4 xbar (CAP - STROKE) + g4.left.start xbar (CAP - STROKE) archv g4 (SB - O * 2 + STROKE * CORRECTION_HX) [mix (CAP - STROKE) ybar 0.6] arcvh @@ -1669,6 +1669,7 @@ symbol-block 'Thorn' eject-contour 'serifLB' include : create-glyph : glyph-construction include glyphs.p + eject-contour 'bowl' eject-contour 'serifLT' include ifMarks diff --git a/pass1-cleanup.py b/pass1-cleanup.py index 8a13085..68d63a3 100644 --- a/pass1-cleanup.py +++ b/pass1-cleanup.py @@ -9,11 +9,11 @@ font = fontforge.open(source) # Replace accented characters into references print " Reference finding: ", font.fontname font.selection.select(("ranges", "unicode", None), 0x1FCD, 0x1FCF, 0x1FDD, 0x1FDF) -font.replaceWithReference(2) +font.replaceWithReference(1) font.selection.all() font.selection.select(("less", None), "I.straight", "dotlessi.straight", "l.straight", "ltailBR", "rtailBR") font.selection.select(("less", "ranges", "unicode"), 0x207A, 0x207E, 0x208A, 0x208E) -font.replaceWithReference(2) +font.replaceWithReference(1) # Remove overlapped area print " Overlap Removal: ", font.fontname @@ -25,16 +25,19 @@ for i in font: glyph.unlinkRef() glyph.removeOverlap() font.selection.all() -font.replaceWithReference(2) +font.replaceWithReference(1) print " Simplify: ", font.fontname font.selection.all() font.transform(psMat.scale(5)) -font.simplify(1, ("smoothcurves", "choosehv"), 0.1) +font.simplify(0.05, ("smoothcurves", "choosehv"), 0.1) font.transform(psMat.scale(0.2)) -font.simplify(1, ("smoothcurves", "choosehv"), 0.1) +font.simplify(0.2, ("smoothcurves", "choosehv"), 0.1) + +#font.em = 2000 font.layers["Fore"].is_quadratic = True font.transform(psMat.skew(float(sys.argv[3]) / 180 * math.pi)) +#font.em = 1000 font.canonicalContours() font.canonicalStart() diff --git a/pass3-features.py b/pass3-features.py index f26cb37..c997aa1 100644 --- a/pass3-features.py +++ b/pass3-features.py @@ -9,6 +9,8 @@ font.selection.select(("ranges", "unicode", None), 0x20, 0x7e) font.unlinkReferences() font.selection.all() font.removeOverlap() -font.simplify(0.1) +font.simplify(0.01) +font.selection.all() +font.removeOverlap() font.mergeFeature(sys.argv[2]) font.generate(sys.argv[3], flags = ("short-post", "opentype")) \ No newline at end of file diff --git a/support/spirokit.aki b/support/spirokit.aki index 9c19a9d..8431715 100644 --- a/support/spirokit.aki +++ b/support/spirokit.aki @@ -104,8 +104,8 @@ export : define [SetupBuilders args] : begin if [not cache.(samples)] : build samples return cache.(samples).vh list hv vh - define [archv samples notiny k raf] : alsothruthem [jhv [fallback samples 4]] raf - define [arcvh samples notiny k raf] : alsothruthem [jvh [fallback samples 4]] raf + define [archv samples notiny k raf] : alsothruthem [jhv [fallback samples 12]] raf + define [arcvh samples notiny k raf] : alsothruthem [jvh [fallback samples 12]] raf define [complexThru] : begin local a : {}.slice.call arguments @@ -136,7 +136,8 @@ export : define [SetupBuilders args] : begin set knots.(j) : knots.(j).af.call s knots.(j - 1) knots.(j + 1) knots.(j) if closed : knots.pop return {.knots [flatten knots] .closed closed .lastafs lastafs} - + + define QUAD false define [dispiro] : begin local s : new SpiroExpansionContext set s.gizmo globalTransform @@ -151,16 +152,16 @@ export : define [SetupBuilders args] : begin local {.lhs lhs .rhs rhs} : s.expand [fallback s.contrast CONTRAST] if closed : then local g : new Glyph - libspiro.spiroToBezierOnContext [lhs.slice 0 (-1)] true g + libspiro.spiroToBezierOnContext [lhs.slice 0 (-1)] true g QUAD 0.5 local lhsContour g.contours.0 set g.contours {} - libspiro.spiroToBezierOnContext [rhs.reverse :.slice 0 (-1)] true g + libspiro.spiroToBezierOnContext [rhs.reverse :.slice 0 (-1)] true g QUAD 0.5 local rhsContour g.contours.0 set g.contours {[lhsContour.concat rhsContour]} : else local g : new Glyph lhs.0.type = rhs.0.type = lhs.(lhs.length - 1).type = rhs.(rhs.length - 1).type = 'corner' - libspiro.spiroToBezierOnContext [lhs.concat : rhs.reverse] true g + libspiro.spiroToBezierOnContext [lhs.concat : rhs.reverse] true g QUAD 0.5 set g.knots knots set g.lhsknots lhs set g.rhsknots rhs