Skip to content

Commit

Permalink
Hbarfbuzz: add bindings to set/get hb_segment_properties_t
Browse files Browse the repository at this point in the history
  • Loading branch information
tinchodias committed Nov 30, 2023
1 parent 3b64f1f commit 37fa359
Show file tree
Hide file tree
Showing 33 changed files with 993 additions and 793 deletions.
37 changes: 19 additions & 18 deletions src/Alexandrie-Harfbuzz-Tests/AeHarfbuzzRenderExample.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@
I represent examples to compare usage of Harfbuzz library.
"
Class {
#name : #AeHarfbuzzRenderExample,
#superclass : #Object,
#name : 'AeHarfbuzzRenderExample',
#superclass : 'Object',
#instVars : [
'freetypeFace',
'string',
'fontHeight'
],
#category : #'Alexandrie-Harfbuzz-Tests'
#category : 'Alexandrie-Harfbuzz-Tests',
#package : 'Alexandrie-Harfbuzz-Tests'
}

{ #category : #examples }
{ #category : 'examples' }
AeHarfbuzzRenderExample class >> arrowsFontSize [

^ 22
]

{ #category : #examples }
{ #category : 'examples' }
AeHarfbuzzRenderExample class >> arrowsString [

^ 'a := A->B->>C <= c|=>d~~>e.'
]

{ #category : #examples }
{ #category : 'examples' }
AeHarfbuzzRenderExample class >> example1SourceSansPro [

| aFTLibrary aFace |
Expand All @@ -38,7 +39,7 @@ AeHarfbuzzRenderExample class >> example1SourceSansPro [
newForm inspect
]

{ #category : #examples }
{ #category : 'examples' }
AeHarfbuzzRenderExample class >> example2InriaSerif [

| aFTLibrary aFace |
Expand All @@ -52,7 +53,7 @@ AeHarfbuzzRenderExample class >> example2InriaSerif [
newForm inspect
]

{ #category : #examples }
{ #category : 'examples' }
AeHarfbuzzRenderExample class >> example5CascadiaCode [

| aFTLibrary aFace |
Expand All @@ -69,7 +70,7 @@ AeHarfbuzzRenderExample class >> example5CascadiaCode [
newForm inspect
]

{ #category : #examples }
{ #category : 'examples' }
AeHarfbuzzRenderExample class >> example6Emoji [

| aFace aWideString aFTLibrary |
Expand All @@ -91,19 +92,19 @@ AeHarfbuzzRenderExample class >> example6Emoji [
newForm inspect
]

{ #category : #examples }
{ #category : 'examples' }
AeHarfbuzzRenderExample class >> ffFontSize [

^ 30
]

{ #category : #examples }
{ #category : 'examples' }
AeHarfbuzzRenderExample class >> ffString [

^ 'The special film starts after coffee et office... (AV.)'
]

{ #category : #'instance creation' }
{ #category : 'instance creation' }
AeHarfbuzzRenderExample class >> freetypeFace: aFace string: aWideString fontHeight: aNumber [

^ self new
Expand All @@ -113,19 +114,19 @@ AeHarfbuzzRenderExample class >> freetypeFace: aFace string: aWideString fontHei
yourself
]

{ #category : #accessing }
{ #category : 'accessing' }
AeHarfbuzzRenderExample >> fontHeight: aNumber [

fontHeight := aNumber
]

{ #category : #accessing }
{ #category : 'accessing' }
AeHarfbuzzRenderExample >> freetypeFace: aeFTFace [

freetypeFace := aeFTFace
]

{ #category : #accessing }
{ #category : 'accessing' }
AeHarfbuzzRenderExample >> glyphArrayWithHarfbuzz [

^ AeHbBuffer new
Expand All @@ -138,13 +139,13 @@ AeHarfbuzzRenderExample >> glyphArrayWithHarfbuzz [
cairoGlyphArrayForFace: freetypeFace size: fontHeight
]

{ #category : #accessing }
{ #category : 'accessing' }
AeHarfbuzzRenderExample >> glyphArrayWithoutHarfbuzz: cairoScaledFont [

^ cairoScaledFont glyphArrayForString: string
]

{ #category : #accessing }
{ #category : 'accessing' }
AeHarfbuzzRenderExample >> newForm [

| aeCanvas cairoScaledFont |
Expand Down Expand Up @@ -173,7 +174,7 @@ AeHarfbuzzRenderExample >> newForm [
^ aeCanvas asForm
]

{ #category : #accessing }
{ #category : 'accessing' }
AeHarfbuzzRenderExample >> string: aString [

string := aString
Expand Down
29 changes: 15 additions & 14 deletions src/Alexandrie-Harfbuzz-Tests/AeHbBlobTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,49 @@
An AeHbBlobTest is a test class for testing the behavior of AeHbBlob
"
Class {
#name : #AeHbBlobTest,
#superclass : #TestCase,
#category : #'Alexandrie-Harfbuzz-Tests'
#name : 'AeHbBlobTest',
#superclass : 'TestCase',
#category : 'Alexandrie-Harfbuzz-Tests',
#package : 'Alexandrie-Harfbuzz-Tests'
}

{ #category : #running }
{ #category : 'running' }
AeHbBlobTest >> inriaSerifRegularBlob [

^ AeHbBlob newLocatedAt: AeFilesystemResources inriaSerifRegularTTF
]

{ #category : #running }
{ #category : 'running' }
AeHbBlobTest >> sourceSansProBlob [

^ AeHbBlob newFrom: AeSourceSansPro_Regular fontContentsData
]

{ #category : #tests }
{ #category : 'tests' }
AeHbBlobTest >> testAsString [

self
assert: self inriaSerifRegularBlob asString
equals: 'an AeHbBlob(1 faces)'
]

{ #category : #tests }
{ #category : 'tests' }
AeHbBlobTest >> testFaceCount [

self
assert: self inriaSerifRegularBlob faceCount
equals: 1
]

{ #category : #tests }
{ #category : 'tests' }
AeHbBlobTest >> testLength [

self
assert: self inriaSerifRegularBlob length
equals: AeFilesystemResources inriaSerifRegularTTF size
]

{ #category : #tests }
{ #category : 'tests' }
AeHbBlobTest >> testNewEmpty [

| aBlob |
Expand All @@ -53,7 +54,7 @@ AeHbBlobTest >> testNewEmpty [
self assert: AeHbBlob newEmpty getHandle equals: aBlob getHandle
]

{ #category : #tests }
{ #category : 'tests' }
AeHbBlobTest >> testNewHbFaces [

| faces |
Expand All @@ -63,7 +64,7 @@ AeHbBlobTest >> testNewHbFaces [
self assert: faces first class equals: AeHbFace
]

{ #category : #tests }
{ #category : 'tests' }
AeHbBlobTest >> testOpenFailure [

self
Expand All @@ -75,7 +76,7 @@ AeHbBlobTest >> testOpenFailure [

]

{ #category : #tests }
{ #category : 'tests' }
AeHbBlobTest >> testOpenFromMemoryFailure [

self
Expand All @@ -87,13 +88,13 @@ AeHbBlobTest >> testOpenFromMemoryFailure [

]

{ #category : #tests }
{ #category : 'tests' }
AeHbBlobTest >> testOpenFromMemorySuccess [

self assert: self sourceSansProBlob faceCount equals: 1
]

{ #category : #tests }
{ #category : 'tests' }
AeHbBlobTest >> testOpenSuccess [

self deny: self inriaSerifRegularBlob isNull
Expand Down
32 changes: 25 additions & 7 deletions src/Alexandrie-Harfbuzz-Tests/AeHbBufferTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
An AeHarfbuffLibraryTest is a test class for testing the behavior of AeHarfbuffLibrary
"
Class {
#name : #AeHbBufferTest,
#superclass : #TestCase,
#category : #'Alexandrie-Harfbuzz-Tests'
#name : 'AeHbBufferTest',
#superclass : 'TestCase',
#category : 'Alexandrie-Harfbuzz-Tests',
#package : 'Alexandrie-Harfbuzz-Tests'
}

{ #category : #tests }
{ #category : 'tests' }
AeHbBufferTest >> testClearContents [

| buffer |
Expand All @@ -17,13 +18,29 @@ AeHbBufferTest >> testClearContents [
language: AeHbLanguage en;
yourself.

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

]

{ #category : #tests }
{ #category : 'tests' }
AeHbBufferTest >> testGuessSegmentProperties [

| buffer |
buffer := AeHbBuffer new
addString: 'Hello';
guessSegmentProperties;
yourself.

self assert: buffer segmentProperties direction equals: AeHbDirection leftToRight.
self assert: buffer segmentProperties script equals: AeHbScript latin.
self assert: buffer segmentProperties language toString equals: 'utf-8'. "is it right?"
]

{ #category : 'tests' }
AeHbBufferTest >> testMultipleAdd [

| buffer |
Expand All @@ -43,7 +60,7 @@ AeHbBufferTest >> testMultipleAdd [

]

{ #category : #tests }
{ #category : 'tests' }
AeHbBufferTest >> testReset [

| buffer |
Expand All @@ -54,12 +71,13 @@ AeHbBufferTest >> testReset [
yourself.

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

]

{ #category : #tests }
{ #category : 'tests' }
AeHbBufferTest >> testSimpleExample [
"Adaptation of https://harfbuzz.github.io/a-simple-shaping-example.html"

Expand Down
Loading

0 comments on commit 37fa359

Please sign in to comment.