Skip to content

Commit

Permalink
Revert "Annotate KerningPair"
Browse files Browse the repository at this point in the history
This reverts commit 0ce8c22.
  • Loading branch information
madig committed Oct 11, 2022
1 parent 09062f0 commit c8b1c87
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions Lib/ufo2ft/featureWriters/kernFeatureWriter.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
from types import SimpleNamespace
from typing import TYPE_CHECKING

from fontTools import unicodedata
from fontTools.feaLib import ast

from ufo2ft.constants import INDIC_SCRIPTS, USE_SCRIPTS
from ufo2ft.featureWriters import BaseFeatureWriter, ast
from ufo2ft.util import classifyGlyphs, quantize, unicodeScriptDirection

if TYPE_CHECKING:
from typing import Iterator, Literal

SIDE1_PREFIX = "public.kern1."
SIDE2_PREFIX = "public.kern2."

Expand All @@ -27,7 +22,7 @@
LTR_BIDI_TYPES = {"L", "AN", "EN"}


def unicodeBidiType(uv: int) -> Literal["R"] | Literal["L"] | None:
def unicodeBidiType(uv):
"""Return "R" for characters with RTL direction, or "L" for LTR (whether
'strong' or 'weak'), or None for neutral direction.
"""
Expand All @@ -37,7 +32,8 @@ def unicodeBidiType(uv: int) -> Literal["R"] | Literal["L"] | None:
return "R"
elif bidiType in LTR_BIDI_TYPES:
return "L"
return None
else:
return None


class KerningPair:
Expand All @@ -52,7 +48,6 @@ def __init__(self, side1, side2, value, directions=None, bidiTypes=None):
else:
raise AssertionError(side1)

self.side2: ast.GlyphName | ast.GlyphClassName | ast.GlyphClass
if isinstance(side2, str):
self.side2 = ast.GlyphName(side2)
elif isinstance(side2, ast.GlyphClassDefinition):
Expand Down Expand Up @@ -119,7 +114,7 @@ def setContext(self, font, feaFile, compiler=None):
ctx.gdefClasses = self.getGDEFGlyphClasses()
ctx.kerning = self.getKerningData(font, feaFile, self.getOrderedGlyphSet())

feaScripts = getScriptLanguageSystems(feaFile)
feaScripts = ast.getScriptLanguageSystems(feaFile)
ctx.scriptGroups = self._groupScriptsByTagAndDirection(feaScripts)

return ctx
Expand Down Expand Up @@ -203,10 +198,10 @@ def getKerningGroups(font, glyphSet=None):
@classmethod
def getKerningClasses(cls, font, feaFile=None, glyphSet=None):
side1Groups, side2Groups = cls.getKerningGroups(font, glyphSet)
side1Classes = makeGlyphClassDefinitions(
side1Classes = ast.makeGlyphClassDefinitions(
side1Groups, feaFile, stripPrefix="public."
)
side2Classes = makeGlyphClassDefinitions(
side2Classes = ast.makeGlyphClassDefinitions(
side2Groups, feaFile, stripPrefix="public."
)
return side1Classes, side2Classes
Expand Down

0 comments on commit c8b1c87

Please sign in to comment.