Switched empty font base from to toml.

This commit is contained in:
be5invis 2015-08-25 11:17:05 +08:00
parent c78b095e5b
commit d61449f0e4
3 changed files with 134 additions and 28 deletions

View File

@ -1,11 +1,17 @@
define fs : require 'fs'
define path : require 'path'
define Glyph [require './support/glyph'].Glyph
define Stroke [require './support/stroke'].Stroke
define tp [require './support/transform'].transformPoint
define inverse [require './support/transform'].inverse
define libspiro : require 'libspiro-js'
define SpiroExpansionContext [require './support/spiroexpand'].SpiroExpansionContext
### COMMON FUNCTIONS
define toml : require 'toml'
### 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 [bilinear x0 x1 y0 y1 z00 z01 z10 z11 x y] : linreg {
@ -17,7 +23,8 @@ define [bilinear x0 x1 y0 y1 z00 z01 z10 z11 x y] : linreg {
}
define [fallback] : for [local j 0] [j < arguments.length] [inc j] : if [arguments`j !== nothing] : return arguments`j
define emptyFontStr : JSON.stringify [require './empty.json']
# Empty font base file
define emptyFontStr : fs.readFileSync : path.join [path.dirname require.main.filename] 'emptyfont.toml'
define-macro $$include : syntax-rules {
('$$include' ('.quote' file)) : begin {
@ -37,9 +44,10 @@ define-macro $$include : syntax-rules {
define [buildFont para recursive] : begin {
define variantSelector para.variantSelector
define font : JSON.parse emptyFontStr
define font : toml.parse emptyFontStr
define glyphList font.glyf
define glyphs (.'.notdef' glyphList.0)
define glyphs (.)
define unicodeGlyphs ()
define UPM 1000
@ -466,7 +474,18 @@ define [buildFont para recursive] : begin {
set font.post.italicAnvle [0 - para.italicangle]
}
# Necessary space glyph
# Necessary notdef glyph
create-glyph '.notdef' : glyph-construction {
start-from SB 0
line-to SB CAP
line-to RIGHTSB CAP
line-to RIGHTSB 0
start-from [SB + STROKE] STROKE
line-to [RIGHTSB - STROKE] STROKE
line-to [RIGHTSB - STROKE] [CAP - STROKE]
line-to [SB + STROKE] [CAP - STROKE]
}
create-glyph 'space' : glyph-construction {
set-width WIDTH
assign-unicode ' '

View File

@ -1,23 +0,0 @@
{
"version":1,
"numTables":12,
"searchRenge":128,
"entrySelector":3,
"rengeShift":64,
"head":{"version":1,"fontRevision":1,"checkSumAdjustment":369537602,"magickNumber":1594834165,"flags":11,"unitsPerEm":1000,"created":"2014-12-06T22:05:19.000Z","modified":"2014-12-06T22:20:03.000Z","xMin":34,"yMin":0,"xMax":306,"yMax":682,"macStyle":0,"lowestRecPPEM":8,"fontDirectionHint":2,"indexToLocFormat":0,"glyphDataFormat":0},
"glyf":[
{"contours":[[{"x":34,"y":0,"onCurve":true},{"x":34,"y":682,"onCurve":true},{"x":306,"y":682,"onCurve":true},{"x":306,"y":0,"onCurve":true}],[{"x":68,"y":34,"onCurve":true},{"x":272,"y":34,"onCurve":true},{"x":272,"y":648,"onCurve":true},{"x":68,"y":648,"onCurve":true}]],"advanceWidth":500,"name":".notdef"}
],
"cmap":{},
"name":{
"fontFamily": "node-sfnt",
"fontSubFamily": "regular",
"uniqueSubFamily": "node-sfnt blank font",
"fullName": "node-sfnt",
"version": "Version 1.0",
"postScriptName": "node-sfnt"
},
"hhea":{"version":1,"ascent":812,"descent":-212,"lineGap":92,"advanceWidthMax":374,"minLeftSideBearing":34,"minRightSideBearing":68,"xMaxExtent":306,"caretSlopeRise":1,"caretSlopeRun":0,"caretOffset":0,"reserved0":0,"reserved1":0,"reserved2":0,"reserved3":0,"metricDataFormat":0,"numOfLongHorMetrics":1},
"post":{"italicAngle":0,"postoints":65411,"underlinePosition":50,"underlineThickness":0,"isFixedPitch":0,"minMemType42":0,"maxMemType42":0,"minMemType1":0,"maxMemType1":1,"format":2},
"OS/2":{"version":4,"xAvgCharWidth":1031,"usWeightClass":400,"usWidthClass":5,"fsType":0,"ySubscriptXSize":665,"ySubscriptYSize":716,"ySubscriptXOffset":0,"ySubscriptYOffset":143,"ySuperscriptXSize":665,"ySuperscriptYSize":716,"ySuperscriptXOffset":0,"ySuperscriptYOffset":491,"yStrikeoutSize":51,"yStrikeoutPosition":265,"sFamilyClass":0,"bFamilyType":2,"bSerifStyle":0,"bWeight":6,"bProportion":3,"bContrast":0,"bStrokeVariation":0,"bArmStyle":0,"bLetterform":0,"bMidline":0,"bXHeight":0,"ulUnicodeRange1":1,"ulUnicodeRange2":268435456,"ulUnicodeRange3":0,"ulUnicodeRange4":0,"achVendID":"PfEd","fsSelection":192,"usFirstCharIndex":0,"usLastCharIndex":0,"sTypoAscender":812,"sTypoDescender":-212,"sTypoLineGap":92,"usWinAscent":812,"usWinDescent":212,"ulCodePageRange1":1,"ulCodePageRange2":0,"sxHeight":792,"sCapHeight":0,"usDefaultChar":0,"usBreakChar":32,"usMaxContext":1}
}

110
emptyfont.toml Normal file
View File

@ -0,0 +1,110 @@
version = 1
entrySelector = 3
glyf = []
[head]
checkSumAdjustment = 369537602
created = "2014-12-06T22:05:19.000Z"
flags = 11
fontDirectionHint = 2
fontRevision = 1
glyphDataFormat = 0
indexToLocFormat = 0
lowestRecPPEM = 8
macStyle = 0
magickNumber = 1594834165
modified = "2014-12-06T22:20:03.000Z"
unitsPerEm = 1000
version = 1
xMax = 306
xMin = 34
yMax = 682
yMin = 0
[hhea]
advanceWidthMax = 374
ascent = 812
caretOffset = 0
caretSlopeRise = 1
caretSlopeRun = 0
descent = -212
lineGap = 92
metricDataFormat = 0
minLeftSideBearing = 34
minRightSideBearing = 68
numOfLongHorMetrics = 1
reserved0 = 0
reserved1 = 0
reserved2 = 0
reserved3 = 0
version = 1
xMaxExtent = 306
["OS/2"]
achVendID = "PfEd"
bArmStyle = 0
bContrast = 0
bFamilyType = 2
bLetterform = 0
bMidline = 0
bProportion = 3
bSerifStyle = 0
bStrokeVariation = 0
bWeight = 6
bXHeight = 0
fsSelection = 192
fsType = 0
sCapHeight = 0
sFamilyClass = 0
sTypoAscender = 812
sTypoDescender = -212
sTypoLineGap = 92
sxHeight = 792
ulCodePageRange1 = 1
ulCodePageRange2 = 0
ulUnicodeRange1 = 1
ulUnicodeRange2 = 268435456
ulUnicodeRange3 = 0
ulUnicodeRange4 = 0
usBreakChar = 32
usDefaultChar = 0
usFirstCharIndex = 0
usLastCharIndex = 0
usMaxContext = 1
usWeightClass = 400
usWidthClass = 5
usWinAscent = 812
usWinDescent = 212
version = 4
xAvgCharWidth = 1031
yStrikeoutPosition = 265
yStrikeoutSize = 51
ySubscriptXOffset = 0
ySubscriptXSize = 665
ySubscriptYOffset = 143
ySubscriptYSize = 716
ySuperscriptXOffset = 0
ySuperscriptXSize = 665
ySuperscriptYOffset = 491
ySuperscriptYSize = 716
[name]
fontFamily = "node-sfnt"
fontSubFamily = "regular"
fullName = "node-sfnt"
postScriptName = "node-sfnt"
uniqueSubFamily = "node-sfnt blank font"
version = "Version 1.0"
[post]
format = 2
isFixedPitch = 0
italicAngle = 0
maxMemType1 = 1
maxMemType42 = 0
minMemType1 = 0
minMemType42 = 0
postoints = 65411
underlinePosition = 50
underlineThickness = 0