Shifted slanted glyphs leftward a little.

This commit is contained in:
be5invis 2015-08-05 22:47:52 +08:00
parent 4b57df8389
commit 9ec44543f3
3 changed files with 22 additions and 13 deletions

View File

@ -1,6 +1,7 @@
define Glyph [require './support/glyph'].Glyph
define Stroke [require './support/stroke'].Stroke
define tp [require './support/transform'].transformPoint
define inverse [require './support/transform'].inverse
### COMMON FUNCTIONS
@ -32,15 +33,16 @@ define [buildFont para recursive] : begin {
define glyphs (.'.notdef' glyphList.0)
define unicodeGlyphs ()
define globalTransform (
.xx 1
.yx [Math.tan [para.italicangle / 180 * Math.PI]]
.xy 0
.yy 1
.x 0
.y 0
)
# Transform constructors
define [Italify angle] : begin {
local slope [Math.tan [[fallback angle para.italicangle] / 180 * Math.PI]]
return (.xx 1 .yx slope .xy 0 .yy 1 .x [-slope * 0.5 * para.xheight] .y 0)
}
define [Upright angle] [inverse : Italify angle]
define [Scale sx sy] (.xx sx .yx 0 .xy 0 .yy [fallback sy sx] .x 0 .y 0)
define [Translate x y] (.xx 1 .yx 0 .xy 0 .yy 1 .x x .y y)
define globalTransform : Italify para.italicAngle
define ITALICCOR : 1 / [Math.sqrt [1 - globalTransform.yx * globalTransform.yx]]
define UPWARD (.x [-ITALICCOR] .y 0)
@ -122,10 +124,6 @@ define [buildFont para recursive] : begin {
define MARKBASE 'markbase'
define AS_BASE 'AS-BASE'
define [Upright angle] (.xx 1 .yx [-[Math.tan [[fallback angle para.italicangle] / 180 * Math.PI]]] .xy 0 .yy 1 .x 0 .y 0)
define [Italify angle] (.xx 1 .yx [Math.tan [[fallback angle para.italicangle] / 180 * Math.PI]] .xy 0 .yy 1 .x 0 .y 0)
define [Scale sx sy] (.xx sx .yx 0 .xy 0 .yy [fallback sy sx] .x 0 .y 0)
define [Translate x y] (.xx 1 .yx 0 .xy 0 .yy 1 .x x .y y)
define [tm anchor] : return (
.x [anchor.x * globalTransform.xx + anchor.y * globalTransform.yx + globalTransform.x]

View File

@ -18,7 +18,7 @@ RemoveOverlap();
ReplaceWithReference(4, 1);
Print("Simplifying");
AddExtrema();
Simplify(0, 3);
Simplify(0, 2);
Print("Finalizing");
CorrectDirection();
CanonicalContours();

View File

@ -6,6 +6,17 @@ exports.transformPoint = function(tfm, pt){
cubic: pt.cubic
}
}
exports.inverse = function(tfm){
var denom = tfm.xx * tfm.yy - tfm.xy * tfm.yx;
return {
xx : tfm.yy / denom,
yx : -tfm.yx / denom,
xy : -tfm.xy / denom,
yy : tfm.xx / denom,
x : -(tfm.x * tfm.yy - tfm.y * tfm.yx) / denom,
y : -(-tfm.x * tfm.xy + tfm.y * tfm.xx) / denom,
}
}
exports.untransform = function(tfm, pt){
var xx = pt.x - tfm.x
var yy = pt.y - tfm.y