This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Fonts and stuff - Travis Griggs
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Travis Griggs talks about fonts in VisualWorks, and the problems/limitations. This talk will stick to the emphasis level - not the lower level stuff. First, you have to understand Text and runs.
DisplayScanner scans each run looking for changes
DefaultFontDescription is copied and modified
FontDescription - flat data structure used for finding the font to match the font policy, and renders the font for the subrange of this text.
So - 2 layers of fonts - the raw character glyphs provided by the OS. They are finite. They have to be matched to what you ask for. Second layer is Glyph decorations (SyntheticFont in VW). It wraps a DeviceFont. Not finite - can have decorations added.
To add new descriptions - patch CharacterAttributes, #newWithDefaultAttributes. Add new attributes to FontDescription and SyntheticFont.
There are lots of people mucking ariound here - PDP (Breakpoint glyphs), RB (code highlighting). What this means is that everyone who wants to change things hacks CharacterAttributes #newWithDefaultAttributes. The conflicting patches to the various requisite classes simply cannot co-exist (similar to the old problem with adding launcher menu items).
Solution - new framework, Extra Emphases in the Public Store. If you hack it, save early, save often! Only patches the base system in 2 places. Obsoletes SyntheticFont. Adds a class side registry to CharacterAttributes so that multiple changes by multiple people are possible.
Adds a new class - DecoratedFont - one subclass per font description. Each font encapsulates its own wrapping logic. The subclasses of DecoratedFont are similar to the UI wrappers - each is added to make its own changes to the base DeviceFont.
Now Travis is going to bail from the slides and add one of these as a demo. He's got a few scripted up, so we can see how this is done when you want to extend things. Let's see how one adds Blinking Text. In the DecoratedFont subclass, there are 3 methods you need to implement - a fourth, if you are in composite text land. Have to add two extensions to FontDescription.