Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/hindkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
6 changes: 5 additions & 1 deletion lib/hindkit/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions lib/hindkit/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 = """
Expand Down
22 changes: 18 additions & 4 deletions lib/hindkit/objects/family.py
Original file line number Diff line number Diff line change
@@ -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__(
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions lib/hindkit/objects/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions lib/hindkit/objects/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/hindkit/objects/glyphdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 23 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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