[gentium] font variants for pdflatex

Thorsten Glaser tg at evolvis.org
Wed May 17 01:29:13 CEST 2023


On Tue, 16 May 2023, Karl Berry wrote:

>I didn't write the code, but my understanding is that the .enc files are
>manually created. The .tfm/.fd/.map are generated from that, using the
>Ruby script source/fonts/gentium-tug/generate-support-files.rb:

Ah, that helps. I still might want to make a shell script out of
that for myself.

>Thus, you'd have to make .enc files for what you want and tweak
>the script to get the output names you want. Does not sound either fun
>or easy to me.

Not fun but not difficult either, just time-consuming. Basically
read the substitution tables (in FontForge they should be shown)
and substitute the corresponding PS names in.

>I haven't seen a general framework made for handling ss features when
>making (pdf)(la)tex support from otf/ttf. Since different fonts give
>completely different meanings to the same ss, there are limits to what

That should not matter because the featuresets, AIUI, only swap
glyphs around, so following them should just be a matter of taking
the un-featured .enc files then following the trail of substitutions
to arrive at a featured .enc file.

>can be done. OTOH, I can imagine some things that could be done across
>fonts.

For the manual process, I’m doing this:

$ fontforge GentiumPlus-Regular.ttf
El̲ement → F̲ont Info…
Lookups (left side)
scroll down to 「'ss01' Style Set 1 lookup 64」 on the right side
click the +
click on 「'ss01' Style Set 1 lookup 64 subtable」
click the 「E̲dit Data」 button on the right

Then I see things like that 「a」 is replaced by 「a.SngStory」
which translates to changing all lines matching exactly
「/a」 in the .enc files to 「/a.SngStory」. Continue on to
the 「a.sc」 to 「a.SngStory.sc」 substitution, and on and on…

There has to be something simpler, less GUI…

$ ttfdump GentiumPlus-Regular.ttf GentiumPlus-Regular.txt

The .txt file has…

  42. 'ss01' feature - lookupCount: 1
                lookupListIndex: 64
                featureParams Offset: 0x0a38

…and…

  64. lookupType: 1, lookupFlag: 0x0000
        subTableCount:  1
       0. lookupFormat: 2 - Single Substitution List
          Coverage - rangeCount: 36
               0. start: 68, end: 68, startCoverageIndex: 0
               1. start: 74, end: 74, startCoverageIndex: 1
[…]
              35. start: 3877, end: 3887, startCoverageIndex: 132
          glyphCount: 143
                  substitute: 300, 852, 301, 302, 304, 328, 326, 332,
[…]
                              3894, 3895, 3896, 3897, 3898, 3899, 3888

…and…
                 Glyf  68  -> Mac Glyph #  68
[…]
                 Glyf 300  -> PSGlyf Name #  77, 'a.SngStory'
[…]
                 Glyf 3877  -> PSGlyf Name # 3622, 'g.sc'
[…]
                 Glyf 3888  -> PSGlyf Name # 3633, 'uniA7A1.SngBowl.sc'

My guess is that Mac Glyph 68 is 'a'… but this is too hard to follow.

I tried with Font::TTF but I utterly fail at that, too ☹

use Data::Dumper;
use Font::TTF::Font;

$f = Font::TTF::Font->open($ARGV[0]);
$f->tables_do(sub { $_[0]->read; });

@lookups = $f->{'GSUB'}->{'FEATURES'}->{'ss01'}->{'LOOKUPS'};

foreach my $lkidx (0..$#lookups) {
	my $lknr = $f->{'GSUB'}->{'FEATURES'}->{'ss01'}->{'LOOKUPS'}[$lkidx];
	my $lk = $f->{'GSUB'}->{'LOOKUP'}[$lknr];
	my @subs = $lk->{'SUB'};
	foreach my $subidx (0..$#subs) {
		my $sub = $lk->{'SUB'}[$subidx];
		my $cov = $sub->{'COVERAGE'}->{'val'};

#               print Dumper([$sub->{'RULES'}, $sub->{'COVERAGE'}]);
#               print Dumper([$sub->{'COVERAGE'}->{'val'}]);
		my $k, $v;
		while (($k, $v) = each($cov)) {
			print "<$k>=<$v>\n";   
		}
	}
}

Perl is very unhappy with this and I have no idea how to
iterate over the coverage table and I don’t know why I
cannot just use foreach my $lknr (@lookups) either…

>Bob, have you done anything along these lines? Any ideas?

bye,
//mirabilos
-- 
15:41⎜<Lo-lan-do:#fusionforge> Somebody write a testsuite for helloworld :-)



More information about the gentium mailing list.