Skip to content

Commit

Permalink
Simplify surfaceWithText to be a better example
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchodias committed Oct 19, 2023
1 parent 5d36030 commit 418671d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Alexandrie-Cairo-Tests/AeCairoExamplesRenderTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ AeCairoExamplesRenderTest >> surfaceWithStretchedIcon [
{ #category : #'tests - text' }
AeCairoExamplesRenderTest >> surfaceWithText [

| fontSize string surfaceSize aSurface aContext aFTLibrary aFTFace aFontFace aScaledFont |
| fontSize string surfaceSize aSurface aContext aFTLibrary aFTFace aScaledFont |
fontSize := 12.
"Get Lorem Ipsum without last cr character"
string := (String loremIpsum: 28) allButLast.
Expand All @@ -641,19 +641,21 @@ AeCairoExamplesRenderTest >> surfaceWithText [
format: AeCairoSurfaceFormat argb32.
aContext := aSurface newContext.

"Set up aScaleFont"
"Paint background"
aContext
sourceColor: Color paleGreen;
paint.

"Set up scaled font in the context"
aFTLibrary := AeFTLibrary newInitialized.
aFTFace := AeSourceSansPro_Regular firstFaceUsing: aFTLibrary.
aFontFace := AeCairoFreetypeFontFace newForFace: aFTFace.
aScaledFont := aFontFace
newScaledFontWithFontMatrix: (AeCairoMatrix newScalingBy: fontSize asPoint)
userToDeviceMatrix: AeCairoMatrix newIdentity
options: AeCairoFontOptions new.
aContext
fontFace: (AeCairoFreetypeFontFace newForFace: aFTFace);
fontSize: fontSize.
aScaledFont := aContext scaledFont.

"Draw glyphs"
"Draw text"
aContext
sourceColor: Color paleGreen;
paint;
translateByX: 5 y: fontSize;
sourceColor: Color blue;
scaledFont: aScaledFont;
Expand Down

0 comments on commit 418671d

Please sign in to comment.