From 6cd8f454c547ef24b9debb8a307ef4c8a5d96a5d Mon Sep 17 00:00:00 2001 From: Pratik Gajjar Date: Sun, 27 Oct 2019 20:46:23 +0530 Subject: [PATCH 1/9] Add py3.7 req file --- requirements.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ea5809a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,21 @@ +afdko==3.0.1 +appdirs==1.4.3 +booleanOperations==0.8.2 +Brotli==1.0.7 +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 +ufonormalizer==0.3.6 +ufoProcessor==1.0.6 +unicodedata2==12.1.0 +zopfli==0.1.6 From 925dffe194111f22cafe366f3851940405b66792 Mon Sep 17 00:00:00 2001 From: Pratik Gajjar Date: Mon, 28 Oct 2019 00:44:24 +0530 Subject: [PATCH 2/9] Use line limit --- lib/hindkit/constants.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) From 7c6c8177fae71e156fc540775fb222dc24447863 Mon Sep 17 00:00:00 2001 From: Pratik Gajjar Date: Mon, 28 Oct 2019 01:17:50 +0530 Subject: [PATCH 3/9] Update req.txt --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements.txt b/requirements.txt index ea5809a..45886db 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ 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 @@ -15,6 +16,7 @@ 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 From b8f57d65620d467b72277f4039dc1161463e8990 Mon Sep 17 00:00:00 2001 From: Pratik Gajjar Date: Mon, 28 Oct 2019 01:30:20 +0530 Subject: [PATCH 4/9] Add comments --- lib/hindkit/filters.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 = """ From 83c90a3a8b18f569b89ac645bab3d3204a9ebad9 Mon Sep 17 00:00:00 2001 From: Pratik Gajjar Date: Mon, 28 Oct 2019 01:36:57 +0530 Subject: [PATCH 5/9] Add comments in init --- lib/hindkit/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/hindkit/__init__.py b/lib/hindkit/__init__.py index e321744..674da39 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 From 749fbe82035b56620380460ee4d68d635ea84039 Mon Sep 17 00:00:00 2001 From: Pratik Gajjar Date: Mon, 28 Oct 2019 01:42:16 +0530 Subject: [PATCH 6/9] Refactor code --- lib/hindkit/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/hindkit/__init__.py b/lib/hindkit/__init__.py index 674da39..b813fc6 100644 --- a/lib/hindkit/__init__.py +++ b/lib/hindkit/__init__.py @@ -82,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 From af32898cf8156a89d55950f24e055b6f4944c1bf Mon Sep 17 00:00:00 2001 From: Pratik Gajjar Date: Mon, 28 Oct 2019 17:13:30 +0530 Subject: [PATCH 7/9] Python 3 paarent call syntax --- lib/hindkit/objects/family.py | 4 ++-- lib/hindkit/objects/feature.py | 4 ++-- lib/hindkit/objects/font.py | 8 ++++---- lib/hindkit/objects/glyphdata.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/hindkit/objects/family.py b/lib/hindkit/objects/family.py index d917922..1e916ef 100644 --- a/lib/hindkit/objects/family.py +++ b/lib/hindkit/objects/family.py @@ -110,7 +110,7 @@ def generate_styles(self): class DesignSpace(kit.BaseFile): def __init__(self, project, name="font"): - super(DesignSpace, self).__init__( + super().__init__( name, project = project, file_format = "DesignSpace", @@ -177,7 +177,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..6ae2480 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, 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, From 1b836593cdcc2f7b729cf222090b67f93ddc316a Mon Sep 17 00:00:00 2001 From: Pratik Gajjar Date: Tue, 29 Oct 2019 01:35:47 +0530 Subject: [PATCH 8/9] Fix ufo file doen't exist error --- lib/hindkit/objects/family.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/hindkit/objects/family.py b/lib/hindkit/objects/family.py index 1e916ef..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,6 +111,14 @@ 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): From 004298d039fc005377fa56a905b45220f23eec23 Mon Sep 17 00:00:00 2001 From: Pratik Gajjar Date: Tue, 29 Oct 2019 02:25:56 +0530 Subject: [PATCH 9/9] Fix function arg order --- lib/hindkit/objects/font.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hindkit/objects/font.py b/lib/hindkit/objects/font.py index 6ae2480..61dbfe8 100644 --- a/lib/hindkit/objects/font.py +++ b/lib/hindkit/objects/font.py @@ -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: