Skip to content

Commit

Permalink
Created a package for HarfbuzzCairo (requires >= v7.0.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchodias committed Oct 19, 2023
1 parent b37ef41 commit 8f5b10d
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 53 deletions.
24 changes: 0 additions & 24 deletions src/Alexandrie-Harfbuzz/AeHbFace.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,6 @@ 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 @@ -176,18 +167,3 @@ 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: 0 additions & 28 deletions src/Alexandrie-Harfbuzz/AeHbFont.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,6 @@ 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 @@ -292,20 +281,3 @@ 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
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ See: https://harfbuzz.github.io/harfbuzz-hb-cairo.html
Class {
#name : #AeHarfbuzzCairoLibrary,
#superclass : #FFILibrary,
#category : #'Alexandrie-Harfbuzz-Library'
#category : #'Alexandrie-HarfbuzzCairo'
}

{ #category : #'accessing - platform' }
Expand Down
25 changes: 25 additions & 0 deletions src/Alexandrie-HarfbuzzCairo/AeHbBuffer.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Extension { #name : #AeHbBuffer }

{ #category : #'*Alexandrie-HarfbuzzCairo' }
AeHbBuffer >> unownedGlyphsFrom: utf8 length: utf8Length xScaleFactor: xScaleFactor yScaleFactor: yScaleFactor intoGlyphs: glyphArrayAddress num: glyphArrayLengthAddress [
"See: https://harfbuzz.github.io/harfbuzz-hb-cairo.html#hb-cairo-glyphs-from-buffer"

^ self
ffiCall: #(
void
hb_cairo_glyphs_from_buffer (
self,
false,
double xScaleFactor,
double yScaleFactor,
double 0.0,
double 0.0,
const char *utf8,
int utf8Length,
void **glyphArrayAddress,
uint *glyphArrayLengthAddress,
nil,
nil,
nil ) )
library: AeHarfbuzzCairoLibrary
]
42 changes: 42 additions & 0 deletions src/Alexandrie-HarfbuzzCairo/AeHbCairoFontFace.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"
I am a FFI binding for a `cairo_font_face_t` provided by Harfbuzz-Cairo integration.
A `cairo_font_face_t` represents a particular font at a particular weight, slant, and other characteristic but not size or transformation.
See: https://harfbuzz.github.io/integration-cairo.html
See: https://harfbuzz.github.io/harfbuzz-hb-cairo.html
See: https://www.cairographics.org/manual/cairo-cairo-font-face-t.html
"
Class {
#name : #AeHbCairoFontFace,
#superclass : #AeCairoFontFace,
#category : #'Alexandrie-HarfbuzzCairo'
}

{ #category : #accessing }
AeHbCairoFontFace >> scaleFactor [
"Answer the scale factor of this font face. Default scale factor is zero.
See: https://harfbuzz.github.io/harfbuzz-hb-cairo.html#hb-cairo-font-face-get-scale-factor"

^ self
ffiCall: #(
uint
hb_cairo_font_face_get_scale_factor ( self ) )
library: AeHarfbuzzCairoLibrary
]

{ #category : #accessing }
AeHbCairoFontFace >> scaleFactor: scaleFactor [
"Sets the scale factor of this font face. Default scale factor is zero.
See: https://harfbuzz.github.io/harfbuzz-hb-cairo.html#hb-cairo-font-face-set-scale-factor"

self
ffiCall: #(
void
hb_cairo_font_face_set_scale_factor (
self,
uint scaleFactor) )
library: AeHarfbuzzCairoLibrary
]
25 changes: 25 additions & 0 deletions src/Alexandrie-HarfbuzzCairo/AeHbFace.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Extension { #name : #AeHbFace }

{ #category : #'*Alexandrie-HarfbuzzCairo' }
AeHbFace >> newCairoFontFace [
"Answer a new `AeHbCairoFontFace` for rendering text according to this face."

^ self unownedNewCairoFontFace
autoRelease;
yourself
]

{ #category : #'*Alexandrie-HarfbuzzCairo' }
AeHbFace >> unownedNewCairoFontFace [
"Answer a new `AeHbCairoFontFace` 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: #(
AeHbCairoFontFace
hb_cairo_font_face_create_for_face ( self ) )
library: AeHarfbuzzCairoLibrary
]
29 changes: 29 additions & 0 deletions src/Alexandrie-HarfbuzzCairo/AeHbFont.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Extension { #name : #AeHbFont }

{ #category : #'*Alexandrie-HarfbuzzCairo' }
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 : #'*Alexandrie-HarfbuzzCairo' }
AeHbFont >> unownedNewCairoFontFace [
"Answer a new `AeHbCairoFontFace` 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: #(
AeHbCairoFontFace
hb_cairo_font_face_create_for_font ( self ) )
library: AeHarfbuzzCairoLibrary
]
1 change: 1 addition & 0 deletions src/Alexandrie-HarfbuzzCairo/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #'Alexandrie-HarfbuzzCairo' }

0 comments on commit 8f5b10d

Please sign in to comment.