Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
skiko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuqiang
skiko
Commits
09aad604
Unverified
Commit
09aad604
authored
Nov 02, 2021
by
Shagen Ogandzhanian
Committed by
GitHub
Nov 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commonize FontMgr and FontStyleSet (#336)
parent
3395afe9
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
199 additions
and
193 deletions
+199
-193
Data.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Data.kt
+0
-1
FontMgr.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/FontMgr.kt
+11
-5
FontStyleSet.kt
.../src/commonMain/kotlin/org/jetbrains/skia/FontStyleSet.kt
+5
-2
Typeface.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Typeface.kt
+4
-2
TypefaceFontProvider.kt
...tlin/org/jetbrains/skia/paragraph/TypefaceFontProvider.kt
+10
-6
FontMgrTest.kt
...o/src/commonTest/kotlin/org/jetbrains/skia/FontMgrTest.kt
+107
-0
FontStyleSetTests.kt
...commonTest/kotlin/org/jetbrains/skia/FontStyleSetTests.kt
+12
-0
TestUtils.kt
.../commonTest/kotlin/org/jetbrains/skiko/tests/TestUtils.kt
+3
-0
TestUtils.js.kt
skiko/src/jsTest/kotlin/TestUtils.js.kt
+4
-1
FontMgr.cc
skiko/src/jvmMain/cpp/common/FontMgr.cc
+3
-3
FontStyleSet.cc
skiko/src/jvmMain/cpp/common/FontStyleSet.cc
+2
-2
Typeface.cc
skiko/src/jvmMain/cpp/common/Typeface.cc
+2
-2
TestUtils.jvm.kt
skiko/src/jvmTest/kotlin/TestUtils.jvm.kt
+4
-0
FontMgrTest.kt
skiko/src/jvmTest/kotlin/org/jetbrains/skiko/FontMgrTest.kt
+0
-100
FontMgr.cc
skiko/src/nativeJsMain/cpp/FontMgr.cc
+21
-36
FontStyleSet.cc
skiko/src/nativeJsMain/cpp/FontStyleSet.cc
+5
-22
Typeface.cc
skiko/src/nativeJsMain/cpp/Typeface.cc
+2
-11
TestUtils.native.kt
...Test/kotlin/org/jetbrains/skiko/tests/TestUtils.native.kt
+4
-0
No files found.
skiko/src/commonMain/kotlin/org/jetbrains/skia/Data.kt
View file @
09aad604
...
@@ -140,7 +140,6 @@ class Data internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerHol
...
@@ -140,7 +140,6 @@ class Data internal constructor(ptr: NativePointer) : Managed(ptr, _FinalizerHol
}
}
}
}
@ExternalSymbolName
(
"org_jetbrains_skia_Data__1nGetFinalizer"
)
@ExternalSymbolName
(
"org_jetbrains_skia_Data__1nGetFinalizer"
)
private
external
fun
Data_nGetFinalizer
():
NativePointer
private
external
fun
Data_nGetFinalizer
():
NativePointer
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/FontMgr.kt
View file @
09aad604
package
org.jetbrains.skia
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.InteropPointer
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.RefCnt
import
org.jetbrains.skia.impl.RefCnt
import
org.jetbrains.skia.impl.Stats
import
org.jetbrains.skia.impl.Stats
import
org.jetbrains.skia.impl.getPtr
import
org.jetbrains.skia.impl.getPtr
import
org.jetbrains.skia.impl.interopScope
import
org.jetbrains.skia.impl.reachabilityBarrier
import
org.jetbrains.skia.impl.reachabilityBarrier
import
org.jetbrains.skia.impl.withStringResult
open
class
FontMgr
:
RefCnt
{
open
class
FontMgr
:
RefCnt
{
companion
object
{
companion
object
{
...
@@ -27,7 +30,9 @@ open class FontMgr : RefCnt {
...
@@ -27,7 +30,9 @@ open class FontMgr : RefCnt {
fun
getFamilyName
(
index
:
Int
):
String
{
fun
getFamilyName
(
index
:
Int
):
String
{
return
try
{
return
try
{
Stats
.
onNativeCall
()
Stats
.
onNativeCall
()
withStringResult
{
_nGetFamilyName
(
_ptr
,
index
)
_nGetFamilyName
(
_ptr
,
index
)
}
}
finally
{
}
finally
{
reachabilityBarrier
(
this
)
reachabilityBarrier
(
this
)
}
}
...
@@ -57,7 +62,7 @@ open class FontMgr : RefCnt {
...
@@ -57,7 +62,7 @@ open class FontMgr : RefCnt {
fun
matchFamily
(
familyName
:
String
?):
FontStyleSet
{
fun
matchFamily
(
familyName
:
String
?):
FontStyleSet
{
return
try
{
return
try
{
Stats
.
onNativeCall
()
Stats
.
onNativeCall
()
FontStyleSet
(
_nMatchFamily
(
_ptr
,
familyName
))
interopScope
{
FontStyleSet
(
_nMatchFamily
(
_ptr
,
toInterop
(
familyName
)))
}
}
finally
{
}
finally
{
reachabilityBarrier
(
this
)
reachabilityBarrier
(
this
)
}
}
...
@@ -116,7 +121,7 @@ open class FontMgr : RefCnt {
...
@@ -116,7 +121,7 @@ open class FontMgr : RefCnt {
):
Typeface
?
{
):
Typeface
?
{
return
try
{
return
try
{
Stats
.
onNativeCall
()
Stats
.
onNativeCall
()
val
ptr
=
_nMatchFamilyStyleCharacter
(
_ptr
,
familyName
,
style
.
_value
,
bcp47
,
character
)
val
ptr
=
_nMatchFamilyStyleCharacter
(
_ptr
,
familyName
,
style
.
_value
,
bcp47
,
bcp47
?.
size
?:
0
,
character
)
if
(
ptr
==
NullPointer
)
null
else
Typeface
(
ptr
)
if
(
ptr
==
NullPointer
)
null
else
Typeface
(
ptr
)
}
finally
{
}
finally
{
reachabilityBarrier
(
this
)
reachabilityBarrier
(
this
)
...
@@ -163,13 +168,13 @@ open class FontMgr : RefCnt {
...
@@ -163,13 +168,13 @@ open class FontMgr : RefCnt {
private
external
fun
_nGetFamiliesCount
(
ptr
:
NativePointer
):
Int
private
external
fun
_nGetFamiliesCount
(
ptr
:
NativePointer
):
Int
@ExternalSymbolName
(
"org_jetbrains_skia_FontMgr__1nGetFamilyName"
)
@ExternalSymbolName
(
"org_jetbrains_skia_FontMgr__1nGetFamilyName"
)
private
external
fun
_nGetFamilyName
(
ptr
:
NativePointer
,
index
:
Int
):
String
private
external
fun
_nGetFamilyName
(
ptr
:
NativePointer
,
index
:
Int
):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_FontMgr__1nMakeStyleSet"
)
@ExternalSymbolName
(
"org_jetbrains_skia_FontMgr__1nMakeStyleSet"
)
private
external
fun
_nMakeStyleSet
(
ptr
:
NativePointer
,
index
:
Int
):
NativePointer
private
external
fun
_nMakeStyleSet
(
ptr
:
NativePointer
,
index
:
Int
):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_FontMgr__1nMatchFamily"
)
@ExternalSymbolName
(
"org_jetbrains_skia_FontMgr__1nMatchFamily"
)
private
external
fun
_nMatchFamily
(
ptr
:
NativePointer
,
familyName
:
String
?
):
NativePointer
private
external
fun
_nMatchFamily
(
ptr
:
NativePointer
,
familyName
:
InteropPointer
):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_FontMgr__1nMatchFamilyStyle"
)
@ExternalSymbolName
(
"org_jetbrains_skia_FontMgr__1nMatchFamilyStyle"
)
private
external
fun
_nMatchFamilyStyle
(
ptr
:
NativePointer
,
familyName
:
String
?,
fontStyle
:
Int
):
NativePointer
private
external
fun
_nMatchFamilyStyle
(
ptr
:
NativePointer
,
familyName
:
String
?,
fontStyle
:
Int
):
NativePointer
...
@@ -180,6 +185,7 @@ private external fun _nMatchFamilyStyleCharacter(
...
@@ -180,6 +185,7 @@ private external fun _nMatchFamilyStyleCharacter(
familyName
:
String
?,
familyName
:
String
?,
fontStyle
:
Int
,
fontStyle
:
Int
,
bcp47
:
Array
<
String
?
>?,
bcp47
:
Array
<
String
?
>?,
bcp47size
:
Int
,
character
:
Int
character
:
Int
):
NativePointer
):
NativePointer
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/FontStyleSet.kt
View file @
09aad604
...
@@ -5,6 +5,7 @@ import org.jetbrains.skia.impl.RefCnt
...
@@ -5,6 +5,7 @@ import org.jetbrains.skia.impl.RefCnt
import
org.jetbrains.skia.impl.Stats
import
org.jetbrains.skia.impl.Stats
import
org.jetbrains.skia.impl.reachabilityBarrier
import
org.jetbrains.skia.impl.reachabilityBarrier
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.withStringResult
class
FontStyleSet
internal
constructor
(
ptr
:
NativePointer
)
:
RefCnt
(
ptr
)
{
class
FontStyleSet
internal
constructor
(
ptr
:
NativePointer
)
:
RefCnt
(
ptr
)
{
companion
object
{
companion
object
{
...
@@ -39,7 +40,9 @@ class FontStyleSet internal constructor(ptr: NativePointer) : RefCnt(ptr) {
...
@@ -39,7 +40,9 @@ class FontStyleSet internal constructor(ptr: NativePointer) : RefCnt(ptr) {
fun
getStyleName
(
index
:
Int
):
String
{
fun
getStyleName
(
index
:
Int
):
String
{
return
try
{
return
try
{
Stats
.
onNativeCall
()
Stats
.
onNativeCall
()
withStringResult
{
_nGetStyleName
(
_ptr
,
index
)
_nGetStyleName
(
_ptr
,
index
)
}
}
finally
{
}
finally
{
reachabilityBarrier
(
this
)
reachabilityBarrier
(
this
)
}
}
...
@@ -77,7 +80,7 @@ private external fun _nCount(ptr: NativePointer): Int
...
@@ -77,7 +80,7 @@ private external fun _nCount(ptr: NativePointer): Int
private
external
fun
_nGetStyle
(
ptr
:
NativePointer
,
index
:
Int
):
Int
private
external
fun
_nGetStyle
(
ptr
:
NativePointer
,
index
:
Int
):
Int
@ExternalSymbolName
(
"org_jetbrains_skia_FontStyleSet__1nGetStyleName"
)
@ExternalSymbolName
(
"org_jetbrains_skia_FontStyleSet__1nGetStyleName"
)
private
external
fun
_nGetStyleName
(
ptr
:
NativePointer
,
index
:
Int
):
String
private
external
fun
_nGetStyleName
(
ptr
:
NativePointer
,
index
:
Int
):
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_FontStyleSet__1nGetTypeface"
)
@ExternalSymbolName
(
"org_jetbrains_skia_FontStyleSet__1nGetTypeface"
)
private
external
fun
_nGetTypeface
(
ptr
:
NativePointer
,
index
:
Int
):
NativePointer
private
external
fun
_nGetTypeface
(
ptr
:
NativePointer
,
index
:
Int
):
NativePointer
...
...
skiko/src/commonMain/kotlin/org/jetbrains/skia/Typeface.kt
View file @
09aad604
...
@@ -313,7 +313,9 @@ class Typeface internal constructor(ptr: NativePointer) : RefCnt(ptr) {
...
@@ -313,7 +313,9 @@ class Typeface internal constructor(ptr: NativePointer) : RefCnt(ptr) {
val
familyName
:
String
val
familyName
:
String
get
()
=
try
{
get
()
=
try
{
Stats
.
onNativeCall
()
Stats
.
onNativeCall
()
withStringResult
{
_nGetFamilyName
(
_ptr
)
_nGetFamilyName
(
_ptr
)
}
}
finally
{
}
finally
{
reachabilityBarrier
(
this
)
reachabilityBarrier
(
this
)
}
}
...
@@ -399,4 +401,4 @@ private external fun _nGetKerningPairAdjustments(ptr: NativePointer, glyphs: Sho
...
@@ -399,4 +401,4 @@ private external fun _nGetKerningPairAdjustments(ptr: NativePointer, glyphs: Sho
private
external
fun
_nGetFamilyNames
(
ptr
:
NativePointer
):
Array
<
FontFamilyName
>
private
external
fun
_nGetFamilyNames
(
ptr
:
NativePointer
):
Array
<
FontFamilyName
>
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetFamilyName"
)
@ExternalSymbolName
(
"org_jetbrains_skia_Typeface__1nGetFamilyName"
)
private
external
fun
_nGetFamilyName
(
ptr
:
NativePointer
):
String
private
external
fun
_nGetFamilyName
(
ptr
:
NativePointer
):
NativePointer
\ No newline at end of file
\ No newline at end of file
skiko/src/commonMain/kotlin/org/jetbrains/skia/paragraph/TypefaceFontProvider.kt
View file @
09aad604
...
@@ -6,8 +6,10 @@ import org.jetbrains.skia.FontMgr
...
@@ -6,8 +6,10 @@ import org.jetbrains.skia.FontMgr
import
org.jetbrains.skia.impl.Stats
import
org.jetbrains.skia.impl.Stats
import
org.jetbrains.skia.impl.reachabilityBarrier
import
org.jetbrains.skia.impl.reachabilityBarrier
import
org.jetbrains.skia.ExternalSymbolName
import
org.jetbrains.skia.ExternalSymbolName
import
org.jetbrains.skia.impl.InteropPointer
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.getPtr
import
org.jetbrains.skia.impl.getPtr
import
org.jetbrains.skia.impl.interopScope
class
TypefaceFontProvider
:
FontMgr
(
TypefaceFontProvider_nMake
())
{
class
TypefaceFontProvider
:
FontMgr
(
TypefaceFontProvider_nMake
())
{
companion
object
{
companion
object
{
...
@@ -19,11 +21,13 @@ class TypefaceFontProvider : FontMgr(TypefaceFontProvider_nMake()) {
...
@@ -19,11 +21,13 @@ class TypefaceFontProvider : FontMgr(TypefaceFontProvider_nMake()) {
fun
registerTypeface
(
typeface
:
Typeface
?,
alias
:
String
?
=
null
):
TypefaceFontProvider
{
fun
registerTypeface
(
typeface
:
Typeface
?,
alias
:
String
?
=
null
):
TypefaceFontProvider
{
return
try
{
return
try
{
Stats
.
onNativeCall
()
Stats
.
onNativeCall
()
interopScope
{
_nRegisterTypeface
(
_nRegisterTypeface
(
_ptr
,
_ptr
,
getPtr
(
typeface
),
getPtr
(
typeface
),
alias
toInterop
(
alias
)
)
)
}
this
this
}
finally
{
}
finally
{
reachabilityBarrier
(
typeface
)
reachabilityBarrier
(
typeface
)
...
@@ -40,4 +44,4 @@ class TypefaceFontProvider : FontMgr(TypefaceFontProvider_nMake()) {
...
@@ -40,4 +44,4 @@ class TypefaceFontProvider : FontMgr(TypefaceFontProvider_nMake()) {
private
external
fun
TypefaceFontProvider_nMake
():
NativePointer
private
external
fun
TypefaceFontProvider_nMake
():
NativePointer
@ExternalSymbolName
(
"org_jetbrains_skia_paragraph_TypefaceFontProvider__1nRegisterTypeface"
)
@ExternalSymbolName
(
"org_jetbrains_skia_paragraph_TypefaceFontProvider__1nRegisterTypeface"
)
private
external
fun
_nRegisterTypeface
(
ptr
:
NativePointer
,
typefacePtr
:
NativePointer
,
alias
:
String
?
):
NativePointer
private
external
fun
_nRegisterTypeface
(
ptr
:
NativePointer
,
typefacePtr
:
NativePointer
,
alias
:
InteropPointer
):
NativePointer
skiko/src/commonTest/kotlin/org/jetbrains/skia/FontMgrTest.kt
0 → 100644
View file @
09aad604
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.use
import
org.jetbrains.skia.paragraph.TypefaceFontProvider
import
org.jetbrains.skia.tests.makeFromResource
import
org.jetbrains.skiko.tests.SkipJsTarget
import
org.jetbrains.skiko.tests.SkipNativeTarget
import
org.jetbrains.skiko.tests.makeFromFileName
import
org.jetbrains.skiko.tests.runTest
import
kotlin.test.Test
import
kotlin.test.assertEquals
import
kotlin.test.assertNull
class
FontMgrTest
{
@Test
fun
fontMgrTest
()
=
runTest
{
TypefaceFontProvider
().
let
{
fontManager
->
val
fontManager
=
TypefaceFontProvider
()
val
jbMono
=
Typeface
.
makeFromResource
(
"./fonts/JetBrainsMono-Regular.ttf"
)
fontManager
.
registerTypeface
(
jbMono
)
val
jbMonoBold
=
Typeface
.
makeFromResource
(
"./fonts/JetBrainsMono-Bold.ttf"
)
fontManager
.
registerTypeface
(
jbMonoBold
)
val
inter
:
Typeface
=
Typeface
.
makeFromResource
(
"./fonts/Inter-Hinted-Regular.ttf"
)
fontManager
.
registerTypeface
(
inter
,
"Interface"
)
assertEquals
(
2
,
fontManager
.
familiesCount
)
assertEquals
(
"JetBrains Mono"
,
fontManager
.
getFamilyName
(
0
))
assertEquals
(
"Interface"
,
fontManager
.
getFamilyName
(
1
))
fontManager
.
makeStyleSet
(
0
)
!!
.
use
{
styleSet
->
assertEquals
(
0
,
styleSet
.
count
())
}
fontManager
.
makeStyleSet
(
1
)
!!
.
use
{
styleSet
->
assertEquals
(
0
,
styleSet
.
count
())
}
fontManager
.
matchFamily
(
"JetBrains Mono"
).
use
{
styleSet
->
assertEquals
(
2
,
styleSet
.
count
())
assertEquals
(
FontStyle
.
NORMAL
,
styleSet
.
getStyle
(
0
))
assertEquals
(
"JetBrains Mono"
,
styleSet
.
getStyleName
(
0
))
assertEquals
(
FontStyle
.
BOLD
,
styleSet
.
getStyle
(
1
))
assertEquals
(
"JetBrains Mono"
,
styleSet
.
getStyleName
(
1
))
assertEquals
(
2
,
jbMono
.
refCount
)
styleSet
.
getTypeface
(
0
)
!!
.
use
{
face
->
assertEquals
(
3
,
jbMono
.
refCount
)
assertEquals
(
jbMono
,
face
)
}
assertEquals
(
2
,
jbMono
.
refCount
)
assertEquals
(
2
,
jbMonoBold
.
refCount
)
styleSet
.
getTypeface
(
1
)
!!
.
use
{
face
->
assertEquals
(
3
,
jbMonoBold
.
refCount
)
assertEquals
(
jbMonoBold
,
face
)
}
assertEquals
(
2
,
jbMonoBold
.
refCount
)
assertEquals
(
2
,
jbMono
.
refCount
)
styleSet
.
matchStyle
(
FontStyle
.
NORMAL
)
!!
.
use
{
face
->
assertEquals
(
3
,
jbMono
.
refCount
)
assertEquals
(
jbMono
,
face
)
}
assertEquals
(
2
,
jbMono
.
refCount
)
assertEquals
(
2
,
jbMonoBold
.
refCount
)
styleSet
.
matchStyle
(
FontStyle
.
BOLD
)
!!
.
use
{
face
->
assertEquals
(
3
,
jbMonoBold
.
refCount
)
assertEquals
(
jbMonoBold
,
face
)
}
assertEquals
(
2
,
jbMonoBold
.
refCount
)
assertEquals
(
jbMono
,
styleSet
.
matchStyle
(
FontStyle
.
ITALIC
))
}
assertNull
(
fontManager
.
matchFamilyStyle
(
"JetBrains Mono"
,
FontStyle
.
BOLD
))
assertNull
(
fontManager
.
matchFamilyStyle
(
"Interface"
,
FontStyle
.
NORMAL
))
// TODO: it would be definitely beneficial to check the notNull branch as well
assertNull
(
fontManager
.
matchFamilyStyleCharacter
(
"JetBrains Mono"
,
FontStyle
.
BOLD
,
arrayOf
(
"en-US"
),
65
/* A */
)
)
}
}
@Test
@SkipJsTarget
@SkipNativeTarget
fun
makeFromDataTest
()
{
makeFromFileName
(
"src/commonTest/resources/fonts/JetBrainsMono-Italic.ttf"
).
use
{
data
->
FontMgr
.
default
.
makeFromData
(
data
)
!!
.
use
{
typeFace
->
assertEquals
(
"JetBrains Mono"
,
typeFace
.
familyName
)
assertEquals
(
FontStyle
.
ITALIC
,
typeFace
.
fontStyle
)
}
}
}
}
\ No newline at end of file
skiko/src/commonTest/kotlin/org/jetbrains/skia/FontStyleSetTests.kt
0 → 100644
View file @
09aad604
package
org.jetbrains.skia
import
kotlin.test.Test
import
kotlin.test.assertEquals
class
FontStyleSetTests
{
@Test
fun
fontStyleSetTest
()
{
val
fontStyle
=
FontStyleSet
.
makeEmpty
()
assertEquals
(
0
,
fontStyle
.
count
())
}
}
\ No newline at end of file
skiko/src/commonTest/kotlin/org/jetbrains/skiko/tests/TestUtils.kt
View file @
09aad604
package
org.jetbrains.skiko.tests
package
org.jetbrains.skiko.tests
import
org.jetbrains.skia.Data
import
org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.NativePointer
...
@@ -12,3 +13,5 @@ expect annotation class SkipNativeTarget
...
@@ -12,3 +13,5 @@ expect annotation class SkipNativeTarget
expect
annotation
class
SkipJsTarget
expect
annotation
class
SkipJsTarget
expect
annotation
class
SkipJvmTarget
expect
annotation
class
SkipJvmTarget
expect
fun
makeFromFileName
(
path
:
String
?):
Data
skiko/src/jsTest/kotlin/TestUtils.js.kt
View file @
09aad604
...
@@ -2,6 +2,7 @@ package org.jetbrains.skiko.tests
...
@@ -2,6 +2,7 @@ package org.jetbrains.skiko.tests
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.promise
import
kotlinx.coroutines.promise
import
org.jetbrains.skia.Data
import
org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skiko.wasm.await
import
org.jetbrains.skiko.wasm.await
...
@@ -21,3 +22,5 @@ actual typealias SkipJsTarget = kotlin.test.Ignore
...
@@ -21,3 +22,5 @@ actual typealias SkipJsTarget = kotlin.test.Ignore
actual
annotation
class
SkipJvmTarget
actual
annotation
class
SkipJvmTarget
actual
annotation
class
SkipNativeTarget
actual
annotation
class
SkipNativeTarget
actual
fun
makeFromFileName
(
path
:
String
?):
Data
=
Data
(
0
)
\ No newline at end of file
skiko/src/jvmMain/cpp/common/FontMgr.cc
View file @
09aad604
...
@@ -11,12 +11,12 @@ extern "C" JNIEXPORT jint JNICALL Java_org_jetbrains_skia_FontMgrKt__1nGetFamili
...
@@ -11,12 +11,12 @@ extern "C" JNIEXPORT jint JNICALL Java_org_jetbrains_skia_FontMgrKt__1nGetFamili
return
instance
->
countFamilies
();
return
instance
->
countFamilies
();
}
}
extern
"C"
JNIEXPORT
j
stri
ng
JNICALL
Java_org_jetbrains_skia_FontMgrKt__1nGetFamilyName
extern
"C"
JNIEXPORT
j
lo
ng
JNICALL
Java_org_jetbrains_skia_FontMgrKt__1nGetFamilyName
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jint
index
)
{
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jint
index
)
{
SkFontMgr
*
instance
=
reinterpret_cast
<
SkFontMgr
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkFontMgr
*
instance
=
reinterpret_cast
<
SkFontMgr
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkString
familyName
;
SkString
familyName
;
instance
->
getFamilyName
(
index
,
&
familyName
);
instance
->
getFamilyName
(
index
,
&
familyName
);
return
javaString
(
env
,
familyName
);
return
reinterpret_cast
<
jlong
>
(
new
SkString
(
familyName
)
);
}
}
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_FontMgrKt__1nMakeStyleSet
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_FontMgrKt__1nMakeStyleSet
...
@@ -43,7 +43,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_FontMgrKt__1nMatchFam
...
@@ -43,7 +43,7 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_FontMgrKt__1nMatchFam
}
}
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_FontMgrKt__1nMatchFamilyStyleCharacter
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_FontMgrKt__1nMatchFamilyStyleCharacter
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jstring
familyNameStr
,
jint
fontStyle
,
jobjectArray
bcp47Array
,
jint
character
)
{
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jstring
familyNameStr
,
jint
fontStyle
,
jobjectArray
bcp47Array
,
jint
bcp47size
,
jint
character
)
{
SkFontMgr
*
instance
=
reinterpret_cast
<
SkFontMgr
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkFontMgr
*
instance
=
reinterpret_cast
<
SkFontMgr
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkString
familyName
=
skString
(
env
,
familyNameStr
);
SkString
familyName
=
skString
(
env
,
familyNameStr
);
...
...
skiko/src/jvmMain/cpp/common/FontStyleSet.cc
View file @
09aad604
...
@@ -24,12 +24,12 @@ extern "C" JNIEXPORT jint JNICALL Java_org_jetbrains_skia_FontStyleSetKt__1nGetS
...
@@ -24,12 +24,12 @@ extern "C" JNIEXPORT jint JNICALL Java_org_jetbrains_skia_FontStyleSetKt__1nGetS
return
fontStyle
.
weight
()
+
(
fontStyle
.
width
()
<<
16
)
+
(
fontStyle
.
slant
()
<<
24
);
return
fontStyle
.
weight
()
+
(
fontStyle
.
width
()
<<
16
)
+
(
fontStyle
.
slant
()
<<
24
);
}
}
extern
"C"
JNIEXPORT
j
stri
ng
JNICALL
Java_org_jetbrains_skia_FontStyleSetKt__1nGetStyleName
extern
"C"
JNIEXPORT
j
lo
ng
JNICALL
Java_org_jetbrains_skia_FontStyleSetKt__1nGetStyleName
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jint
index
)
{
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jint
index
)
{
SkFontStyleSet
*
instance
=
reinterpret_cast
<
SkFontStyleSet
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkFontStyleSet
*
instance
=
reinterpret_cast
<
SkFontStyleSet
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkString
style
;
SkString
style
;
instance
->
getStyle
(
index
,
nullptr
,
&
style
);
instance
->
getStyle
(
index
,
nullptr
,
&
style
);
return
javaString
(
env
,
style
);
return
reinterpret_cast
<
jlong
>
(
new
SkString
(
style
)
);
}
}
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_FontStyleSetKt__1nGetTypeface
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_FontStyleSetKt__1nGetTypeface
...
...
skiko/src/jvmMain/cpp/common/Typeface.cc
View file @
09aad604
...
@@ -208,12 +208,12 @@ extern "C" JNIEXPORT jobjectArray JNICALL Java_org_jetbrains_skia_TypefaceKt__1n
...
@@ -208,12 +208,12 @@ extern "C" JNIEXPORT jobjectArray JNICALL Java_org_jetbrains_skia_TypefaceKt__1n
return
res
;
return
res
;
}
}
extern
"C"
JNIEXPORT
j
stri
ng
JNICALL
Java_org_jetbrains_skia_TypefaceKt__1nGetFamilyName
extern
"C"
JNIEXPORT
j
lo
ng
JNICALL
Java_org_jetbrains_skia_TypefaceKt__1nGetFamilyName
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
)
{
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
)
{
SkTypeface
*
instance
=
reinterpret_cast
<
SkTypeface
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkTypeface
*
instance
=
reinterpret_cast
<
SkTypeface
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkString
name
;
SkString
name
;
instance
->
getFamilyName
(
&
name
);
instance
->
getFamilyName
(
&
name
);
return
javaString
(
env
,
name
);
return
reinterpret_cast
<
jlong
>
(
new
SkString
(
name
)
);
}
}
extern
"C"
JNIEXPORT
jobject
JNICALL
Java_org_jetbrains_skia_TypefaceKt_Typeface_1nGetBounds
extern
"C"
JNIEXPORT
jobject
JNICALL
Java_org_jetbrains_skia_TypefaceKt_Typeface_1nGetBounds
...
...
skiko/src/jvmTest/kotlin/TestUtils.jvm.kt
View file @
09aad604
package
org.jetbrains.skiko.tests
package
org.jetbrains.skiko.tests
import
kotlinx.coroutines.runBlocking
import
kotlinx.coroutines.runBlocking
import
org.jetbrains.skia.Data
import
org.jetbrains.skia.impl.BufferUtil
import
org.jetbrains.skia.impl.BufferUtil
import
org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.makeFromFileName
import
java.nio.ByteBuffer
import
java.nio.ByteBuffer
actual
fun
runTest
(
block
:
suspend
()
->
Unit
)
{
actual
fun
runTest
(
block
:
suspend
()
->
Unit
)
{
...
@@ -19,3 +21,5 @@ actual annotation class SkipJsTarget
...
@@ -19,3 +21,5 @@ actual annotation class SkipJsTarget
actual
typealias
SkipJvmTarget
=
org
.
junit
.
Ignore
actual
typealias
SkipJvmTarget
=
org
.
junit
.
Ignore
actual
annotation
class
SkipNativeTarget
actual
annotation
class
SkipNativeTarget
actual
fun
makeFromFileName
(
path
:
String
?):
Data
=
Data
.
Companion
.
makeFromFileName
(
path
)
\ No newline at end of file
skiko/src/jvmTest/kotlin/org/jetbrains/skiko/FontMgrTest.kt
deleted
100644 → 0
View file @
3395afe9
package
org.jetbrains.skiko
import
org.jetbrains.skia.Data
import
org.jetbrains.skia.FontStyle
import
org.jetbrains.skia.Typeface
import
org.jetbrains.skia.makeFromFileName
import
org.jetbrains.skia.paragraph.TypefaceFontProvider
import
kotlin.test.Test
import
kotlin.test.assertEquals
import
kotlin.test.assertNull
import
org.jetbrains.skia.tests.makeFromResource
import
org.jetbrains.skiko.tests.runTest
class
FontMgrTest
{
@Test
fun
fontMgrTest
()
=
runTest
{
val
fontManager
=
TypefaceFontProvider
()
val
jbMono
=
Typeface
.
makeFromResource
(
"./fonts/JetBrainsMono-Regular.ttf"
)
fontManager
.
registerTypeface
(
jbMono
)
val
jbMonoBold
=
Typeface
.
makeFromResource
(
"./fonts/JetBrainsMono-Bold.ttf"
)
fontManager
.
registerTypeface
(
jbMonoBold
)
val
inter
:
Typeface
=
Typeface
.
makeFromResource
(
"./fonts/Inter-Hinted-Regular.ttf"
)
fontManager
.
registerTypeface
(
inter
,
"Interface"
)
assertEquals
(
2
,
fontManager
.
familiesCount
)
assertEquals
(
"JetBrains Mono"
,
fontManager
.
getFamilyName
(
0
))
assertEquals
(
"Interface"
,
fontManager
.
getFamilyName
(
1
))
fontManager
.
makeStyleSet
(
0
).
use
{
styleSet
->
assertEquals
(
0
,
styleSet
?.
count
())
}
fontManager
.
makeStyleSet
(
1
).
use
{
styleSet
->
assertEquals
(
0
,
styleSet
?.
count
())
}
fontManager
.
matchFamily
(
"JetBrains Mono"
).
use
{
styleSet
->
assertEquals
(
2
,
styleSet
.
count
())
assertEquals
(
FontStyle
.
NORMAL
,
styleSet
.
getStyle
(
0
))
assertEquals
(
"JetBrains Mono"
,
styleSet
.
getStyleName
(
0
))
assertEquals
(
FontStyle
.
BOLD
,
styleSet
.
getStyle
(
1
))
assertEquals
(
"JetBrains Mono"
,
styleSet
.
getStyleName
(
1
))
assertEquals
(
2
,
jbMono
.
refCount
)
styleSet
.
getTypeface
(
0
).
use
{
face
->
assertEquals
(
3
,
jbMono
.
refCount
)
assertEquals
(
jbMono
,
face
)
}
assertEquals
(
2
,
jbMono
.
refCount
)
assertEquals
(
2
,
jbMonoBold
.
refCount
)
styleSet
.
getTypeface
(
1
).
use
{
face
->
assertEquals
(
3
,
jbMonoBold
.
refCount
)
assertEquals
(
jbMonoBold
,
face
)
}
assertEquals
(
2
,
jbMonoBold
.
refCount
)
assertEquals
(
2
,
jbMono
.
refCount
)
styleSet
.
matchStyle
(
FontStyle
.
NORMAL
).
use
{
face
->
assertEquals
(
3
,
jbMono
.
refCount
)
assertEquals
(
jbMono
,
face
)
}
assertEquals
(
2
,
jbMono
.
refCount
)
assertEquals
(
2
,
jbMonoBold
.
refCount
)
styleSet
.
matchStyle
(
FontStyle
.
BOLD
).
use
{
face
->
assertEquals
(
3
,
jbMonoBold
.
refCount
)
assertEquals
(
jbMonoBold
,
face
)
}
assertEquals
(
2
,
jbMonoBold
.
refCount
)
assertEquals
(
jbMono
,
styleSet
.
matchStyle
(
FontStyle
.
ITALIC
))
}
assertNull
(
fontManager
.
matchFamilyStyle
(
"JetBrains Mono"
,
FontStyle
.
BOLD
))
assertNull
(
fontManager
.
matchFamilyStyle
(
"Interface"
,
FontStyle
.
NORMAL
))
assertEquals
(
null
,
fontManager
.
matchFamilyStyleCharacter
(
"JetBrains Mono"
,
FontStyle
.
BOLD
,
arrayOf
(
"en-US"
),
65
/* A */
)
)
Data
.
makeFromFileName
(
"src/commonTest/resources/fonts/JetBrainsMono-Italic.ttf"
).
use
{
data
->
fontManager
.
makeFromData
(
data
).
use
{
fontManager
.
matchFamily
(
"JetBrains Mono"
).
use
{
styleSet
->
assertEquals
(
2
,
fontManager
.
familiesCount
)
assertEquals
(
2
,
styleSet
.
count
())
}
}
}
fontManager
.
close
()
}
}
\ No newline at end of file
skiko/src/nativeJsMain/cpp/FontMgr.cc
View file @
09aad604
...
@@ -16,65 +16,50 @@ SKIKO_EXPORT KInt org_jetbrains_skia_FontMgr__1nGetFamiliesCount
...
@@ -16,65 +16,50 @@ SKIKO_EXPORT KInt org_jetbrains_skia_FontMgr__1nGetFamiliesCount
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_FontMgr__1nGetFamilyName
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_FontMgr__1nGetFamilyName
(
KNativePointer
ptr
,
KInt
index
)
{
(
KNativePointer
ptr
,
KInt
index
)
{
TODO
(
"implement org_jetbrains_skia_FontMgr__1nGetFamilyName"
);
SkFontMgr
*
instance
=
reinterpret_cast
<
SkFontMgr
*>
(
ptr
);
}
#if 0
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_FontMgr__1nGetFamilyName
(KNativePointer ptr, KInt index) {
SkFontMgr* instance = reinterpret_cast<SkFontMgr*>((ptr));
SkString
familyName
;
SkString
familyName
;
instance
->
getFamilyName
(
index
,
&
familyName
);
instance
->
getFamilyName
(
index
,
&
familyName
);
return
javaString(env,
familyName);
return
new
SkString
(
familyName
);
}
}
#endif
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_FontMgr__1nMakeStyleSet
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_FontMgr__1nMakeStyleSet
(
KNativePointer
ptr
,
KInt
index
)
{
(
KNativePointer
ptr
,
KInt
index
)
{
SkFontMgr
*
instance
=
reinterpret_cast
<
SkFontMgr
*>
(
(
ptr
)
);
SkFontMgr
*
instance
=
reinterpret_cast
<
SkFontMgr
*>
(
ptr
);
SkFontStyleSet
*
styleSet
=
instance
->
createStyleSet
(
index
);
SkFontStyleSet
*
styleSet
=
instance
->
createStyleSet
(
index
);
return
reinterpret_cast
<
KNativePointer
>
(
styleSet
);
return
reinterpret_cast
<
KNativePointer
>
(
styleSet
);
}
}
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_FontMgr__1nMatchFamily
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_FontMgr__1nMatchFamily
(
KNativePointer
ptr
,
KInteropPointer
familyNameStr
)
{
(
KNativePointer
ptr
,
KInteropPointer
familyNameStr
)
{
TODO
(
"implement org_jetbrains_skia_FontMgr__1nMatchFamily"
);
SkFontMgr
*
instance
=
reinterpret_cast
<
SkFontMgr
*>
(
ptr
);
}
SkFontStyleSet
*
styleSet
=
instance
->
matchFamily
(
reinterpret_cast
<
char
*>
(
familyNameStr
));
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontMgr__1nMatchFamily
(KNativePointer ptr, KInteropPointer familyNameStr) {
SkFontMgr* instance = reinterpret_cast<SkFontMgr*>((ptr));
SkString familyName = skString(env, familyNameStr);
SkFontStyleSet* styleSet = instance->matchFamily(familyName.c_str());
return
reinterpret_cast
<
KNativePointer
>
(
styleSet
);
return
reinterpret_cast
<
KNativePointer
>
(
styleSet
);
}
}
#endif
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_FontMgr__1nMatchFamilyStyle
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_FontMgr__1nMatchFamilyStyle
(
KNativePointer
ptr
,
KInteropPointer
familyNameStr
,
KInt
fontStyle
)
{
(
KNativePointer
ptr
,
KInteropPointer
familyNameStr
,
KInt
fontStyle
)
{
TODO
(
"implement org_jetbrains_skia_FontMgr__1nMatchFamilyStyle"
);
SkFontMgr
*
instance
=
reinterpret_cast
<
SkFontMgr
*>
(
ptr
);
}
SkString
familyName
=
skString
(
familyNameStr
);
SkTypeface
*
typeface
=
instance
->
matchFamilyStyle
(
familyName
.
c_str
(),
skija
::
FontStyle
::
fromKotlin
(
fontStyle
));
#if 0
SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontMgr__1nMatchFamilyStyle
(KNativePointer ptr, KInteropPointer familyNameStr, KInt fontStyle) {
SkFontMgr* instance = reinterpret_cast<SkFontMgr*>((ptr));
SkString familyName = skString(env, familyNameStr);
SkTypeface* typeface = instance->matchFamilyStyle(familyName.c_str(), skija::FontStyle::fromJava(fontStyle));
return
reinterpret_cast
<
KNativePointer
>
(
typeface
);
return
reinterpret_cast
<
KNativePointer
>
(
typeface
);
}
}
#endif
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_FontMgr__1nMatchFamilyStyleCharacter
(
KNativePointer
ptr
,
KInteropPointer
familyNameStr
,
KInt
fontStyle
,
KInteropPointerArray
bcp47Array
,
KInt
bcp47size
,
KInt
character
)
{
SkFontMgr
*
instance
=
reinterpret_cast
<
SkFontMgr
*>
(
ptr
);
SkString
familyName
=
skString
(
familyNameStr
);
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_FontMgr__1nMatchFamilyStyleCharacter
std
::
vector
<
SkString
>
bcp47Strings
=
skStringVector
(
bcp47Array
,
bcp47size
);
(
KNativePointer
ptr
,
KInteropPointer
familyNameStr
,
KInt
fontStyle
,
KInteropPointerArray
bcp47Array
,
KInt
character
)
{
std
::
vector
<
const
char
*>
bcp47
(
bcp47Strings
.
size
());
TODO
(
"implement org_jetbrains_skia_FontMgr__1nMatchFamilyStyleCharacter"
);
for
(
int
i
=
0
;
i
<
bcp47
.
size
();
++
i
)
bcp47
[
i
]
=
bcp47Strings
[
i
].
c_str
();
SkTypeface
*
typeface
=
instance
->
matchFamilyStyleCharacter
(
familyName
.
c_str
(),
skija
::
FontStyle
::
fromKotlin
(
fontStyle
),
bcp47
.
data
(),
(
int
)
bcp47
.
size
(),
character
);
return
reinterpret_cast
<
KNativePointer
>
(
typeface
);
}
}
#if 0
#if 0
...
...
skiko/src/nativeJsMain/cpp/FontStyleSet.cc
View file @
09aad604
...
@@ -14,7 +14,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontStyleSet__1nMakeEmpty
...
@@ -14,7 +14,7 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontStyleSet__1nMakeEmpty
SKIKO_EXPORT
KInt
org_jetbrains_skia_FontStyleSet__1nCount
SKIKO_EXPORT
KInt
org_jetbrains_skia_FontStyleSet__1nCount
(
KNativePointer
ptr
)
{
(
KNativePointer
ptr
)
{
SkFontStyleSet
*
instance
=
reinterpret_cast
<
SkFontStyleSet
*>
(
(
ptr
)
);
SkFontStyleSet
*
instance
=
reinterpret_cast
<
SkFontStyleSet
*>
(
ptr
);
return
instance
->
count
();
return
instance
->
count
();
}
}
...
@@ -27,21 +27,13 @@ SKIKO_EXPORT KInt org_jetbrains_skia_FontStyleSet__1nGetStyle
...
@@ -27,21 +27,13 @@ SKIKO_EXPORT KInt org_jetbrains_skia_FontStyleSet__1nGetStyle
}
}
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_FontStyleSet__1nGetStyleName
(
KNativePointer
ptr
,
KInt
index
)
{
TODO
(
"implement org_jetbrains_skia_FontStyleSet__1nGetStyleName"
);
}
#if 0
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_FontStyleSet__1nGetStyleName
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_FontStyleSet__1nGetStyleName
(
KNativePointer
ptr
,
KInt
index
)
{
(
KNativePointer
ptr
,
KInt
index
)
{
SkFontStyleSet
*
instance
=
reinterpret_cast
<
SkFontStyleSet
*>
((
ptr
));
SkFontStyleSet
*
instance
=
reinterpret_cast
<
SkFontStyleSet
*>
((
ptr
));
SkString
style
;
SkString
style
;
instance
->
getStyle
(
index
,
nullptr
,
&
style
);
instance
->
getStyle
(
index
,
nullptr
,
&
style
);
return
javaString(env,
style);
return
new
SkString
(
style
);
}
}
#endif
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_FontStyleSet__1nGetTypeface
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_FontStyleSet__1nGetTypeface
(
KNativePointer
ptr
,
KInt
index
)
{
(
KNativePointer
ptr
,
KInt
index
)
{
...
@@ -50,18 +42,9 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontStyleSet__1nGetTypeface
...
@@ -50,18 +42,9 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_FontStyleSet__1nGetTypeface
return
reinterpret_cast
<
KNativePointer
>
(
typeface
);
return
reinterpret_cast
<
KNativePointer
>
(
typeface
);
}
}
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_FontStyleSet__1nMatchStyle
(
KNativePointer
ptr
,
KInt
fontStyle
)
{
TODO
(
"implement org_jetbrains_skia_FontStyleSet__1nMatchStyle"
);
}
#if 0
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_FontStyleSet__1nMatchStyle
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_FontStyleSet__1nMatchStyle
(
KNativePointer
ptr
,
KInt
fontStyle
)
{
(
KNativePointer
ptr
,
KInt
fontStyle
)
{
SkFontStyleSet
*
instance
=
reinterpret_cast
<
SkFontStyleSet
*>
((
ptr
));
SkFontStyleSet
*
instance
=
reinterpret_cast
<
SkFontStyleSet
*>
((
ptr
));
SkTypeface* typeface = instance->matchStyle(skija::FontStyle::from
Java
(fontStyle));
SkTypeface
*
typeface
=
instance
->
matchStyle
(
skija
::
FontStyle
::
from
Kotlin
(
fontStyle
));
return
reinterpret_cast
<
KNativePointer
>
(
typeface
);
return
reinterpret_cast
<
KNativePointer
>
(
typeface
);
}
}
\ No newline at end of file
#endif
skiko/src/nativeJsMain/cpp/Typeface.cc
View file @
09aad604
...
@@ -288,20 +288,11 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_Typeface__1nGetFamilyNames
...
@@ -288,20 +288,11 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_Typeface__1nGetFamilyNames
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_Typeface__1nGetFamilyName
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_Typeface__1nGetFamilyName
(
KNativePointer
ptr
)
{
(
KNativePointer
ptr
)
{
TODO
(
"implement org_jetbrains_skia_Typeface__1nGetFamilyName"
);
SkTypeface
*
instance
=
reinterpret_cast
<
SkTypeface
*>
(
ptr
);
}
#if 0
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_Typeface__1nGetFamilyName
(KNativePointer ptr) {
SkTypeface* instance = reinterpret_cast<SkTypeface*>((ptr));
SkString
name
;
SkString
name
;
instance
->
getFamilyName
(
&
name
);
instance
->
getFamilyName
(
&
name
);
return
javaString(env,
name);
return
new
SkString
(
name
);
}
}
#endif
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_Typeface__1nGetBounds
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_Typeface__1nGetBounds
(
KNativePointer
ptr
)
{
(
KNativePointer
ptr
)
{
...
...
skiko/src/nativeTest/kotlin/org/jetbrains/skiko/tests/TestUtils.native.kt
View file @
09aad604
package
org.jetbrains.skiko.tests
package
org.jetbrains.skiko.tests
import
kotlinx.coroutines.runBlocking
import
kotlinx.coroutines.runBlocking
import
org.jetbrains.skia.Data
import
org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.makeFromFileName
actual
fun
runTest
(
block
:
suspend
()
->
Unit
)
{
actual
fun
runTest
(
block
:
suspend
()
->
Unit
)
{
runBlocking
{
block
()
}
runBlocking
{
block
()
}
...
@@ -17,3 +19,5 @@ actual annotation class SkipJsTarget
...
@@ -17,3 +19,5 @@ actual annotation class SkipJsTarget
actual
annotation
class
SkipJvmTarget
actual
annotation
class
SkipJvmTarget
actual
typealias
SkipNativeTarget
=
kotlin
.
test
.
Ignore
actual
typealias
SkipNativeTarget
=
kotlin
.
test
.
Ignore
actual
fun
makeFromFileName
(
path
:
String
?):
Data
=
Data
.
Companion
.
makeFromFileName
(
path
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment