[squeak-dev] The Trunk: Graphics-nice.181.mcz

commits at source.squeak.org commits at source.squeak.org
Sun May 8 11:37:29 UTC 2011


Nicolas Cellier uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-nice.181.mcz

==================== Summary ====================

Name: Graphics-nice.181
Author: nice
Time: 29 April 2011, 2:35:20.972 am
UUID: 501ef332-95aa-4ea6-bb4c-74a4a6b884ff
Ancestors: Graphics-ul.180

Horrible hack to let Pen>>print:withFont: work with an antialiased font if ever character form depth is 16 or 24.

The hack hopefully works with legacy depth 1 fonts.

Though, the result won't be that nice, letters being rendered by replacing nice antialiasing shadows with dumb thick monochrome paths.

Not sure the whole hack is worth !

=============== Diff against Graphics-ul.180 ===============

Item was changed:
  ----- Method: Pen>>print:withFont: (in category 'operations') -----
  print: str withFont: font
  	"Print the given string in the given font at the current heading"
  	| lineStart scale wasDown |
  	scale := sourceForm width.
  	wasDown := penDown.
  	lineStart := location.
  	str do:
+ 		[:char |
- 		[:char | | charStart pix rowStart form bb |
  		char = Character cr ifTrue:
  			[self place: lineStart; up; turn: 90; go: font height*scale; turn: -90; down]
  		ifFalse:
+ 			[ | charStart pix rowStart form bb backgroundCode |
+ 			form := font characterFormAt: char.
+ 			backgroundCode := 1<< (form depth // 3 * 3) - 1.
- 			[form := font characterFormAt: char.
  			charStart := location.
  wasDown ifTrue: [
  			self up; turn: -90; go: font descent*scale; turn: 90; down.
  			0 to: form height-1 do:
  				[:y |
  				rowStart := location.
  				bb := BitBlt current bitPeekerFromForm: form.
  				pix := RunArray newFrom:
  					((0 to: form width-1) collect: [:x | bb pixelAt: x at y]).
  				pix runs with: pix values do:
  					[:run :value |
+ 					value = backgroundCode
- 					value = 0
  						ifTrue: [self up; go: run*scale; down]
  						ifFalse: [self go: run*scale]].
  				self place: rowStart; up; turn: 90; go: scale; turn: -90; down].
  ].
  			self place: charStart; up; go: form width*scale; down].
  			].
  	wasDown ifFalse: [self up]
  "
  Display restoreAfter:
  [Pen new squareNib: 2; color: Color red; turn: 45;
  	print: 'The owl and the pussycat went to sea
  in a beautiful pea green boat.' withFont: TextStyle defaultFont]
  "!




More information about the Squeak-dev mailing list