Fontinst challenge...

Lars Hellström Lars.Hellstrom@math.umu.se
Tue, 27 Jun 2000 15:03:01 -0400


At 21.02 +0200 0-06-21, Han The Thanh wrote:
>Hi,
>
>I did the following, according to your hints:
>
>==================== cut here ==========================
>\input fontinst.sty
>
>\installfonts
>\transformfont{putr8ax}
>    {\yscalefont{800}{\xscalefont{1200}{\fromafm{putr8a}}}}
>
>\reglyphfonts
>\renameglyph{Acute}{acute}
>\renameglyph{Grave}{grave}
>\renameglyph{Dieresis}{dieresis}
>\renameglyph{Caron}{caron}
>\renameglyph{Circumflex}{circumflex}
>\renameglyph{Ring}{ring}
>
>\resetcommand\iftokeep#1{\ifnumber{#1}>{0}}
>\killglyphweighted{grave}{1}
>\killglyphweighted{acute}{1}
>\killglyphweighted{circumflex}{1}
>\killglyphweighted{dieresis}{1}
>\killglyphweighted{ring}{1}

It appears I wasn't as clear about what I commented on as I should have
been. The \killglyphweighted commands + changing \iftokill was only given
as an alternative to

\reglyphfonts
\input kill.tex
\reglyphfont{putr8A}{putr8rx}
\endreglyphfonts

since I thought the very long list of \killglyph commands in kill.tex was
an unnecessarily prolix solution. I didn't notice that the code I commented
on also contained an \input ac2Ac.tex, which consists of the \renameglyph
commands you gave above. Thus to reach the combined effect of kill.tex and
ac2Ac.tex, you really wouldn't need the \killglyphweighted's (as the
default weight for \renameglyph already is 1), indeed by doing both you
probably mess things up, as the \killglyphweighted's will overwrite the
settings made by the \renameglyph's (the glyphs won't be renamed)!

>\offmtxcommand{\setkern}
>\offmtxcommand{\setglyph}
>\offmtxcommand{\setint}
>
>\reglyphfont{putr8A}{putr8ax}
>
>\endreglyphfonts
>
>\installfont{putr8z}{putr8a,putr8A,latin,test}{xl2}{IL2}{put}{m}{n}{}
>
>\endinstallfonts
>
>\bye
>==================== cut here ==========================
>
>
>where test.mtx looks like:
>
>==================== cut here ==========================
>\relax
>
>\metrics
>
>\setglyph{Ccaron-test}
>   \topaccent{C}{Caron}{1000}
>\endsetglyph
>\endmetrics
>==================== cut here ==========================
>
>
>and the map entries are:
>
>putr8ax "1.5 ExtendFont" <putr8a.pfb <8a.enc
>putr8a <putr8a.pfb <8a.enc
>
The <8a.enc words here worries me, since unless something is really wrong
the encodings should appear first, and the 8a encoding shouldn't have an
encoding file to be downloaded at all because (i) it's the font's default
encoding and (ii) because it is predeclared in every postscript interpreter
(it's the StandardEncoding). Did you by any chance give a \specifypsfont
command? It shouldn't be necessary in this case, since you can get the
suffix .pfb simply through the command

  \resetstr{PSfontsuffix}{.pfb}

>
>It seems to do what I want, ie to have the glyph Ccaron with the smaller and
>wider caron accent. But the placement is rather poor, the caron is placed
>rather at the left side of the glyph.

Don't you mean the right? You have after all told it to center the accent
over the right edge of the character box (the TeX box, not the bbox).

>Can you please provide a way to access to BBox of glyphs read from an afm?

I notice that it's a frequent request, but it seems that you have already
done something about it youself by now. What you sent me looks like it
should be contrib'ed, but there are a few points I think you should think
about:
- What's the raw font name argument of \setglyphbbox good for?
- Is there really a need for duplicating the height and depth information
like that? (You store it once in \g-<glyph> and once in \gb-<glyph>.)
- Is that really the best way to transform the glyph bbox when shearing?
(As an alternative, I would suggest considering the x-coordinates as
coordinates of points on the baseline.)
- There should be an \ifglyphhasbbox test (use \if_defined).
- Several of the commands rather belong in an MTX file (but that could well
be generated from the same .dtx file as the .sty).

Those are minor matters, though. On the whole it looks fine.

>I think that's better to compose glyphs based on their BBox rather than
>width and xheight.

Well, it's not as if the bbox is totally ignored---the standard height and
depth of raw glyphs are almost always the top and bottom of the bbox. I
suspect that the reason \topaccent uses the xheight for vertical
positioning is that it is modelled after the \accent primitive.

>Another question is I'd like to use the space character as left as well as
>right boundary char, but the following doesn't work:
>
>\setleftboundary{space}
>\makerightboundary{space}
>\endsetleftboundary
>\endencoding

No, because the left boundary is simply an entrypoint into the ligkern
table, whereas the right boundary has to be a slot (integer in the range
0--255), since that is all that KRN and LIG commands can look for.

>So I did:
>
>...
>
>\setslot{space}
>\makerightboundary{space}
>\endsetslot

As long as you have a spare slot in your encoding, you should use

   \setrightboundary{space}

but that's explained in Subsection 3.2 of fisource.tex.

Lars Hellström