From 418671d0a3d5f144c37c56cc9cfdfa75289eafcd Mon Sep 17 00:00:00 2001 From: Martin Dias Date: Thu, 19 Oct 2023 17:23:12 -0300 Subject: [PATCH] Simplify surfaceWithText to be a better example --- .../AeCairoExamplesRenderTest.class.st | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Alexandrie-Cairo-Tests/AeCairoExamplesRenderTest.class.st b/src/Alexandrie-Cairo-Tests/AeCairoExamplesRenderTest.class.st index ef5d7c3..bd13936 100644 --- a/src/Alexandrie-Cairo-Tests/AeCairoExamplesRenderTest.class.st +++ b/src/Alexandrie-Cairo-Tests/AeCairoExamplesRenderTest.class.st @@ -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. @@ -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;