diff --git a/lib/hindkit/__init__.py b/lib/hindkit/__init__.py index e321744..b813fc6 100644 --- a/lib/hindkit/__init__.py +++ b/lib/hindkit/__init__.py @@ -10,6 +10,9 @@ def relative_to_cwd(path): return os.path.join(os.getcwd(), path) def memoize(obj): + """ + Decorator to add caching in function. + """ memoized = {} @functools.wraps(obj) def memoizer(*args, **kwargs): @@ -51,6 +54,10 @@ def copy(src, dst): shutil.copy(src, dst) def fallback(*candidates): + """ + :param candidates: + :return: First argument which is not None + """ for i in candidates: if i is not None: return i @@ -64,6 +71,9 @@ def remove_illegal_chars_for_postscript_name_part(name): ord(i): None for i in "[](){}<>/%\u0000\u0020\u0009\u000D\u000A\u000C-" }) +""" +To have a import functionality of library at single entry point +""" from hindkit import constants from hindkit import filters @@ -72,5 +82,7 @@ def remove_illegal_chars_for_postscript_name_part(name): from hindkit.objects.font import Master, Style, Product from hindkit.objects.glyphdata import GlyphData, Goadb from hindkit.objects.client import Client -from hindkit.objects.feature import FeatureClasses, FeatureTables, FeatureLanguagesystems, FeatureGSUB, FeatureGPOS, FeatureKern, FeatureMark, FeatureOS2Extension, FeatureNameExtension, FeatureMatches, FeatureReferences +from hindkit.objects.feature import (FeatureClasses, FeatureTables, FeatureLanguagesystems, FeatureGSUB, FeatureGPOS, + FeatureKern, FeatureMark, FeatureOS2Extension, FeatureNameExtension, + FeatureMatches, FeatureReferences) from hindkit.objects.project import Project diff --git a/lib/hindkit/constants.py b/lib/hindkit/constants.py index 71cd295..49acbb9 100644 --- a/lib/hindkit/constants.py +++ b/lib/hindkit/constants.py @@ -246,7 +246,11 @@ def get_adobe_latin(number, get_combined=False): adobe_latin[production_name] = u_scalar return adobe_latin -ITF_GENERAL = "exclam quotedbl numbersign dollar percent ampersand quotesingle parenleft parenright asterisk plus comma hyphen period slash zero one two three four five six seven eight nine colon semicolon less equal greater question at bracketleft backslash bracketright asciicircum underscore grave braceleft bar braceright asciitilde cent sterling yen copyright guillemotleft registered degree periodcentered guillemotright endash emdash quoteleft quoteright quotedblleft quotedblright dagger daggerdbl bullet ellipsis guilsinglleft guilsinglright Euro trademark".split() +ITF_GENERAL = """exclam quotedbl numbersign dollar percent ampersand quotesingle parenleft parenright asterisk plus +comma hyphen period slash zero one two three four five six seven eight nine colon semicolon less equal greater +question at bracketleft backslash bracketright asciicircum underscore grave braceleft bar braceright asciitilde cent +sterling yen copyright guillemotleft registered degree periodcentered guillemotright endash emdash quoteleft quoteright +quotedblleft quotedblright dagger daggerdbl bullet ellipsis guilsinglleft guilsinglright Euro trademark""".split() ITF_GENERAL_DEVELOPMENT = [ {"guillemotleft": "guillemetleft", "guillemotright": "guillemetright"}.get(i, i) diff --git a/lib/hindkit/filters.py b/lib/hindkit/filters.py index 5f6f7b4..49003fe 100644 --- a/lib/hindkit/filters.py +++ b/lib/hindkit/filters.py @@ -2,6 +2,11 @@ import hindkit as kit def marks(family, glyph): + """ + :param family: + :param glyph: + :return: True when glyph has at least one anchor + """ has_mark_anchor = False for anchor in glyph.anchors: if anchor.name: @@ -30,9 +35,19 @@ def get_end(family, glyph): return end def bases_alive(family, glyph): + """ + :param family: + :param glyph: + :return: True if full character + """ return get_end(family, glyph) in kit.FeatureMatches.CONSONANTS_ALIVE def bases_dead(family, glyph): + """ + :param family: + :param glyph: + :return: True if half character + """ return get_end(family, glyph) in kit.FeatureMatches.CONSONANTS_DEAD POTENTIAL_BASES_FOR_LONG_mII = """ diff --git a/lib/hindkit/objects/family.py b/lib/hindkit/objects/family.py index d917922..3567e62 100644 --- a/lib/hindkit/objects/family.py +++ b/lib/hindkit/objects/family.py @@ -1,7 +1,13 @@ -import os, subprocess -import defcon, mutatorMath.ufo.document +import os +import shutil +import subprocess + +import defcon +import mutatorMath.ufo.document + import hindkit as kit + class Family(object): def __init__( @@ -105,12 +111,20 @@ def generate_styles(self): "-c", "-n", ]) + self.move_instances_ufo_to_intermediate_style() + + def move_instances_ufo_to_intermediate_style(self): + for style in self.styles: + shutil.copytree( + os.path.join('intermediates', 'instances', f'{style.full_name_postscript}.{style.extension}'), + os.path.join('intermediates', 'styles', f'{style.name}', f'font.{style.extension}') + ) class DesignSpace(kit.BaseFile): def __init__(self, project, name="font"): - super(DesignSpace, self).__init__( + super().__init__( name, project = project, file_format = "DesignSpace", @@ -177,7 +191,7 @@ class Fmndb(kit.BaseFile): ] def __init__(self, project, name="FontMenuNameDB"): - super(Fmndb, self).__init__(name, project=project) + super().__init__(name, project=project) self.lines = [] self.lines.extend(self.LINES_HEAD) diff --git a/lib/hindkit/objects/feature.py b/lib/hindkit/objects/feature.py index e99d873..ee3b117 100644 --- a/lib/hindkit/objects/feature.py +++ b/lib/hindkit/objects/feature.py @@ -11,7 +11,7 @@ def __init__(self, project, name=None, style=None): abstract_directory = style.abstract_directory else: abstract_directory = kit.Project.directories["features"] - super(BaseFeature, self).__init__( + super().__init__( name = kit.fallback(name, self._name), file_format = "FEA", project = project, @@ -386,7 +386,7 @@ def __init__(self, feature, mI_variant_name): POTENTIAL_abvm_ANCHOR_NAMES = ["abvm.e", "abvm"] def __init__(self, project, style=None): - super(FeatureMatches, self).__init__(project, style=style) + super().__init__(project, style=style) self._bases_alive = None self._bases_dead = None diff --git a/lib/hindkit/objects/font.py b/lib/hindkit/objects/font.py index daf7f4b..61dbfe8 100644 --- a/lib/hindkit/objects/font.py +++ b/lib/hindkit/objects/font.py @@ -26,7 +26,7 @@ def __init__( weight_and_width_class = (400, 5), ): - super(BaseFont, self).__init__( + super().__init__( name, file_format = file_format, abstract_directory = abstract_directory, @@ -359,7 +359,7 @@ class Master(BaseFont): def __init__(self, family, name, location=0): - super(Master, self).__init__( + super().__init__( family, name, abstract_directory = kit.Project.directories["masters"], @@ -396,7 +396,7 @@ def __init__( weight_and_width_class = (400, 5), ): - super(Style, self).__init__( + super().__init__( family, name, abstract_directory = os.path.join(kit.Project.directories["styles"], name), @@ -431,7 +431,7 @@ def __init__(self, project, style, file_format="OTF", subsidiary=False): self.weight_class = self.style.weight_class self.width_class = self.style.width_class - super(Product, self).__init__( + super().__init__( self.style.family, self.style.name, file_format = file_format, @@ -493,7 +493,7 @@ def generate(self): ) if options.doOverlapRemoval or options.doAutoHint: logger.info("Applying post-processing...") - updateInstance(options, instancePath) + updateInstance(instancePath, options) if not options.doOverlapRemoval: validateLayers(instancePath) if options.doOverlapRemoval or options.doAutoHint: diff --git a/lib/hindkit/objects/glyphdata.py b/lib/hindkit/objects/glyphdata.py index 3fb561f..d982267 100644 --- a/lib/hindkit/objects/glyphdata.py +++ b/lib/hindkit/objects/glyphdata.py @@ -76,7 +76,7 @@ def __init__( abstract_directory = product.style.abstract_directory else: abstract_directory = kit.Project.directories["sources"] - super(Goadb, self).__init__( + super().__init__( name, project = project, abstract_directory = abstract_directory, diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..45886db --- /dev/null +++ b/requirements.txt @@ -0,0 +1,23 @@ +afdko==3.0.1 +appdirs==1.4.3 +booleanOperations==0.8.2 +Brotli==1.0.7 +compreffor==0.4.6.post1 +cu2qu==1.6.5 +defcon==0.6.0 +fontMath==0.5.0 +fontParts==0.9.1 +fontPens==0.2.4 +fonttools==4.0.0 +fs==2.4.11 +lxml==4.4.1 +MutatorMath==2.1.2 +psautohint==2.0.0a1 +pyclipper==1.1.0.post1 +pytz==2019.3 +six==1.12.0 +ufo2ft==2.9.1 +ufonormalizer==0.3.6 +ufoProcessor==1.0.6 +unicodedata2==12.1.0 +zopfli==0.1.6