Skip to content

Commit

Permalink
Merge pull request #329 from pharo-graphics/text_decorations_fix
Browse files Browse the repository at this point in the history
Support text line through decoration
  • Loading branch information
tinchodias authored Oct 24, 2023
2 parents 830edab + e884e59 commit 203b85f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
39 changes: 17 additions & 22 deletions src/Bloc-Alexandrie/BlTextDecorationAttribute.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,27 @@ Extension { #name : #BlTextDecorationAttribute }
{ #category : #'*Bloc-Alexandrie' }
BlTextDecorationAttribute >> aeDrawAboveOn: aeCanvas span: aBASpan [

| fromY |
aeCanvas restoreContextAfter: [
| fromX fromY toX toY |
fromX := 0.0.
toX := aBASpan advance.

decoration typesDo: [ :eachType |
eachType = BlTextDecorationType underline ifTrue: [
fromY := 2. "magic number taken from Sparta... why 2?"
toY := 2 + self thickness ].

eachType = BlTextDecorationType lineThrough ifTrue: [
self notYetImplemented ] ].

aeCanvas pathFactory: [ :cairoContext |
cairoContext
rectangleX: fromX
y: fromY
width: toX
height: toY ].

aeCanvas
setBackgroundWith: [ aeCanvas setSourceColor: self color ];
setBorderOff.
"ToDo: set line joins?"

aeCanvas drawFigure.
aeCanvas pathFactory: [ :cairoContext |

]
decoration typesDo: [ :eachType |
eachType = BlTextDecorationType underline
ifTrue: [ fromY := 2 ]
ifFalse: [
eachType = BlTextDecorationType lineThrough
ifTrue: [ fromY := aBASpan ascent / 4.0 ]
ifFalse: [ self notYetImplemented ] ].

cairoContext
rectangleX: 0.0
y: fromY
width: aBASpan advance
height: fromY + self thickness ] ].

aeCanvas drawFigure ]
]
8 changes: 8 additions & 0 deletions src/Bloc-Text/BlTextDecorationAttribute.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ BlTextDecorationAttribute >> paint: aColor [
self color: aColor
]

{ #category : 'printing' }
BlTextDecorationAttribute >> printOn: aStream [

aStream
nextPutAll: 'decoration: ';
print: self decoration
]

{ #category : 'api - decoration' }
BlTextDecorationAttribute >> solid [
decoration solid
Expand Down

0 comments on commit 203b85f

Please sign in to comment.