Skip to content

Commit

Permalink
Update a new example of Athens displaying text with a border style.
Browse files Browse the repository at this point in the history
  • Loading branch information
akevalion committed Aug 23, 2019
1 parent 944f6ef commit 92fd575
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Athens-Cairo/AthensCairoCanvas.class.st
Expand Up @@ -96,6 +96,13 @@ AthensCairoCanvas >> fill [

]

{ #category : #'ffi-calls' }
AthensCairoCanvas >> fillPreserve [
^ self nbCall: #(#void #cairo_fill_preserve #(#self))


]

{ #category : #accessing }
AthensCairoCanvas >> fillRule [
^ self ffiCall: #( cairo_fill_rule_t cairo_get_fill_rule ( self ) )
Expand Down Expand Up @@ -393,6 +400,14 @@ void cairo_text_extents (cairo_t *cr,

]

{ #category : #'ffi-calls' }
AthensCairoCanvas >> textPath: anUTF8String [
"A drawing operator that generates the shape from a string of UTF-8 characters, rendered according to the current font_face, font_size (font_matrix), and font_options. "

^ self nbCall: #(void cairo_text_path (self, char * anUTF8String ))

]

{ #category : #'path segments visitor' }
AthensCairoCanvas >> visitCloseSegment: closeSegment [
self closePath
Expand Down
44 changes: 44 additions & 0 deletions src/Athens-Examples/AthensCairoSurfaceExamples.class.st
Expand Up @@ -7,6 +7,50 @@ Class {
#category : #'Athens-Examples-Demos'
}

{ #category : #examples }
AthensCairoSurfaceExamples class >> exampleDrawTextPath [

| surf font |
font := LogicalFont familyName: 'Source Sans Pro' pointSize: 40.

surf := self newSurface: 500@100.

surf drawDuring: [:can |
| f |
"clear background"
surf clear: Color white.

f := CairoScaledFont fromFreetypeFont: font realFont.
"Set text position"
can pathTransform translateX: 10 Y: (font getPreciseAscent)+10.
"new path to draw the string"
can newPath.

f lock.
"set font properties"
can
setPathMatrix;
setScaledFont: f.
(Color red asAthensPaintOn: can)
loadOnCairoCanvas: can.
"creates a path text"
can textPath: 'Text with border :V'.
"It fills and preserve the last path"
can fillPreserve.

(can setStrokePaint: Color black)
width: 2;
dashes: #(10 1) offset: 0;
"in order to use the path of cairo"
prepareForDrawingOn: can.
can stroke.
f unlock.
].

Display getCanvas drawImage: surf asForm at: 0@0

]

{ #category : #examples }
AthensCairoSurfaceExamples class >> exampleInterop [

Expand Down

0 comments on commit 92fd575

Please sign in to comment.