Add weight 'Book'. Fixes #424.
This commit is contained in:
parent
1765923f8d
commit
296afad705
4 changed files with 194 additions and 183 deletions
|
@ -535,6 +535,11 @@ shape = 400
|
|||
menu = 400
|
||||
css = 400
|
||||
|
||||
[weights.book]
|
||||
shape = 450
|
||||
menu = 450
|
||||
css = 450
|
||||
|
||||
[weights.medium]
|
||||
shape = 500
|
||||
menu = 500
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
* Fix “Lucida” style's `one` character
|
||||
* Fix “Lucida” style's `one` character.
|
||||
* Added weight “Book”.
|
362
meta/naming.ptl
362
meta/naming.ptl
|
@ -1,180 +1,182 @@
|
|||
define COPYRIGHT 0
|
||||
define FAMILY 1
|
||||
define STYLE 2
|
||||
define UNIQUE_NAME 3
|
||||
define FULL_NAME 4
|
||||
define VERSION 5
|
||||
define POSTSCRIPT 6
|
||||
define TRADEMARK 7
|
||||
define MANUFACTURER 8
|
||||
define DESIGNER 9
|
||||
define DESCRIPTION 10
|
||||
define LICENCE 13
|
||||
define PREFERRED_FAMILY 16
|
||||
define PREFERRED_STYLE 17
|
||||
define WWS_PREFERRED_FAMILY 21
|
||||
define WWS_PREFERRED_STYLE 22
|
||||
|
||||
define [nameFont font nameid str] : begin
|
||||
font.name.push : object # Mac Roman
|
||||
platformID 1
|
||||
encodingID 0
|
||||
languageID 0
|
||||
nameID nameid
|
||||
nameString str
|
||||
font.name.push : object # Windows Unicode English
|
||||
platformID 3
|
||||
encodingID 1
|
||||
languageID 1033
|
||||
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 widthToMenuStyleMap : object
|
||||
1 "Ultra-condensed"
|
||||
2 "Extra-condensed"
|
||||
3 "Condensed"
|
||||
4 "Semi-condensed"
|
||||
5 ""
|
||||
6 "Semi-extended"
|
||||
7 "Extended"
|
||||
8 "Extra-extended"
|
||||
9 "Ultra-extended"
|
||||
define slantToMenuStyleMap : object
|
||||
normal ""
|
||||
italic "Italic"
|
||||
oblique "Oblique"
|
||||
|
||||
define weightToMenuStyleMapShort : object
|
||||
100 "Th"
|
||||
200 "XLt"
|
||||
300 "Lt"
|
||||
400 ""
|
||||
500 "Md"
|
||||
600 "SmBd"
|
||||
700 "Bd"
|
||||
800 "XBd"
|
||||
900 "Xv"
|
||||
define widthToMenuStyleMapShort : object
|
||||
1 "UltCn"
|
||||
2 "XCn"
|
||||
3 "Cn"
|
||||
4 "SmCn"
|
||||
5 ""
|
||||
6 "SmEx"
|
||||
7 "Ex"
|
||||
8 "XEx"
|
||||
9 "UltEx"
|
||||
define slantToMenuStyleMapShort : object
|
||||
normal ""
|
||||
italic "It"
|
||||
oblique "Obl"
|
||||
|
||||
define [getStyle weight width slant] : [[(weightToMenuStyleMap.(weight) + " " + widthToMenuStyleMap.(width) + " " + slantToMenuStyleMap.(slant)).replace [regex ' +' 'g'] ' '].trim] || "Regular"
|
||||
|
||||
define [getShortStyle weight width slant] : [(weightToMenuStyleMapShort.(weight) + " " + widthToMenuStyleMapShort.(width) + " " + slantToMenuStyleMapShort.(slant)).replace [regex ' ' 'g'] ''] || "Regular"
|
||||
|
||||
define [isRBIBI weight slant] : (weight == 400 || weight == 700) && (slant == "normal" || slant == "italic")
|
||||
|
||||
define [getStyleLinkedStyles weight width slant] : begin
|
||||
local linkWeight weight
|
||||
local linkSlant slant
|
||||
local nameSuffixWeight 400
|
||||
local nameSuffixWidth width
|
||||
local nameSuffixSlant "normal"
|
||||
|
||||
# Not regular or bold
|
||||
if (linkWeight != 400 && linkWeight != 700) : begin
|
||||
nameSuffixWeight = linkWeight
|
||||
linkWeight = 400
|
||||
|
||||
# Not "normal" or italic
|
||||
if (linkSlant != "normal" && linkSlant != "italic") : begin
|
||||
nameSuffixSlant = linkSlant
|
||||
linkSlant = "normal"
|
||||
|
||||
return : list
|
||||
getStyle linkWeight 5 linkSlant
|
||||
getStyle nameSuffixWeight nameSuffixWidth nameSuffixSlant
|
||||
getShortStyle nameSuffixWeight nameSuffixWidth nameSuffixSlant
|
||||
|
||||
|
||||
|
||||
export : define [assignFontNames para metrics font] : begin
|
||||
set font.name {}
|
||||
|
||||
define family : para.naming.family.trim
|
||||
define style : getStyle para.naming.weight para.naming.width 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 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 family
|
||||
set font.name.preferredSubFamily style
|
||||
|
||||
local {compatStyle compatFamilySuffix shortCompatFamilySuffix} : getStyleLinkedStyles para.naming.weight para.naming.width para.naming.slant
|
||||
local compatFamily family
|
||||
if (compatFamilySuffix != "Regular") : set compatFamily : family + ' ' + compatFamilySuffix
|
||||
if (compatFamily.length >= 31) : set compatFamily : family + ' ' + shortCompatFamilySuffix
|
||||
|
||||
nameFont font FAMILY compatFamily # Family
|
||||
nameFont font STYLE compatStyle # Style
|
||||
|
||||
nameFont font UNIQUE_NAME "\(family) \(style) \(version)" # Unique Name
|
||||
|
||||
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 version # Version
|
||||
|
||||
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
|
||||
|
||||
set font.name : font.name.sort : lambda [a b] : begin
|
||||
if (a.platformID != b.platformID) : return : a.platformID - b.platformID
|
||||
if (a.encodingID != b.encodingID) : return : a.encodingID - b.encodingID
|
||||
if (a.languageID != b.languageID) : return : a.languageID - b.languageID
|
||||
return : a.nameID - b.nameID
|
||||
|
||||
# Weight, width and slantness
|
||||
set font.OS_2.usWeightClass para.naming.weight
|
||||
set font.OS_2.usWidthClass para.naming.width
|
||||
set font.OS_2.panose.2 : 1 + para.naming.weight / 100
|
||||
set font.OS_2.fsSelection : object
|
||||
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.OS_2.xAvgCharWidth para.width
|
||||
set font.head.macStyle : object
|
||||
bold : not : not isBold
|
||||
italic : not : not (isItalic || isOblique)
|
||||
|
||||
if (para.diversityM == 1 && para.diversityF == 1 && para.diversityI == 1 && para.diversityII == 1) : begin
|
||||
set font.OS_2.panose.3 9 # Monospaced
|
||||
set font.post.isFixedPitch true
|
||||
: else : begin
|
||||
set font.OS_2.panose.3 0
|
||||
set font.post.isFixedPitch false
|
||||
define COPYRIGHT 0
|
||||
define FAMILY 1
|
||||
define STYLE 2
|
||||
define UNIQUE_NAME 3
|
||||
define FULL_NAME 4
|
||||
define VERSION 5
|
||||
define POSTSCRIPT 6
|
||||
define TRADEMARK 7
|
||||
define MANUFACTURER 8
|
||||
define DESIGNER 9
|
||||
define DESCRIPTION 10
|
||||
define LICENCE 13
|
||||
define PREFERRED_FAMILY 16
|
||||
define PREFERRED_STYLE 17
|
||||
define WWS_PREFERRED_FAMILY 21
|
||||
define WWS_PREFERRED_STYLE 22
|
||||
|
||||
define [nameFont font nameid str] : begin
|
||||
font.name.push : object # Mac Roman
|
||||
platformID 1
|
||||
encodingID 0
|
||||
languageID 0
|
||||
nameID nameid
|
||||
nameString str
|
||||
font.name.push : object # Windows Unicode English
|
||||
platformID 3
|
||||
encodingID 1
|
||||
languageID 1033
|
||||
nameID nameid
|
||||
nameString str
|
||||
|
||||
define weightToMenuStyleMap : object
|
||||
100 "Thin"
|
||||
200 "Extralight"
|
||||
300 "Light"
|
||||
400 ""
|
||||
450 "Book"
|
||||
500 "Medium"
|
||||
600 "Semibold"
|
||||
700 "Bold"
|
||||
800 "Extrabold"
|
||||
900 "Heavy"
|
||||
define widthToMenuStyleMap : object
|
||||
1 "Ultra-condensed"
|
||||
2 "Extra-condensed"
|
||||
3 "Condensed"
|
||||
4 "Semi-condensed"
|
||||
5 ""
|
||||
6 "Semi-extended"
|
||||
7 "Extended"
|
||||
8 "Extra-extended"
|
||||
9 "Ultra-extended"
|
||||
define slantToMenuStyleMap : object
|
||||
normal ""
|
||||
italic "Italic"
|
||||
oblique "Oblique"
|
||||
|
||||
define weightToMenuStyleMapShort : object
|
||||
100 "Th"
|
||||
200 "XLt"
|
||||
300 "Lt"
|
||||
400 ""
|
||||
450 "Bk"
|
||||
500 "Md"
|
||||
600 "SmBd"
|
||||
700 "Bd"
|
||||
800 "XBd"
|
||||
900 "Xv"
|
||||
define widthToMenuStyleMapShort : object
|
||||
1 "UltCn"
|
||||
2 "XCn"
|
||||
3 "Cn"
|
||||
4 "SmCn"
|
||||
5 ""
|
||||
6 "SmEx"
|
||||
7 "Ex"
|
||||
8 "XEx"
|
||||
9 "UltEx"
|
||||
define slantToMenuStyleMapShort : object
|
||||
normal ""
|
||||
italic "It"
|
||||
oblique "Obl"
|
||||
|
||||
define [getStyle weight width slant] : [[(weightToMenuStyleMap.(weight) + " " + widthToMenuStyleMap.(width) + " " + slantToMenuStyleMap.(slant)).replace [regex ' +' 'g'] ' '].trim] || "Regular"
|
||||
|
||||
define [getShortStyle weight width slant] : [(weightToMenuStyleMapShort.(weight) + " " + widthToMenuStyleMapShort.(width) + " " + slantToMenuStyleMapShort.(slant)).replace [regex ' ' 'g'] ''] || "Regular"
|
||||
|
||||
define [isRBIBI weight slant] : (weight == 400 || weight == 700) && (slant == "normal" || slant == "italic")
|
||||
|
||||
define [getStyleLinkedStyles weight width slant] : begin
|
||||
local linkWeight weight
|
||||
local linkSlant slant
|
||||
local nameSuffixWeight 400
|
||||
local nameSuffixWidth width
|
||||
local nameSuffixSlant "normal"
|
||||
|
||||
# Not regular or bold
|
||||
if (linkWeight != 400 && linkWeight != 700) : begin
|
||||
nameSuffixWeight = linkWeight
|
||||
linkWeight = 400
|
||||
|
||||
# Not "normal" or italic
|
||||
if (linkSlant != "normal" && linkSlant != "italic") : begin
|
||||
nameSuffixSlant = linkSlant
|
||||
linkSlant = "normal"
|
||||
|
||||
return : list
|
||||
getStyle linkWeight 5 linkSlant
|
||||
getStyle nameSuffixWeight nameSuffixWidth nameSuffixSlant
|
||||
getShortStyle nameSuffixWeight nameSuffixWidth nameSuffixSlant
|
||||
|
||||
|
||||
|
||||
export : define [assignFontNames para metrics font] : begin
|
||||
set font.name {}
|
||||
|
||||
define family : para.naming.family.trim
|
||||
define style : getStyle para.naming.weight para.naming.width 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 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 family
|
||||
set font.name.preferredSubFamily style
|
||||
|
||||
local {compatStyle compatFamilySuffix shortCompatFamilySuffix} : getStyleLinkedStyles para.naming.weight para.naming.width para.naming.slant
|
||||
local compatFamily family
|
||||
if (compatFamilySuffix != "Regular") : set compatFamily : family + ' ' + compatFamilySuffix
|
||||
if (compatFamily.length >= 31) : set compatFamily : family + ' ' + shortCompatFamilySuffix
|
||||
|
||||
nameFont font FAMILY compatFamily # Family
|
||||
nameFont font STYLE compatStyle # Style
|
||||
|
||||
nameFont font UNIQUE_NAME "\(family) \(style) \(version)" # Unique Name
|
||||
|
||||
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 version # Version
|
||||
|
||||
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
|
||||
|
||||
set font.name : font.name.sort : lambda [a b] : begin
|
||||
if (a.platformID != b.platformID) : return : a.platformID - b.platformID
|
||||
if (a.encodingID != b.encodingID) : return : a.encodingID - b.encodingID
|
||||
if (a.languageID != b.languageID) : return : a.languageID - b.languageID
|
||||
return : a.nameID - b.nameID
|
||||
|
||||
# Weight, width and slantness
|
||||
set font.OS_2.usWeightClass para.naming.weight
|
||||
set font.OS_2.usWidthClass para.naming.width
|
||||
set font.OS_2.panose.2 : 1 + para.naming.weight / 100
|
||||
set font.OS_2.fsSelection : object
|
||||
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.OS_2.xAvgCharWidth para.width
|
||||
set font.head.macStyle : object
|
||||
bold : not : not isBold
|
||||
italic : not : not (isItalic || isOblique)
|
||||
|
||||
if (para.diversityM == 1 && para.diversityF == 1 && para.diversityI == 1 && para.diversityII == 1) : begin
|
||||
set font.OS_2.panose.3 9 # Monospaced
|
||||
set font.post.isFixedPitch true
|
||||
: else : begin
|
||||
set font.OS_2.panose.3 0
|
||||
set font.post.isFixedPitch false
|
||||
|
|
|
@ -137,8 +137,11 @@ function nValidate(key, v, f) {
|
|||
function vlShapeWeight(x) {
|
||||
return x >= 100 && x <= 900;
|
||||
}
|
||||
function vlCssWeight(x) {
|
||||
return x >= 0 && x <= 1000;
|
||||
}
|
||||
function vlMenuWeight(x) {
|
||||
return x >= 100 && x <= 900 && x % 100 === 0;
|
||||
return (x >= 100 && x <= 900 && x % 100 === 0) || x === 450;
|
||||
}
|
||||
function vlShapeWidth(x) {
|
||||
return x === 3 || x === 5 || x === 7;
|
||||
|
@ -157,7 +160,7 @@ function getSuffixSet(weights, slants, widths) {
|
|||
hives: [`shape-weight`, `s-${s}`, `wd-${widths[wd].shape}`],
|
||||
weight: w,
|
||||
shapeWeight: nValidate("Shape weight of " + w, weights[w].shape, vlShapeWeight),
|
||||
cssWeight: nValidate("CSS weight of " + w, weights[w].css),
|
||||
cssWeight: nValidate("CSS weight of " + w, weights[w].css, vlCssWeight),
|
||||
menuWeight: nValidate("Menu weight of " + w, weights[w].menu, vlMenuWeight),
|
||||
width: wd,
|
||||
shapeWidth: nValidate("Shape width of " + wd, widths[wd].shape, vlShapeWidth),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue