Added parameter upmscale to produce fonts in a higher upm.

This commit is contained in:
Belleve Invis 2015-07-24 03:42:37 +08:00
parent 19f6f894cc
commit 01536b54e5
8 changed files with 1599 additions and 2204 deletions

View file

@ -1,3 +1,13 @@
### Zoom all glyphs
foreach glyph [items-of glyphList] : begin {
glyph.advanceWidth = glyph.advanceWidth * upmscale
if glyph.contours: foreach contour [items-of glyph.contours] : foreach point [items-of contour] : begin {
point.x = point.x * upmscale
point.y = point.y * upmscale
}
}
return font
}

View file

@ -1,6 +1,12 @@
define Glyph [require './support/glyph'].Glyph
define Stroke [require './support/stroke'].Stroke
### COMMON FUNCTIONS
define [mix a b p] : a + [b - a] * p
define [linreg x0 y0 x1 y1 x] : y0 + [x - x0] * [y1 - y0] / [x1 - x0]
define [fallback] : for [local j 0] [j < arguments.length] [inc j] : if [arguments`j !== nothing] : return arguments`j
define [exports.build para] : begin {
define variantSelector para.variantSelector
@ -132,15 +138,20 @@ set font.'OS/2'.fsSelection : [if para.isBold 32 0] + [if para.isItalic 1
set font.head.macStyle : [if para.isBold 1 0] + [if para.isItalic 2 0]
### Metric metadata
set font.hhea.ascent CAP
set font.'OS/2'.usWinAscent : CAP + CAP * 0.1
set font.'OS/2'.sTypoAscender CAP
set font.hhea.descent DESCENDER
set font.'OS/2'.usWinDescent : [Math.abs DESCENDER] + CAP * 0.1
set font.'OS/2'.sTypoDescender DESCENDER
set font.hhea.lineGap : CAP * 0.2
set font.'OS/2'.sTypoLineGap : CAP * 0.2
set font.'OS/2'.sxHeight XH
# Note: we use 1000upm in design, and 4096upm in production
define upmscale : fallback para.upmscale 1
set font.head.unitsPerEm : upmscale * 1000
set font.hhea.ascent : upmscale * CAP
set font.'OS/2'.usWinAscent : upmscale * [CAP + CAP * 0.1]
set font.'OS/2'.sTypoAscender : upmscale * CAP
set font.hhea.descent : upmscale * DESCENDER
set font.'OS/2'.usWinDescent : upmscale * [[Math.abs DESCENDER] + CAP * 0.1]
set font.'OS/2'.sTypoDescender : upmscale * DESCENDER
set font.hhea.lineGap : upmscale * CAP * 0.2
set font.'OS/2'.sTypoLineGap : upmscale * CAP * 0.2
set font.'OS/2'.sxHeight : upmscale * XH
set font.post.italicAnvle : 0 - para.italicangle
### Necessary macros
@ -184,6 +195,8 @@ define [select-variant glyphid unicode default] : begin {
###### HERE WE GO!
define [xgrid p] : mix SB RIGHTSB p
create-glyph 'space' : glyph-construction {
set-width WIDTH
assign-unicode ' '

File diff suppressed because it is too large Load diff

View file

@ -12,11 +12,11 @@ AddExtrema();
RemoveOverlap();
RoundToInt()
RemoveOverlap();
ReplaceWithReference(3, 1);
ReplaceWithReference(10, 1);
SetFontOrder(3);
Simplify(0, 2);
Simplify(0, 8);
SetFontOrder(2);
Simplify(0, 1);
Simplify(0, 4);
CorrectDirection();
CanonicalContours();
CanonicalStart();

View file

@ -1,11 +1,4 @@
### COMMON FUNCTIONS
define [mix a b p] : a + [b - a] * p
define [xgrid p] : mix SB RIGHTSB p
define [linreg x0 y0 x1 y1 x] : y0 + [x - x0] * [y1 - y0] / [x1 - x0]
define [fallback] : for [local j 0] [j < arguments.length] [inc j] : if [arguments`j !== nothing] : return arguments`j
### COMMON SHAPES
define [Ring u d l r] : begin {

View file

@ -33,7 +33,7 @@ $(SUPPORT_FILES) :
.buildglyphs.all.patel : buildglyphs-intro.patel $(GLYPH_SEGMENTS) buildglyphs-final.patel
cat $^ > .buildglyphs.all.patel
buildglyphs.js : .buildglyphs.all.patel
patel-c --strict $^ | uglifyjs -c -b -o $@
patel-c --strict $^ | uglifyjs -b -c -m -o $@
support/glyph.js : support/glyph.patel
support/stroke.js : support/stroke.patel
parameters.js : parameters.patel

View file

@ -1,6 +1,7 @@
{
var r0_regular, r0_bold, r0_italic, r0_bolditalic;
r0_regular = {
'upmscale': 4.096,
'width': 500,
'stroke': 80,
'dotsize': 125,

View file

@ -1,4 +1,7 @@
define regular (
.upmscale 4.096
.width 500
.stroke 80
.dotsize 125