Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert panoseDefault to namespace object #3201

Merged
merged 5 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 2 additions & 12 deletions Lib/fontTools/fontBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def drawTestGlyph(pen):
from .ttLib import TTFont, newTable
from .ttLib.tables._c_m_a_p import cmap_classes
from .ttLib.tables._g_l_y_f import flagCubic
from .ttLib.tables.O_S_2f_2 import Panose
from .misc.timeTools import timestampNow
import struct
from collections import OrderedDict
Expand Down Expand Up @@ -263,18 +264,7 @@ def drawTestGlyph(pen):
# to insert in setupNameTable doc string:
# print("\n".join(("%s (nameID %s)" % (k, v)) for k, v in sorted(_nameIDs.items(), key=lambda x: x[1])))

_panoseDefaults = dict(
bFamilyType=0,
bSerifStyle=0,
bWeight=0,
bProportion=0,
bContrast=0,
bStrokeVariation=0,
bArmStyle=0,
bLetterForm=0,
bMidline=0,
bXHeight=0,
)
_panoseDefaults = Panose()

_OS2Defaults = dict(
version=3,
Expand Down
8 changes: 8 additions & 0 deletions Lib/fontTools/ttLib/tables/O_S_2f_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@


class Panose(object):
def __init__(self, panoseDict=None):
formatstring, names, fixes = sstruct.getformat(panoseFormat)
for name in names:
if panoseDict is not None and name in panoseDict:
setattr(self, name, safeEval(panoseDict[name]))

Check warning on line 32 in Lib/fontTools/ttLib/tables/O_S_2f_2.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/ttLib/tables/O_S_2f_2.py#L32

Added line #L32 was not covered by tests
else:
setattr(self, name, 0)
NightFurySL2001 marked this conversation as resolved.
Show resolved Hide resolved

def toXML(self, writer, ttFont):
formatstring, names, fixes = sstruct.getformat(panoseFormat)
for name in names:
Expand Down