[gentium-commits] [SCM] gentium updated: r42 - trunk/test/type1/Scripts/TestMissing

Pavel Far?? INVALID.NOREPLY at gnu.org.ua
Mon Mar 21 19:31:24 CET 2022


Author: pavel
Date: 2022-03-21 18:31:24 +0000 (Mon, 21 Mar 2022)
New Revision: 42

Modified:
   trunk/test/type1/Scripts/TestMissing/test_missing_chars.py
Log:
refactor test_missing_chars.py

Modified: trunk/test/type1/Scripts/TestMissing/test_missing_chars.py
===================================================================
--- trunk/test/type1/Scripts/TestMissing/test_missing_chars.py	2022-03-21 08:52:43 UTC (rev 41)
+++ trunk/test/type1/Scripts/TestMissing/test_missing_chars.py	2022-03-21 18:31:24 UTC (rev 42)
@@ -11,23 +11,24 @@
 # test_missing_chars.py GentiumPlus-R.afm GentiumPlus-R-extra.afm
 
 
-import os, sys, string
+import sys
 
-gentiumglyphs = set("")
-f = open(sys.argv[1], "r")
-for s in f:
-    if s.find("C ") == 0:
-        a = s.strip().split()
-        gentiumglyphs.add(a[7])
-f.close()
+converted_font_afm = sys.argv[1]
+extra_kerns_afm = sys.argv[2]
 
+# create set with the names of all the glyphs in the font
+gentium_font_glyphs = set("")
+with open(converted_font_afm) as afm_file:
+    for line in afm_file:
+        if line.startswith("C "):
+            glyph_name = line.strip().split()[7]  # name is at position 7
+            gentium_font_glyphs.add(glyph_name)
 
-fin = open(sys.argv[2], "r")
-for s in fin:
-    if s.find("Small") < 0:
-        [a, b, c, d] = s.split()
-        if b not in gentiumglyphs:
-    	    print(b, "missing")
-        if c not in gentiumglyphs:
-    	    print(c, "missing")
-fin.close()
+# write glyphs with names not in the font
+with open(extra_kerns_afm) as extra_kerns_file:
+    for line in extra_kerns_file:
+        _, first_glyph, second_glyph, _ = line.split()
+        if first_glyph not in gentium_font_glyphs:
+            print(first_glyph, "missing")
+        if second_glyph not in gentium_font_glyphs:
+            print(second_glyph, "missing")



More information about the gentium-commits mailing list.