summaryrefslogtreecommitdiff
path: root/scripts/lib/fontbuild/italics.py
diff options
context:
space:
mode:
authorChristian Robertson <robertsonc@google.com>2014-05-22 19:02:36 -0700
committerChristian Robertson <robertsonc@google.com>2014-05-22 19:02:36 -0700
commit89eea596b60ba75c2b51595b1c5ff7012ce94e77 (patch)
treef2c8c1d56d242fe3c0cce45e35a4002b41c5c372 /scripts/lib/fontbuild/italics.py
parentd8bb7b4efc18c8bf413ec4bc5ffc914dda00fbed (diff)
Fixed inconsistent ymin and ymax values (for reals this time), removed old versions from 'out' directory.
Diffstat (limited to 'scripts/lib/fontbuild/italics.py')
-rw-r--r--scripts/lib/fontbuild/italics.py71
1 files changed, 37 insertions, 34 deletions
diff --git a/scripts/lib/fontbuild/italics.py b/scripts/lib/fontbuild/italics.py
index 72178b4..8e12619 100644
--- a/scripts/lib/fontbuild/italics.py
+++ b/scripts/lib/fontbuild/italics.py
@@ -29,7 +29,7 @@ def italicizeGlyph(g, angle=10, stemWidth=185):
def italicize(glyph, angle=12, stemWidth=180, xoffset=-50):
CURVE_CORRECTION_WEIGHT = .03
CORNER_WEIGHT = 10
- ga,subsegments = segmentGlyph(glyph,25)
+ ga, subsegments = segmentGlyph(glyph,25)
va, e = glyphToMesh(ga)
n = len(va)
grad = mapEdges(lambda a,(p,n): normalize(p-a), va, e)
@@ -79,38 +79,6 @@ def italicize(glyph, angle=12, stemWidth=180, xoffset=-50):
# return gOut
return fitGlyph(glyph, gOut, subsegments)
-def condenseGlyph(glyph, scale=.8, stemWidth=185):
- ga, subsegments = segmentGlyph(glyph, 25)
- va, e = glyphToMesh(ga)
- n = len(va)
-
- normals = edgeNormals(va,e)
- cn = va.dot(np.array([[scale, 0],[0,1]]))
- grad = mapEdges(lambda a,(p,n): normalize(p-a), cn, e)
- # ograd = mapEdges(lambda a,(p,n): normalize(p-a), va, e)
-
- cn[:,0] -= normals[:,0] * stemWidth * .5 * (1 - scale)
- out = recompose(cn, grad, e, smooth=.5)
- # out = recompose(out, grad, e, smooth=.1)
- out = recompose(out, grad, e, smooth=.01)
-
- # cornerWeights = mapEdges(lambda a,(p,n): normalize(p-a).dot(normalize(a-n)), grad, e)[:,0].reshape((-1,1))
- # smooth = np.ones((n,1)) * .1
- # smooth[cornerWeights < .6] = 10
- #
- # grad2 = quantizeGradient(grad).astype(float)
- # grad2 = copyGradDetails(grad, grad2, e, scale=10)
- # grad2 = mapEdges(lambda a,e: normalize(a), grad2, e)
- # out = recompose(out, grad2, e, smooth=smooth)
- out[:,0] += 15
- out[:,1] = va[:,1]
- # out = recompose(out, grad, e, smooth=.5)
- gOut = meshToGlyph(out, ga)
- gOut = fitGlyph(glyph, gOut, subsegments)
- for i,seg in enumerate(gOut):
- gOut[i].points[0].y = glyph[i].points[0].y
- return gOut
-
def transformFLGlyphMembers(g, m, transformAnchors = True):
# g.transform(m)
@@ -264,4 +232,39 @@ def copyMeshDetails(va,vb,e,scale=5,smooth=.01):
gradB = mapEdges(lambda a,(p,n): normalize(p-a), vb, e)
grad = copyGradDetails(gradA, gradB, e, scale)
grad = mapEdges(lambda a,(p,n): normalize(a), grad, e)
- return recompose(vb, grad, e, smooth=smooth) \ No newline at end of file
+ return recompose(vb, grad, e, smooth=smooth)
+
+
+
+
+def condenseGlyph(glyph, scale=.8, stemWidth=185):
+ ga, subsegments = segmentGlyph(glyph, 25)
+ va, e = glyphToMesh(ga)
+ n = len(va)
+
+ normals = edgeNormals(va,e)
+ cn = va.dot(np.array([[scale, 0],[0,1]]))
+ grad = mapEdges(lambda a,(p,n): normalize(p-a), cn, e)
+ # ograd = mapEdges(lambda a,(p,n): normalize(p-a), va, e)
+
+ cn[:,0] -= normals[:,0] * stemWidth * .5 * (1 - scale)
+ out = recompose(cn, grad, e, smooth=.5)
+ # out = recompose(out, grad, e, smooth=.1)
+ out = recompose(out, grad, e, smooth=.01)
+
+ # cornerWeights = mapEdges(lambda a,(p,n): normalize(p-a).dot(normalize(a-n)), grad, e)[:,0].reshape((-1,1))
+ # smooth = np.ones((n,1)) * .1
+ # smooth[cornerWeights < .6] = 10
+ #
+ # grad2 = quantizeGradient(grad).astype(float)
+ # grad2 = copyGradDetails(grad, grad2, e, scale=10)
+ # grad2 = mapEdges(lambda a,e: normalize(a), grad2, e)
+ # out = recompose(out, grad2, e, smooth=smooth)
+ out[:,0] += 15
+ out[:,1] = va[:,1]
+ # out = recompose(out, grad, e, smooth=.5)
+ gOut = meshToGlyph(out, ga)
+ gOut = fitGlyph(glyph, gOut, subsegments)
+ for i,seg in enumerate(gOut):
+ gOut[i].points[0].y = glyph[i].points[0].y
+ return gOut \ No newline at end of file