Improved outline simplification subpass.

This commit is contained in:
be5invis 2015-12-14 04:38:37 +08:00
parent 8d8c7f4cf0
commit 1449401097
5 changed files with 26 additions and 19 deletions

View File

@ -1225,7 +1225,7 @@ symbol-block 'p'
assign-unicode 'p' assign-unicode 'p'
include pMarks include pMarks
include : OBarLeftShape include : tagged 'bowl' : OBarLeftShape
include : VBarLeft SB DESCENDER XH include : VBarLeft SB DESCENDER XH
if SLAB : begin if SLAB : begin
include : LeftwardTopSerif SB XH SIDEJUT include : LeftwardTopSerif SB XH SIDEJUT
@ -2591,7 +2591,7 @@ symbol-block 't'
local center : MIDDLE - TBALANCE - HALFSTROKE * CORRECTION_HX local center : MIDDLE - TBALANCE - HALFSTROKE * CORRECTION_HX
local hookx (center + (WIDTH - SB * 2) * 0.8 - OXHOOK + TAILADJX * globalTransform.yx) local hookx (center + (WIDTH - SB * 2) * 0.8 - OXHOOK + TAILADJX * globalTransform.yx)
local turn : [mix center hookx 0.5] + CORRECTION_OMIDS 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 local g : dispiro
widths.lhs widths.lhs

View File

@ -205,7 +205,7 @@ symbol-block 'epsilon and cyrze'
include : dispiro include : dispiro
widths.lhs widths.lhs
g4 RIGHTSB (top - [fallback hook SHOOK]) g4 RIGHTSB (top - [fallback hook SHOOK])
hookstart top hookstart (top - O)
g4 (SB + OXE) (top - sma) g4 (SB + OXE) (top - sma)
arcvh arcvh
flat MIDDLE (midy - (fine - HALFSTROKE)) [widths.heading fine 0 RIGHTWARD] flat MIDDLE (midy - (fine - HALFSTROKE)) [widths.heading fine 0 RIGHTWARD]
@ -213,7 +213,7 @@ symbol-block 'epsilon and cyrze'
include : dispiro include : dispiro
widths.rhs widths.rhs
g4 RIGHTSB [fallback hook SHOOK] g4 RIGHTSB [fallback hook SHOOK]
hookstart 0 hookstart O
g4 (SB + OXE) smb g4 (SB + OXE) smb
arcvh arcvh
flat MIDDLE (midy + (fine - HALFSTROKE)) [widths.heading 0 fine RIGHTWARD] flat MIDDLE (midy + (fine - HALFSTROKE)) [widths.heading 0 fine RIGHTWARD]
@ -238,7 +238,7 @@ symbol-block 'epsilon and cyrze'
include : dispiro include : dispiro
widths.rhs widths.rhs
g4 SB (top - [fallback hook SHOOK]) g4 SB (top - [fallback hook SHOOK])
hookstart top hookstart (top - O)
g4 (RIGHTSB - OXE) (top - smb) g4 (RIGHTSB - OXE) (top - smb)
arcvh arcvh
flat MIDDLE (midy - (fine - HALFSTROKE)) [widths.heading 0 fine LEFTWARD] flat MIDDLE (midy - (fine - HALFSTROKE)) [widths.heading 0 fine LEFTWARD]
@ -246,7 +246,7 @@ symbol-block 'epsilon and cyrze'
include : dispiro include : dispiro
widths.lhs widths.lhs
g4 SB [fallback hook SHOOK] g4 SB [fallback hook SHOOK]
hookstart 0 hookstart O
g4 (RIGHTSB - OXE) sma g4 (RIGHTSB - OXE) sma
arcvh arcvh
flat MIDDLE (midy + (fine - HALFSTROKE)) [widths.heading fine 0 LEFTWARD] 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 local ybar : mix 0 CAP 0.55
include : dispiro include : dispiro
widths.rhs widths.rhs
g4 xbar (CAP - STROKE) g4.left.start xbar (CAP - STROKE)
archv archv
g4 (SB - O * 2 + STROKE * CORRECTION_HX) [mix (CAP - STROKE) ybar 0.6] g4 (SB - O * 2 + STROKE * CORRECTION_HX) [mix (CAP - STROKE) ybar 0.6]
arcvh arcvh
@ -1669,6 +1669,7 @@ symbol-block 'Thorn'
eject-contour 'serifLB' eject-contour 'serifLB'
include : create-glyph : glyph-construction include : create-glyph : glyph-construction
include glyphs.p include glyphs.p
eject-contour 'bowl'
eject-contour 'serifLT' eject-contour 'serifLT'
include ifMarks include ifMarks

