Skip to content

Commit

Permalink
AeHbBuffer: Rename addUtf8String: to addString:
Browse files Browse the repository at this point in the history
Any String can be encoded as utf8, it's meaningless on the selector.
  • Loading branch information
tinchodias committed Sep 15, 2023
1 parent 03e6c54 commit 35932ee
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ AeHarfbuzzRenderExample >> glyphArrayWithHarfbuzz [
language: AeHbLanguage en;
clusterLevel: AeHbBufferClusterLevel recommended;
flags: AeHbBufferFlags beginningOrEndingOfText;
addUtf8String: string;
addString: string;
cairoGlyphArrayForFace: freetypeFace size: fontHeight
]

Expand Down
10 changes: 5 additions & 5 deletions src/Alexandrie-Harfbuzz-Tests/AeHbBufferTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ AeHbBufferTest >> testClearContents [
language: AeHbLanguage en;
yourself.

buffer addUtf8String: 'ab'.
buffer addString: 'ab'.
buffer clearContents.
self assert: buffer length equals: 0.

Expand All @@ -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.

]
Expand All @@ -53,7 +53,7 @@ AeHbBufferTest >> testReset [
language: AeHbLanguage en;
yourself.

buffer addUtf8String: 'ab'.
buffer addString: 'ab'.
buffer reset.
self assert: buffer length equals: 0.

Expand All @@ -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.
Expand Down
23 changes: 13 additions & 10 deletions src/Alexandrie-Harfbuzz/AeHbBuffer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
]

Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit 35932ee

Please sign in to comment.