'From etoys3.0 of 24 February 2008 [latest update: #2072] on 5 August 2008 at 8:33:50 pm'! "Change Set: pangoFixesAug5-yo Date: 5 August 2008 Author: Yoshiki Ohshima Some fixes for the pango rendering binding."! !PangoParagraph methodsFor: 'as yet unclassified' stamp: 'yo 8/5/2008 18:32'! pangoDrawOn: aCanvas in: bnds color: c | r start stop clip | (aCanvas isKindOf: FormCanvas) ifFalse: [^ self]. clip := (bnds intersect: aCanvas clipRect) translateBy: aCanvas origin. r := RomePluginCanvas drawingCanvasFor: aCanvas. r clipRectangle: clip. r clear. start := selectionStart ifNil: [-1] ifNotNil: [selectionStart stringIndex]. stop := selectionStop ifNil: [-1] ifNotNil: [selectionStop stringIndex]. r pangoString: text string attributeArray: self asPangoAttributes at: (container origin + aCanvas origin + (0@1)) width: bnds width height: bnds height selectionStart: start selectionEnd: stop selectionColorPixel: (self insertionPointColor pixelValueForDepth: 32). r finish: clip. ! ! !RunArray methodsFor: '*pango' stamp: 'yo 8/5/2008 16:50'! pangoFontAttributeFromArray: a from: start to: end | font fontName fontSize fontRef fontChange r | fontRef := a detect: [:e | e isMemberOf: TextFontReference] ifNone: [nil]. font := fontRef ifNil: [TextStyle defaultFont] ifNotNil: [fontRef font]. fontName := font familyName. (fontName beginsWith: 'Accuny') ifTrue: [ fontName := 'Times New Roman'. ]. (fontName beginsWith: 'Accujen') ifTrue: [ fontName := 'Arial'. ]. fontChange := a detect: [:e | e isMemberOf: TextFontChange] ifNone: [nil]. fontSize := fontChange ifNil: [font pointSize] ifNotNil: [ (font textStyle fontArray at: fontChange fontNumber) pointSize]. r := RomePangoFont familyName: fontName size: (fontSize * 0.8) asInteger. ^ Array with: #F with: start with: end with: r descriptionIndex with: r. ! ! !StringMorph methodsFor: 'editing' stamp: 'yo 8/5/2008 17:48'! launchMiniEditor: evt | textMorph | hasFocus _ true. "Really only means edit in progress for this morph" textMorph _ StringMorphEditor new. textMorph contents: contents. textMorph fontName: self fontToUse name pointSize: (self fontToUse pointSize) asInteger. textMorph usePango: self usePango. textMorph bounds: (self bounds expandBy: 0@2). self addMorphFront: textMorph. evt hand newKeyboardFocus: textMorph. textMorph editor selectFrom: 1 to: textMorph paragraph text string size. ^ textMorph! ! !StringMorph methodsFor: '*pango' stamp: 'yo 8/4/2008 18:54'! asPangoAttributes | usedFont fontName fontSize colorArray emphasisArray r utf8Contents | usedFont := font ifNil: [TextStyle defaultFont] ifNotNil: [font]. utf8Contents := (contents ifNotNil: [contents convertToWithConverter: UTF8TextConverter new] ifNil: ['']). fontName := usedFont familyName. (fontName beginsWith: 'Accuny') ifTrue: [ fontName := 'Times New Roman'. ]. (fontName beginsWith: 'Accujen') ifTrue: [ fontName := 'Arial'. ]. fontSize := usedFont pointSize. colorArray := Array with: #C with: 0 with: utf8Contents size with: color pixelValue32. emphasisArray := Array with: #E with: 0 with: utf8Contents size with: emphasis. r := RomePangoFont familyName: fontName size: (fontSize*0.8) asInteger. ^ Array with: (Array with: #F with: 0 with: utf8Contents size with: r descriptionIndex with: r) with: colorArray with: emphasisArray. ! ! !TextMorph methodsFor: 'accessing' stamp: 'yo 8/4/2008 19:49'! fontName: fontName pointSize: fontSize | newTextStyle | newTextStyle _ ((TextStyle named: fontName asSymbol) ifNil: [ TextStyle default ]) copy. newTextStyle ifNil: [self error: 'font ', fontName, ' not found.']. textStyle _ newTextStyle. text addAttribute: (TextFontChange fontNumber: (newTextStyle fontIndexOfPointSize: fontSize)). text addAttribute: (TextFontReference toFont: (StrikeFont familyName: fontName pointSize: fontSize)). paragraph ifNotNil: [paragraph textStyle: newTextStyle]! ! !TextMorph methodsFor: 'accessing' stamp: 'yo 8/4/2008 20:03'! fontName: fontName size: fontSize | newTextStyle | newTextStyle _ ((TextStyle named: fontName asSymbol) ifNil: [ TextStyle default ]) copy. textStyle _ newTextStyle. text addAttribute: (TextFontChange fontNumber: (newTextStyle fontIndexOfSize: fontSize)). text addAttribute: (TextFontReference toFont: (StrikeFont familyName: fontName pointSize: fontSize)). paragraph ifNotNil: [paragraph textStyle: newTextStyle]! ! !TextMorph methodsFor: 'accessing' stamp: 'yo 8/4/2008 20:03'! font: aFont | newTextStyle | newTextStyle _ aFont textStyle copy ifNil: [ TextStyle fontArray: { aFont } ]. textStyle _ newTextStyle. text addAttribute: (TextFontChange fontNumber: (newTextStyle fontIndexOf: aFont)). text addAttribute: (TextFontReference toFont: aFont). paragraph ifNotNil: [paragraph textStyle: newTextStyle]! ! "Postscript: " Flaps disableGlobalFlaps: false. Flaps enableEToyFlaps. !