[XeTeX] [off-topic] proper OpenType tag for hanging diacritics
Benct Philip Jonsson
bpj at melroch.se
Wed Oct 7 11:57:48 CEST 2009
On 2009-10-06 Pablo Rodríguez wrote:
> John Was wrote:
> > > Hello Pablo
>
> Hi, John. Thanks for your reply.
>
> > > Until this can be fixed properly from within the font
> itself, you might
> > > try the following approach (this takes as its example
> Unicode character
> > > 1F1D, viz. asper acute in front of capital epsilon):
> > >
> > > \catcode"1F1D=\active
> > >
> > > \def
{\leavevmode \hbox to 0.2em{\hfill
> \char"1FDE\hfill}\char"0395}
>
> Thanks also for thinking that I was the one composing
> such beautiful
> texts. I wish I could ;-). I'm afraid I can't.
>
> I guess that your fix would take so much time as fixing
> the font itself
> (as it is released under the Open Font License).
Not quite as much. Since it's a repetetive task it's a
task for a computer, and so I couldn't resist the
temptation to write a Perl script which generates the
TeX code for the fix -- or at least the part of it
without the poetry conditional. Since it was more
about how it could be done rather than actually
doing it I have checked the output only cursorily
and not tested it at all. I put the width of the
\hbox in a new dimen, so that one can change that in
only one place. Hope I did it right and that it works!
Time wasted: 20 min! ;-) Script and output are below.
/BP
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use open ':utf8';
use open ':std';
use Unicode::Normalize;
use Unicode::UCD 'charinfo';
my %marksh = (
"\x{313}\x{301}" => "1FCE", # PSILI AND OXIA
"\x{313}\x{300}" => "1FCD", # PSILI AND VARIA
"\x{313}" => "1FBF", # PSILI
"\x{314}\x{301}" => "1FDE", # DASIA AND OXIA
"\x{314}" => "1FFE", # DASIA
"\x{314}\x{300}" => "1FDD", # DASIA AND VARIA
"\x{314}\x{342}" => "1FDF", # DASIA AND PERISPOMENI
"\x{313}\x{342}" => "1FCF", # PSILI AND PERISPOMENI'
);
print '\newdimen\greekmarkwidth \greekmarkwidth=0.2em',"\n\n";
for my $num (0x1f00..0x1fff)
{
my $char = chr $num;
next unless $char =~ /\p{Lu}/;
my %info = %{charinfo($num)};
my $nfd = NFD($char);
my($letter,$marks) = $nfd =~ /(\p{L}+)(\p{M}+)/;
next unless exists $marksh{$marks};
my $mark = $marksh{$marks};
$letter = sprintf "%04X", ord $letter;
printf "\\catcode\"%s=\\active%% %s\n\n", @info{'code','name'};
printf "\\def %s{\\leavevmode \\hbox to
\\greekmarkwidth{\\hfill \\char\"%s\\hfill}\\char\"%s}\n\n",
$char, $mark, $letter;
}
__END__
\newdimen\greekmarkwidth \greekmarkwidth=0.2em
\catcode"1F08=\active% GREEK CAPITAL LETTER ALPHA WITH PSILI
\def Ἀ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FBF\hfill}\char"0391}
\catcode"1F09=\active% GREEK CAPITAL LETTER ALPHA WITH DASIA
\def Ἁ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FFE\hfill}\char"0391}
\catcode"1F0A=\active% GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA
\def Ἂ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCD\hfill}\char"0391}
\catcode"1F0B=\active% GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA
\def Ἃ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDD\hfill}\char"0391}
\catcode"1F0C=\active% GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA
\def Ἄ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCE\hfill}\char"0391}
\catcode"1F0D=\active% GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA
\def Ἅ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDE\hfill}\char"0391}
\catcode"1F0E=\active% GREEK CAPITAL LETTER ALPHA WITH PSILI AND
PERISPOMENI
\def Ἆ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCF\hfill}\char"0391}
\catcode"1F0F=\active% GREEK CAPITAL LETTER ALPHA WITH DASIA AND
PERISPOMENI
\def Ἇ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDF\hfill}\char"0391}
\catcode"1F18=\active% GREEK CAPITAL LETTER EPSILON WITH PSILI
\def Ἐ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FBF\hfill}\char"0395}
\catcode"1F19=\active% GREEK CAPITAL LETTER EPSILON WITH DASIA
\def Ἑ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FFE\hfill}\char"0395}
\catcode"1F1A=\active% GREEK CAPITAL LETTER EPSILON WITH PSILI AND
VARIA
\def Ἒ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCD\hfill}\char"0395}
\catcode"1F1B=\active% GREEK CAPITAL LETTER EPSILON WITH DASIA AND
VARIA
\def Ἓ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDD\hfill}\char"0395}
\catcode"1F1C=\active% GREEK CAPITAL LETTER EPSILON WITH PSILI AND
OXIA
\def Ἔ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCE\hfill}\char"0395}
\catcode"1F1D=\active% GREEK CAPITAL LETTER EPSILON WITH DASIA AND
OXIA
\def Ἕ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDE\hfill}\char"0395}
\catcode"1F28=\active% GREEK CAPITAL LETTER ETA WITH PSILI
\def Ἠ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FBF\hfill}\char"0397}
\catcode"1F29=\active% GREEK CAPITAL LETTER ETA WITH DASIA
\def Ἡ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FFE\hfill}\char"0397}
\catcode"1F2A=\active% GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA
\def Ἢ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCD\hfill}\char"0397}
\catcode"1F2B=\active% GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA
\def Ἣ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDD\hfill}\char"0397}
\catcode"1F2C=\active% GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA
\def Ἤ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCE\hfill}\char"0397}
\catcode"1F2D=\active% GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA
\def Ἥ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDE\hfill}\char"0397}
\catcode"1F2E=\active% GREEK CAPITAL LETTER ETA WITH PSILI AND
PERISPOMENI
\def Ἦ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCF\hfill}\char"0397}
\catcode"1F2F=\active% GREEK CAPITAL LETTER ETA WITH DASIA AND
PERISPOMENI
\def Ἧ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDF\hfill}\char"0397}
\catcode"1F38=\active% GREEK CAPITAL LETTER IOTA WITH PSILI
\def Ἰ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FBF\hfill}\char"0399}
\catcode"1F39=\active% GREEK CAPITAL LETTER IOTA WITH DASIA
\def Ἱ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FFE\hfill}\char"0399}
\catcode"1F3A=\active% GREEK CAPITAL LETTER IOTA WITH PSILI AND VARIA
\def Ἲ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCD\hfill}\char"0399}
\catcode"1F3B=\active% GREEK CAPITAL LETTER IOTA WITH DASIA AND VARIA
\def Ἳ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDD\hfill}\char"0399}
\catcode"1F3C=\active% GREEK CAPITAL LETTER IOTA WITH PSILI AND OXIA
\def Ἴ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCE\hfill}\char"0399}
\catcode"1F3D=\active% GREEK CAPITAL LETTER IOTA WITH DASIA AND OXIA
\def Ἵ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDE\hfill}\char"0399}
\catcode"1F3E=\active% GREEK CAPITAL LETTER IOTA WITH PSILI AND
PERISPOMENI
\def Ἶ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCF\hfill}\char"0399}
\catcode"1F3F=\active% GREEK CAPITAL LETTER IOTA WITH DASIA AND
PERISPOMENI
\def Ἷ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDF\hfill}\char"0399}
\catcode"1F48=\active% GREEK CAPITAL LETTER OMICRON WITH PSILI
\def Ὀ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FBF\hfill}\char"039F}
\catcode"1F49=\active% GREEK CAPITAL LETTER OMICRON WITH DASIA
\def Ὁ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FFE\hfill}\char"039F}
\catcode"1F4A=\active% GREEK CAPITAL LETTER OMICRON WITH PSILI AND
VARIA
\def Ὂ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCD\hfill}\char"039F}
\catcode"1F4B=\active% GREEK CAPITAL LETTER OMICRON WITH DASIA AND
VARIA
\def Ὃ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDD\hfill}\char"039F}
\catcode"1F4C=\active% GREEK CAPITAL LETTER OMICRON WITH PSILI AND
OXIA
\def Ὄ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCE\hfill}\char"039F}
\catcode"1F4D=\active% GREEK CAPITAL LETTER OMICRON WITH DASIA AND
OXIA
\def Ὅ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDE\hfill}\char"039F}
\catcode"1F59=\active% GREEK CAPITAL LETTER UPSILON WITH DASIA
\def Ὑ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FFE\hfill}\char"03A5}
\catcode"1F5B=\active% GREEK CAPITAL LETTER UPSILON WITH DASIA AND
VARIA
\def Ὓ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDD\hfill}\char"03A5}
\catcode"1F5D=\active% GREEK CAPITAL LETTER UPSILON WITH DASIA AND
OXIA
\def Ὕ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDE\hfill}\char"03A5}
\catcode"1F5F=\active% GREEK CAPITAL LETTER UPSILON WITH DASIA AND
PERISPOMENI
\def Ὗ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDF\hfill}\char"03A5}
\catcode"1F68=\active% GREEK CAPITAL LETTER OMEGA WITH PSILI
\def Ὠ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FBF\hfill}\char"03A9}
\catcode"1F69=\active% GREEK CAPITAL LETTER OMEGA WITH DASIA
\def Ὡ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FFE\hfill}\char"03A9}
\catcode"1F6A=\active% GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA
\def Ὢ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCD\hfill}\char"03A9}
\catcode"1F6B=\active% GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA
\def Ὣ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDD\hfill}\char"03A9}
\catcode"1F6C=\active% GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA
\def Ὤ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCE\hfill}\char"03A9}
\catcode"1F6D=\active% GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA
\def Ὥ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDE\hfill}\char"03A9}
\catcode"1F6E=\active% GREEK CAPITAL LETTER OMEGA WITH PSILI AND
PERISPOMENI
\def Ὦ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FCF\hfill}\char"03A9}
\catcode"1F6F=\active% GREEK CAPITAL LETTER OMEGA WITH DASIA AND
PERISPOMENI
\def Ὧ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FDF\hfill}\char"03A9}
\catcode"1FEC=\active% GREEK CAPITAL LETTER RHO WITH DASIA
\def Ῥ{\leavevmode \hbox to \greekmarkwidth{\hfill
\char"1FFE\hfill}\char"03A1}
More information about the XeTeX
mailing list