summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/fonts/ptsans/caroncorrection.py
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-01-29 17:27:38 +0000
committerKarl Berry <karl@freefriends.org>2011-01-29 17:27:38 +0000
commit5653f521de3c7bb4734e39cd3b84164bba23a39a (patch)
tree0130dcd3c463476046c00e8e370131486146d2e8 /Master/texmf-dist/doc/fonts/ptsans/caroncorrection.py
parent7d7ca96b28d4e8cdcda09c5ee2e74ac30a79d03a (diff)
new font package ptsans
git-svn-id: svn://tug.org/texlive/trunk@21222 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/fonts/ptsans/caroncorrection.py')
-rw-r--r--Master/texmf-dist/doc/fonts/ptsans/caroncorrection.py97
1 files changed, 97 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/fonts/ptsans/caroncorrection.py b/Master/texmf-dist/doc/fonts/ptsans/caroncorrection.py
new file mode 100644
index 00000000000..55fa11bb68f
--- /dev/null
+++ b/Master/texmf-dist/doc/fonts/ptsans/caroncorrection.py
@@ -0,0 +1,97 @@
+#! /usr/bin/env python
+
+
+## Copyright 2011 Pavel Farar
+#
+# This work may be distributed and/or modified under the conditions of the
+# LaTeX Project Public License, either version 1.3 of this license or (at
+# your option) any later version. The latest version of this license is in
+# http://www.latex-project.org/lppl.txt and version 1.3 or later is part of
+# all distributions of LaTeX version 2005/12/01 or later.
+
+
+# This script corrects the width of dcaron, tcaron, lcaron and Lcaron
+# (where needed) in files *.pl and *.vpl -- the width will be the same
+# as the width of the unaccented letter.
+
+# USAGE: The script is called without arguments and processes all *.pl and
+# *.vpl files in the current directory -- even those that do not contain
+# Latin alphabet. New files are generated (will be the same as the original
+# if no change was really needed) and the original files are renamed
+# by appending the suffix .old.
+
+# TODO: Change files only if necessary. Allow arguments for the script.
+# Some clean-up.
+
+
+
+import os
+
+
+class PropertyFile:
+
+ def init(self, name):
+ self.name = name
+ self.width_d = ""
+ self.width_t = ""
+ self.width_l = ""
+ self.width_L = ""
+
+ def parseWidth(self, s):
+ assert s.find(" (CHARWD R ") == 0 # the string should contain the width
+ s = s.replace(" (CHARWD R ","")
+ s = s[0:-2] # remove the last character
+ return s # return string -- different for *.pl and *.vpl
+
+ def getWidths(self):
+ fin = open(self.name, "r")
+ while True:
+ s = fin.readline()
+ if s == "": break # end of file
+ if s.find("CHARACTER C d") == 1:
+ s = fin.readline()
+ self.width_d = self.parseWidth(s)
+ if s.find("CHARACTER C t") == 1:
+ s = fin.readline()
+ self.width_t = self.parseWidth(s)
+ if s.find("CHARACTER C l") == 1:
+ s = fin.readline()
+ self.width_l = self.parseWidth(s)
+ if s.find("CHARACTER C L") == 1:
+ s = fin.readline()
+ self.width_L = self.parseWidth(s)
+ fin.close()
+
+ def writeCorrectedFile(self):
+ tempName = "TeMpFiLe.pl"
+ fin = open(self.name, "r")
+ fout = open(tempName, "w")
+ while True:
+ s = fin.readline()
+ if s == "": break # end of file
+ fout.write(s) # should be here
+ if s.find("CHARACTER") == 1:
+ if s.find("dcaron") > 0:
+ s = fin.readline()
+ fout.write(" (CHARWD R " + self.width_d + ")\n")
+ if s.find("tcaron") > 0:
+ s = fin.readline()
+ fout.write(" (CHARWD R " + self.width_t + ")\n")
+ if s.find("lcaron") > 0:
+ s = fin.readline()
+ fout.write(" (CHARWD R " + self.width_l + ")\n")
+ if s.find("Lcaron") > 0:
+ s = fin.readline()
+ fout.write(" (CHARWD R " + self.width_L + ")\n")
+ fout.close()
+ fin.close()
+ os.rename(self.name, self.name + ".old")
+ os.rename(tempName, self.name)
+
+
+f = PropertyFile()
+for fname in os.listdir("."):
+ if fname.endswith(".pl") or fname.endswith(".vpl"):
+ f.init(fname)
+ f.getWidths()
+ f.writeCorrectedFile()