[FIX] PSPointSizeFix-nk v3

Ned Konz ned at squeakland.org
Fri Apr 30 02:18:53 UTC 2004


The prior version of this got into the update stream, so I'm re-posting
this version in hopes that it can join its ancestor there...

"Change Set:		PSPointSizeFix-nk (v3)
Date:				13 April 2004
Author:			Ned Konz

Postscript output from Squeak has been in pixel units. However, we're
outputting requests for fonts in point units, making the fonts appear
3/4 as big as they should on output.

This change set fixes that problem by also requesting fonts in pixel
units.

v3 (13 April): fixed discrepancy between (ascender+descender) and
(unitsPerEm) in TTCFont. This will rename existing point sizes but keep
glyphs the same size.

v2 (25 March): improved decoding of font names and attributes.

Factored out knowledge of font naming to TextStyle class.

"

"Repair bad sizes *before* installing new code (see TTCFont
class>>repairBadSizes)"

	| description computedScale cached desiredScale newPointSize repaired |
	repaired _ OrderedCollection new.
	TTCFont allInstancesDo: [ :font |
		cached := (font cache copyFrom: $A asciiValue + 1 to: $z asciiValue +
1)
			detect: [ :f | f notNil ] ifNone: [].
		cached := cached ifNil: [  font formOf: $A ] ifNotNil: [ cached value
].
		description _ font ttcDescription.
		desiredScale _ cached height asFloat / (description ascender -
description descender).
		computedScale _ font pixelSize asFloat / font ttcDescription
unitsPerEm.
		(((computedScale / desiredScale) - 1.0 * cached height) abs < 1.0)
ifFalse: [
			newPointSize _ (font pointSize * desiredScale / computedScale)
rounded.
			font pointSize: newPointSize; flushCache.
			repaired add: font.
			font derivativeFonts do: [ :df | df ifNotNil: [
				df pointSize: newPointSize; flushCache.
				repaired add: df. ]].
		].
	].
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PSPointSizeFix-nk.cs.gz
Type: application/octet-stream
Size: 8587 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20040430/6287a0e8/PSPointSizeFix-nk.cs.obj


More information about the Squeak-dev mailing list