Skip to content

Commit

Permalink
refactored the process of weight assigning.
Browse files Browse the repository at this point in the history
  • Loading branch information
be5invis committed Jul 20, 2018
1 parent 7436a05 commit b4ba453
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 119 deletions.
51 changes: 38 additions & 13 deletions build-plans.toml
Expand Up @@ -173,20 +173,45 @@ from = [
"iosevka-cc-slab"
]

# Weight mappings (style => CSS)
# Weight mappings (style => shape weight, CSS weight)
# Shape weight : affects the shape of the glyphs
# CSS weight : affects the font menu name and webfont CSS
# Comment the lines to build less weights
# NOTE: This mapping does NOT affect the font's metadata, only affects
# the webfont CSS. Change `parameters.toml` instead.
[weights]
thin = 100
extralight = 200
light = 300
book = 400
medium = 500
semibold = 600
bold = 700
extrabold = 800
heavy = 900
[weights.thin]
shape = 100
css = 100

[weights.extralight]
shape = 200
css = 200

[weights.light]
shape = 300
css = 300

[weights.regular]
shape = 400
css = 400

[weights.medium]
shape = 500
css = 500

[weights.semibold]
shape = 600
css = 600

[weights.bold]
shape = 700
css = 700

[weights.extrabold]
shape = 800
css = 800

[weights.heavy]
shape = 900
css = 900

# Slant mappings (style => CSS)
# NOTE: This mapping does NOT affect the font's metadata, only affects
Expand Down
10 changes: 8 additions & 2 deletions gen/generator.js
Expand Up @@ -108,8 +108,14 @@ function getParameters(argv) {
para.variants = variantsData;
para.variantSelector = parameters.build(variantsData, argv._);
para.defaultVariant = variantsData.default;
if (argv.family) para.family = argv.family;
if (argv.ver) para.version = argv.ver;

para.naming = {
family: argv.family,
version: argv.ver,
weight: argv.weight - 0,
slant: argv.slant
};

return para;
}

Expand Down
Binary file modified images/charvars.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/download-options.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/family.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/languages.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/ligations.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/matrix.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/preview-all.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/stylesets.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/variants.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/weights.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 53 additions & 29 deletions meta/naming.ptl
Expand Up @@ -29,41 +29,65 @@ define [nameFont font nameid str] : begin
nameID nameid
nameString str

define weightToMenuStyleMap : object
100 "Thin"
200 "Extralight"
300 "Light"
400 ""
500 "Medium"
600 "Semibold"
700 "Bold"
800 "Extrabold"
900 "Heavy"

define slantToMenuStyleMap : object
normal ""
italic "Italic"
oblique "Oblique"

define [getStyle weight slant] : [(weightToMenuStyleMap.(weight) + " " + slantToMenuStyleMap.(slant)).trim] || "Regular"


export : define [assignFontNames para metrics font] : begin
set font.name {}

set para.family [para.family.trim]
set para.style : [para.style.trim] || "Regular"
define family : para.naming.family.trim
define style : getStyle para.naming.weight para.naming.slant
define version para.naming.version

define isItalic : para.naming.slant == "italic"
define isOblique : para.naming.slant == "oblique"
define isBold : para.naming.weight > 650

nameFont font PREFERRED_FAMILY para.family # Preferred Family
nameFont font PREFERRED_STYLE para.style # Preferred Style
nameFont font WWS_PREFERRED_FAMILY para.family # WWS Preferred Family
nameFont font WWS_PREFERRED_STYLE para.style # WWS Preferred Style
nameFont font PREFERRED_FAMILY family # Preferred Family
nameFont font PREFERRED_STYLE style # Preferred Style
nameFont font WWS_PREFERRED_FAMILY family # WWS Preferred Family
nameFont font WWS_PREFERRED_STYLE style # WWS Preferred Style

set font.name.preferredFamily para.family
set font.name.preferredSubFamily para.style
if (para.style == 'Regular' || para.style == 'Bold' || para.style == 'Italic' || para.style == "Bold Italic") : then
nameFont font FAMILY para.family # Family
nameFont font STYLE para.style # Style
set font.name.preferredFamily family
set font.name.preferredSubFamily style
if (style == 'Regular' || style == 'Bold' || style == 'Italic' || style == "Bold Italic") : then
nameFont font FAMILY family # Family
nameFont font STYLE style # Style
: else
local compatFamilySuffix : para.style.replace [regex ' Italic$'] '' :.replace [regex ' Extra'] 'X'
local compatStyle : if [[regex ' Italic$'].test para.style] 'Italic' 'Regular'
nameFont font FAMILY : para.family + ' ' + compatFamilySuffix
local compatFamilySuffix : style.replace [regex ' Italic$'] '' :.replace [regex ' Extra'] 'X'
local compatStyle : if [[regex ' Italic$'].test style] 'Italic' 'Regular'
nameFont font FAMILY : family + ' ' + compatFamilySuffix
nameFont font STYLE compatStyle

nameFont font UNIQUE_NAME "\(para.family) \(para.style) \(para.version)" # Unique Name
nameFont font UNIQUE_NAME "\(family) \(style) \(version)" # Unique Name

local fontfullName : if (para.style != 'Regular') (para.family + ' ' + para.style) para.family
local fontfullName : if (style != 'Regular') (family + ' ' + style) family
nameFont font FULL_NAME fontfullName # Full Name
nameFont font POSTSCRIPT : fontfullName.replace [regex ' ' 'g'] '-' # Postscript

nameFont font VERSION para.version # Version
nameFont font VERSION version # Version

