From 35932eed727b7e1780e42b3e74c069f1c145d411 Mon Sep 17 00:00:00 2001 From: Martin Dias Date: Fri, 15 Sep 2023 19:24:26 -0300 Subject: [PATCH] AeHbBuffer: Rename addUtf8String: to addString: Any String can be encoded as utf8, it's meaningless on the selector. --- .../AeHarfbuzzRenderExample.class.st | 2 +- .../AeHbBufferTest.class.st | 10 ++++---- src/Alexandrie-Harfbuzz/AeHbBuffer.class.st | 23 +++++++++++-------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/Alexandrie-Harfbuzz-Tests/AeHarfbuzzRenderExample.class.st b/src/Alexandrie-Harfbuzz-Tests/AeHarfbuzzRenderExample.class.st index 4abd522..4f1550e 100644 --- a/src/Alexandrie-Harfbuzz-Tests/AeHarfbuzzRenderExample.class.st +++ b/src/Alexandrie-Harfbuzz-Tests/AeHarfbuzzRenderExample.class.st @@ -134,7 +134,7 @@ AeHarfbuzzRenderExample >> glyphArrayWithHarfbuzz [ language: AeHbLanguage en; clusterLevel: AeHbBufferClusterLevel recommended; flags: AeHbBufferFlags beginningOrEndingOfText; - addUtf8String: string; + addString: string; cairoGlyphArrayForFace: freetypeFace size: fontHeight ] diff --git a/src/Alexandrie-Harfbuzz-Tests/AeHbBufferTest.class.st b/src/Alexandrie-Harfbuzz-Tests/AeHbBufferTest.class.st index ee87b49..56a5ba5 100644 --- a/src/Alexandrie-Harfbuzz-Tests/AeHbBufferTest.class.st +++ b/src/Alexandrie-Harfbuzz-Tests/AeHbBufferTest.class.st @@ -17,7 +17,7 @@ AeHbBufferTest >> testClearContents [ language: AeHbLanguage en; yourself. - buffer addUtf8String: 'ab'. + buffer addString: 'ab'. buffer clearContents. self assert: buffer length equals: 0. @@ -35,10 +35,10 @@ AeHbBufferTest >> testMultipleAdd [ self assert: buffer length equals: 0. - buffer addUtf8String: 'ab'. + buffer addString: 'ab'. self assert: buffer length equals: 2. - buffer addUtf8String: 'cd'. + buffer addString: 'cd'. self assert: buffer length equals: 4. ] @@ -53,7 +53,7 @@ AeHbBufferTest >> testReset [ language: AeHbLanguage en; yourself. - buffer addUtf8String: 'ab'. + buffer addString: 'ab'. buffer reset. self assert: buffer length equals: 0. @@ -66,7 +66,7 @@ AeHbBufferTest >> testSimpleExample [ | buffer font infos positions blob face | "1. Create a buffer and put your text in it." buffer := AeHbBuffer new. - buffer addUtf8String: 'flor'. + buffer addString: 'flor'. "2. Set the script, language and direction of the buffer." buffer direction: AeHbDirection leftToRight. diff --git a/src/Alexandrie-Harfbuzz/AeHbBuffer.class.st b/src/Alexandrie-Harfbuzz/AeHbBuffer.class.st index 130d812..d412584 100644 --- a/src/Alexandrie-Harfbuzz/AeHbBuffer.class.st +++ b/src/Alexandrie-Harfbuzz/AeHbBuffer.class.st @@ -30,7 +30,7 @@ AeHbBuffer class >> defaultCairoGlyphArrayFor: aString face: aeFTFace size: font script: AeHbScript latin; language: AeHbLanguage en; clusterLevel: AeHbBufferClusterLevel recommended; - addUtf8String: aString; + addString: aString; cairoGlyphArrayForFace: aeFTFace size: fontSize ] @@ -58,6 +58,18 @@ AeHbBuffer class >> unownedNew [ ) ] +{ #category : #'accessing - input' } +AeHbBuffer >> addString: aString [ + + | encoded | + encoded := aString utf8Encoded. + self + addUTF8ByteArray: encoded + length: encoded size + itemOffset: 0 + itemLength: encoded size +] + { #category : #'accessing - input' } AeHbBuffer >> addUTF8ByteArray: text length: text_length itemOffset: item_offset itemLength: item_length [ "See: https://harfbuzz.github.io/harfbuzz-hb-buffer.html#hb-buffer-add-utf8" @@ -73,15 +85,6 @@ AeHbBuffer >> addUTF8ByteArray: text length: text_length itemOffset: item_offset ) ] -{ #category : #'accessing - input' } -AeHbBuffer >> addUtf8String: aString [ - - | encoded | - encoded := aString utf8Encoded. - self addUTF8ByteArray: encoded length: encoded size itemOffset: 0 itemLength: encoded size - -] - { #category : #convenience } AeHbBuffer >> cairoGlyphArrayForFace: freetypeFace size: fontSize [ "Based on: https://github.com/harfbuzz/harfbuzz-tutorial/blob/master/hello-harfbuzz-freetype.c"