summaryrefslogtreecommitdiff
path: root/fonts/gentium-tug/source
diff options
context:
space:
mode:
Diffstat (limited to 'fonts/gentium-tug/source')
-rw-r--r--fonts/gentium-tug/source/Makefile96
-rwxr-xr-xfonts/gentium-tug/source/generate-support-files.rb29
-rw-r--r--fonts/gentium-tug/source/gentium.rb153
-rwxr-xr-xfonts/gentium-tug/source/make-zip-4CTAN.sh11
-rw-r--r--fonts/gentium-tug/source/type1/GentiumBookPlus-Bold-Czech.kern17
-rw-r--r--fonts/gentium-tug/source/type1/GentiumBookPlus-BoldItalic-Czech.kern17
-rw-r--r--fonts/gentium-tug/source/type1/GentiumBookPlus-Italic-Czech.kern17
-rw-r--r--fonts/gentium-tug/source/type1/GentiumBookPlus-Regular-Czech.kern17
-rw-r--r--fonts/gentium-tug/source/type1/GentiumPlus-Bold-Czech.kern (renamed from fonts/gentium-tug/source/type1/GentiumPlus-I-Czech.kern)4
-rw-r--r--fonts/gentium-tug/source/type1/GentiumPlus-BoldItalic-Czech.kern17
-rw-r--r--fonts/gentium-tug/source/type1/GentiumPlus-Italic-Czech.kern17
-rw-r--r--fonts/gentium-tug/source/type1/GentiumPlus-Regular-Czech.kern (renamed from fonts/gentium-tug/source/type1/GentiumPlus-R-Czech.kern)0
-rw-r--r--fonts/gentium-tug/source/type1/Makefile4
-rw-r--r--fonts/gentium-tug/source/type1/README149
-rwxr-xr-xfonts/gentium-tug/source/type1/afmcreator.py20
-rwxr-xr-xfonts/gentium-tug/source/type1/ff-gentium.pe97
-rwxr-xr-xfonts/gentium-tug/source/type1/generate-extra-kerns.sh8
-rwxr-xr-xfonts/gentium-tug/source/type1/greekcorrection.py173
-rw-r--r--fonts/gentium-tug/source/type1/kern-test-greek.txt4
-rw-r--r--fonts/gentium-tug/source/type1/kern-word-list-caron.txt24
-rw-r--r--fonts/gentium-tug/source/type1/kern-word-list-cyrillic.txt51
-rwxr-xr-xfonts/gentium-tug/source/type1/kerncorrection.py493
22 files changed, 1130 insertions, 288 deletions
diff --git a/fonts/gentium-tug/source/Makefile b/fonts/gentium-tug/source/Makefile
index 5c081a6223..0f20d302d6 100644
--- a/fonts/gentium-tug/source/Makefile
+++ b/fonts/gentium-tug/source/Makefile
@@ -1,3 +1,4 @@
+# $Id: Makefile 147 2022-05-21 22:20:08Z karl $
# This file is part of the Gentium package for TeX.
# It is licensed under the Expat License, see doc//README for details.
#
@@ -8,40 +9,113 @@
fontdir = ../../../fonts
tfmdir = $(fontdir)/tfm/public/gentium-tug
+mapdir_pdftex = $(fontdir)/map/pdftex/gentium-tug
+mapdir_dvips = $(fontdir)/map/dvips/gentium-tug
+
default: try-ital
# the diff should show differences, hence exit nonzero.
try-reg: lgr-gentiumplus-regular.pl
afm2pl -p $(fontdir)/enc/dvips/gentium-tug/gentium-lgr.enc \
-l lig/gentium-lgr.lig \
- $(fontdir)/afm/public/gentium-tug/GentiumPlus-R.afm \
- && pltotf GentiumPlus-R \
- && tftopl GentiumPlus-R GentiumPlus-R \
- && ! diff -u lgr-gentiumplus-regular.pl GentiumPlus-R.pl
+ $(fontdir)/afm/public/gentium-tug/GentiumPlus-Regular.afm \
+ && pltotf GentiumPlus-Regular \
+ && tftopl GentiumPlus-Regular GentiumPlus-Regular \
+ && ! diff -u lgr-gentiumplus-regular.pl GentiumPlus-Regular.pl
#
# clearly this could all be factored out, but maybe we will never touch
# this stuff again, so ...
try-ital: lgr-gentiumplus-italic.pl
afm2pl -p $(fontdir)/enc/dvips/gentium-tug/gentium-lgr.enc \
-l lig/gentium-lgr.lig \
- $(fontdir)/afm/public/gentium-tug/GentiumPlus-I.afm \
- && pltotf GentiumPlus-I \
- && tftopl GentiumPlus-I GentiumPlus-I \
- && ! diff -u lgr-gentiumplus-italic.pl GentiumPlus-I.pl
+ $(fontdir)/afm/public/gentium-tug/GentiumPlus-Italic.afm \
+ && pltotf GentiumPlus-Italic \
+ && tftopl GentiumPlus-Italic GentiumPlus-Italic \
+ && ! diff -u lgr-gentiumplus-italic.pl GentiumPlus-Italic.pl
+# new fonts in version 6.101
+try-bold: lgr-gentiumplus-bold.pl
+ afm2pl -p $(fontdir)/enc/dvips/gentium-tug/gentium-lgr.enc \
+ -l lig/gentium-lgr.lig \
+ $(fontdir)/afm/public/gentium-tug/GentiumPlus-Bold.afm \
+ && pltotf GentiumPlus-Bold \
+ && tftopl GentiumPlus-Bold GentiumPlus-Bold \
+ && ! diff -u lgr-gentiumplus-bold.pl GentiumPlus-Bold.pl
+try-boldital: lgr-gentiumplus-bolditalic.pl
+ afm2pl -p $(fontdir)/enc/dvips/gentium-tug/gentium-lgr.enc \
+ -l lig/gentium-lgr.lig \
+ $(fontdir)/afm/public/gentium-tug/GentiumPlus-BoldItalic.afm \
+ && pltotf GentiumPlus-BoldItalic \
+ && tftopl GentiumPlus-BoldItalic GentiumPlus-BoldItalic \
+ && ! diff -u lgr-gentiumplus-bolditalic.pl GentiumPlus-BoldItalic.pl
+# GentiumBookPlus family
+try-book-reg: lgr-gentiumbook-regular.pl
+ afm2pl -p $(fontdir)/enc/dvips/gentium-tug/gentium-lgr.enc \
+ -l lig/gentium-lgr.lig \
+ $(fontdir)/afm/public/gentium-tug/GentiumBookPlus-Regular.afm \
+ && pltotf GentiumBookPlus-Regular \
+ && tftopl GentiumBookPlus-Regular GentiumBookPlus-Regular \
+ && ! diff -u lgr-gentiumbook-regular.pl GentiumBookPlus-Regular.pl
+try-book-ital: lgr-gentiumbook-italic.pl
+ afm2pl -p $(fontdir)/enc/dvips/gentium-tug/gentium-lgr.enc \
+ -l lig/gentium-lgr.lig \
+ $(fontdir)/afm/public/gentium-tug/GentiumBookPlus-Italic.afm \
+ && pltotf GentiumBookPlus-Italic \
+ && tftopl GentiumBookPlus-Italic GentiumBookPlus-Italic \
+ && ! diff -u lgr-gentiumbook-italic.pl GentiumBookPlus-Italic.pl
+try-book-bold: lgr-gentiumbook-bold.pl
+ afm2pl -p $(fontdir)/enc/dvips/gentium-tug/gentium-lgr.enc \
+ -l lig/gentium-lgr.lig \
+ $(fontdir)/afm/public/gentium-tug/GentiumBookPlus-Bold.afm \
+ && pltotf GentiumBookPlus-Bold \
+ && tftopl GentiumBookPlus-Bold GentiumBookPlus-Bold \
+ && ! diff -u lgr-gentiumbook-bold.pl GentiumBookPlus-Bold.pl
+try-book-boldital: lgr-gentiumbook-bolditalic.pl
+ afm2pl -p $(fontdir)/enc/dvips/gentium-tug/gentium-lgr.enc \
+ -l lig/gentium-lgr.lig \
+ $(fontdir)/afm/public/gentium-tug/GentiumBookPlus-BoldItalic.afm \
+ && pltotf GentiumBookPlus-BoldItalic \
+ && tftopl GentiumBookPlus-BoldItalic GentiumBookPlus-BoldItalic \
+ && ! diff -u lgr-gentiumbook-bolditalic.pl GentiumBookPlus-BoldItalic.pl
+
# the original pl's, for comparison.
lgr-gentiumplus-regular.pl:
tftopl $(tfmdir)/lgr-gentiumplus-regular $@ || rm -f $@
lgr-gentiumplus-italic.pl:
tftopl $(tfmdir)/lgr-gentiumplus-italic $@ || rm -f $@
+lgr-gentiumplus-bold.pl:
+ tftopl $(tfmdir)/lgr-gentiumplus-bold $@ || rm -f $@
+lgr-gentiumplus-bolditalic.pl:
+ tftopl $(tfmdir)/lgr-gentiumplus-bolditalic $@ || rm -f $@
+lgr-gentiumbook-regular.pl:
+ tftopl $(tfmdir)/lgr-gentiumbook-regular $@ || rm -f $@
+lgr-gentiumbook-italic.pl:
+ tftopl $(tfmdir)/lgr-gentiumbook-italic $@ || rm -f $@
+lgr-gentiumbook-bold.pl:
+ tftopl $(tfmdir)/lgr-gentiumbook-bold $@ || rm -f $@
+lgr-gentiumbook-bolditalic.pl:
+ tftopl $(tfmdir)/lgr-gentiumbook-bolditalic $@ || rm -f $@
# dist just copies the working directory, so have to install and clean.
install:
- mv GentiumPlus-R.tfm $(tfmdir)/lgr-gentiumplus-regular.tfm
- mv GentiumPlus-I.tfm $(tfmdir)/lgr-gentiumplus-italic.tfm
+ mv GentiumPlus-Regular.tfm $(tfmdir)/lgr-gentiumplus-regular.tfm
+ mv GentiumPlus-Italic.tfm $(tfmdir)/lgr-gentiumplus-italic.tfm
+ mv GentiumPlus-Bold.tfm $(tfmdir)/lgr-gentiumplus-bold.tfm
+ mv GentiumPlus-BoldItalic.tfm $(tfmdir)/lgr-gentiumplus-bolditalic.tfm
+ mv GentiumBookPlus-Regular.tfm $(tfmdir)/lgr-gentiumbook-regular.tfm
+ mv GentiumBookPlus-Italic.tfm $(tfmdir)/lgr-gentiumbook-italic.tfm
+ mv GentiumBookPlus-Bold.tfm $(tfmdir)/lgr-gentiumbook-bold.tfm
+ mv GentiumBookPlus-BoldItalic.tfm $(tfmdir)/lgr-gentiumbook-bolditalic.tfm
clean:
- rm -f GentiumPlus-* lgr-gent*.pl
+ rm -f GentiumPlus-* GentiumBookPlus-* lgr-gent*.pl
dist: clean
./make-zip-4CTAN.sh
+
+# generate *.tfm, *.map, *.fd; also *.enc files for small caps
+support-files:
+ ./generate-support-files.rb
+ # make maps containing everything
+ cd $(mapdir_pdftex); cat gentiumplus-truetype.map gentiumbook-truetype.map > gentium-truetype.map
+ cd $(mapdir_dvips); cat gentiumplus-type1.map gentiumbook-type1.map > gentium-type1.map
diff --git a/fonts/gentium-tug/source/generate-support-files.rb b/fonts/gentium-tug/source/generate-support-files.rb
index 97c16a1b0a..ef0b55bcf5 100755
--- a/fonts/gentium-tug/source/generate-support-files.rb
+++ b/fonts/gentium-tug/source/generate-support-files.rb
@@ -1,6 +1,14 @@
#!/usr/bin/env ruby
# This file is part of the Gentium package for TeX.
# It is licensed under the Expat License, see doc//README for details.
+#
+# This script generates *.fd, *.tfm and *.map files. It also takes encoding
+# files (*.enc) containing small and capital letters and creates encoding
+# files for small caps from them. It doesn't touch other files, like *.sty or
+# support files for ConTeXt. This script is called without any parameters.
+#
+# TODO: Make it work with current version of Ruby! It works with version
+# 1.8.7, but not with version as old as 1.9.1.
require 'gentium'
@@ -14,11 +22,17 @@ end
end
# fonts
-font_gentiumplus_rm = Font.new("GentiumPlus-R", "GentiumPlus-Regular", "gentiumplus-regular")
-font_gentiumplus_it = Font.new("GentiumPlus-I", "GentiumPlus-Italic", "gentiumplus-italic")
-font_gentiumbasic_bf = Font.new("GenBasB", "GentiumBasic-Bold", "gentiumbasic-bold")
-font_gentiumbasic_bi = Font.new("GenBasBI", "GentiumBasic-BoldItalic", "gentiumbasic-bolditalic")
-fontlist = [font_gentiumplus_rm, font_gentiumplus_it, font_gentiumbasic_bf, font_gentiumbasic_bi]
+font_gentiumplus_rm = Font.new("GentiumPlus-Regular", "GentiumPlus-Regular", "gentiumplus-regular")
+font_gentiumplus_it = Font.new("GentiumPlus-Italic", "GentiumPlus-Italic", "gentiumplus-italic")
+font_gentiumplus_bf = Font.new("GentiumPlus-Bold", "GentiumPlus-Bold", "gentiumplus-bold")
+font_gentiumplus_bi = Font.new("GentiumPlus-BoldItalic", "GentiumPlus-BoldItalic", "gentiumplus-bolditalic")
+fontlist = [font_gentiumplus_rm, font_gentiumplus_it, font_gentiumplus_bf, font_gentiumplus_bi]
+
+font_gentiumbook_rm = Font.new("GentiumBookPlus-Regular", "GentiumBookPlus-Regular", "gentiumbook-regular")
+font_gentiumbook_it = Font.new("GentiumBookPlus-Italic", "GentiumBookPlus-Italic", "gentiumbook-italic")
+font_gentiumbook_bf = Font.new("GentiumBookPlus-Bold", "GentiumBookPlus-Bold", "gentiumbook-bold")
+font_gentiumbook_bi = Font.new("GentiumBookPlus-BoldItalic", "GentiumBookPlus-BoldItalic", "gentiumbook-bolditalic")
+fontlist_book = [font_gentiumbook_rm, font_gentiumbook_it, font_gentiumbook_bf, font_gentiumbook_bi]
encodings.each_value do |encoding|
@@ -31,14 +45,19 @@ encodings.each_value do |encoding|
# generate 'fd' files
if encoding.is_used_in_latex? then
encoding.generate_fd
+ encoding.generate_fd_book # GentiumBookPlus family
end
# generate 'tfm' files
fontlist.each do |font|
font.generate_tfms(encoding)
end
+ fontlist_book.each do |font|
+ font.generate_tfms(encoding)
+ end
end
# generate 'map' files
encodings.generate_maps(fontlist)
+encodings.generate_maps_book(fontlist_book)
diff --git a/fonts/gentium-tug/source/gentium.rb b/fonts/gentium-tug/source/gentium.rb
index 9f68654fd9..3e000645cf 100644
--- a/fonts/gentium-tug/source/gentium.rb
+++ b/fonts/gentium-tug/source/gentium.rb
@@ -1,5 +1,11 @@
# This file is part of the Gentium package for TeX.
# It is licensed under the Expat License, see doc//README for details.
+#
+# This is just helper file for the main script generate-support-files.rb.
+# It is not intended to be run directly
+#
+# TODO: Make it work with current version of Ruby! It works with version
+# 1.8.7, but not with version as old as 1.9.1.
require 'fileutils'
@@ -226,7 +232,8 @@ class Encoding
end
end
def has_bold?
- return @supported_by_basic_family
+ # TODO: (Pavel) All fonts have bold weight. Refactor out the tests for bold.
+ return true
end
def has_smallcaps?
if ["ts1", "agr", "lgr"].include?(@name) then
@@ -274,8 +281,7 @@ class Encoding
return "\\DeclareFontShape{#{name_latex_uppercase}}{gentium}{#{width1}}{#{shape1}}{<->ssub * gentium/#{width2}/#{shape2}}{}"
end
def generate_fd
- date = "2012/02/06"
- date = "2011/01/13"
+ date = "2022/05/09"
filename = "#{name_latex}gentium.fd"
File.open(File.join($path_fd,filename), 'w') do |file|
@@ -293,14 +299,17 @@ class Encoding
file.puts declare_font_shape("m", "n", "plus-regular")
file.puts declare_font_shape("m", "it", "plus-italic")
if has_bold? then
- file.puts declare_font_shape("b", "n", "basic-bold")
- file.puts declare_font_shape("b", "it", "basic-bolditalic")
+ file.puts declare_font_shape("b", "n", "plus-bold")
+ file.puts declare_font_shape("b", "it", "plus-bolditalic")
# TODO: set the correct tfm names in the following two lines
if has_smallcaps? then
file.puts declare_font_shape("m", "sc", "plus-regular-sc")
file.puts declare_font_shape("m", "scit", "plus-italic-sc")
+ file.puts declare_font_shape("b", "sc", "plus-bold-sc")
+ file.puts declare_font_shape("b", "scit", "plus-bolditalic-sc")
end
# TODO: a clever algorithm to do replacements instead
+ # TODO: (Pavel) Look at substitutions (bold, small caps)
file.puts declare_font_shape_sub("m", "sl", "m", "it")
file.puts declare_font_shape_sub("b", "sl", "b", "it")
file.puts declare_font_shape_sub("bx", "sl", "b", "it")
@@ -314,6 +323,59 @@ class Encoding
end
end
+ # TODO: (Pavel) Merge the following 3 methods with the previous 3 methods
+ def declare_font_shape_book(width, shape, name)
+ text = "\\DeclareFontShape{#{name_latex_uppercase}}{gentiumbook}{#{width}}{#{shape}}{\n" +
+ " <-> \\gentiumbook@@scale #{@name}-gentium#{name}\n" +
+ "}{}\n\n"
+ return text
+ end
+ def declare_font_shape_sub_book(width1, shape1, width2, shape2)
+ return "\\DeclareFontShape{#{name_latex_uppercase}}{gentiumbook}{#{width1}}{#{shape1}}{<->ssub * gentiumbook/#{width2}/#{shape2}}{}"
+ end
+ def generate_fd_book
+ date = "2022/05/09"
+
+ filename = "#{name_latex}gentiumbook.fd"
+ File.open(File.join($path_fd,filename), 'w') do |file|
+ file.puts "\\ProvidesFile{#{name_latex}gentiumbook.fd}"
+ file.puts " [#{date} Font definitions for gentiumbook.]"
+ file.puts
+ file.puts '\expandafter\ifx\csname gentiumbook@scale\endcsname\relax'
+ file.puts ' \let\gentiumbook@@scale\@empty'
+ file.puts '\else'
+ file.puts ' \edef\gentiumbook@@scale{s*[\csname gentiumbook@scale\endcsname]}%'
+ file.puts '\fi'
+ file.puts
+ file.puts "\\DeclareFontFamily{#{name_latex_uppercase}}{gentiumbook}{}"
+ file.puts
+ file.puts declare_font_shape_book("m", "n", "book-regular")
+ file.puts declare_font_shape_book("m", "it", "book-italic")
+ if has_bold? then
+ file.puts declare_font_shape_book("b", "n", "book-bold")
+ file.puts declare_font_shape_book("b", "it", "book-bolditalic")
+ # TODO: set the correct tfm names in the following two lines
+ if has_smallcaps? then
+ file.puts declare_font_shape_book("m", "sc", "book-regular-sc")
+ file.puts declare_font_shape_book("m", "scit", "book-italic-sc")
+ file.puts declare_font_shape_book("b", "sc", "book-bold-sc")
+ file.puts declare_font_shape_book("b", "scit", "book-bolditalic-sc")
+ end
+ # TODO: a clever algorithm to do replacements instead
+ # TODO: (Pavel) Look at substitutions (bold, small caps)
+ file.puts declare_font_shape_sub_book("m", "sl", "m", "it")
+ file.puts declare_font_shape_sub_book("b", "sl", "b", "it")
+ file.puts declare_font_shape_sub_book("bx", "sl", "b", "it")
+ file.puts declare_font_shape_sub_book("bx", "it", "b", "it")
+ file.puts declare_font_shape_sub_book("bx", "n", "b", "n")
+ else
+ file.puts declare_font_shape_sub_book("m", "sl", "m", "it")
+ end
+ file.puts
+ file.puts '\endinput'
+ end
+ end
+
attr_reader :name
end
@@ -332,32 +394,95 @@ class EncodingSet < Hash
fontlist.each do |font|
self.each_value do |encoding|
# TODO: fix the last name (gentium) & encodings: this is another parameter that we have to introduce
- name_tfm = "#{encoding.name}-#{font.filename_tex}".ljust(33)
+ name_tfm = "#{encoding.name}-#{font.filename_tex}".ljust(35)
+ line_reenc = "\"gentium-#{encoding.name}Encoding ReEncodeFont\"".ljust(42)
+ name_enc = "gentium-#{encoding.name}.enc"
+ name_enc_ttf = "gentium-#{encoding.name_truetype}.enc"
+
+ # normal
+ if font.is_plus? or encoding.has_bold? then
+ map_lines_type1[encoding.name].push("#{name_tfm} #{font.name_something.ljust(28)} #{line_reenc} <#{name_enc.ljust(24)} <#{font.filename_type1}")
+ map_lines_ttf[encoding.name].push("#{name_tfm} #{font.name_something.ljust(28)} <#{font.filename_ttf.ljust(18)} #{name_enc_ttf}")
+ end
+ # small caps
+ if font.is_plus? and encoding.has_smallcaps? then
+ name_tfm = "#{encoding.name}-#{font.filename_tex}-sc".ljust(35)
+ line_reenc = "\"gentium-#{encoding.name}scEncoding ReEncodeFont\"".ljust(42)
+ name_enc = "gentium-#{encoding.name}-sc.enc"
+ name_enc_ttf = "gentium-#{encoding.name_truetype_sc}.enc"
+
+ map_lines_type1[encoding.name].push("#{name_tfm} #{font.name_something.ljust(28)} #{line_reenc} <#{name_enc.ljust(24)} <#{font.filename_type1}")
+ map_lines_ttf[encoding.name].push("#{name_tfm} #{font.name_something.ljust(28)} <#{font.filename_ttf.ljust(18)} #{name_enc_ttf}")
+ end
+ end
+ end
+
+ # write map files into files
+ map_file_type1 = File.open(File.join($path_map, "gentiumplus-type1.map" ), 'w')
+ map_file_ttf = File.open(File.join($path_map_ttf, "gentiumplus-truetype.map"), 'w')
+ self.sort.map do |k,encoding|
+ # map file for Type1
+ map_lines_type1[encoding.name].each do |line|
+ map_file_type1.puts line
+ end
+ # map file fon TrueType
+ map_lines_ttf[encoding.name].each do |line|
+ map_file_ttf.puts line
+ end
+ # map file for TrueType for a single encoding (for ConTeXt)
+ # if encoding.is_used_in_context? then
+ if true then
+ File.open(File.join($path_map_ttf, "gentiumplus-#{encoding.name}.map"), 'w') do |map_file_enc|
+ map_lines_ttf[encoding.name].each do |line|
+ map_file_enc.puts line
+ end
+ end
+ end
+ end
+ map_file_type1.close
+ map_file_ttf.close
+ end
+
+ # TODO: (Pavel) Merge methods "generate_maps" and "generate_maps_book"
+ def generate_maps_book(fontlist)
+ # initialize lines for map files, one array for each encoding
+ map_lines_type1 = Hash.new
+ map_lines_ttf = Hash.new
+ self.each_value do |encoding|
+ map_lines_type1[encoding.name] = Array.new
+ map_lines_ttf[encoding.name] = Array.new
+ end
+
+ # fill data
+ fontlist.each do |font|
+ self.each_value do |encoding|
+ # TODO: fix the last name (gentium) & encodings: this is another parameter that we have to introduce
+ name_tfm = "#{encoding.name}-#{font.filename_tex}".ljust(35)
line_reenc = "\"gentium-#{encoding.name}Encoding ReEncodeFont\"".ljust(42)
name_enc = "gentium-#{encoding.name}.enc"
name_enc_ttf = "gentium-#{encoding.name_truetype}.enc"
# normal
if font.is_plus? or encoding.has_bold? then
- map_lines_type1[encoding.name].push("#{name_tfm} #{font.name_something.ljust(24)} #{line_reenc} <#{name_enc.ljust(24)} <#{font.filename_type1}")
- map_lines_ttf[encoding.name].push("#{name_tfm} #{font.name_something.ljust(24)} <#{font.filename_ttf.ljust(18)} #{name_enc_ttf}")
+ map_lines_type1[encoding.name].push("#{name_tfm} #{font.name_something.ljust(28)} #{line_reenc} <#{name_enc.ljust(24)} <#{font.filename_type1}")
+ map_lines_ttf[encoding.name].push("#{name_tfm} #{font.name_something.ljust(28)} <#{font.filename_ttf.ljust(18)} #{name_enc_ttf}")
end
# small caps
if font.is_plus? and encoding.has_smallcaps? then
- name_tfm = "#{encoding.name}-#{font.filename_tex}-sc".ljust(33)
+ name_tfm = "#{encoding.name}-#{font.filename_tex}-sc".ljust(35)
line_reenc = "\"gentium-#{encoding.name}scEncoding ReEncodeFont\"".ljust(42)
name_enc = "gentium-#{encoding.name}-sc.enc"
name_enc_ttf = "gentium-#{encoding.name_truetype_sc}.enc"
- map_lines_type1[encoding.name].push("#{name_tfm} #{font.name_something.ljust(24)} #{line_reenc} <#{name_enc.ljust(24)} <#{font.filename_type1}")
- map_lines_ttf[encoding.name].push("#{name_tfm} #{font.name_something.ljust(24)} <#{font.filename_ttf.ljust(18)} #{name_enc_ttf}")
+ map_lines_type1[encoding.name].push("#{name_tfm} #{font.name_something.ljust(28)} #{line_reenc} <#{name_enc.ljust(24)} <#{font.filename_type1}")
+ map_lines_ttf[encoding.name].push("#{name_tfm} #{font.name_something.ljust(28)} <#{font.filename_ttf.ljust(18)} #{name_enc_ttf}")
end
end
end
# write map files into files
- map_file_type1 = File.open(File.join($path_map, "gentium-type1.map" ), 'w')
- map_file_ttf = File.open(File.join($path_map_ttf, "gentium-truetype.map"), 'w')
+ map_file_type1 = File.open(File.join($path_map, "gentiumbook-type1.map" ), 'w')
+ map_file_ttf = File.open(File.join($path_map_ttf, "gentiumbook-truetype.map"), 'w')
self.sort.map do |k,encoding|
# map file for Type1
map_lines_type1[encoding.name].each do |line|
@@ -370,7 +495,7 @@ class EncodingSet < Hash
# map file for TrueType for a single encoding (for ConTeXt)
# if encoding.is_used_in_context? then
if true then
- File.open(File.join($path_map_ttf, "gentium-#{encoding.name}.map"), 'w') do |map_file_enc|
+ File.open(File.join($path_map_ttf, "gentiumbook-#{encoding.name}.map"), 'w') do |map_file_enc|
map_lines_ttf[encoding.name].each do |line|
map_file_enc.puts line
end
diff --git a/fonts/gentium-tug/source/make-zip-4CTAN.sh b/fonts/gentium-tug/source/make-zip-4CTAN.sh
index 28ff5c5316..a7df3507cb 100755
--- a/fonts/gentium-tug/source/make-zip-4CTAN.sh
+++ b/fonts/gentium-tug/source/make-zip-4CTAN.sh
@@ -1,6 +1,10 @@
#!/bin/sh
+# $Id: make-zip-4CTAN.sh 147 2022-05-21 22:20:08Z karl $
# This file is part of the Gentium package for TeX.
# It is licensed under the Expat License, see doc//README for details.
+#
+# Build the distribution zip file for uploading to CTAN, which includes
+# a "flat" tree and another .tds.zip with the full TDS directory tree.
mydir=`cd \`dirname $0\` && pwd`
@@ -24,7 +28,7 @@ else
fi
pkgname=gentium-tug
-(cd $TDS/doc/fonts/$pkgname && make clean)
+(cd $TDS/doc/fonts/$pkgname/$pkgname && make clean)
(cd $TDS/source/fonts/$pkgname && make clean)
CTAN="$tmpdir/$pkgname"
@@ -33,7 +37,6 @@ mkdir -p "$CTAN/map" || exit 1
rsync="rsync -a --delete --exclude=**/.svn"
$rsync "$TDS/doc/fonts/$pkgname/" "$CTAN/doc/" || exit 1
$rsync "$TDS/source/fonts/$pkgname/" "$CTAN/source/"
-$rsync "$TDS/tex/context/third/$pkgname/" "$CTAN/context/"
$rsync "$TDS/tex/latex/$pkgname/" "$CTAN/latex/"
$rsync "$TDS/fonts/afm/public/$pkgname/" "$CTAN/afm/"
$rsync "$TDS/fonts/tfm/public/$pkgname/" "$CTAN/tfm/"
@@ -65,5 +68,5 @@ if $local; then :; else
echo
fi
-ls -l $tdszip_dest/$pkgname.tds.zip $tmpdir/$pkgname.zip
-
+zipinfo -1 $tmpdir/$pkgname.zip >$tmpdir/$pkgname.lst
+ls -l $tdszip_dest/$pkgname.tds.zip $tmpdir/$pkgname.zip $tmpdir/$pkgname.lst
diff --git a/fonts/gentium-tug/source/type1/GentiumBookPlus-Bold-Czech.kern b/fonts/gentium-tug/source/type1/GentiumBookPlus-Bold-Czech.kern
new file mode 100644
index 0000000000..ace9bbbe70
--- /dev/null
+++ b/fonts/gentium-tug/source/type1/GentiumBookPlus-Bold-Czech.kern
@@ -0,0 +1,17 @@
+KPX dcaron a -110
+KPX dcaron aacute -110
+KPX dcaron o -110
+KPX dcaron oacute -110
+KPX dcaron u -90
+KPX dcaron uring -90
+KPX dcaron t -90
+KPX dcaron m -90
+KPX dcaron k -50
+KPX lcaron a -110
+KPX lcaron aacute -110
+KPX lcaron o -110
+KPX lcaron oacute -110
+KPX lcaron u -90
+KPX lcaron t -90
+KPX lcaron m -90
+KPX lcaron k -50
diff --git a/fonts/gentium-tug/source/type1/GentiumBookPlus-BoldItalic-Czech.kern b/fonts/gentium-tug/source/type1/GentiumBookPlus-BoldItalic-Czech.kern
new file mode 100644
index 0000000000..53af221624
--- /dev/null
+++ b/fonts/gentium-tug/source/type1/GentiumBookPlus-BoldItalic-Czech.kern
@@ -0,0 +1,17 @@
+KPX dcaron a -150
+KPX dcaron aacute -150
+KPX dcaron o -150
+KPX dcaron oacute -150
+KPX dcaron u -110
+KPX dcaron uring -110
+KPX dcaron t -130
+KPX dcaron m -110
+KPX dcaron k -70
+KPX lcaron a -150
+KPX lcaron aacute -150
+KPX lcaron o -150
+KPX lcaron oacute -150
+KPX lcaron u -110
+KPX lcaron t -130
+KPX lcaron m -110
+KPX lcaron k -70
diff --git a/fonts/gentium-tug/source/type1/GentiumBookPlus-Italic-Czech.kern b/fonts/gentium-tug/source/type1/GentiumBookPlus-Italic-Czech.kern
new file mode 100644
index 0000000000..9b875902e5
--- /dev/null
+++ b/fonts/gentium-tug/source/type1/GentiumBookPlus-Italic-Czech.kern
@@ -0,0 +1,17 @@
+KPX dcaron a -110
+KPX dcaron aacute -110
+KPX dcaron o -110
+KPX dcaron oacute -110
+KPX dcaron u -90
+KPX dcaron uring -90
+KPX dcaron t -110
+KPX dcaron m -90
+KPX dcaron k -70
+KPX lcaron a -110
+KPX lcaron aacute -110
+KPX lcaron o -110
+KPX lcaron oacute -110
+KPX lcaron u -90
+KPX lcaron t -110
+KPX lcaron m -90
+KPX lcaron k -70
diff --git a/fonts/gentium-tug/source/type1/GentiumBookPlus-Regular-Czech.kern b/fonts/gentium-tug/source/type1/GentiumBookPlus-Regular-Czech.kern
new file mode 100644
index 0000000000..5f790dc095
--- /dev/null
+++ b/fonts/gentium-tug/source/type1/GentiumBookPlus-Regular-Czech.kern
@@ -0,0 +1,17 @@
+KPX dcaron a -90
+KPX dcaron aacute -90
+KPX dcaron o -90
+KPX dcaron oacute -90
+KPX dcaron u -70
+KPX dcaron uring -70
+KPX dcaron t -70
+KPX dcaron m -70
+KPX dcaron k -50
+KPX lcaron a -90
+KPX lcaron aacute -90
+KPX lcaron o -90
+KPX lcaron oacute -90
+KPX lcaron u -70
+KPX lcaron t -70
+KPX lcaron m -70
+KPX lcaron k -50
diff --git a/fonts/gentium-tug/source/type1/GentiumPlus-I-Czech.kern b/fonts/gentium-tug/source/type1/GentiumPlus-Bold-Czech.kern
index 9a9e6af87b..adc000c02e 100644
--- a/fonts/gentium-tug/source/type1/GentiumPlus-I-Czech.kern
+++ b/fonts/gentium-tug/source/type1/GentiumPlus-Bold-Czech.kern
@@ -6,7 +6,7 @@ KPX dcaron u -80
KPX dcaron uring -80
KPX dcaron t -80
KPX dcaron m -80
-KPX dcaron k -60
+KPX dcaron k -40
KPX lcaron a -100
KPX lcaron aacute -100
KPX lcaron o -100
@@ -14,4 +14,4 @@ KPX lcaron oacute -100
KPX lcaron u -80
KPX lcaron t -80
KPX lcaron m -80
-KPX lcaron k -60
+KPX lcaron k -40
diff --git a/fonts/gentium-tug/source/type1/GentiumPlus-BoldItalic-Czech.kern b/fonts/gentium-tug/source/type1/GentiumPlus-BoldItalic-Czech.kern
new file mode 100644
index 0000000000..cfeda1d857
--- /dev/null
+++ b/fonts/gentium-tug/source/type1/GentiumPlus-BoldItalic-Czech.kern
@@ -0,0 +1,17 @@
+KPX dcaron a -140
+KPX dcaron aacute -140
+KPX dcaron o -140
+KPX dcaron oacute -140
+KPX dcaron u -100
+KPX dcaron uring -100
+KPX dcaron t -120
+KPX dcaron m -100
+KPX dcaron k -60
+KPX lcaron a -140
+KPX lcaron aacute -140
+KPX lcaron o -140
+KPX lcaron oacute -140
+KPX lcaron u -100
+KPX lcaron t -120
+KPX lcaron m -100
+KPX lcaron k -60
diff --git a/fonts/gentium-tug/source/type1/GentiumPlus-Italic-Czech.kern b/fonts/gentium-tug/source/type1/GentiumPlus-Italic-Czech.kern
new file mode 100644
index 0000000000..3df10391be
--- /dev/null
+++ b/fonts/gentium-tug/source/type1/GentiumPlus-Italic-Czech.kern
@@ -0,0 +1,17 @@
+KPX dcaron a -100
+KPX dcaron aacute -100
+KPX dcaron o -100
+KPX dcaron oacute -100
+KPX dcaron u -80
+KPX dcaron uring -80
+KPX dcaron t -100
+KPX dcaron m -80
+KPX dcaron k -60
+KPX lcaron a -100
+KPX lcaron aacute -100
+KPX lcaron o -100
+KPX lcaron oacute -100
+KPX lcaron u -80
+KPX lcaron t -100
+KPX lcaron m -80
+KPX lcaron k -60
diff --git a/fonts/gentium-tug/source/type1/GentiumPlus-R-Czech.kern b/fonts/gentium-tug/source/type1/GentiumPlus-Regular-Czech.kern
index 1129eff7b9..1129eff7b9 100644
--- a/fonts/gentium-tug/source/type1/GentiumPlus-R-Czech.kern
+++ b/fonts/gentium-tug/source/type1/GentiumPlus-Regular-Czech.kern
diff --git a/fonts/gentium-tug/source/type1/Makefile b/fonts/gentium-tug/source/type1/Makefile
index d432621ee9..2360fcce36 100644
--- a/fonts/gentium-tug/source/type1/Makefile
+++ b/fonts/gentium-tug/source/type1/Makefile
@@ -18,8 +18,8 @@ AFM_PATH='../../../../fonts/afm/public/gentium-tug'
PFB_PATH='../../../../fonts/type1/public/gentium-tug'
all: kerns
- ./ff-gentium.pe GentiumPlus-R.ttf GentiumPlus-I.ttf \
- GenBasB.ttf GenBasBI.ttf
+ # The order of font processing is important for correct BlueValues!
+ ./ff-gentium.pe Gentium{,Book}Plus-{Regular,Italic,Bold,BoldItalic}.ttf
# Change the creator to "TeX Users Group"
for I in *.pfb; do \
t1disasm $$I | sed 's/%%Creator: .*/%%Creator: TeX Users Group/' \
diff --git a/fonts/gentium-tug/source/type1/README b/fonts/gentium-tug/source/type1/README
new file mode 100644
index 0000000000..21815d95b5
--- /dev/null
+++ b/fonts/gentium-tug/source/type1/README
@@ -0,0 +1,149 @@
+==================================================
+Scripts for the conversion from TrueType to Type 1
+==================================================
+
+They are based on the 'make' utility.
+
+The directory is self-contained.
+
+The scripts don't need internet connection.
+
+
+Usage
+=====
+
+make [ kerns | test ]
+
+test
+ Test the converted fonts using t1lint.
+
+kerns
+ Generate files that will contain all the added kerning pairs except the
+ kerning between D and V. The kern between D and V is changed, not added.
+
+
+The usual usage is just 'make' which converts the fonts, deletes the
+intermediate files and checks the fonts with t1lint.
+
+Use "make" three times to convert the fonts to Type 1. You need to call "make"
+twice for all kerning changes to propagate. However the third call to "make"
+reorders some lines in the afm files. The order of lines in afm files is
+stable after the third call to "make".
+
+The second call to "make" is sufficient from the functional point of view,
+however the diff of afm files created using two and three calls of "make"
+would contain too many differences.
+
+
+File dependency tree
+====================
+
+Makefile
+ generate-extra-kerns.sh
+ greekcorrection.py
+ kerncorrection.py
+ Gentium*-Czech.kern
+ ff-gentium.pe
+ afmcreator.py
+
+kern-test-greek.txt
+kern-word-list-caron.txt
+kern-word-list-cyrillic.txt
+
+
+File description
+================
+
+Makefile
+ This is the root of the conversion scripts.
+
+generate-extra-kerns.sh
+ Calls the scripts greekcorrection.py and kerncorrection.py and adds the kerning
+ pairs for the Czech and Slovak letters dcaron and lcaron.
+
+greekcorrection.py
+ Generates kerning pairs for the combinations accent + capital Greek letter.
+
+kerncorrection.py
+ Generates kerning pairs for the accented Latin letters, small caps and some
+ combinations with quotes or punctuation.
+
+Gentium*-Czech.kern
+ Contains manually added kerning pairs for dcaron and lcaron.
+
+ff-gentium.pe
+ Converts the fonts to Type 1.
+
+afmcreator.py
+ Currently just writes to the afm files that the creator is TeX Users Group.
+
+kern-word-list.txt
+ Independent file that is not used for the conversion. It contains words and
+ character pairs for testing the kerning of dcaron and lcaron. It is used in
+ the Metrics Window in FontForge to manually review the kerning pairs.
+
+
+Changes from the original fonts
+===============================
+
+* Added kerning pairs for accented Latin letters
+
+* Added kerning pairs for small caps.
+
+* Added kerning pairs for some combinations of letters, quotes and
+ punctuation.
+
+* Added kerning pairs for combination accent + Greek capital letter.
+
+* Added kerning pairs for dcaron and lcaron.
+
+* Changed kerning pair between D and V from positive to negative value (where
+ appropriate).
+
+
+Remarks
+=======
+
+* The converted italic fonts have all the 63 extra Greek kerning pairs. The
+ upright fonts have less (GentiumPlus-Regular has currently 44 pairs). This
+ is not an error. Some pairs like 'tonos' + 'Epsilon' would have the kerning
+ equal to 0 and these zeroes are eliminated in the script.
+
+* The characters like Alphatonos are created from the base letter (Alpha) and
+ the accent (tonos). The combined character defines the relative horizontal
+ position of the accent and character. However, there is also non-zero
+ relative *vertical* position between these two. That means that e.g. tonos is
+ not in the same height in the combined character as it is when tonos is
+ alone. The result should be checked!
+
+
+Files for testing kerning in FontForge
+--------------------------------------
+
+These files are used in the Metrics window of FontForge to look how the
+introduced kerning pairs look in the converted fonts in some context. This is
+just about the fonts themselves, not about the TeX support files. Some issues
+might be corrected in the TeX support files (such as the vertical position of
+the accents for composite capital Greek letters).
+
+kern-test-greek.txt
+ This file shows some combinations of accent + capital Greek letter and
+ sometimes compares this to the precomposed accented letter. You can compare
+ the position of accent in the pair accent + letter with the precomposed
+ letter. Even the vertical position of the accent may be different in the
+ pair from the position in the precomposed letter.
+
+ It also shows the accent tonos folowed by a precomposed letter with this
+ accent so that you can easily see if there is some difference in the
+ vertical position of the accent.
+
+ There are two glyphs for Omega in the fonts and it shows how both of these
+ behave.
+
+kern-word-list-caron.txt
+ This file has some words and character pairs that show the kerning of dcaron
+ or lcaron followed by other letters.
+
+kern-word-list-cyrillic.txt
+ This file shows kerning for some Russian words and groups of Cyrillic
+ letters.
diff --git a/fonts/gentium-tug/source/type1/afmcreator.py b/fonts/gentium-tug/source/type1/afmcreator.py
index bc44f1cd85..7d81f9f7a1 100755
--- a/fonts/gentium-tug/source/type1/afmcreator.py
+++ b/fonts/gentium-tug/source/type1/afmcreator.py
@@ -1,22 +1,18 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# This file is part of the Gentium package for TeX.
# It is licensed under the Expat License, see doc//README for details.
-import os, sys
+import os
+import sys
creatortext = "Comment Creator: TeX Users Group\n"
tempname = "temp.afm"
-fin = open(sys.argv[1], "r")
-fout = open(tempname, "w")
-while True:
- s = fin.readline()
- if s == "": break # end of file
- fout.write(s)
- if s.find("Comment Creation Date") == 0 :
- fout.write(creatortext) # Creator after Creation Date
-fin.close()
-fout.close()
+with open(sys.argv[1], "r") as fin, open(tempname, "w") as fout:
+ for line in fin:
+ fout.write(line)
+ if line.startswith("Comment Creation Date"):
+ fout.write(creatortext) # Creator after Creation Date
os.rename(tempname, sys.argv[1])
diff --git a/fonts/gentium-tug/source/type1/ff-gentium.pe b/fonts/gentium-tug/source/type1/ff-gentium.pe
index 108d231835..55b6ec5c00 100755
--- a/fonts/gentium-tug/source/type1/ff-gentium.pe
+++ b/fonts/gentium-tug/source/type1/ff-gentium.pe
@@ -1,5 +1,5 @@
#!/usr/bin/env fontforge
-# $Id: ff-gentium.pe 15 2015-04-23 22:29:19Z karl $
+# $Id: ff-gentium.pe 116 2022-05-11 00:51:36Z karl $
# This file is part of the Gentium package for TeX.
# It is licensed under the Expat License, see doc//README for details.
@@ -12,11 +12,11 @@
# the latter, because the syntax is more familiar to me.
# You can set the desired copyright text in the following variable
-FONT_COPYRIGHT='Copyright (c) SIL International, 2003-2014. TeX conversion additions copyright (c) 2013-2015 TeX Users Group. Released under the OFL, http://scripts.sil.org/OFL.'
+FONT_COPYRIGHT='Copyright (c) SIL International, 2003-2022. TeX conversion additions copyright (c) 2013-2022 TeX Users Group. Released under the OFL, https://scripts.sil.org/OFL.'
TTF_PATH='../../../../fonts/truetype/public/gentium-tug/'
-FONT_VERSION_PLUS='gentiumps-1.1 (from Gentium Plus 5.000; 2014; Major update)'
-FONT_VERSION_BASIC='gentiumps-1.0 (from Gentium Basic 1.100; 2008; Maintenance release)'
+FONT_VERSION_PLUS='gentiumps-1.101 (from Gentium Plus 6.101; 2022; Maintenance release)'
+FONT_VERSION_BOOK='gentiumps-1.101 (from Gentium Book Plus 6.101; 2022; Maintenance release)'
LoadNamelist("vgx.nam")
@@ -29,17 +29,6 @@ while ( i < $argc )
Print("* Reading TrueType")
Open(TTF_PATH + $argv[i])
- # Removing problematic lookups "mark" and "mkmk" from GentiumPlus.
- # This eliminates really huge amount of error messages.
- if ( $argv[i] == "GentiumPlus-R.ttf" || $argv[i] == "GentiumPlus-I.ttf" )
- Print("* Removing problematic lookups mark and mkmk")
- # TODO: Don't use these hard-coded names, use GetLookups("GPOS")
- RemoveLookup("'mark' Mark Positioning lookup 0")
- RemoveLookup("'mark' Mark Positioning lookup 1")
- RemoveLookup("'mkmk' Mark to Mark lookup 2")
- RemoveLookup("'mkmk' Mark to Mark lookup 3")
- endif
-
# attempt to follow Hirwen's instructions:
Print("* Scaling")
ScaleToEm(1000)
@@ -87,26 +76,47 @@ while ( i < $argc )
# It makes sense from another point of view: two fonts from GentiumPlus
# make one family, two fonts from GentiumBasic make other family.
# TODO: clean-up of the following code
- if ( $argv[i] == "GentiumPlus-R.ttf" )
+
+ # GentiumPlus family
+ if ( $argv[i] == "GentiumPlus-Regular.ttf" )
BlueValuesRegular = GetPrivateEntry("BlueValues")
OtherBluesRegular = GetPrivateEntry("OtherBlues")
endif
- if ( $argv[i] == "GentiumPlus-I.ttf" )
+ if ( $argv[i] == "GentiumPlus-Italic.ttf" )
ChangePrivateEntry("FamilyBlues", BlueValuesRegular)
ChangePrivateEntry("FamilyOtherBlues", OtherBluesRegular)
endif
- if ( $argv[i] == "GenBasB.ttf" )
+ if ( $argv[i] == "GentiumPlus-Bold.ttf" )
BlueValuesBold = GetPrivateEntry("BlueValues")
OtherBluesBold = GetPrivateEntry("OtherBlues")
endif
- if ( $argv[i] == "GenBasBI.ttf" )
+ if ( $argv[i] == "GentiumPlus-BoldItalic.ttf" )
ChangePrivateEntry("FamilyBlues", BlueValuesBold)
ChangePrivateEntry("FamilyOtherBlues", OtherBluesBold)
endif
+ # GentiumBookPlus family
+ if ( $argv[i] == "GentiumBookPlus-Regular.ttf" )
+ BlueValuesBookRegular = GetPrivateEntry("BlueValues")
+ OtherBluesBookRegular = GetPrivateEntry("OtherBlues")
+ endif
+ if ( $argv[i] == "GentiumBookPlus-Italic.ttf" )
+ ChangePrivateEntry("FamilyBlues", BlueValuesBookRegular)
+ ChangePrivateEntry("FamilyOtherBlues", OtherBluesBookRegular)
+ endif
+ if ( $argv[i] == "GentiumBookPlus-Bold.ttf" )
+ BlueValuesBookBold = GetPrivateEntry("BlueValues")
+ OtherBluesBookBold = GetPrivateEntry("OtherBlues")
+ endif
+ if ( $argv[i] == "GentiumBookPlus-BoldItalic.ttf" )
+ ChangePrivateEntry("FamilyBlues", BlueValuesBookBold)
+ ChangePrivateEntry("FamilyOtherBlues", OtherBluesBookBold)
+ endif
+
# Hirwen says add forcebold and write true if font is bold (or bold italic).
# Adobe strongly advises to set ForceBold explicitly (true or false).
- if ( $argv[i] == "GentiumPlus-R.ttf" || $argv[i] == "GentiumPlus-I.ttf" )
+ if ( $argv[i] == "GentiumPlus-Regular.ttf" || $argv[i] == "GentiumPlus-Italic.ttf" || \
+ $argv[i] == "GentiumBookPlus-Regular.ttf" || $argv[i] == "GentiumBookPlus-Italic.ttf" )
ChangePrivateEntry("ForceBold", "false")
else
ChangePrivateEntry("ForceBold", "true")
@@ -136,10 +146,10 @@ while ( i < $argc )
# Note that this is not at all robust. If it doesn't work, comment out all the lines in the next block except for the single line between the "else" and the "endif". This will produce names which may be less than ideal from an aesthetic point of view but should at least work.
hyphened=Strrstr($fontname,"-")
spaced=Strrstr($fullname," ")
- if ( $argv[i] == "GentiumPlus-R.ttf" || $argv[i] == "GentiumPlus-I.ttf" )
+ if ( Strcasestr($argv[i], "GentiumPlus") == 0 )
FONT_VERSION=FONT_VERSION_PLUS
else
- FONT_VERSION=FONT_VERSION_BASIC
+ FONT_VERSION=FONT_VERSION_BOOK
endif
if ( hyphened > 0 )
fontnamecyntaf=Strsub($fontname,0,hyphened)
@@ -154,17 +164,48 @@ while ( i < $argc )
# Corrections for Greek (automatically generated values) and additional kerns
# TODO: Don't use hard-coded names, check the existence of extra kernings instead
- if ( $argv[i] == "GentiumPlus-R.ttf" )
+ if ( $argv[i] == "GentiumPlus-Regular.ttf" )
Print("* Correction for Greek and additional kerning pairs")
- MergeFeature("GentiumPlus-R-extra.afm")
+ MergeFeature("GentiumPlus-Regular-extra.afm")
endif
- if ( $argv[i] == "GentiumPlus-I.ttf" )
+ if ( $argv[i] == "GentiumPlus-Italic.ttf" )
Print("* Correction for Greek and additional kerning pairs")
- MergeFeature("GentiumPlus-I-extra.afm")
+ MergeFeature("GentiumPlus-Italic-extra.afm")
endif
+ if ( $argv[i] == "GentiumPlus-Bold.ttf" )
+ Print("* Correction for Greek and additional kerning pairs")
+ MergeFeature("GentiumPlus-Bold-extra.afm")
+ endif
+ if ( $argv[i] == "GentiumPlus-BoldItalic.ttf" )
+ Print("* Correction for Greek and additional kerning pairs")
+ MergeFeature("GentiumPlus-BoldItalic-extra.afm")
+ endif
+ if ( $argv[i] == "GentiumBookPlus-Regular.ttf" )
+ Print("* Correction for Greek and additional kerning pairs")
+ MergeFeature("GentiumBookPlus-Regular-extra.afm")
+ endif
+ if ( $argv[i] == "GentiumBookPlus-Italic.ttf" )
+ Print("* Correction for Greek and additional kerning pairs")
+ MergeFeature("GentiumBookPlus-Italic-extra.afm")
+ endif
+ if ( $argv[i] == "GentiumBookPlus-Bold.ttf" )
+ Print("* Correction for Greek and additional kerning pairs")
+ MergeFeature("GentiumBookPlus-Bold-extra.afm")
+ endif
+ if ( $argv[i] == "GentiumBookPlus-BoldItalic.ttf" )
+ Print("* Correction for Greek and additional kerning pairs")
+ MergeFeature("GentiumBookPlus-BoldItalic-extra.afm")
+ endif
+
- # Correction of the kern between D and V in "GentiumPlus-R.ttf"
- if ( $argv[i] == "GentiumPlus-R.ttf" )
+ # Correction of the kern between D and V in "GentiumPlus-Regular.ttf" and some other
+ # All these fonts had 20 and it will be changed to -20.
+ if ( \
+ $argv[i] == "GentiumPlus-Regular.ttf" || \
+ $argv[i] == "GentiumPlus-Bold.ttf" || \
+ $argv[i] == "GentiumBookPlus-Regular.ttf" || \
+ $argv[i] == "GentiumBookPlus-Bold.ttf" \
+ )
Print("* Correction of kern between D and V")
Select("D")
SetKern("V", -20)
diff --git a/fonts/gentium-tug/source/type1/generate-extra-kerns.sh b/fonts/gentium-tug/source/type1/generate-extra-kerns.sh
index 8c2dc4dff6..d4049aa528 100755
--- a/fonts/gentium-tug/source/type1/generate-extra-kerns.sh
+++ b/fonts/gentium-tug/source/type1/generate-extra-kerns.sh
@@ -11,7 +11,7 @@
TTF_PATH="../../../../fonts/truetype/public/gentium-tug"
AFM_PATH="../../../../fonts/afm/public/gentium-tug"
-for i in GentiumPlus-R.ttf GentiumPlus-I.ttf; do
+for i in Gentium{,Book}Plus-{Regular,Italic,Bold,BoldItalic}.ttf; do
echo "----------------------------------------------"
echo "* Generating extra kerns for $i"
echo "* Converting font to sfd"
@@ -21,7 +21,11 @@ for i in GentiumPlus-R.ttf GentiumPlus-I.ttf; do
echo "* Calculating the kerns"
./greekcorrection.py $(basename $i .ttf).sfd
./kerncorrection.py "$AFM_PATH/$(basename $i .ttf).afm" $(basename $i .ttf)-extra.afm
- cat $(basename $i .ttf)-Czech.kern >> $(basename $i .ttf)-extra.afm
+
+ if [ -f "$(basename $i .ttf)-Czech.kern" ]
+ then
+ cat $(basename $i .ttf)-Czech.kern >> $(basename $i .ttf)-extra.afm
+ fi
done
rm *sfd
diff --git a/fonts/gentium-tug/source/type1/greekcorrection.py b/fonts/gentium-tug/source/type1/greekcorrection.py
index 16b328f590..aebe686af4 100755
--- a/fonts/gentium-tug/source/type1/greekcorrection.py
+++ b/fonts/gentium-tug/source/type1/greekcorrection.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# This file is part of the Gentium package for TeX.
# It is licensed under the Expat License, see doc//README for details.
# author: Pavel Farar, pavel.farar@centrum.cz
@@ -37,7 +37,7 @@ import sys
# from the LIGKERN commands for the precomposed small Greek
# accented letters in the encoding LGR. Then I did uppercasing
# using information from Unicode and looked if there is
-# some accented letter missing. Therefore I call it
+# some accented letter missing. Therefore I call it
# LigatureTable and this file uses one line for every
# capital Greek letter. I did it in such a way to avoid
# random errors.
@@ -109,30 +109,32 @@ LigatureTable.append(['tonos', 'Omega', 'Omegatonos'])
# Set with Greek accents
-GreekAccents = set() # empty set
+GreekAccents = set() # empty set
for i in range(len(LigatureTable)):
- GreekAccents.add(LigatureTable[i][0])
+ GreekAccents.add(LigatureTable[i][0])
# Set with Greek letters
-GreekLetters = set() # empty set
+GreekLetters = set() # empty set
for i in range(len(LigatureTable)):
- GreekLetters.add(LigatureTable[i][1])
+ GreekLetters.add(LigatureTable[i][1])
# Set with precomposed Greek letters
-PrecomposedGreekLetters = set() # empty set
+PrecomposedGreekLetters = set() # empty set
for i in range(len(LigatureTable)):
- PrecomposedGreekLetters.add(LigatureTable[i][2])
+ PrecomposedGreekLetters.add(LigatureTable[i][2])
def UnicodeValue(s):
- # The unicode value is the second number after "Encoding:"
- if s.find('Encoding:') != 0: sys.exit('UnicodeValue error')
- return s.split()[2] # The third item
+ # The unicode value is the second number after "Encoding:"
+ if s.find('Encoding:') != 0:
+ sys.exit('UnicodeValue error')
+ return s.split()[2] # The third item
def WidthValue(s):
- if s.find('Width:') != 0: sys.exit('WidthValue error')
- return s.split()[1] # The second item
+ if s.find('Width:') != 0:
+ sys.exit('WidthValue error')
+ return s.split()[1] # The second item
# Dictionaries (all values are strings, not numbers!)
@@ -147,87 +149,98 @@ farray = f.readlines()
f.close()
findex = -1
while True:
- findex = findex + 1
- if findex >= len(farray): break # end of file
- s = farray[findex]
- if s.find('StartChar: ') == 0 :
- CharacterName = s[11:-1]
- if CharacterName in GreekLetters:
- findex = findex + 1
- s = farray[findex]
- LetterUnicode[CharacterName] = UnicodeValue(s)
- if CharacterName in GreekAccents:
- findex = findex + 1
- s = farray[findex]
- AccentUnicode[CharacterName] = UnicodeValue(s)
- findex = findex + 1
- s = farray[findex]
- AccentWidth[CharacterName] = WidthValue(s)
+ findex = findex + 1
+ if findex >= len(farray):
+ break # end of file
+ s = farray[findex]
+ if s.find('StartChar: ') == 0:
+ CharacterName = s[11:-1]
+ if CharacterName in GreekLetters:
+ findex = findex + 1
+ s = farray[findex]
+ LetterUnicode[CharacterName] = UnicodeValue(s)
+ if CharacterName in GreekAccents:
+ findex = findex + 1
+ s = farray[findex]
+ AccentUnicode[CharacterName] = UnicodeValue(s)
+ findex = findex + 1
+ s = farray[findex]
+ AccentWidth[CharacterName] = WidthValue(s)
def MoveValue(ss, lindex):
- sarray = ss.split()
- if sarray[0] != 'Refer:': sys.exit('No Refer:')
- x = int(sarray[8]) # the value of move
-
- # dirty hack to make Omega work in both Gentium and GentiumPlus
- # This script without the following hack would work well for Gentium, but not for
- # GentiumPlus. The problem with GentiumPlus is that the accented letters with Omega
- # uses as a base letter that with the unicode value 937 (which should be Omega), but
- # this letter has PostScript name uni03A9, not Omega. Omega has a different value.
- if sarray[2] == '937': # the standard unicode value for Omega = problems in GentiumPlus
- sarray[2] = LetterUnicode['Omega']
-
- # is it accent or letter?
- # unicode is the second number (third value)
- if sarray[2] == AccentUnicode[LigatureTable[lindex][0]]: # accent
- x = -x # the move of accent is taken negatively
- elif sarray[2] == LetterUnicode[LigatureTable[lindex][1]]: # letter
- x = +x # the move of letter is taken positively
- else:
- sys.exit('Bad unicode of component')
-
- return x
+ sarray = ss.split()
+ if sarray[0] != 'Refer:':
+ sys.exit('No Refer:')
+ x = int(sarray[8]) # the value of move
+
+ # dirty hack to make Omega work in both Gentium and GentiumPlus
+ # This script without the following hack would work well for Gentium, but not for
+ # GentiumPlus. The problem with GentiumPlus is that the accented letters with Omega
+ # uses as a base letter that with the unicode value 937 (which should be Omega), but
+ # this letter has PostScript name uni03A9, not Omega. Omega has a different value.
+ if (
+ sarray[2] == '937'
+ ): # the standard unicode value for Omega = problems in GentiumPlus
+ sarray[2] = LetterUnicode['Omega']
+
+ # is it accent or letter?
+ # unicode is the second number (third value)
+ if sarray[2] == AccentUnicode[LigatureTable[lindex][0]]: # accent
+ x = -x # the move of accent is taken negatively
+ elif sarray[2] == LetterUnicode[LigatureTable[lindex][1]]: # letter
+ x = +x # the move of letter is taken positively
+ else:
+ sys.exit('Bad unicode of component')
+
+ return x
def KernValue(letter, s1, s2):
- # letter - the name of the precomposed letter
- # s1 - Refer to the accent (expected to be first)
- # s2 - Refer to the letter
- for i in range(len(LigatureTable)):
- if LigatureTable[i][2] == letter: LetterIndex = i
-
- FirstMove = MoveValue(s1, LetterIndex)
- SecondMove = MoveValue(s2, LetterIndex)
-
- return FirstMove + SecondMove - int(AccentWidth[LigatureTable[LetterIndex][0]])
-
-
-
-
-KernTable = {}
+ # letter - the name of the precomposed letter
+ # s1 - Refer to the accent (expected to be first)
+ # s2 - Refer to the letter
+ for i in range(len(LigatureTable)):
+ if LigatureTable[i][2] == letter:
+ LetterIndex = i
+
+ FirstMove = MoveValue(s1, LetterIndex)
+ SecondMove = MoveValue(s2, LetterIndex)
+
+ return FirstMove + SecondMove - int(AccentWidth[LigatureTable[LetterIndex][0]])
+
+
+KernTable = {}
# Process the precomposed letters
# The sfd file is still in "farray"
findex = -1
while True:
- findex = findex + 1
- if findex >= len(farray): break # end of file
- s = farray[findex]
- if s.find('StartChar: ') == 0 :
- CharacterName = s[11:-1]
- if CharacterName in PrecomposedGreekLetters:
- while s.find('Refer: ') != 0 :
- findex = findex + 1
- s = farray[findex]
- KernTable[CharacterName] = KernValue(CharacterName, s, farray[findex + 1])
+ findex = findex + 1
+ if findex >= len(farray):
+ break # end of file
+ s = farray[findex]
+ if s.find('StartChar: ') == 0:
+ CharacterName = s[11:-1]
+ if CharacterName in PrecomposedGreekLetters:
+ while s.find('Refer: ') != 0:
+ findex = findex + 1
+ s = farray[findex]
+ KernTable[CharacterName] = KernValue(CharacterName, s, farray[findex + 1])
# Write the kerning table
fafm = open(sys.argv[1][:-4] + '-extra.afm', 'w')
for i in range(len(LigatureTable)):
- sourceKern = KernTable[LigatureTable[i][2]]
- if sourceKern != 0: # remove zero kerns
- fafm.write('KPX ' + LigatureTable[i][0] + ' ' + LigatureTable[i][1] + ' ' +
- str(int(round(1000.0 / 2048.0 * sourceKern))) + '\n')
+ sourceKern = KernTable[LigatureTable[i][2]]
+ if sourceKern != 0: # remove zero kerns
+ fafm.write(
+ 'KPX '
+ + LigatureTable[i][0]
+ + ' '
+ + LigatureTable[i][1]
+ + ' '
+ + str(int(round(1000.0 / 2048.0 * sourceKern)))
+ + '\n'
+ )
fafm.close()
diff --git a/fonts/gentium-tug/source/type1/kern-test-greek.txt b/fonts/gentium-tug/source/type1/kern-test-greek.txt
new file mode 100644
index 0000000000..f8e51dfe85
--- /dev/null
+++ b/fonts/gentium-tug/source/type1/kern-test-greek.txt
@@ -0,0 +1,4 @@
+/tonos/Omega /tonos/uni03A9 /Omegatonos /tonos/Omegatonos
+΄Ω Ώ
+΄Α Ά
+῏Α Ἆ
diff --git a/fonts/gentium-tug/source/type1/kern-word-list-caron.txt b/fonts/gentium-tug/source/type1/kern-word-list-caron.txt
new file mode 100644
index 0000000000..08bc32a494
--- /dev/null
+++ b/fonts/gentium-tug/source/type1/kern-word-list-caron.txt
@@ -0,0 +1,24 @@
+Áďa
+da ďa ďá
+do ďo ďó
+du ďu ďů
+dt ďt
+dm ďm
+dk ďk
+pruďas
+ďábel
+náklaďák
+poďobat
+ďubka
+pojďte
+pojďme
+loďka
+la ľa ľá
+lo ľo ľó
+lu ľu
+lt ľt
+lm ľm
+lk ľk
+veľa
+veľmi
+koľko
diff --git a/fonts/gentium-tug/source/type1/kern-word-list-cyrillic.txt b/fonts/gentium-tug/source/type1/kern-word-list-cyrillic.txt
new file mode 100644
index 0000000000..e88d761b7c
--- /dev/null
+++ b/fonts/gentium-tug/source/type1/kern-word-list-cyrillic.txt
@@ -0,0 +1,51 @@
+БРАТА
+ВРАЧ
+ГДЕ
+ГЛАЗА
+ГОЛОД
+ГУЛЯТЬ
+Галерея
+Герой
+Голубой
+КРАСАВИЦА
+НОЖОМ
+ОТКУДА
+ОТЛИЧНО
+ПОХОЖИЙ
+ПРАГА
+Татьяна
+Терешкова
+Толстой
+брата
+где
+глаза
+голубой
+гулять
+долго
+нога
+ножом
+один
+откуда
+отлично
+похожий
+только
+НУЛН
+НУДН
+НУАН
+НГЛН
+НГДН
+НГАН
+НТЛН
+НТДН
+НТАН
+НАЧН
+нулн
+нудн
+нуан
+нглн
+нгдн
+нган
+нтлн
+нтдн
+нтан
+начн
diff --git a/fonts/gentium-tug/source/type1/kerncorrection.py b/fonts/gentium-tug/source/type1/kerncorrection.py
index 323a065fa2..f264cd5b5c 100755
--- a/fonts/gentium-tug/source/type1/kerncorrection.py
+++ b/fonts/gentium-tug/source/type1/kerncorrection.py
@@ -1,32 +1,99 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# This file is part of the Gentium package for TeX.
# It is licensed under the Expat License, see doc//README for details.
# Used uni0162 for Tcedilla and uni021A for Tcommaaccent
+
+# ERROR (non-critical)
+# --------------------
+# Found where the duplicate kerning pairs are written.
+# Example of such duplicate kerning pair is 'A cacute.sc'
+# It is generated is initialcap() for the first time and in
+# accentedinitialcapsmallcap() for the second time.
+#
+# FIXED
+#
+# The previous error was fixed, althought in a dirty way. Instead of
+# writing directly to a file, the lines with extra kerning are added
+# to 'Counter' object from 'collections'. This automatically eliminates
+# duplicates, but keep track of them (they have count of 2).
+#
+# It was tested that just the duplicates are removed and nothing is lost.
+# When the duplicates were removed from the file generated by the old
+# script, the result is exactly the same as the file generated by this new
+# version of the script.
+#
+# This file will be cleaned up later (or completely rewritten). I know
+# this script is very dirty and it might be easier to rewrite it completely.
+
+
+# TODO: use variable for the small caps extension '.sc'
+
+# TODO: refactor the script; maybe remove classes
+
+
+# TODO: Decide if should be used purely class-based kerning.
+
+# TODO: It might be good idea to split this script into two scripts (Latin and
+# Cyrillic). It would be better to do different kerning for roman and
+# italic styles (at least for the small Cyrillic letters; especially
+# de, el, ge). It would be even better to do manual kerning, but it would take
+# much time. But I could do support for files with manual kerning. These
+# files would be used if they were present. This would be similar to the
+# files that are used for manual kerning for letters dcaron and lcaron.
+# There shoud be probably three such files for each font (Latin, Greek,
+# Cyrillic).
+
+# The script currently combines class-based kerning and deriving kerning from list
+# of kerns. Changing it to completely class-based kerning would create more kerning
+# pairs than now. The current (mixed) sollution makes it possible to make exceptions
+# to class-based kerning.
+
+# TODO: It might be good idea to find out which kerning pairs can really occur for
+# e.g. encoding T1. Pure class-based kernig would give too many kerning pairs.
+# This is probably no problem for TeX, but it means too many kerning pairs
+# that would never be needed (and it would be more work to look at the changes
+# from the original fonts). The solution would be to look for languages that
+# are supported by T1 and take only those pairs where both the letter are in
+# the same language. Even this would be a superset of what is really possible.
+# For example Czech has letters dcaron and ecaron, but the pair
+# dcaron + ecaron can never occur.
+#
+# These pairs might be useful also for other fonts for TeX.
+
+
import os, sys, re
+import collections
+
+SMALL_CAPS_CORRECTION = 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
+
+input_file_name = sys.argv[1]
+output_file_name = sys.argv[2]
+
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):
- 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 lines with kerning, format of *.afm
+
+ TODO: Check that there is only one matching line.
+ """
+ return [line for line in self.kern_lines if re.match(regex, line)]
class KernWriter:
# TODO: improve methods for quotes; probably merge them; also accented small caps; look
# also at other types of quotes, such as Polish and French; start with improving
- # aacute.SC + quotedblleft and adieresis.SC + quotedblleft
+ # aacute.sc + quotedblleft and adieresis.sc + quotedblleft
# TODO: several methods could be merged (simpler code, but worse result to report to Victor)
- kernpairscapital = [
+ kern_pairs_capital = [
+ # BE CAREFULL: It is used also for small caps and may cause problems
+ # when moving to class kerning
["V A", "V Aacute", "V Abreve", "V Acircumflex", "V Adieresis", "V AE", "V Agrave", "V Amacron", "V Aogonek", "V Aring", "V Atilde"],
["A Y", "A Yacute", "A Ydieresis", "Aacute Y", "Abreve Y", "Acircumflex Y", "Adieresis Y", "Agrave Y", "Amacron Y", "Aogonek Y", "Aring Y", "Atilde Y", "Aacute Yacute"],
["L V", "Lcommaaccent V", "Lslash V"],
@@ -70,54 +137,34 @@ class KernWriter:
# 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"],
- ["V o", "V oacute", "V ocircumflex", "V odieresis", "V oe", "V ograve", "V ohungarumlaut", "V omacron", "V oslash", "V otilde"],
+
+ kern_pairs_initial_cap = [
["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"],
["Y e", "Y eacute", "Y ecaron", "Y ecircumflex", "Y edieresis", "Y edotaccent", "Y egrave", "Y emacron", "Y eogonek", "Yacute e", "Ydieresis e", "Yacute eacute", "Yacute ecaron"],
["Y o", "Y oacute", "Y ocircumflex", "Y odieresis", "Y oe", "Y ograve", "Y ohungarumlaut", "Y omacron", "Y oslash", "Y otilde", "Yacute o", "Ydieresis o", "Yacute oacute"],
# not used the combination "Y u" that is only in GentiumPlus regular
- ["A v", "Aacute v", "Abreve v", "Acircumflex v", "Adieresis v", "Agrave v", "Amacron v", "Aogonek v", "Aring v", "Atilde v"],
- ["A w", "Aacute w", "Abreve w", "Acircumflex w", "Adieresis w", "Agrave w", "Amacron w", "Aogonek w", "Aring w", "Atilde w"],
["A y", "A yacute", "A ydieresis", "Aacute y", "Abreve y", "Acircumflex y", "Adieresis y", "Agrave y", "Amacron y", "Aogonek y", "Aring y", "Atilde y", "Aacute yacute"],
- ["F a", "F aacute", "F abreve", "F acircumflex", "F adieresis", "F ae", "F agrave", "F amacron", "F aogonek", "F aring", "F atilde"],
- ["F e", "F eacute", "F ecaron", "F ecircumflex", "F edieresis", "F edotaccent", "F egrave", "F emacron", "F eogonek"],
- ["F o", "F oacute", "F ocircumflex", "F odieresis", "F oe", "F ograve", "F ohungarumlaut", "F omacron", "F oslash", "F otilde"],
["T a", "T aacute", "T abreve", "T acircumflex", "T adieresis", "T ae", "T agrave", "T amacron", "T aogonek", "T aring", "T atilde", "Tcaron a", "uni0162 a", "uni021A a", "Tcaron aacute"],
["T e", "T eacute", "T ecaron", "T ecircumflex", "T edieresis", "T edotaccent", "T egrave", "T emacron", "T eogonek", "Tcaron e", "uni0162 e", "uni021A e"],
["T o", "T oacute", "T ocircumflex", "T odieresis", "T oe", "T ograve", "T ohungarumlaut", "T omacron", "T oslash", "T otilde", "Tcaron o", "uni0162 o", "uni021A o", "Tcaron oacute"],
- ["W a", "W aacute", "W abreve", "W acircumflex", "W adieresis", "W ae", "W agrave", "W amacron", "W aogonek", "W aring", "W atilde"],
- ["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"],
+
+ kern_pairs_small = [
["k e", "k eacute", "k ecaron", "k ecircumflex", "k edieresis", "k edotaccent", "k egrave", "k emacron", "k eogonek", "kcommaaccent e"],
- ["o v", "oacute v", "ocircumflex v", "odieresis v", "ograve v", "oslash v", "otilde v"],
- ["o x", "oacute x", "ocircumflex x", "odieresis x", "ograve x", "oslash x", "otilde x"],
- ["v a", "v aacute", "v abreve", "v acircumflex", "v adieresis", "v ae", "v agrave", "v amacron", "v aogonek", "v aring", "v atilde"],
- ["v o", "v oacute", "v ocircumflex", "v odieresis", "v oe", "v ograve", "v ohungarumlaut", "v omacron", "v oslash", "v otilde"],
["r a", "r aacute", "r abreve", "r acircumflex", "r adieresis", "r ae", "r agrave", "r amacron", "r aogonek", "r aring", "r atilde", "racute a", "rcaron a", "rcommaaccent a", "rcaron aacute"],
["r e", "r eacute", "r ecaron", "r edieresis", "r edotaccent", "r egrave", "r emacron", "r eogonek", "racute e", "rcaron e", "rcommaaccent e", "rcaron eacute"],
["r c", "r cacute", "r ccaron", "r ccedilla", "r cdotaccent", "racute c", "rcaron c", "rcommaaccent c", "rcaron ccaron"],
- ["r q", "racute q", "rcaron q", "rcommaaccent q"],
["y e", "y eacute", "y ecaron", "y ecircumflex", "y edieresis", "y edotaccent", "y egrave", "y emacron", "y eogonek", "yacute e", "ydieresis e", "yacute eacute"],
["y o", "y oacute", "y ocircumflex", "y odieresis", "y oe", "y ograve", "y ohungarumlaut", "y omacron", "y oslash", "y otilde", "yacute o", "ydieresis o", "yacute oacute"],
- ["a v", "aacute v", "abreve v", "acircumflex v", "adieresis v", "agrave v", "amacron v", "aogonek v", "aring v", "atilde v"],
- ["a w", "aacute w", "abreve w", "acircumflex w", "adieresis w", "agrave w", "amacron w", "aogonek w", "aring w", "atilde w"],
- ["c h", "cacute h", "ccaron h", "ccedilla h", "cdotaccent h"],
- ["c k", "cacute k", "ccaron k", "ccedilla k", "cdotaccent k"],
- ["e x", "eacute x", "ecaron x", "ecircumflex x", "edieresis x", "edotaccent x", "egrave x", "emacron x", "eogonek x"],
- ["o w", "oacute w", "ocircumflex w", "odieresis w", "ograve w", "oslash w", "otilde w"],
["r o", "r oacute", "r ocircumflex", "r odieresis", "r oe", "r ograve", "r ohungarumlaut", "r omacron", "r oslash", "r otilde", "racute o", "rcaron o", "rcommaaccent o", "rcaron oacute"],
- ["x e", "x eacute", "x ecaron", "x ecircumflex", "x edieresis", "x edotaccent", "x egrave", "x emacron", "x eogonek"],
["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 = [
+
+ kern_pairs_quotes = [
+ # TODO pairs that have collisions can be removed in "make_derived_latin_kerns" create list for it!
# this is far from complete
- # TODO: use this list also for accented small caps (using kernfactor)
+ # TODO: use this list also for accented small caps (using SMALL_CAPS_CORRECTION)
["A quotedblright", "A quotedblleft", "Aacute quotedblleft", "Adieresis quotedblleft"],
["L quotedblright", "L quotedblleft"], # Lcaron and Lacute left out (collision)
["A quoteright", "A quoteleft", "Aacute quoteleft", "Adieresis quoteleft"],
@@ -127,75 +174,221 @@ class KernWriter:
["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"],
- ["r period", "racute period", "rcaron period", "rcommaaccent period"],
- ["y period", "yacute period", "ydieresis period"]
+
+ # TODO: It is possible to create several kerning classes for one letter. For example 'A' can be used
+ # for letter A with all possible accents and 'A_unaccented' can be used for just the letter 'A',
+ # 'A_subset' can be used for just some accented variants of 'A'. The base kern is now removed,
+ # therefore there shouldn't be problems with non-existing letters like 'A_unaccented' (but check
+ # that it is true).
+ #
+ # This would enable to move more kerns to kerning classes.
+ #
+ # Deriving all kerns from e.g. 'a e' would give too many kerns. It might help to check
+ # which combinations can really exist in some language, but it would require some research
+ # and a lot of work.
+ latin_class_kerns = [
+ # sort lines before commit!
+ "A v",
+ "A w",
+ "F a",
+ "F e",
+ "F o",
+ "V a",
+ "V e",
+ "V o",
+ "W a",
+ "W e",
+ "W o",
+ "a v",
+ "a w",
+ "c h",
+ "c k",
+ "e x",
+ "o v",
+ "o w",
+ "o x",
+ "r comma",
+ "r period",
+ "r q",
+ "v a",
+ "v e",
+ "v o",
+ "x e",
+ "y comma",
+ "y period",
# nothing to be derived from "f quoteright" and "f quotedblright"
]
+
+ # similar Latin letters that come first in the kerning pair
+ latin_left_classes = {
+ # sort lines before commit!
+ "A": ["A", "Aacute", "Abreve", "Acircumflex", "Adieresis", "Agrave", "Amacron", "Aogonek", "Aring", "Atilde"],
+ "F": ["F"],
+ "V": ["V"],
+ "W": ["W"],
+ "a": ["a", "aacute", "abreve", "acircumflex", "adieresis", "agrave", "amacron", "aogonek", "aring", "atilde"],
+ "c": ["c", "cacute", "ccaron", "ccedilla", "cdotaccent"],
+ "e": ["e", "eacute", "ecaron", "ecircumflex", "edieresis", "edotaccent", "egrave", "emacron", "eogonek"],
+ "o": ["o", "oacute", "ocircumflex", "odieresis", "ograve", "oslash", "otilde"],
+ "r": ["r", "racute", "rcaron", "rcommaaccent"],
+ "v": ["v"],
+ "x": ["x"],
+ "y": ["y", "yacute", "ydieresis"],
+ }
+
+ # similar Latin letters that come second in the kerning pair
+ latin_right_classes = {
+ # sort lines before commit!
+ "a": ["a", "aacute", "abreve", "acircumflex", "adieresis", "ae", "agrave", "amacron", "aogonek", "aring", "atilde"],
+ "comma": ["comma"],
+ "e": ["e", "eacute", "ecaron", "ecircumflex", "edieresis", "edotaccent", "egrave", "emacron", "eogonek"],
+ "h": ["h"],
+ "k": ["k"],
+ "o": ["o", "oacute", "ocircumflex", "odieresis", "oe", "ograve", "ohungarumlaut", "omacron", "oslash", "otilde"],
+ "period": ["period"],
+ "q": ["q"],
+ "v": ["v"],
+ "w": ["w"],
+ "x": ["x"],
+ }
+
+
+ # first pair has Latin letters, the second pair has Cyrillic letters; probably not very obvious
+ # there is no kern for 'X O' in the fonts
+ kern_pairs_cyrillic = [
+ # sort lines before commit!
+ ["A C", "А С"],
+ ["A O", "А О"],
+ ["A T", "А Т"],
+ ["A V", "А Ч"], # make it better
+ ["A Y", "А Ү"],
+ ["A y", "А у"],
+ ["C A", "С А"],
+ ["O A", "О А"],
+ ["O X", "О Х"],
+ ["O Y", "О Ү"],
+ ["P A", "Р А"],
+ ["T A", "Г А"],
+ ["T A", "Г Д"], # make it better
+ ["T A", "Г Л"], # make it better
+ ["T A", "Т А"],
+ ["T A", "Т Д"], # make it better
+ ["T A", "Т Л"], # make it better
+ ["T a", "Г а"],
+ ["T a", "Т а"],
+ ["T e", "Г е"],
+ ["T e", "Т е"],
+ ["T o", "Г о"],
+ ["T o", "Т о"],
+ ["Y A", "У А"], # make it better
+ ["Y A", "Ү А"],
+ ["Y O", "Ү О"],
+ ["Y a", "Ү а"],
+ ["Y e", "Ү е"],
+ ["Y o", "У Д"], # make it better
+ ["Y o", "У Л"], # make it better
+ ["Y o", "Ү о"],
+ ["e x", "е х"],
+ ["o x", "о х"],
+ ["x e", "х е"],
+ ["x o", "х о"],
+ ["y o", "у д"], # make it better
+ ["y o", "у л"], # make it better
+ ]
+
+ # similar Cyrillic letters that come first in the kerning pair
+ cyrillic_left_classes = {
+ # sort lines before commit!
+ "А": ["А"],
+ "Г": ["Г", "Ӷ"],
+ "О": ["О"],
+ "Р": ["Р", "Ҏ"],
+ "С": ["С", "Ҫ"],
+ "Т": ["Т", "Ҭ"],
+ "У" : ["У"],
+ "е": ["е", "ё"],
+ "о": ["о"],
+ "у" : ["у"],
+ "х": ["х", "ҳ", "ӽ"],
+ "Ү": ["Ү"], # not Russian
+ }
+
+ # similar Cyrillic letters that come second in the kerning pair
+ cyrillic_right_classes = {
+ # sort lines before commit!
+ "А": ["А"],
+ "Д" : ["Д"],
+ "Л" : ["Л", "Љ", "Ӆ", "Ԓ"],
+ "О": ["О"],
+ "С": ["С", "Ҫ"],
+ "Т": ["Т", "Ҭ"],
+ "Х": ["Х", "Ҳ", "Ӽ"],
+ "Ч" : ["Ч", "Ҷ", "Ҹ", "Ӌ"],
+ "а": ["а", "ӕ"],
+ "д" : ["д"],
+ "е": ["е", "ё"],
+ "л" : ["л", "љ", "ӆ", "ԓ"],
+ "о": ["о"],
+ "у": ["у", "ў"],
+ "х": ["х", "ҳ", "ӽ"],
+ "Ү": ["Ү"], # not Russian
+ }
+
def __init__(self, filename):
- self.f = open(filename, "a") # append
- def writetofile(self, s):
- # This method writes one extra kerning pair to the output file.
+ self.filename = filename # the name of the file with extra kerning pairs
+ self.kern_lines = collections.Counter() # contains lines with extra kerning pairs
+
+ def add_to_kern_lines(self, s):
+ # This method adds one extra kerning pair to kern_lines.
# It also makes correction for small cap Tcommaaccent and Tcedilla.
- # Tcedilla is uni0162 and the small cap is uni0163.SC, not
- # uni0162.SC. Tcommaaccent is uni021A and the small cap is uni021B.SC,
- # not uni021a.SC (look also at the small "a"; there is problem not only
+ # Tcedilla is uni0162 and the small cap is uni0163.sc, not
+ # uni0162.sc. Tcommaaccent is uni021A and the small cap is uni021B.sc,
+ # not uni021a.sc (look also at the small "a"; there is problem not only
# in the unicode value, but also in the case, because method lower() is
# used).
- self.f.write(s.replace("uni021a.SC", "uni021B.SC").replace("uni0162.SC", "uni0163.SC"))
- def smallcaps(self, fromreader, kernfactor):
+ extra_line = s.replace("uni021a.sc", "uni021B.sc").replace("uni0162.sc", "uni0163.sc")
+ self.kern_lines.update([extra_line]) # must use '[]', otherwise iterates over letters
+
+ def write_kern_lines_to_file(self):
+ with open(self.filename, "a") as extra_kern_file: # append to file!
+ for line in self.kern_lines:
+ extra_kern_file.write(line)
+
+
+ def small_caps(self, fromreader):
a = fromreader.getkerns("KPX [A-Z] [A-Z]")
for s in a:
parts = s.split()
- self.writetofile("KPX " + parts[1].lower() + ".SC " + parts[2].lower() +
- ".SC " + str(int(round(kernfactor * float(parts[3])))) +
+ # Write two small caps
+ self.add_to_kern_lines("KPX " + parts[1].lower() + ".sc " + parts[2].lower() +
+ ".sc " + str(int(round(SMALL_CAPS_CORRECTION * float(parts[3])))) +
'\n')
- def initialcap(self, fromreader, kernfactor):
- a = fromreader.getkerns("KPX [A-Z] [A-Z]")
- for s in a:
- parts = s.split()
- self.writetofile("KPX " + parts[1] + " " + parts[2].lower() + ".SC " +
- str(int(round(kernfactor * float(parts[3])))) + '\n')
- def rightpunctuation(self, fromreader, kernfactor):
+ # Write capital letter + small cap
+ self.add_to_kern_lines("KPX " + parts[1] + " " + parts[2].lower() + ".sc " +
+ str(int(round(SMALL_CAPS_CORRECTION * float(parts[3])))) + '\n')
+
+ def right_punctuation(self, fromreader):
# small cap and punctuation
- a = fromreader.getkerns("KPX [A-Z] period")
+ a = fromreader.getkerns("KPX [A-Z] period")
a.extend(fromreader.getkerns("KPX [A-Z] comma"))
a.extend(fromreader.getkerns("KPX [A-Z] quotedblright"))
a.extend(fromreader.getkerns("KPX [A-Z] quoteright"))
for s in a:
parts = s.split()
- self.writetofile("KPX " + parts[1].lower() + ".SC " + parts[2] + " " +
- str(int(round(kernfactor * float(parts[3])))) + '\n')
- def leftpunctuation(self, fromreader, kernfactor):
+ self.add_to_kern_lines("KPX " + parts[1].lower() + ".sc " + parts[2] + " " +
+ str(int(round(SMALL_CAPS_CORRECTION * float(parts[3])))) + '\n')
+
+ def left_punctuation(self, fromreader):
# punctuation and small cap
- a = fromreader.getkerns("KPX quotedblleft [A-Z]")
+ a = fromreader.getkerns("KPX quotedblleft [A-Z]")
a.extend(fromreader.getkerns("KPX quoteleft [A-Z]"))
for s in a:
parts = s.split()
- self.writetofile("KPX " + parts[1] + " " + parts[2].lower() + ".SC " +
- str(int(round(kernfactor * float(parts[3])))) + '\n')
- def accentedcapitalletters(self, fromreader):
- for x in self.kernpairscapital:
- basekern = x[0]
- derivedkerns = x[1:]
- a = fromreader.getkerns("KPX " + basekern + " ")
- kernline = a[0]
- for b in derivedkerns:
- newkernline = kernline.replace(basekern, b)
- self.writetofile(newkernline)
- def accentedsmallletters(self, fromreader):
- for x in self.kernpairssmall:
- basekern = x[0]
- derivedkerns = x[1:]
- a = fromreader.getkerns("KPX " + basekern + " ")
- kernline = a[0]
- for b in derivedkerns:
- newkernline = kernline.replace(basekern, b)
- self.writetofile(newkernline)
- def accentedsmallcaps(self, fromreader, kernfactor):
- for x in self.kernpairscapital:
+ self.add_to_kern_lines("KPX " + parts[1] + " " + parts[2].lower() + ".sc " +
+ str(int(round(SMALL_CAPS_CORRECTION * float(parts[3])))) + '\n')
+
+ def accented_capital_letters(self, fromreader):
+ for x in self.kern_pairs_capital:
basekern = x[0]
derivedkerns = x[1:]
a = fromreader.getkerns("KPX " + basekern + " ")
@@ -203,72 +396,116 @@ class KernWriter:
for b in derivedkerns:
newkernline = kernline.replace(basekern, b)
parts = newkernline.split()
- self.writetofile("KPX " + parts[1].lower() + ".SC " + parts[2].lower() +
- ".SC " + str(int(round(kernfactor * float(parts[3])))) +
+ # Write two capital letters
+ self.add_to_kern_lines(newkernline)
+ # Write two small caps
+ self.add_to_kern_lines("KPX " + parts[1].lower() + ".sc " + parts[2].lower() +
+ ".sc " + str(int(round(SMALL_CAPS_CORRECTION * float(parts[3])))) +
'\n')
- def accentedinitialcap(self, fromreader):
- for x in self.kernpairsinitialcap:
+ # Write capital letter + small cap
+ self.add_to_kern_lines("KPX " + parts[1] + " " + parts[2].lower() + ".sc " +
+ str(int(round(SMALL_CAPS_CORRECTION * float(parts[3])))) + '\n')
+
+ def accented_small_letters(self, fromreader):
+ for x in self.kern_pairs_small:
basekern = x[0]
derivedkerns = x[1:]
a = fromreader.getkerns("KPX " + basekern + " ")
kernline = a[0]
for b in derivedkerns:
newkernline = kernline.replace(basekern, b)
- self.writetofile(newkernline)
- def accentedinitialcapsmallcap(self, fromreader, kernfactor):
- for x in self.kernpairscapital:
+ self.add_to_kern_lines(newkernline)
+
+ def accented_initial_cap(self, fromreader):
+ for x in self.kern_pairs_initial_cap:
basekern = x[0]
derivedkerns = x[1:]
a = fromreader.getkerns("KPX " + basekern + " ")
kernline = a[0]
for b in derivedkerns:
newkernline = kernline.replace(basekern, b)
- parts = newkernline.split()
- self.writetofile("KPX " + parts[1] + " " + parts[2].lower() + ".SC " +
- str(int(round(kernfactor * float(parts[3])))) + '\n')
- def accentedrightpunctuation(self, fromreader):
- for x in self.rightpunctuationsmall:
- basekern = x[0]
- derivedkerns = x[1:]
+ self.add_to_kern_lines(newkernline)
+
+ def make_derived_latin_kerns(self, latin_kern):
+ left_base_letter, right_base_letter = latin_kern.split()
+
+ derived_kerns = [ left + " " + right
+ for left in self.latin_left_classes[left_base_letter]
+ for right in self.latin_right_classes[right_base_letter] ]
+
+ return derived_kerns[1:] # remove the base kern that is already in the font
+
+ def make_latin_class_kerns(self, fromreader):
+ for basekern in self.latin_class_kerns:
+ derivedkerns = self.make_derived_latin_kerns(basekern)
a = fromreader.getkerns("KPX " + basekern + " ")
kernline = a[0]
+
for b in derivedkerns:
newkernline = kernline.replace(basekern, b)
- self.writetofile(newkernline)
- def accentedleftpunctuation(self, fromreader):
+ self.add_to_kern_lines(newkernline)
+
+ def accented_left_punctuation(self, fromreader):
# nothing to be done
pass
- def czechquotes(self, fromreader):
- for x in self.kernpairsquotes:
+
+ def czech_quotes(self, fromreader):
+ for x in self.kern_pairs_quotes:
basekern = x[0]
derivedkerns = x[1:]
a = fromreader.getkerns("KPX " + basekern + " ")
kernline = a[0]
for b in derivedkerns:
newkernline = kernline.replace(basekern, b)
- self.writetofile(newkernline)
- def close(self):
- self.f.close()
+ 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 kern_pairs_cyrillic array. First pair must be Latin letters,
+ # all the remaining pairs must be Cyrillic letters.
+
+ def make_derived_cyrillic_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
+ for left in self.cyrillic_left_classes[left_base_letter]
+ for right in self.cyrillic_right_classes[right_base_letter] ]
-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
+ def cyrillic_kerns(self, fromreader):
+ for x in self.kern_pairs_cyrillic:
+ basekern = x[0]
+ derivedkerns = self.make_derived_cyrillic_kerns(x[1])
+ base_kern_line = fromreader.getkerns("KPX " + basekern + " ")
+
+ # skip the Cyrillic kerns if the corresponding Latin kern is not found
+ if not base_kern_line:
+ continue
+
+ 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)
+ newkernline = kernline.replace(basekern, new_kern)
+ self.add_to_kern_lines(newkernline)
-fin = KernReader(sys.argv[1])
+fin = KernReader(input_file_name)
-fout = KernWriter(sys.argv[2])
+# output_generator is not a file ane more! Rename!
+output_generator = KernWriter(output_file_name)
# letters without accents
-fout.smallcaps(fin, kernfactor)
-fout.initialcap(fin, kernfactor)
-fout.rightpunctuation(fin, kernfactor)
-fout.leftpunctuation(fin, kernfactor)
+output_generator.small_caps(fin)
+output_generator.right_punctuation(fin)
+output_generator.left_punctuation(fin)
# letters with accents
-fout.accentedcapitalletters(fin)
-fout.accentedsmallletters(fin)
-fout.accentedsmallcaps(fin, kernfactor)
-fout.accentedinitialcap(fin)
-fout.accentedinitialcapsmallcap(fin, kernfactor)
-fout.accentedrightpunctuation(fin)
-fout.accentedleftpunctuation(fin)
-fout.czechquotes(fin)
-fout.close()
+output_generator.accented_capital_letters(fin)
+output_generator.accented_small_letters(fin)
+output_generator.accented_initial_cap(fin)
+output_generator.make_latin_class_kerns(fin)
+output_generator.accented_left_punctuation(fin)
+output_generator.czech_quotes(fin)
+output_generator.cyrillic_kerns(fin)
+output_generator.write_kern_lines_to_file()