nameFont font COPYRIGHT para.copyright # Copyright
nameFont font COPYRIGHT para.copyright # Copyright
nameFont font MANUFACTURER para.manufacturer # Manufacturer
nameFont font DESIGNER para.designer # Designer
nameFont font DESCRIPTION para.description # Description
nameFont font LICENCE para.licence # Licence
nameFont font DESIGNER para.designer # Designer
nameFont font DESCRIPTION para.description # Description
nameFont font LICENCE para.licence # Licence

set font.name : font.name.sort : lambda [a b] : begin
if (a.platformID != b.platformID) : return : a.platformID - b.platformID
Expand All @@ -72,18 +96,18 @@ export : define [assignFontNames para metrics font] : begin
return : a.nameID - b.nameID

# Weight, width and slantness
set font.OS_2.usWeightClass para.weight
set font.OS_2.usWeightClass para.naming.weight
set font.OS_2.panose.3 9 # Monospaced
set font.OS_2.panose.2 : 1 + para.weight / 100
set font.OS_2.panose.2 : 1 + para.naming.weight / 100
set font.OS_2.fsSelection : object
oblique : not : not para.isOblique
bold : not : not para.isBold
italic : not : not (para.isItalic || para.isOblique)
regular : not : not ([not para.isBold] && [not para.isItalic] && [not para.isOblique])
oblique : not : not isOblique
bold : not : not isBold
italic : not : not (isItalic || isOblique)
regular : not : not ([not isBold] && [not isItalic] && [not isOblique])
useTypoMetrics true
set font.OS_2.sFamilyClass : 8 * 0x100 + 9
set font.post.isFixedPitch true
set font.OS_2.xAvgCharWidth para.width
set font.head.macStyle : object
bold : not : not para.isBold
italic : not : not (para.isItalic || para.isOblique)
bold : not : not isBold
italic : not : not (isItalic || isOblique)
96 changes: 27 additions & 69 deletions parameters.toml
Expand Up @@ -59,8 +59,8 @@ jbalance = 63
fbalance = 6
onebalance = 30

isBold = false # Mark the font as bold?
isItalic = false # Use italic shapes?
isOblique = false # Use oblique shapes?

lllcrowdedness = 3.33333333

Expand All @@ -82,10 +82,7 @@ noCJKV = true
verbose = true

### Weights
[w-thin]
weight = 100
style = 'Thin'

[w-100]
stroke = 18
sb = 72
dotsize = 53
Expand All @@ -97,10 +94,7 @@ vtipfine = 1
shoulderfine = 0.8
pbarpos = 0.5

[w-extralight]
weight = 200
style = 'Extralight'

[w-200]
stroke = 36
sb = 68
dotsize = 70
Expand All @@ -111,10 +105,7 @@ cthinb = 0.75
vtipfine = 1
pbarpos = 0.5

[w-light]
weight = 300
style = 'Light'

[w-300]
stroke = 56
sb = 64
dotsize = 100
Expand All @@ -123,53 +114,39 @@ periodsize = 115
vtipfine = 0.9
pbarpos = 0.51

[w-book]
isBold = false
weight = 400 # "Weight" metadata.
style = ''

[w-400]
sb = 60 # Side bearing.
stroke = 72 # Stroke width of horizontal strokes.
dotsize = 125 # "Visual" size of dots in /i.
periodsize = 140 # "Visual" size of period.

[w-medium]
weight = 500
style = 'Medium'

[w-500]
sb = 57
stroke = 81
dotsize = 133
periodsize = 158
stroke = 84
dotsize = 135
periodsize = 160
smooth = 200

[w-semibold]
weight = 600
style = 'Semibold'

[w-600]
sb = 54
stroke = 92
dotsize = 140
periodsize = 165
stroke = 97
dotsize = 145
periodsize = 168
essx = 1.07

rbalance = 55
rbalance2 = 20
smooth = 203

[w-bold]
isBold = true
weight = 700
style = 'Bold'

[w-700]
sb = 50
stroke = 102
dotsize = 152
periodsize = 176
stroke = 106
dotsize = 157
periodsize = 180
essx = 1.06
essxq = 1.10
jut = 87
vjut = 155
jut = 89
vjut = 158

barpos = 0.51
fivebarpos = 0.64
Expand All @@ -178,32 +155,24 @@ rbalance2 = 23
rhook = 95
smooth = 206

[w-extrabold]
isBold = true
weight = 800
style = 'Extrabold'

[w-800]
sb = 45
stroke = 112
dotsize = 164
periodsize = 184
stroke = 116
dotsize = 167
periodsize = 188
essx = 1.05
essxq = 1.15
jut = 94
vjut = 170
jut = 96
vjut = 172

barpos = 0.51
fivebarpos = 0.64
rbalance = 50
rbalance2 = 25
rhook = 97
smooth = 212

[w-heavy]
isBold = true
weight = 900
style = 'Heavy'
smooth = 210

[w-900]
sb = 42
stroke = 126
dotsize = 180
Expand All @@ -221,27 +190,16 @@ rhook = 105
smooth = 215

### Slantness
[s-upright]
isItalic = false

[s-italic]
isItalic = true
slantAngle = 10
jhook = 120

[s-italic.adds]
style = " Italic"

[s-oblique]
isOblique = true
isItalic = false
slantAngle = 10
jhook = 120

[s-oblique.adds]
style = " Oblique"


### Slab variant
[slab]
slab = true
Expand Down

0 comments on commit b4ba453

Please sign in to comment.