Skip to content

Commit

Permalink
#AeHbBuffer: improve 2 FFI bindings selectors
Browse files Browse the repository at this point in the history
Shouldn't impact users as they are kind of private
  • Loading branch information
tinchodias committed Nov 28, 2023
1 parent fa2ec58 commit b57513e
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions src/Alexandrie-Harfbuzz/AeHbBuffer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ AeHbBuffer >> cairoGlyphArray [
length = 0 ifTrue: [ ^ AeCairoGlyphArray newOf: 0 ].

infos := AeHbGlyphInfoArray
fromHandle: (self getGlyphInfosInto: ExternalAddress null)
fromHandle: (self glyphInfosWritingSizeInto: ExternalAddress null)
size: length.
positions := AeHbGlyphPositionArray
fromHandle: (self getGlyphPositionsInto: ExternalAddress null)
fromHandle: (self glyphPositionsWritingSizeInto: ExternalAddress null)
size: length.

cairoGlyphsArray := AeCairoGlyphArray newOf: length.
Expand Down Expand Up @@ -179,32 +179,6 @@ AeHbBuffer >> flags: flags [
)
]

{ #category : #'accessing - output' }
AeHbBuffer >> getGlyphInfosInto: aPointer [
"Returns a collection of `AeHbGlyphInfo` with glyph information. Returned pointer is valid as long as buffer contents are not modified.
See: https://harfbuzz.github.io/harfbuzz-hb-buffer.html#hb-buffer-get-glyph-infos"

^ self ffiCall: #(
"hb_glyph_info_t" void *
hb_buffer_get_glyph_infos (
self,
uint * aPointer)
)
]

{ #category : #'accessing - output' }
AeHbBuffer >> getGlyphPositionsInto: aPointer [
"See: https://harfbuzz.github.io/harfbuzz-hb-buffer.html#hb-buffer-get-glyph-positions"

^ self ffiCall: #(
"hb_glyph_position_t" void *
hb_buffer_get_glyph_positions (
self,
uint * aPointer)
)
]

{ #category : #'cairo integration' }
AeHbBuffer >> glyphArrayForString: aString scaleFactor: aPoint [

Expand Down Expand Up @@ -249,27 +223,53 @@ AeHbBuffer >> glyphInfos [

| lengthPointer aHandle |
lengthPointer := FFIUInt32 newBuffer.
aHandle := self getGlyphInfosInto: lengthPointer.
aHandle := self glyphInfosWritingSizeInto: lengthPointer.

^ AeHbGlyphInfoArray
fromHandle: aHandle
size: (lengthPointer unsignedLongAt: 1)
]

{ #category : #'accessing - output' }
AeHbBuffer >> glyphInfosWritingSizeInto: aPointer [
"Returns a collection of `AeHbGlyphInfo` with glyph information. Returned pointer is valid as long as buffer contents are not modified.
See: https://harfbuzz.github.io/harfbuzz-hb-buffer.html#hb-buffer-get-glyph-infos"

^ self ffiCall: #(
"hb_glyph_info_t" void *
hb_buffer_get_glyph_infos (
self,
uint * aPointer)
)
]

{ #category : #'accessing - output' }
AeHbBuffer >> glyphPositions [
"Answer an array of `AeHbGlyphPosition` that indicate the position of each glyph of this buffer.
Library has responsability to free it."

| lengthPointer aHandle |
lengthPointer := FFIUInt32 newBuffer.
aHandle := self getGlyphPositionsInto: lengthPointer.
aHandle := self glyphPositionsWritingSizeInto: lengthPointer.

^ AeHbGlyphPositionArray
fromHandle: aHandle
size: (lengthPointer unsignedLongAt: 1)
]

{ #category : #'accessing - output' }
AeHbBuffer >> glyphPositionsWritingSizeInto: aPointer [
"See: https://harfbuzz.github.io/harfbuzz-hb-buffer.html#hb-buffer-get-glyph-positions"

^ self ffiCall: #(
"hb_glyph_position_t" void *
hb_buffer_get_glyph_positions (
self,
uint * aPointer)
)
]

{ #category : #'accessing - input' }
AeHbBuffer >> guessSegmentProperties [
"See: https://harfbuzz.github.io/harfbuzz-hb-buffer.html#hb-buffer-guess-segment-properties"
Expand Down

0 comments on commit b57513e

Please sign in to comment.