[gentium-commits] [SCM] gentium updated: r88 - trunk/gentium/source/fonts/gentium-tug/type1

Pavel Far?? INVALID.NOREPLY at gnu.org.ua
Wed Apr 6 19:47:41 CEST 2022


Author: pavel
Date: 2022-04-06 17:47:40 +0000 (Wed, 06 Apr 2022)
New Revision: 88

Modified:
   trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py
Log:
start using kerning classes for Latin letters

As a side effect it should clean up the code. It starts
with generating the same extra kerns as before.


Modified: trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py
===================================================================
--- trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py	2022-04-06 16:35:02 UTC (rev 87)
+++ trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py	2022-04-06 17:47:40 UTC (rev 88)
@@ -161,6 +161,7 @@
     ]
 
     kern_pairs_quotes = [
+        # TODO pairs that have collisions can be removed in "make_derived_latin_kerns" create list for it!
         # this is far from complete
         # TODO: use this list also for accented small caps (using SMALL_CAPS_CORRECTION)
         ["A quotedblright", "A quotedblleft", "Aacute quotedblleft", "Adieresis quotedblleft"],
@@ -174,13 +175,28 @@
     ]
 
     right_punctuation_small = [
-        ["r comma", "racute comma", "rcaron comma", "rcommaaccent comma"],
-        ["y comma", "yacute comma", "ydieresis comma"],
-        ["r period", "racute period", "rcaron period", "rcommaaccent period"],
-        ["y period", "yacute period", "ydieresis period"]
+        "r comma",
+        "y comma",
+        "r period",
+        "y period",
         # nothing to be derived from "f quoteright" and "f quotedblright"
     ]
 
+    # similar Latin letters that come first in the kerning pair
+    latin_left_classes = {
+        # sort lines before commit!
+        "r": ["r", "racute", "rcaron", "rcommaaccent"],
+        "y": ["y", "yacute", "ydieresis"],
+    }
+
+    # similar Latin letters that come second in the kerning pair
+    latin_right_classes = {
+        # sort lines before commit!
+        "comma": ["comma"],
+        "period": ["period"],
+    }
+
+
     # first pair has Latin letters, the second pair has Cyrillic letters; probably not very obvious
     # there is no kern for 'X O' in the fonts
     kern_pairs_cyrillic = [
@@ -356,10 +372,18 @@
                 self.add_to_kern_lines("KPX " + parts[1] + " " + parts[2].lower() + ".sc " +
                                  str(int(round(SMALL_CAPS_CORRECTION * float(parts[3])))) + '\n')
 
+    def make_derived_latin_kerns(self, latin_kern):
+        left_base_letter, right_base_letter = latin_kern.split()
+
+        derived_kerns =  [ left + " " + right
+                    for left in self.latin_left_classes[left_base_letter]
+                    for right in self.latin_right_classes[right_base_letter] ]
+
+        return derived_kerns[1:]  # remove the base kern that is already in the font
+
     def accented_right_punctuation(self, fromreader):
-        for x in self.right_punctuation_small:
-            basekern = x[0]
-            derivedkerns = x[1:]
+        for basekern in self.right_punctuation_small:
+            derivedkerns = self.make_derived_latin_kerns(basekern)
             a = fromreader.getkerns("KPX " + basekern + " ")
             kernline = a[0]
 
@@ -388,7 +412,7 @@
     # TODO: Test the kern_pairs_cyrillic array. First pair must be Latin letters,
     #       all the remaining pairs must be Cyrillic letters.
 
-    def make_derived_kerns(self, cyrillic_kern):
+    def make_derived_cyrillic_kerns(self, cyrillic_kern):
         """ make kerns from the base cyrillic kern and kern classes """
         left_base_letter = cyrillic_kern[0]
         right_base_letter = cyrillic_kern[-1]
@@ -400,7 +424,7 @@
     def cyrillic_kerns(self, fromreader):
         for x in self.kern_pairs_cyrillic:
             basekern = x[0]
-            derivedkerns = self.make_derived_kerns(x[1])
+            derivedkerns = self.make_derived_cyrillic_kerns(x[1])
             base_kern_line = fromreader.getkerns("KPX " + basekern + " ")
 
             # skip the Cyrillic kerns if the corresponding Latin kern is not found



More information about the gentium-commits mailing list.