From 5afab0ee363fa7a500410ef58bce4cae129b8e6f Mon Sep 17 00:00:00 2001 From: Martin Dias Date: Sat, 14 Oct 2023 20:26:00 -0300 Subject: [PATCH] Add bindings for Harfbuzz-Cairo, introduced in Harfbuzz v7.0.0 --- .../AeHarfbuzzCairoLibrary.class.st | 29 +++++++++++++++++++ src/Alexandrie-Harfbuzz/AeHbFace.class.st | 24 +++++++++++++++ src/Alexandrie-Harfbuzz/AeHbFont.class.st | 28 ++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 src/Alexandrie-Harfbuzz/AeHarfbuzzCairoLibrary.class.st diff --git a/src/Alexandrie-Harfbuzz/AeHarfbuzzCairoLibrary.class.st b/src/Alexandrie-Harfbuzz/AeHarfbuzzCairoLibrary.class.st new file mode 100644 index 0000000..5baeac9 --- /dev/null +++ b/src/Alexandrie-Harfbuzz/AeHarfbuzzCairoLibrary.class.st @@ -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' +] diff --git a/src/Alexandrie-Harfbuzz/AeHbFace.class.st b/src/Alexandrie-Harfbuzz/AeHbFace.class.st index b7dd878..3b2ee13 100644 --- a/src/Alexandrie-Harfbuzz/AeHbFace.class.st +++ b/src/Alexandrie-Harfbuzz/AeHbFace.class.st @@ -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" @@ -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 +] diff --git a/src/Alexandrie-Harfbuzz/AeHbFont.class.st b/src/Alexandrie-Harfbuzz/AeHbFont.class.st index 44596ce..61eac2d 100644 --- a/src/Alexandrie-Harfbuzz/AeHbFont.class.st +++ b/src/Alexandrie-Harfbuzz/AeHbFont.class.st @@ -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. @@ -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 +]