[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BlueSky fonts and subfont (really FixFont and dvips)

Across two messages, Berthold wrote:
> [...] DVIPS output is not resolution-independent.  It uses rounded
> off advance widths for the characters.  Normally these `rounding
> effects' tend to cancel out since they tend to be random.  But you
> can see them build up when the same letter is used repeatedly or in
> a fixed width font, where all the `rounding effects' have the same
> sign.  The advance widths in the Type 1 fonts are exact (fractional)
> and hence do not match the PK fonts advance widths exactly.
> You don't see this problem when you produce output from DVIPS directly
> using Type 1 fonts, since it forces the same fixed resolution onto
> the Type 1 fonts by redefining their metrics.
> [Working out how fix FixFont so it too fiddled with the metrics
> of the font] a worthy project for someone stuck with a huge pile of
> legacy documents.  For me, I rather produce clean PS and clean PDF from
> scratch :-)

Well, I did it, I wrote postscript code that tied into the CDevProc
hook in the font to round the advance widths appropriately. I still didn't
get good results though, and it turned out that the code for font selection
inserted by the `FixFonts' program was just plain wrong.

The details are short enough for me to enclose for anyone who cares.



First, we have the macro to alter the advance widths; it actually does
nothing on older Level-1, but I can't say as I care about that. Thus:

    % NEWNAME OLDNAME hackfont -
    /hackfont {findfont dup length 1 add dict begin {1 index /FID ne 2
      index /UniqueID ne and {def} {pop pop} ifelse} forall /CDevProc
      {pop 10 -1 roll matrix defaultmatrix dup dup 0 get exch 2 get add
      abs 72 mul exch currentmatrix dup 0 get exch 2 get add abs div dup
      3 1 roll div Resolution mul round Resolution div mul 10 1 roll}
      def currentdict end definefont pop} def

... and then the macro to scale the font to the appropriate size:
    /dvipsmakefont {[Resolution 72.27 div 2 index mul 0 0 Resolution
      -72.27 div 6 -1 roll mul 0 0] makefont} def

Thus, whereas before, FixFont would have output:
    /Fa { /CMR10 findfont 10.0 scalefont DvipsFontMatrix makefont setfont } def

... we replace that with:
    /CMR10fixed /CMR10 hackfont
    /Fa { /CMR10fixed findfont 10.0 dvipsmakefont setfont } def

And that, is all there is to it (I think). Whoop-de-do.