[gentium-commits] [SCM] gentium updated: r82 - trunk/gentium/source/fonts/gentium-tug/type1
Pavel Far??
INVALID.NOREPLY at gnu.org.ua
Mon Apr 4 16:53:33 CEST 2022
Author: pavel
Date: 2022-04-04 14:53:33 +0000 (Mon, 04 Apr 2022)
New Revision: 82
Modified:
trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py
Log:
start creating Cyrillic kerns using classes
Imitate using kerning classes. Started using classes for the
first (left) letter in the pair.
Modified: trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py
===================================================================
--- trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py 2022-04-04 14:45:43 UTC (rev 81)
+++ trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py 2022-04-04 14:53:33 UTC (rev 82)
@@ -30,6 +30,8 @@
# TODO: use variable for the small caps extension '.sc'
+# TODO: refactor the script; maybe remove classes
+
import os, sys, re
import collections
@@ -39,6 +41,10 @@
self.filename = filename
def getkerns(self, regex):
+ """ return lines with kerning, format of *.afm
+
+ TODO: Check that there is only one matching line.
+ """
a = []
f = open(self.filename, "r")
while True:
@@ -169,7 +175,7 @@
# 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
+ # first pair has Latin letters, the second pair has Cyrillic letters; probably not very obvious
kern_pairs_cyrillic = [
["A C", "А С"],
["A O", "А О"],
@@ -192,7 +198,20 @@
["x o", "х о"],
]
+ # similar Cyrillic letters that come first in the kerning pair
+ cyrillic_left_classes = {
+ "А": ["А"],
+ "Г": ["Г", "Ӷ"],
+ "О": ["О"],
+ "Р": ["Р", "Ҏ"],
+ "С": ["С", "Ҫ"],
+ "Т": ["Т", "Ҭ"],
+ "е": ["е", "ё"],
+ "о": ["о"],
+ "х": ["х", "ҳ", "ӽ"],
+ }
+
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
@@ -336,17 +355,23 @@
# 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):
+ """ make kerns from the base cyrillic kern and kern classes """
+ left_base_letter = cyrillic_kern[0]
+ right_base_letter = cyrillic_kern[-1]
+ return [left + " " + right_base_letter for left in self.cyrillic_left_classes[left_base_letter] ]
+
def cyrillic_kerns(self, fromreader):
for x in self.kern_pairs_cyrillic:
basekern = x[0]
- derivedkerns = x[1:]
- a = fromreader.getkerns("KPX " + basekern + " ")
+ derivedkerns = self.make_derived_kerns(x[1])
+ base_kern_line = fromreader.getkerns("KPX " + basekern + " ")
# skip the Cyrillic kerns if the corresponding Latin kern is not found
- if not a:
+ if not base_kern_line:
continue
- kernline = a[0]
+ kernline = base_kern_line[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)
More information about the gentium-commits
mailing list.