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

Split kerning by script, not by direction (second attempt) #667

Closed
wants to merge 107 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
8315c29
Split kerning by script, not by direction (#636)
simoncozens Jul 21, 2022
c049bc6
Annotate KerningPair
madig Jul 22, 2022
f3db45f
Some set syntax simplification
madig Jul 22, 2022
0d65864
Revert "Rewind test case"
madig Oct 11, 2022
d782045
Add some typing
madig Aug 9, 2022
7ac9db8
Use Hashable instead
madig Aug 9, 2022
54257e8
Stop using Hashable actually
madig Aug 9, 2022
481c702
Add commentary about lookup sorting
madig Oct 18, 2022
85f4915
Add typing for KerningPair.getKerningPairs
madig Oct 18, 2022
8400082
Remove leftover typing comment
madig Oct 18, 2022
f4409a0
Add missing return type
madig Oct 18, 2022
b96addb
Derive scripts from glyphs, not languagesystems
madig Oct 18, 2022
300c862
WIP: Split kerning at source
madig Oct 19, 2022
875cf24
Add cleared-out test sources with permission from @yanone
madig Oct 21, 2022
664c07d
Use imported sources
madig Oct 21, 2022
e308b13
Simplify pair splitting logic
madig Oct 21, 2022
322dc04
WIP: some test
madig Oct 21, 2022
9b7d6a3
Add sanity checking
madig Oct 22, 2022
af51288
Remove unused import
madig Oct 22, 2022
8e7875e
Preserve KerningPair type when splitting
madig Oct 22, 2022
d25e20c
WIP: rewrite some code for clarity
madig Oct 22, 2022
e994eb6
Refactor: move script inference into setContext
madig Oct 22, 2022
82a69b0
WIP: add some todos and tiny refactor
madig Oct 23, 2022
8a6a128
Merge some methods into _makeSplitScriptKernLookups
madig Oct 23, 2022
041b7a4
Add typing to _makeSplitScriptKernLookups
madig Oct 23, 2022
bf8568a
glyphScripts should be immutable
madig Oct 23, 2022
0378139
Add more typing
madig Oct 23, 2022
c3e0f0c
More WIP experimentation
madig Oct 23, 2022
90682e8
More WIPing
madig Oct 23, 2022
c005ab4
Add to docstring of BaseFeatureWriter.write
madig Oct 24, 2022
6b66162
Add TODO
madig Oct 24, 2022
ef24b3b
Keep RTL logic in one place
madig Oct 24, 2022
5bbf9a9
Post-process split kerning pairs
madig Oct 24, 2022
987e9f2
WIP: insert newly generated class names
madig Oct 24, 2022
c1dfc61
WIP: prune Zyyy membership if also member of soimething else
madig Oct 24, 2022
e110c5e
Amend comment
madig Oct 25, 2022
b22c06f
implement __eq__ for KerningPair
madig Oct 25, 2022
797d1f3
Simplify kern splitting and avoid emitting mixed common script pairs
madig Oct 25, 2022
2694b9e
WIP: help
madig Oct 25, 2022
df103a9
Clarify exception
madig Oct 26, 2022
f2f7b74
Drop cleverness again for now
madig Oct 26, 2022
f372559
More refactoring plus more tests
madig Oct 26, 2022
b329fc8
Fill in test
madig Oct 28, 2022
a948fab
Treat common+other glyphs as common
simoncozens Nov 3, 2022
49880e4
Don't expect common/common to be emitted twice
simoncozens Nov 3, 2022
7e0eb95
Register lookups irregardless of global languagesystems
madig Nov 4, 2022
1b549ff
Clarify invariant
madig Nov 5, 2022
79a69e8
Update TTX dumps
madig Nov 7, 2022
bdf96f0
Split lookups into kern and dist
madig Nov 7, 2022
7a2e6be
Read ignoreMarks option in one place
madig Nov 7, 2022
0d53f62
Adapt tests to current code
madig Nov 7, 2022
6e08952
Catch feature compilation failures from feature writers
madig Nov 7, 2022
f6d414e
isort
madig Nov 7, 2022
5d88e0e
Fix lints
madig Nov 7, 2022
3a04b47
Simplify getKerningPairs
madig Nov 7, 2022
6c58cfb
Quantize kerning values early on
madig Nov 7, 2022
3f0c2e4
Actually sort in getKerningPairs
madig Nov 8, 2022
3a4f6cf
Fix unique pair filtering
madig Nov 8, 2022
846088f
Move _makePairPosRule into KerningPair
madig Nov 8, 2022
cef3a58
Remove KerningPair.directions attribute
madig Nov 8, 2022
d6d1e3d
Remove stale comments
madig Nov 8, 2022
7402945
Update comment
madig Nov 8, 2022
a566573
Drop groupby for disjointment
madig Nov 8, 2022
8e2ac01
Remove disjointment
madig Nov 8, 2022
991c799
Try harder to make KerningPairs always sort the same
madig Nov 8, 2022
0f5b027
Update docstring
madig Nov 8, 2022
ed362fa
Remove unused imports
madig Nov 8, 2022
1578114
Refactor ensure_no_duplicates into own function
madig Nov 8, 2022
9efc96b
Just use (first|second)Glyphs for order and eq testing
madig Nov 8, 2022
43a94be
Add comment
madig Nov 8, 2022
2781b23
Use ufo2ft.Error instead of generic Exception
madig Nov 9, 2022
827e374
Stop writing out classDefs
madig Nov 9, 2022
f88609f
Sort imports
madig Nov 9, 2022
35b3e21
Refactor out make_split_script_kern_lookups
madig Nov 9, 2022
6fb8bf6
Move interesting tests over
madig Nov 9, 2022
6599afe
Repurpose test
madig Nov 9, 2022
d2f9eb3
Turn into integration test
madig Nov 9, 2022
51e5f43
Consolidate new tests and make integration tests
madig Nov 10, 2022
51b5735
Minor line move because it looks better
madig Nov 10, 2022
8914b08
Add comment
madig Nov 11, 2022
7471f8c
Simplify _registerLookups
madig Nov 11, 2022
7d0ec88
Remove redundant context variable
madig Nov 11, 2022
a8adf6c
Mark _splitBaseAndMarkPairs a static method
madig Nov 11, 2022
7d13cb6
Translate test into integration test
madig Nov 11, 2022
a1b7aa7
Remove unused import
madig Nov 11, 2022
eee7a76
Mark _splitBaseAndMarkPairs a static method
madig Nov 11, 2022
bbf002d
Write scripts and bidiTypes nito pairs up front
madig Nov 11, 2022
88ff076
Turn test into integration tests
madig Nov 11, 2022
20419a8
Remove now unused imports
madig Nov 11, 2022
38c3303
Remove redudant "or"
madig Nov 11, 2022
4015ba0
WIP: try to simplify kerningpair
madig Nov 11, 2022
0962d45
More WIP
madig Nov 11, 2022
f483564
WIP: add test for bidis
madig Nov 11, 2022
9661866
WIP: add assert
madig Nov 11, 2022
3097ff5
Split and filter BiDi types correctly
madig Nov 11, 2022
a314b7d
Restore test to original
madig Nov 11, 2022
b854e77
Change logger messages
madig Nov 11, 2022
a0f7068
add comment
madig Nov 12, 2022
2ae3bad
WIP
madig Nov 12, 2022
6ac95c8
Simplify KerningPair by using tuples
madig Nov 14, 2022
9ef27cd
Avoid sorting because we already did
madig Nov 14, 2022
f2826b0
Move splitting and PairPos making into standalone functions
madig Nov 14, 2022
4459404
Make KerningPair a dataclass
madig Nov 14, 2022
e44b0f3
Remove stale comment
madig Nov 14, 2022
3a1752d
Remove bidiTypes from KerningPair
madig Nov 14, 2022
2575bc6
Remove scripts from KerningPair
madig Nov 14, 2022
d07125e
Remove redundant set
madig Nov 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 2 additions & 0 deletions Lib/ufo2ft/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

UNICODE_VARIATION_SEQUENCES_KEY = "public.unicodeVariationSequences"

COMMON_SCRIPT = "Zyyy"

INDIC_SCRIPTS = [
"Beng", # Bengali
"Cham", # Cham
Expand Down
23 changes: 15 additions & 8 deletions Lib/ufo2ft/featureCompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,14 @@ def setupFeatures(self):
if self.featureWriters:
featureFile = parseLayoutFeatures(self.ufo, self.feaIncludeDir)

path = self.ufo.path
for writer in self.featureWriters:
writer.write(self.ufo, featureFile, compiler=self)
try:
writer.write(self.ufo, featureFile, compiler=self)
except FeatureLibError:
if path is None:
self._write_temporary_feature_file(featureFile.asFea())
raise

# stringify AST to get correct line numbers in error messages
self.features = featureFile.asFea()
Expand Down Expand Up @@ -316,15 +322,16 @@ def buildTables(self):
addOpenTypeFeaturesFromString(self.ttFont, self.features, filename=path)
except FeatureLibError:
if path is None:
# if compilation fails, create temporary file for inspection
data = self.features.encode("utf-8")
with NamedTemporaryFile(delete=False) as tmp:
tmp.write(data)
logger.error(
"Compilation failed! Inspect temporary file: %r", tmp.name
)
self._write_temporary_feature_file(self.features)
raise

def _write_temporary_feature_file(self, features: str) -> None:
# if compilation fails, create temporary file for inspection
data = features.encode("utf-8")
with NamedTemporaryFile(delete=False) as tmp:
tmp.write(data)
logger.error("Compilation failed! Inspect temporary file: %r", tmp.name)


class MtiFeatureCompiler(BaseFeatureCompiler):
"""Compile OpenType layout tables from MTI feature files using
Expand Down
8 changes: 6 additions & 2 deletions Lib/ufo2ft/featureWriters/baseFeatureWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ def shouldContinue(self):
def write(self, font, feaFile, compiler=None):
"""Write features and class definitions for this font to a feaLib
FeatureFile object.
Returns True if feature file was modified, False if no new features
were generated.

The main entry point for the FeatureCompiler to any of the
FeatureWriters.

Returns True if feature file was modified, False if no new features were
generated.
"""
self.setContext(font, feaFile, compiler=compiler)
try:
Expand Down
Loading