Skip to content

Commit

Permalink
Issue #333: STAT table needs Axis Value tables
Browse files Browse the repository at this point in the history
- [SG] Export stylespace [Tool] 1.0 [Init]: A tool for automatically generating .stylespace files from within FontLab using current font setup. The resulting .stylespace (plist) file is to be fed to statmake.exe tool in order to generate a valid STAT table.
- Generated Ver 1.0 of SG .stylespace to be modified further;
  • Loading branch information
kateliev committed Jul 16, 2024
1 parent 9255cbc commit 9498dd6
Show file tree
Hide file tree
Showing 2 changed files with 272 additions and 0 deletions.
211 changes: 211 additions & 0 deletions lib/ScienceGothic[YOPQ,slnt,wdth,wght].stylespace
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>axes</key>
<array>
<dict>
<key>locations</key>
<array>
<dict>
<key>name</key>
<string>MaximumContrast</string>
<key>value</key>
<real>18.0</real>
</dict>
<dict>
<key>name</key>
<string>HighContrast</string>
<key>value</key>
<real>44.0</real>
</dict>
<dict>
<key>name</key>
<string>MediumContrast</string>
<key>value</key>
<real>70.0</real>
</dict>
<dict>
<key>name</key>
<string>LowContrast</string>
<key>value</key>
<real>96.0</real>
</dict>
<dict>
<key>flags</key>
<array>
<string>ElidableAxisValueName</string>
</array>
<key>name</key>
<string>Regular</string>
<key>value</key>
<real>122.0</real>
</dict>
</array>
<key>name</key>
<string>y opaque</string>
<key>tag</key>
<string>YOPQ</string>
</dict>
<dict>
<key>locations</key>
<array>
<dict>
<key>name</key>
<string>Oblique</string>
<key>value</key>
<real>-10.0</real>
</dict>
<dict>
<key>name</key>
<string>SemiOblique</string>
<key>value</key>
<real>-4.0</real>
</dict>
<dict>
<key>flags</key>
<array>
<string>ElidableAxisValueName</string>
</array>
<key>name</key>
<string>Regular</string>
<key>value</key>
<real>0.0</real>
</dict>
</array>
<key>name</key>
<string>slant</string>
<key>tag</key>
<string>slnt</string>
</dict>
<dict>
<key>locations</key>
<array>
<dict>
<key>name</key>
<string>UltraCondensed</string>
<key>value</key>
<real>50.0</real>
</dict>
<dict>
<key>name</key>
<string>ExtraCondensed</string>
<key>value</key>
<real>125.0</real>
</dict>
<dict>
<key>name</key>
<string>Condensed</string>
<key>value</key>
<real>200.0</real>
</dict>
<dict>
<key>name</key>
<string>SemiCondensed</string>
<key>value</key>
<real>200.0</real>
</dict>
<dict>
<key>flags</key>
<array>
<string>ElidableAxisValueName</string>
</array>
<key>name</key>
<string>Regular</string>
<key>value</key>
<real>200.0</real>
</dict>
<dict>
<key>name</key>
<string>SemiExpanded</string>
<key>value</key>
<real>200.0</real>
</dict>
<dict>
<key>name</key>
<string>Expanded</string>
<key>value</key>
<real>200.0</real>
</dict>
<dict>
<key>name</key>
<string>ExtraExpanded</string>
<key>value</key>
<real>200.0</real>
</dict>
</array>
<key>name</key>
<string>width</string>
<key>tag</key>
<string>wdth</string>
</dict>
<dict>
<key>locations</key>
<array>
<dict>
<key>name</key>
<string>Thin</string>
<key>value</key>
<real>100.0</real>
</dict>
<dict>
<key>name</key>
<string>ExtraLight</string>
<key>value</key>
<real>116.0</real>
</dict>
<dict>
<key>name</key>
<string>Light</string>
<key>value</key>
<real>260.0</real>
</dict>
<dict>
<key>flags</key>
<array>
<string>ElidableAxisValueName</string>
</array>
<key>name</key>
<string>Regular</string>
<key>value</key>
<real>421.0</real>
</dict>
<dict>
<key>name</key>
<string>Medium</string>
<key>value</key>
<real>500.0</real>
</dict>
<dict>
<key>name</key>
<string>SemiBold</string>
<key>value</key>
<real>590.0</real>
</dict>
<dict>
<key>name</key>
<string>Bold</string>
<key>value</key>
<real>700.0</real>
</dict>
<dict>
<key>name</key>
<string>ExtraBold</string>
<key>value</key>
<real>840.0</real>
</dict>
<dict>
<key>name</key>
<string>Black</string>
<key>value</key>
<real>900.0</real>
</dict>
</array>
<key>name</key>
<string>weight</string>
<key>tag</key>
<string>wght</string>
</dict>
</array>
</dict>
</plist>
61 changes: 61 additions & 0 deletions scripts/FontLab/sg-toolbox/SG-Font-ExportStylespace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#FLM: Font: Export Stylespace
# NOTE: Export .stylespace file to be used
# NOTE: for STAT table definition using Statmake tool
# ----------------------------------------
# (C) Vassil Kateliev, 2024 (http://www.kateliev.com)
# (C) Karandash Type Foundry
#-----------------------------------------
# www.typerig.com


# No warranties. By using this you agree
# that you use it at your own risk!

# - Dependencies -----------------
import os
import plistlib

import fontlab as fl6
import fontgate as fgt

from PythonQt import QtCore, QtGui
from typerig.proxy.fl.objects.font import pFont

# - Fuctions ---------------------
def parse_location_str(location_string):
# - FL location string parse dictionary
equation_sign = '='
delimiter_sign = ','
default_start = '('
default_end = ')'

# - Process
location_list = [item.strip().replace(default_start,'').replace(default_end,'').split(equation_sign) + [default_start in item] for item in location_string.split(delimiter_sign)]
return location_list

def parse_axis(axis):
axis_data = {'name':axis.name, 'tag':axis.tag, 'locations':[]}
location_list_str = parse_location_str(axis.instances2string())

for name, value, default in location_list_str:
location_dict = {'name':name, 'value':axis.checkValue(float(value))}
if default: location_dict['flags'] = ['ElidableAxisValueName']
axis_data['locations'].append(location_dict)

return axis_data

# - Process --------------------------
app_version = '1.0'
app_name = '[SG] Export Stylespace'

font = pFont()
curr_path = os.path.split(font.fg.path)[0]
export_data = {'axes':[parse_axis(axis) for axis in font.fl.axes]}

export_file = QtGui.QFileDialog.getSaveFileName(None, '{} : {}'.format(app_name, app_version), str(curr_path), 'Property List (*.stylespace)')

if len(export_file):
with open(export_file, 'wb') as exportFile:
plistlib.dump(export_data, exportFile)

print('DONE:\tSaving stylespace: {}'.format(export_file))

0 comments on commit 9498dd6

Please sign in to comment.