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

View File

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

View File

@ -6,6 +6,17 @@ exports.transformPoint = function(tfm, pt){
cubic: pt.cubic 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){ exports.untransform = function(tfm, pt){
var xx = pt.x - tfm.x var xx = pt.x - tfm.x
var yy = pt.y - tfm.y var yy = pt.y - tfm.y