Skip to content

Commit

Permalink
Add bindings for Harfbuzz-Cairo, introduced in Harfbuzz v7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchodias committed Oct 14, 2023
1 parent d118265 commit 5afab0e
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Alexandrie-Harfbuzz/AeHarfbuzzCairoLibrary.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"
I am the FFI bindings library for Harfbuzz-Cairo, introduced in Harfbuzz v7.0.0.
See: https://harfbuzz.github.io/integration-cairo.html
See: https://harfbuzz.github.io/harfbuzz-hb-cairo.html
"
Class {
#name : #AeHarfbuzzCairoLibrary,
#superclass : #FFILibrary,
#category : #'Alexandrie-Harfbuzz-Library'
}

{ #category : #'accessing - platform' }
AeHarfbuzzCairoLibrary >> macLibraryName [

^ FFIMacLibraryFinder findLibrary: 'libharfbuzz-cairo.0.dylib'
]

{ #category : #'accessing - platform' }
AeHarfbuzzCairoLibrary >> unix64LibraryName [

^ FFIUnix64LibraryFinder findLibrary: 'libharfbuzz-cairo.so.0'
]

{ #category : #'accessing - platform' }
AeHarfbuzzCairoLibrary >> win32LibraryName [

^ FFIWindowsLibraryFinder findLibrary: 'libharfbuzz-cairo-0.dll'
]
24 changes: 24 additions & 0 deletions src/Alexandrie-Harfbuzz/AeHbFace.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ AeHbFace >> hasPng [
hb_ot_color_has_png ( self ) )
]

{ #category : #accessing }
AeHbFace >> newCairoFontFace [
"Answer a new `AeCairoFontFace` for rendering text according to this face."

^ self unownedNewCairoFontFace
autoRelease;
yourself
]

{ #category : #accessing }
AeHbFace >> newHbFont [
"Answer a new `AeHbFont` from me"
Expand All @@ -167,3 +176,18 @@ AeHbFace >> unitsPerEm [
uint
hb_face_get_upem ( self ) )
]

{ #category : #accessing }
AeHbFace >> unownedNewCairoFontFace [
"Answer a new `AeCairoFontFace` for rendering text according to this face.
Sender is responsible of destroying the new object.
See: https://harfbuzz.github.io/harfbuzz-hb-cairo.html#hb-cairo-font-face-create-for-face"

^ self
ffiCall: #(
AeCairoFontFace
hb_cairo_font_face_create_for_face ( self ) )
library: AeHarfbuzzCairoLibrary
]
28 changes: 28 additions & 0 deletions src/Alexandrie-Harfbuzz/AeHbFont.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ AeHbFont >> lock [
hb_ft_font_lock_face ( self ) )
]

{ #category : #'instance creation' }
AeHbFont >> newCairoFontFace [
"Answer a new `AeCairoFontFace` for rendering text according to this font.
Note that the scale of font does not affect the rendering, but the variations and slant that are set on font do."

^ self unownedNewCairoFontFace
autoRelease;
yourself
]

{ #category : #accessing }
AeHbFont >> pointSize [
"Fetches the 'point size' of a font. Zero means unset value.
Expand Down Expand Up @@ -281,3 +292,20 @@ AeHbFont >> unlock [
void
hb_ft_font_unlock_face ( self ) )
]

{ #category : #'instance creation' }
AeHbFont >> unownedNewCairoFontFace [
"Answer a new `AeCairoFontFace` for rendering text according to this font.
Note that the scale of font does not affect the rendering, but the variations and slant that are set on font do.
Sender is responsible of destroying the new object.
See: https://harfbuzz.github.io/harfbuzz-hb-cairo.html#hb-cairo-font-face-create-for-font"

^ self
ffiCall: #(
AeCairoFontFace
hb_cairo_font_face_create_for_font ( self ) )
library: AeHarfbuzzCairoLibrary
]

0 comments on commit 5afab0e

Please sign in to comment.