Squeak
  links to this page:    
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Installing and debugging TrueType fonts
Last updated at 4:32 pm UTC on 14 January 2006
Ron Jeffries March 18, 2004 I can't figure out how to get a Windows /TrueType/ font loaded into Squeak. Can you point me to a way to do that, please?
Yoshiki Ohshima If you're on Windows, drag a .ttf file onto the Squeak's window. Or, you can open FileList and install a .ttf file from there. [Repeat for other fonts in the same family if you want.] You can install the fonts in the same family in any order, I believe.

How to save a part bin I don't mean to make it too simple, but:
 t := TextMorph new
  backgroundColor: Color white;
  beAllFont: ((TextStyle named: 'BitstreamVeraSans') fontOfSize: 36);
  contentsAsIs: 'BitstreamVeraSans';
  yourself.
 GIFReadWriter putForm: t imageForm onFileNamed: 'textGifTest.gif'.
Avi Bryant And on the off chance (since you mentioned Seaside) that you're using this within a web app - you can just do this wherever you want it to appear:
 html imageWithForm: t imageForm
Seaside will take care of generating the GIF, assigning it a URL, and putting that as the src of your img element.

Ron Jeffries [Following, your advice I used a depth of 16 or 32 instead of 8, that seems to make the black outlines go away, [but I don't understand why?
How to save a part bin . The anti-aliasing of the fonts means that the edges are actually in shades of grey (assuming black text and white background). And in 8-bit depth, we're using a color map that isn't covering the range very well. Apparently, when we do the 16-to-8 or 32-to-8 bit conversion (because GIFs have an 8-bit depth) we do a better job of mapping the colors.

Also, if you're using GIFs you should make sure that the background is opaque. Because of the anti-aliasing, the edges are a mixture of background and text colors; when the background is transparent, that would make the edges actually translucent (alpha between 0 and 1). Some of the examples you showed suffer the ragged edges typical of rendering
antialiased text to a transparent background. If you want to have a transparent image of these fonts, use PNG instead of GIF. It handles translucency and larger color spaces.

Ron Jeffries [Following, your advice I used a depth of 16 or 32 instead of 8, that seems to make the black outlines go away, but it's still cutting off the tops of letters and the descenders, though.
How to save a part bin If you inspect the font itself (open an explorer on a TextMorph and find the font), look at the 'lineGrid' (maybe in the TextStyle), 'ascender', and 'descender' settings. You can change the lineGrid and try again.
Ron JeffrieslineGrid is 14. There are no settings for ascender and descender that I can find. There are three instances of TextStyle accessible (that I can find, and two of them are identical, one is not). When I change alignment on the one that occurs twice, it will right align the next. Changes on the other numbers seem to have no effect.
How to save a part bin [Looks at the actual font and says...] Bad font design. The ascender is set too small.
font := ((TextStyle named: #'Bunnigrrrl''shandwriting') fontOfPointSize: 36). 
desc := font ttcDescription. 
glyph := desc at: $B.
Ok, look at the bounds of the 'B' character: glyph bounds 17@-18 corner: 719@804 But...
desc ascender 750
desc descender -170
So the region from 750 to 804 (at the top of the B) will be chopped off. Let's look at the alphabetic characters alone:
Rectangle merging: (($A to: $Z), ($a to: $z) collect: [ :i | (desc at: i) bounds ])
-217@-581 corner: 1040@982
So the ascender would have to be set at least to 982, and the descender to at least -581 to get all the characters.To prove this (and to fix this), try this in a Workspace:
style := TextStyle named: #'Bunnigrrrl''shandwriting'.
style fontArray do: [ :font |
 font flushCache.
 t := TextMorph new
  backgroundColor: Color white;
  beAllFont: font;
  contentsAsIs: (String streamContents: [ :strm | strm print: font pointSize; nextPutAll: ' Before:'; cr; 
       nextPutAll: ($A to: $Z); cr; nextPutAll: ($a to: $z) ]);  yourself.
 PNGReadWriter putForm: t imageForm onFileNamed: (font pointSize printString, 'Before.png')].
"then fix the font description"
style fontArray first ttcDescription setAscender: 982 descender: -581 lineGap: 30.
"And make samples again:"
style fontArray do: [ :font |
 font flushCache.
 t := TextMorph new
  backgroundColor: Color white;
  beAllFont: font;
  contentsAsIs: (String streamContents: [ :strm | strm print: font pointSize; nextPutAll: ' After:'; cr; 
       nextPutAll: ($A to: $Z); cr; nextPutAll: ($a to: $z) ]);  yourself.
 PNGReadWriter putForm: t imageForm onFileNamed: (font pointSize printString, 'After.png')].
Yoshiki Ohshima [Not agreeing it's bad font design.] I think that the font designer wanted to have the characters overlapped holizontally and vertically. We should fix the renderer. It should benefit other languges, such as that require complex ligature.