One of the very
few things I don't like in Squeak is font support. I'm used to nice subpixel
rendered text. I find StrikeFonts and TTFFonts in Squeak equally ugly on LCD
monitors.
I have been a
long time admirer of Henrik Gedenryd FreeType work, now continued by Andy
Tween. But Andy's image
requires linking the FreeType library, and a new BitBlt plugin with newer
modes to work.
Something
smaller and simpler needs to be done! Something that could look like this:
Why not just use
StrikeFonts, but with 32bit glyphs? Why not just take already rendered glyphs
from the host OS, instead of rendering them with FreeType?
This started as
an experiment. I modified existing instances of StrikeFonts to use 32bit forms
for glyphs. But it didn't work. So I fixed several issues there. I wanted to
import the glyphs from the OS. Using a BMP file sounded natural. But it would
be cumbersome to have extra parameters for the creation of the fonts. So I came
up with a format for StrikeFonts that is contained in the BMP file. This is an
example:
With this
format, it was pretty easy to have a basic 32 bit font working. The issues that
needed further work are:
Colored text and
Black text on color (non white) backgrounds.
For Black text
on colored backgrounds I started experimenting with alpha blending (BitBlt rule
34). But I realized that rule 28 could do a much better work. Rule 28 takes the
min value between source and destiny for each rgb component. So it will leave
the background untouched except for those pixels where the font wants something
darker. There, the font rules. It looks great.
For doing
subpixel AA of colored text on colored background I believe you need to render the
font again. As I can't do that, I use whole pixel AA (i.e. regular AA). So I
prepared color maps. For example, to render a red font, I prepared a colormap
that maps the different colors in the font to red with different translucency.
Then I display the text with alpha blending (BitBlt rule 34).
What's missing
from a full solution, such as FreeType?
- No modelling
of the fonts themselves
- No way to
tweak the rendering other than editing the BMP files
- no kerning
(fixed width for each character)
- Colored text
doesn't use subpixel rendering
- Poor
automatically generated italic (although you can import nice italized fonts)
Advantages:
- Very compact.
Very little complexity added to StrikeFont
- Very easy to
build your own glyphs or entire fonts
You can get the
code and sample fonts here.
After loading, execute:
TextConstants
at: #Vera put: (TextStyle fontArray: (Array
with: (StrikeFont new buildFrom:
(Form fromFileNamed: 'Vera7.bmp') name: 'Vera 7')
with: (StrikeFont new buildFrom:
(Form fromFileNamed: 'Vera8.bmp') name: 'Vera 8')
with: (StrikeFont new buildFrom:
(Form fromFileNamed: 'Vera9.bmp') name: 'Vera 9')
with: (StrikeFont new buildFrom:
(Form fromFileNamed: 'Vera10.bmp') name: 'Vera 10')
with: (StrikeFont new buildFrom:
(Form fromFileNamed: 'Vera11.bmp') name: 'Vera 11')
with: (StrikeFont new buildFrom:
(Form fromFileNamed: 'Vera12.bmp') name: 'Vera 12')
))
BTW, if you get
my morphic 3.0 image, it has
this loaded. I also got rid of TTCFonts. And the image is now 3.6Mb!
I hope you like
it.
Juan Vuletich