View File

@ -9,11 +9,11 @@ font = fontforge.open(source)
# Replace accented characters into references # Replace accented characters into references
print " Reference finding: ", font.fontname print " Reference finding: ", font.fontname
font.selection.select(("ranges", "unicode", None), 0x1FCD, 0x1FCF, 0x1FDD, 0x1FDF) font.selection.select(("ranges", "unicode", None), 0x1FCD, 0x1FCF, 0x1FDD, 0x1FDF)
font.replaceWithReference(2) font.replaceWithReference(1)
font.selection.all() font.selection.all()
font.selection.select(("less", None), "I.straight", "dotlessi.straight", "l.straight", "ltailBR", "rtailBR") font.selection.select(("less", None), "I.straight", "dotlessi.straight", "l.straight", "ltailBR", "rtailBR")
font.selection.select(("less", "ranges", "unicode"), 0x207A, 0x207E, 0x208A, 0x208E) font.selection.select(("less", "ranges", "unicode"), 0x207A, 0x207E, 0x208A, 0x208E)
font.replaceWithReference(2) font.replaceWithReference(1)
# Remove overlapped area # Remove overlapped area
print " Overlap Removal: ", font.fontname print " Overlap Removal: ", font.fontname
@ -25,16 +25,19 @@ for i in font:
glyph.unlinkRef() glyph.unlinkRef()
glyph.removeOverlap() glyph.removeOverlap()
font.selection.all() font.selection.all()
font.replaceWithReference(2) font.replaceWithReference(1)
print " Simplify: ", font.fontname print " Simplify: ", font.fontname
font.selection.all() font.selection.all()
font.transform(psMat.scale(5)) 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.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.layers["Fore"].is_quadratic = True
font.transform(psMat.skew(float(sys.argv[3]) / 180 * math.pi)) font.transform(psMat.skew(float(sys.argv[3]) / 180 * math.pi))
#font.em = 1000
font.canonicalContours() font.canonicalContours()
font.canonicalStart() font.canonicalStart()

View File

@ -9,6 +9,8 @@ font.selection.select(("ranges", "unicode", None), 0x20, 0x7e)
font.unlinkReferences() font.unlinkReferences()
font.selection.all() font.selection.all()
font.removeOverlap() font.removeOverlap()
font.simplify(0.1) font.simplify(0.01)
font.selection.all()
font.removeOverlap()
font.mergeFeature(sys.argv[2]) font.mergeFeature(sys.argv[2])
font.generate(sys.argv[3], flags = ("short-post", "opentype")) font.generate(sys.argv[3], flags = ("short-post", "opentype"))

View File

@ -104,8 +104,8 @@ export : define [SetupBuilders args] : begin
if [not cache.(samples)] : build samples if [not cache.(samples)] : build samples
return cache.(samples).vh return cache.(samples).vh
list hv vh list hv vh
define [archv samples notiny k raf] : alsothruthem [jhv [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 4]] raf define [arcvh samples notiny k raf] : alsothruthem [jvh [fallback samples 12]] raf
define [complexThru] : begin define [complexThru] : begin
local a : {}.slice.call arguments local a : {}.slice.call arguments
@ -137,6 +137,7 @@ export : define [SetupBuilders args] : begin
if closed : knots.pop if closed : knots.pop
return {.knots [flatten knots] .closed closed .lastafs lastafs} return {.knots [flatten knots] .closed closed .lastafs lastafs}
define QUAD false
define [dispiro] : begin define [dispiro] : begin
local s : new SpiroExpansionContext local s : new SpiroExpansionContext
set s.gizmo globalTransform set s.gizmo globalTransform
@ -151,16 +152,16 @@ export : define [SetupBuilders args] : begin
local {.lhs lhs .rhs rhs} : s.expand [fallback s.contrast CONTRAST] local {.lhs lhs .rhs rhs} : s.expand [fallback s.contrast CONTRAST]
if closed : then if closed : then
local g : new Glyph 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 local lhsContour g.contours.0
set g.contours {} 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 local rhsContour g.contours.0
set g.contours {[lhsContour.concat rhsContour]} set g.contours {[lhsContour.concat rhsContour]}
: else : else
local g : new Glyph local g : new Glyph
lhs.0.type = rhs.0.type = lhs.(lhs.length - 1).type = rhs.(rhs.length - 1).type = 'corner' 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.knots knots
set g.lhsknots lhs set g.lhsknots lhs
set g.rhsknots rhs set g.rhsknots rhs