Colored TTF rendering

Andreas Raab andreas.raab at gmx.de
Wed Nov 15 09:04:13 UTC 2006


Diego Gomez Deck wrote:
> Do you have any code snippet to test (an compare) the TTF rendering
> speed?

Sure. Try this:

text :=
	('Hello World\' withCRs asText addAttribute: TextColor red),
	('Hello World\' withCRs asText addAttribute: TextColor green),
	('Hello World\' withCRs asText addAttribute: TextColor blue).
text addAttribute: (TextFontReference toFont:
	((TextStyle named: 'BitstreamVeraSans') fontOfSize: 24)).
morph := TextMorph new contentsAsIs: text.
form := Form extent: morph fullBounds extent depth: 32.
Transcript cr; show: (
   [1 to: 1000 do:[:i| morph fullDrawOn: form getCanvas]] timeToRun
).

On my machine this results in:
	Before: 8700 msecs
	After:   750 msecs
And the speed difference is actually quite noticeable in interactions.

Cheers,
   - Andreas



More information about the Squeak-dev mailing list