[comp.sys.amiga.tech] Font Smoothing Algorithm

doug@eris (Doug Merritt) (04/05/88)

In article <8310@agate.BERKELEY.EDU> doug@eris.berkeley.edu (Doug Merritt) writes:
>The standard conceptual model for doing this with *any* bitmap images,
>including but not limited to fonts, is to do a spatial lowpass filtering

I forgot to mention that this also tends to *add* serifs to sans serif
fonts, which has some interesting implications about why serif fonts
look pleasing to the eye, considering that the visual system does
something akin to an FFT during processing. (Actually a Gabor transform,
according to Dr. Karl Pribram [NeuroPsychology chairman at Stanford], which
is a finite rather than infinite equivalent of the Fourier transform with
implications of a sort of Uncertainty Principle of resolvable details. Not
to digress or anything...)

The reason for the serif embellishment is that, to create a perfectly
straight line requires infinite high spatial frequencies (to the resolution
of the display, anyway). The fourier transform of a square wave (which is
analogous to a straight line/rectangle) is composed of an infinite sequence
of spatial sinusoids. This means that to draw a perfect square wave, or
perfectly straight line/rectangle, you need all the high frequency components
you can display.

If you filter out any of the high frequency components (for instance
in order to accomplish the smoothing I describe), then sharp square
edges will tend to get more rounded, which in this application means
that, at a sufficiently large magnification level, the fonts will be
more curvaceous, with serifs.

If you wanted to end up with a sans serif font with horizontal and
vertical straight lines preserved, modify the lowpass filter a bit
to preserve the purely vertical and purely horizontal high spatial
frequencies, but filter out the ones with both a vertical and horizontal
component. Do this by averaging only over diagonal neighbors, not
including the horizontal and vertical neighbors.

If you want your font to have straight diagonal lines along with horizontal
and vertical lines, but still to have no curves, then the filter gets
even more complex. In general you can draw an image composed of all
of the types of features you are concerned with, and take an FFT of it.
The result can be used directly as a filter to delete those features,
or its complement can be used to preserve only those features.

For further details see any text on one dimensional signal processing, or
on Fourier optics for two dimensional signal processing, such as
"Introduction to Fourier Optics" by Joseph Goodman (rigorous), or
"Optical Information Processing" by Francis Yu (more accessible,
and with photos, still mathematical), or "Array Signal Processing"
by Justice/Owsley/Yen/Kak (more general, e.g. includes phased array
radar and CT techniques).

The fact that you have a choice like this as to the appearance of the
magnified font is a consequence of the fact that there are several
different ways to introduce new high resolution (high spatial frequency)
detail where there was none to begin with.

Interestingly enough, it is possible to model most different styles
of fonts as appropriately filtered versions of vector fonts, keeping
in mind that there are several *entirely different* ways of visually
symbolizing the same letter (e.g. look at "A" versus "a") in the
vector font.

	Doug Merritt		doug@mica.berkeley.edu (ucbvax!mica!doug)
			or	ucbvax!unisoft!certes!doug