ttfFontReaderRefactored

Summary: Attempt to make TTFontReader more understandable and manageable (aiming at full unicode support)
Author: danil osipchuk
Owner: danil osipchuk (dao)
Co-maintainers: <None>
Categories:
Homepage:
PackageInfo name: <Not entered>
RSS feed:

Description:

This is a refactored version of TTFontReader and friends. You may find it useful, if you want to load Unicode ttf in image.

Here is a short story:

I tried to load unicode ttf using stock TTFontReader (to render Russian symbols) and failed. After looking at TTFontReaderreadFrom: I couldn't find out an easy way to use it, it is almost absolutly unmanageable.

Reworked version now caches all interesting info about ttf-font (instance variables are merely ttf-file structures), thus allowing reuse and modification. Default behaviour is left unchanged - 'TTFontReader readFrom: stream' will give you an old style TTFontDescription with 256 glyphs (sure, reading of unicode is also there, it was the main goal). Unicode style processing involves reading of all glyphs of a font, you may filter out what you need by youself using new infrastructure, but personally I don't care. Both versions are registered in FileList services.

One remarkable change in system is changing of MultiTTCFont caching policy. When I first loaded full fonts table and opened workspace with unicode text - I found that rendering was very slow. I went ahead and changed cache to be an WeakValueDictionary (as WeakArray is used for TTCFont). I'm typing this in squeak with new fonts enabled everywhere and it seems that all is fine. I'm aware of possible problems with such use of WeakArrays http://impara.de/pipermail/tweak/2005-August/000880.html but I'm putting it aside up to time when I really face it.

You may NOT want to load this package if you allready use MultiTTCFont in your system (caching policy changed and TTCFontDescription was removed). And of course it's alpha quality - don't load it into your golden image without backup.

Now, when you are warned, collect some fonts (msfonts seem to be available legally at http://corefonts.sourceforge.net/ ), install this package and poke at class-side methods of TTFontReader, or navigate FileList to fonts location, or even fire 'TTFontReader suggestBatchInstallToUser'. It works for me in Squeak-3.9a-3880 and later.

Releases


Back