The Trunk: Graphics-nice.147.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Graphics-nice.147.mcz

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

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

Name: Graphics-nice.147
Author: nice
Time: 22 August 2010, 8:34:28.056 pm
UUID: a63d5fff-0971-48d2-bd1a-5c69db803809
Ancestors: Graphics-nice.146

minor change: avoid creating a SortedCollection when not necessary...
asSortedCollection asArray -> asArray sort

=============== Diff against Graphics-nice.146 ===============

Item was changed:
  ----- Method: StrikeFont class>>readStrikeFont2Family:fromDirectory: (in category 'examples') -----
  readStrikeFont2Family: familyName fromDirectory: aDirectory
  "StrikeFont readStrikeFont2Family: 'Lucida' fromDirectory: FileDirectory default"
  "This utility reads all available .sf2 StrikeFont files for a given family from  
  the current directory. It returns an Array, sorted by size, suitable for handing
  to TextStyle newFontArray: ."
  "For this utility to work as is, the .sf2 files must be named 'familyNN.sf2'."
+ | fileNames strikeFonts |
- | fileNames strikeFonts fontArray |
  fileNames := aDirectory fileNamesMatching: familyName , '##.sf2'.
  strikeFonts := fileNames collect: [:fname | StrikeFont new readFromStrike2: fname].
  strikeFonts do: [ :font | font reset ].
+ ^strikeFonts asArray sort: [:a :b | a height < b height].
- strikeFonts := strikeFonts asSortedCollection: [:a :b | a height < b height].
- fontArray := strikeFonts asArray.
- ^ fontArray
 
  "TextConstants at: #Lucida put: (TextStyle fontArray: (StrikeFont
  readStrikeFont2Family: 'Lucida'))."!

Item was changed:
  ----- Method: TextStyle>>addNewFontSize: (in category 'fonts and font indexes') -----
  addNewFontSize: pointSize
  "Add a font in specified size to the array of fonts."
  | f d newArray t isSet |
  fontArray first emphasis ~= 0 ifTrue: [
  t := TextConstants at: self fontArray first familyName asSymbol.
  t fonts first emphasis = 0 ifTrue: [
  ^ t addNewFontSize: pointSize.
  ].
  ].
 
  pointSize <= 0 ifTrue: [^ nil].
  fontArray do: [:s |
  s pointSize = pointSize ifTrue: [^ s].
  ].
 
  (isSet := fontArray first isKindOf: TTCFontSet)
  ifTrue:[
  | fonts |
  fonts := fontArray first fontArray collect: [ :font |
  | newFont |
  (font isNil)
  ifTrue: [newFont := nil]
  ifFalse: [
  newFont := (font ttcDescription size > 256)
  ifTrue: [MultiTTCFont new initialize]
  ifFalse: [TTCFont new initialize].
  newFont ttcDescription: font ttcDescription.
  newFont pixelSize: pointSize * 96 // 72.
  font derivativeFonts notEmpty ifTrue: [font derivativeFonts do: [ :proto |
  proto ifNotNil: [
  d := proto class new initialize.
  d ttcDescription: proto ttcDescription.
  d pixelSize: newFont pixelSize.
  newFont derivativeFont: d]]].
  ].
  newFont].
  f := TTCFontSet newFontArray: fonts]
  ifFalse: [
  f := fontArray first class new initialize: fontArray first.
  f pointSize: pointSize.
  fontArray first derivativeFonts do: [:proto |
  proto ifNotNil: [
  d := proto class new initialize: proto.
  d pointSize: f pointSize.
  f derivativeFont: d mainFont: proto.
  ].
  ].
  ].
+ newArray := (fontArray copyWith: f) asArray sort: [:a :b | a pointSize <= b pointSize].
- newArray := ((fontArray copyWith: f) asSortedCollection: [:a :b | a pointSize <= b pointSize]) asArray.
  self newFontArray: newArray.
  isSet ifTrue: [
  TTCFontSet register: newArray at: newArray first familyName asSymbol.
  ].
  ^ self fontOfPointSize: pointSize
  !