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

Pavel Far?? INVALID.NOREPLY at gnu.org.ua
Thu Mar 31 15:12:41 CEST 2022


Author: pavel
Date: 2022-03-31 13:12:40 +0000 (Thu, 31 Mar 2022)
New Revision: 71

Modified:
   trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py
Log:
start adding Cyrillic kerning pairs

I started the infrastructure for adding the extra kerning pairs for
Cyrillic letters. There is currently no ambition for complete kerning
for Cyrillic letters or many manual kerning pairs. I will start with
the low-hanging fruits. I will take the advantage of the similar Latin
and Cyrillic letters and I might look at the most problematic Cyrillic
pairs of letters.

There are no kerning pairs for Cyrillic letters in the original fonts.
Therefore, adding even just some kerning pairs should greatly improve
the fonts.


Modified: trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py
===================================================================
--- trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py	2022-03-29 19:21:08 UTC (rev 70)
+++ trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py	2022-03-31 13:12:40 UTC (rev 71)
@@ -100,6 +100,7 @@
         # problematic kern follows (the kern value of DV was positive in GentiumPlus Regular)
         ["D V", "Dcaron V", "Dcroat V"]
     ]
+
     kernpairsinitialcap = [
         ["V a", "V aacute", "V abreve", "V acircumflex", "V adieresis", "V ae", "V agrave", "V amacron", "V aogonek", "V aring", "V atilde"],
         ["V e", "V eacute", "V ecaron", "V ecircumflex", "V edieresis", "V edotaccent", "V egrave", "V emacron", "V eogonek"],
@@ -121,6 +122,7 @@
         ["W e", "W eacute", "W ecaron", "W ecircumflex", "W edieresis", "W edotaccent", "W egrave", "W emacron", "W eogonek"],
         ["W o", "W oacute", "W ocircumflex", "W odieresis", "W oe", "W ograve", "W ohungarumlaut", "W omacron", "W oslash", "W otilde"]
     ]
+
     kernpairssmall = [
         ["v e", "v eacute", "v ecaron", "v ecircumflex", "v edieresis", "v edotaccent", "v egrave", "v emacron", "v eogonek"],
         ["k e", "k eacute", "k ecaron", "k ecircumflex", "k edieresis", "k edotaccent", "k egrave", "k emacron", "k eogonek", "kcommaaccent e"],
@@ -145,6 +147,7 @@
         ["y a", "y aacute", "y abreve", "y acircumflex", "y adieresis", "y ae", "y agrave", "y amacron", "y aogonek", "y aring", "y atilde", "yacute a", "ydieresis a", "yacute aacute"],
         ["r d", "r dcaron", "r dcroat", "racute d", "rcaron d", "rcommaaccent d", "rcaron dcaron"]
     ]
+
     kernpairsquotes = [
         # this is far from complete
         # TODO: use this list also for accented small caps (using kernfactor)
@@ -157,6 +160,7 @@
         ["A quotedblright", "quotedblbase V", "quotedblbase W", "quotedblbase Y", "quotedblbase Yacute", "quotedblbase T", "quotedblbase Tcaron"],
         ["A quoteright", "quotesinglbase V", "quotesinglbase W", "quotesinglbase Y", "quotesinglbase Yacute", "quotesinglbase T", "quotesinglbase Tcaron"]
     ]
+
     rightpunctuationsmall = [
         ["r comma", "racute comma", "rcaron comma", "rcommaaccent comma"],
         ["y comma", "yacute comma", "ydieresis comma"],
@@ -165,6 +169,13 @@
         # nothing to be derived from "f quoteright" and "f quotedblright"
     ]
 
+    # first pair are Latin letters, the other pairs are Cyrillic letters; probably not very obvious
+    kernpairscyrillic = [
+        ["T A", "Т А", "Г А"],
+        ["A T", "А Т"],
+    ]
+
+
     def __init__(self, filename):
         self.filename = filename  # the name of the file with extra kerning pairs
         self.kern_lines = collections.Counter()  # contains lines with extra kerning pairs
@@ -282,6 +293,7 @@
             derivedkerns = x[1:]
             a = fromreader.getkerns("KPX " + basekern + " ")
             kernline = a[0]
+
             for b in derivedkerns:
                 newkernline = kernline.replace(basekern, b)
                 self.add_to_kern_lines(newkernline)
@@ -300,8 +312,27 @@
                 newkernline = kernline.replace(basekern, b)
                 self.add_to_kern_lines(newkernline)
 
+    def char_to_uni(self, c):
+        """ Convert character to 'uniXXXX' string """
+        return "uni{0:04x}".format(ord(c))
 
+    # TODO: Test the kernpairscyrillic array. First pair must be Latin letters,
+    #       all the remaining pairs must be Cyrillic letters.
 
+    def cyrillic_kerns(self, fromreader):
+        for x in self.kernpairscyrillic:
+            basekern = x[0]
+            derivedkerns = x[1:]
+            a = fromreader.getkerns("KPX " + basekern + " ")
+            kernline = a[0]
+            for b in derivedkerns:
+                first_char, second_char = b.split()
+                new_kern = self.char_to_uni(first_char) + ' ' + self.char_to_uni(second_char)
+                newkernline = kernline.replace(basekern, new_kern)
+                self.add_to_kern_lines(newkernline)
+
+
+
 kernfactor = 0.94  # width of small caps / width of capital letters; tested for
                    # letters A, L, T, V, W and Y, all had nearly the same ratio
 
@@ -323,4 +354,5 @@
 output_generator.accentedrightpunctuation(fin)
 output_generator.accentedleftpunctuation(fin)
 output_generator.czechquotes(fin)
+output_generator.cyrillic_kerns(fin)
 output_generator.write_kern_lines_to_file()



More information about the gentium-commits mailing list.