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

Pavel Far?? INVALID.NOREPLY at gnu.org.ua
Sat Apr 30 20:23:08 CEST 2022


Author: pavel
Date: 2022-04-30 18:23:08 +0000 (Sat, 30 Apr 2022)
New Revision: 100

Modified:
   trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py
Log:
refactor kerncorrection.py a little

Modified: trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py
===================================================================
--- trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py	2022-04-26 21:37:47 UTC (rev 99)
+++ trunk/gentium/source/fonts/gentium-tug/type1/kerncorrection.py	2022-04-30 18:23:08 UTC (rev 100)
@@ -75,7 +75,8 @@
 
 class KernReader:
     def __init__(self, filename):
-        self.filename = filename
+        with open(filename, "r") as afm_file:
+            self.kern_lines = [line for line in afm_file if line.startswith('KPX ')]
 
     def getkerns(self, regex):
         """ return lines with kerning, format of *.afm
@@ -82,16 +83,7 @@
 
         TODO: Check that there is only one matching line.
         """
-        a = []
-        f = open(self.filename, "r")
-        while True:
-            s = f.readline()
-            if s == "":
-                break  # end of file
-            if re.match(regex, s):
-                a.append(s)
-        f.close()
-        return a
+        return [line for line in self.kern_lines if re.match(regex, line)]
 
 
 class KernWriter:



More information about the gentium-commits mailing list.