mirror of
https://github.com/be5invis/Iosevka.git
synced 2026-10-28 08:28:01 +00:00
118 lines
4.2 KiB
Plaintext
118 lines
4.2 KiB
Plaintext
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 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 {}
|
|
|
|
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 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
|
|
if (style == 'Regular' || style == 'Bold' || style == 'Italic' || style == "Bold Italic") : then
|
|
nameFont font FAMILY family # Family
|
|
nameFont font STYLE style # Style
|
|
: else
|
|
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 "\(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.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.diversityW == 1 && para.diversityM == 1 && para.diversityF == 1 && para.diversityI == 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 |