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
b5e2a775
Unverified
Commit
b5e2a775
authored
Nov 18, 2021
by
Shagen Ogandzhanian
Committed by
GitHub
Nov 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commonize Font (#382)
parent
eb4bee60
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
445 additions
and
299 deletions
+445
-299
build.gradle.kts
skiko/build.gradle.kts
+11
-1
Font.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Font.kt
+80
-42
Rect.kt
skiko/src/commonMain/kotlin/org/jetbrains/skia/Rect.kt
+8
-0
FontTests.kt
skiko/src/commonTest/kotlin/org/jetbrains/skia/FontTests.kt
+138
-0
assertCloseEnough.kt
...nTest/kotlin/org/jetbrains/skia/util/assertCloseEnough.kt
+28
-1
Font.cc
skiko/src/jvmMain/cpp/common/Font.cc
+68
-55
Font.cc
skiko/src/nativeJsMain/cpp/Font.cc
+112
-200
No files found.
skiko/build.gradle.kts
View file @
b5e2a775
import
de.undercouch.gradle.tasks.download.Download
import
org.gradle.crypto.checksum.Checksum
import
org.gradle.api.tasks.testing.AbstractTestTask
import
org.jetbrains.compose.internal.publishing.MavenCentralProperties
import
org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import
org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import
org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
import
org.gradle.api.tasks.testing.logging.TestExceptionFormat
plugins
{
kotlin
(
"multiplatform"
)
version
"1.5.31"
...
...
@@ -207,7 +209,6 @@ kotlin {
js
(
IR
)
{
browser
()
{
testTask
{
testLogging
.
showStandardStreams
=
true
dependsOn
(
linkWasm
)
useKarma
{
useChromeHeadless
()
...
...
@@ -1144,3 +1145,12 @@ fun registerOrGetSkiaDirProvider(os: OS, arch: Arch): Provider<File> {
}.
map
{
it
.
destinationDir
.
absoluteFile
}
}
}
tasks
.
withType
<
AbstractTestTask
>
{
testLogging
{
events
(
"FAILED"
,
"SKIPPED"
)
exceptionFormat
=
TestExceptionFormat
.
FULL
showStandardStreams
=
true
showStackTraces
=
true
}
}
skiko/src/commonMain/kotlin/org/jetbrains/skia/Font.kt
View file @
b5e2a775
...
...
@@ -2,6 +2,15 @@ package org.jetbrains.skia
import
org.jetbrains.skia.impl.*
import
org.jetbrains.skia.impl.Library.Companion.staticLoad
import
org.jetbrains.skia.impl.InteropPointer
import
org.jetbrains.skia.impl.Managed
import
org.jetbrains.skia.impl.Native
import
org.jetbrains.skia.impl.Stats
import
org.jetbrains.skia.impl.reachabilityBarrier
import
org.jetbrains.skia.impl.NativePointer
import
org.jetbrains.skia.impl.getPtr
import
org.jetbrains.skia.impl.interopScope
import
org.jetbrains.skia.impl.withResult
class
Font
:
Managed
{
companion
object
{
...
...
@@ -327,8 +336,12 @@ class Font : Managed {
fun
getUTF32Glyphs
(
uni
:
IntArray
?):
ShortArray
{
return
try
{
Stats
.
onNativeCall
()
withResult
(
ShortArray
(
uni
?.
size
?:
0
))
{
_nGetUTF32Glyphs
(
_ptr
,
toInterop
(
uni
),
uni
?.
size
?:
0
,
it
)
if
(
uni
==
null
)
{
shortArrayOf
()
}
else
{
withResult
(
ShortArray
(
uni
.
size
))
{
_nGetUTF32Glyphs
(
_ptr
,
toInterop
(
uni
),
uni
.
size
,
it
)
}
}
}
finally
{
reachabilityBarrier
(
this
)
...
...
@@ -353,7 +366,7 @@ class Font : Managed {
fun
getStringGlyphsCount
(
s
:
String
?):
Int
{
return
try
{
Stats
.
onNativeCall
()
_nGetStringGlyphsCount
(
_ptr
,
s
)
interopScope
{
_nGetStringGlyphsCount
(
_ptr
,
toInterop
(
s
),
s
?.
length
?:
0
)
}
}
finally
{
reachabilityBarrier
(
this
)
}
...
...
@@ -368,7 +381,9 @@ class Font : Managed {
fun
measureText
(
s
:
String
?,
p
:
Paint
?
=
null
):
Rect
{
return
try
{
Stats
.
onNativeCall
()
_nMeasureText
(
_ptr
,
s
,
getPtr
(
p
))
Rect
.
fromInteropPointer
()
{
_nMeasureText
(
_ptr
,
toInterop
(
s
),
s
?.
length
?:
0
,
getPtr
(
p
),
it
)
}
}
finally
{
reachabilityBarrier
(
this
)
reachabilityBarrier
(
p
)
...
...
@@ -383,11 +398,15 @@ class Font : Managed {
fun
measureTextWidth
(
s
:
String
?,
p
:
Paint
?):
Float
{
return
try
{
Stats
.
onNativeCall
()
interopScope
{
_nMeasureTextWidth
(
_ptr
,
s
,
toInterop
(
s
),
s
?.
length
?:
0
,
getPtr
(
p
)
)
}
}
finally
{
reachabilityBarrier
(
this
)
reachabilityBarrier
(
p
)
...
...
@@ -400,7 +419,13 @@ class Font : Managed {
fun
getWidths
(
glyphs
:
ShortArray
?):
FloatArray
{
return
try
{
Stats
.
onNativeCall
()
_nGetWidths
(
_ptr
,
glyphs
)
if
(
glyphs
==
null
)
{
return
floatArrayOf
()
}
else
{
withResult
(
FloatArray
(
glyphs
.
size
))
{
_nGetWidths
(
_ptr
,
toInterop
(
glyphs
),
glyphs
.
size
,
it
)
}
}
}
finally
{
reachabilityBarrier
(
this
)
}
...
...
@@ -419,11 +444,20 @@ class Font : Managed {
fun
getBounds
(
glyphs
:
ShortArray
?,
p
:
Paint
?):
Array
<
Rect
>
{
return
try
{
Stats
.
onNativeCall
()
if
(
glyphs
==
null
)
{
emptyArray
()
}
else
{
Rect
.
fromInteropPointer
(
glyphs
.
size
*
4
)
{
_nGetBounds
(
_ptr
,
glyphs
,
getPtr
(
p
)
toInterop
(
glyphs
),
glyphs
.
size
,
getPtr
(
p
),
it
)
}
}
}
finally
{
reachabilityBarrier
(
this
)
reachabilityBarrier
(
p
)
...
...
@@ -434,12 +468,7 @@ class Font : Managed {
* Retrieves the positions for each glyph.
*/
fun
getPositions
(
glyphs
:
ShortArray
?):
Array
<
Point
>
{
return
try
{
Stats
.
onNativeCall
()
_nGetPositions
(
_ptr
,
glyphs
,
0f
,
0f
)
}
finally
{
reachabilityBarrier
(
this
)
}
return
getPositions
(
glyphs
,
Point
(
0f
,
0f
))
}
/**
...
...
@@ -448,22 +477,26 @@ class Font : Managed {
fun
getPositions
(
glyphs
:
ShortArray
?,
offset
:
Point
):
Array
<
Point
>
{
return
try
{
Stats
.
onNativeCall
()
_nGetPositions
(
_ptr
,
glyphs
,
offset
.
x
,
offset
.
y
)
if
(
glyphs
==
null
)
{
emptyArray
()
}
else
{
val
positionsData
=
withResult
(
FloatArray
(
glyphs
.
size
*
2
))
{
_nGetPositions
(
_ptr
,
toInterop
(
glyphs
),
glyphs
.
size
,
offset
.
x
,
offset
.
y
,
it
)
}
(
0
until
glyphs
.
size
).
map
{
i
->
Point
(
positionsData
[
2
*
i
],
positionsData
[
2
*
i
+
1
])
}.
toTypedArray
()
}
}
finally
{
reachabilityBarrier
(
this
)
}
}
/**
* Retrieves the x-positions for each glyph.
* Retrieves the x-positions for each glyph
, beginning at the specified origin
.
*/
fun
getXPositions
(
glyphs
:
ShortArray
?):
FloatArray
{
return
try
{
Stats
.
onNativeCall
()
_nGetXPositions
(
_ptr
,
glyphs
,
0f
)
}
finally
{
reachabilityBarrier
(
this
)
}
return
getXPositions
(
glyphs
,
0f
)
}
/**
...
...
@@ -472,7 +505,13 @@ class Font : Managed {
fun
getXPositions
(
glyphs
:
ShortArray
?,
offset
:
Float
):
FloatArray
{
return
try
{
Stats
.
onNativeCall
()
_nGetXPositions
(
_ptr
,
glyphs
,
offset
)
if
(
glyphs
==
null
)
{
floatArrayOf
()
}
else
{
withResult
(
FloatArray
(
glyphs
.
size
))
{
_nGetXPositions
(
_ptr
,
toInterop
(
glyphs
),
offset
,
glyphs
.
size
,
it
)
}
}
}
finally
{
reachabilityBarrier
(
this
)
}
...
...
@@ -511,7 +550,9 @@ class Font : Managed {
val
metrics
:
FontMetrics
get
()
=
try
{
Stats
.
onNativeCall
()
_nGetMetrics
(
_ptr
)
FontMetrics
.
fromInteropPointer
{
_nGetMetrics
(
_ptr
,
it
)
}
}
finally
{
reachabilityBarrier
(
this
)
}
...
...
@@ -630,9 +671,6 @@ private external fun _nSetScaleX(ptr: NativePointer, value: Float)
@ExternalSymbolName
(
"org_jetbrains_skia_Font__1nSetSkewX"
)
private
external
fun
_nSetSkewX
(
ptr
:
NativePointer
,
value
:
Float
)
@ExternalSymbolName
(
"org_jetbrains_skia_Font__1nGetStringGlyphs"
)
private
external
fun
_nGetStringGlyphs
(
ptr
:
NativePointer
,
str
:
String
?):
ShortArray
?
@ExternalSymbolName
(
"org_jetbrains_skia_Font__1nGetUTF32Glyph"
)
private
external
fun
_nGetUTF32Glyph
(
ptr
:
NativePointer
,
uni
:
Int
):
Short
...
...
@@ -640,25 +678,25 @@ private external fun _nGetUTF32Glyph(ptr: NativePointer, uni: Int): Short
private
external
fun
_nGetUTF32Glyphs
(
ptr
:
NativePointer
,
uni
:
InteropPointer
,
uniArrLen
:
Int
,
resultGlyphs
:
InteropPointer
)
@ExternalSymbolName
(
"org_jetbrains_skia_Font__1nGetStringGlyphsCount"
)
private
external
fun
_nGetStringGlyphsCount
(
ptr
:
NativePointer
,
str
:
String
?
):
Int
private
external
fun
_nGetStringGlyphsCount
(
ptr
:
NativePointer
,
str
:
InteropPointer
,
len
:
Int
):
Int
@ExternalSymbolName
(
"org_jetbrains_skia_Font__1nMeasureText"
)
private
external
fun
_nMeasureText
(
ptr
:
NativePointer
,
str
:
String
?,
paintPtr
:
Native
Pointer
):
Rect
private
external
fun
_nMeasureText
(
ptr
:
NativePointer
,
str
:
InteropPointer
,
len
:
Int
,
paintPtr
:
NativePointer
,
rect
:
Interop
Pointer
):
Rect
@ExternalSymbolName
(
"org_jetbrains_skia_Font__1nMeasureTextWidth"
)
private
external
fun
_nMeasureTextWidth
(
ptr
:
NativePointer
,
str
:
String
?
,
paintPtr
:
NativePointer
):
Float
private
external
fun
_nMeasureTextWidth
(
ptr
:
NativePointer
,
str
:
InteropPointer
,
len
:
Int
,
paintPtr
:
NativePointer
):
Float
@ExternalSymbolName
(
"org_jetbrains_skia_Font__1nGetWidths"
)
private
external
fun
_nGetWidths
(
ptr
:
NativePointer
,
glyphs
:
ShortArray
?):
FloatArray
private
external
fun
_nGetWidths
(
ptr
:
NativePointer
,
glyphs
:
InteropPointer
,
count
:
Int
,
width
:
InteropPointer
)
@ExternalSymbolName
(
"org_jetbrains_skia_Font__1nGetBounds"
)
private
external
fun
_nGetBounds
(
ptr
:
NativePointer
,
glyphs
:
ShortArray
?,
paintPtr
:
NativePointer
):
Array
<
Rect
>
private
external
fun
_nGetBounds
(
ptr
:
NativePointer
,
glyphs
:
InteropPointer
,
count
:
Int
,
paintPtr
:
NativePointer
,
bounds
:
InteropPointer
)
@ExternalSymbolName
(
"org_jetbrains_skia_Font__1nGetPositions"
)
private
external
fun
_nGetPositions
(
ptr
:
NativePointer
,
glyphs
:
ShortArray
?,
x
:
Float
,
y
:
Float
):
Array
<
Point
>
private
external
fun
_nGetPositions
(
ptr
:
NativePointer
,
glyphs
:
InteropPointer
,
count
:
Int
,
x
:
Float
,
y
:
Float
,
positions
:
InteropPointer
)
@ExternalSymbolName
(
"org_jetbrains_skia_Font__1nGetXPositions"
)
private
external
fun
_nGetXPositions
(
ptr
:
NativePointer
,
glyphs
:
ShortArray
?,
x
:
Float
):
FloatArray
private
external
fun
_nGetXPositions
(
ptr
:
NativePointer
,
glyphs
:
InteropPointer
,
x
:
Float
,
count
:
Int
,
positions
:
InteropPointer
)
@ExternalSymbolName
(
"org_jetbrains_skia_Font__1nGetPath"
)
private
external
fun
_nGetPath
(
ptr
:
NativePointer
,
glyph
:
Short
):
NativePointer
...
...
@@ -667,7 +705,7 @@ private external fun _nGetPath(ptr: NativePointer, glyph: Short): NativePointer
private
external
fun
_nGetPaths
(
ptr
:
NativePointer
,
glyphs
:
ShortArray
?):
Array
<
Path
>
@ExternalSymbolName
(
"org_jetbrains_skia_Font__1nGetMetrics"
)
private
external
fun
_nGetMetrics
(
ptr
:
NativePointer
):
FontMetrics
private
external
fun
_nGetMetrics
(
ptr
:
NativePointer
,
metrics
:
InteropPointer
)
@ExternalSymbolName
(
"org_jetbrains_skia_Font__1nGetSpacing"
)
private
external
fun
_nGetSpacing
(
ptr
:
NativePointer
):
Float
skiko/src/commonMain/kotlin/org/jetbrains/skia/Rect.kt
View file @
b5e2a775
...
...
@@ -2,6 +2,7 @@ package org.jetbrains.skia
import
org.jetbrains.skia.impl.InteropPointer
import
org.jetbrains.skia.impl.InteropScope
import
org.jetbrains.skia.impl.getPtr
import
org.jetbrains.skia.impl.withResult
import
kotlin.jvm.JvmStatic
...
...
@@ -116,6 +117,13 @@ open class Rect constructor(val left: Float, val top: Float, val right: Float, v
return
Rect
(
result
[
0
],
result
[
1
],
result
[
2
],
result
[
3
])
}
internal
fun
fromInteropPointer
(
size
:
Int
,
block
:
InteropScope
.(
InteropPointer
)
->
Unit
):
Array
<
Rect
>
{
val
result
=
withResult
(
FloatArray
(
size
),
block
)
return
result
.
toList
().
chunked
(
4
).
map
{
(
left
,
top
,
right
,
bottom
)
->
Rect
(
left
,
right
,
top
,
bottom
)
}.
toTypedArray
()
}
internal
fun
fromInteropPointerNullable
(
block
:
(
InteropPointer
)
->
Boolean
):
Rect
?
{
var
result
=
true
val
rect
=
fromInteropPointer
{
result
=
block
(
it
)
}
...
...
skiko/src/commonTest/kotlin/org/jetbrains/skia/FontTests.kt
0 → 100644
View file @
b5e2a775
package
org.jetbrains.skia
import
org.jetbrains.skia.impl.use
import
org.jetbrains.skia.tests.assertCloseEnough
import
org.jetbrains.skia.tests.assertContentCloseEnough
import
org.jetbrains.skia.tests.makeFromResource
import
org.jetbrains.skiko.KotlinBackend
import
org.jetbrains.skiko.OS
import
org.jetbrains.skiko.hostOs
import
org.jetbrains.skiko.kotlinBackend
import
org.jetbrains.skiko.tests.runTest
import
kotlin.test.Test
import
kotlin.test.assertContentEquals
import
kotlin.test.assertEquals
private
fun
isLinuxOrJs
()
=
(
hostOs
==
OS
.
Linux
)
||
(
hostOs
==
OS
.
JS
)
private
fun
isWin
()
=
(
hostOs
==
OS
.
Windows
)
private
val
COARSE_EPSILON
=
2.4f
class
FontTests
{
@Test
fun
fontTest
()
=
runTest
{
val
jbMono
=
Typeface
.
makeFromResource
(
"./fonts/JetBrainsMono-Regular.ttf"
)
Font
(
jbMono
).
use
{
font
->
assertEquals
(
12f
,
font
.
size
)
// TODO: we have to use bigger epsilon because of MacOS and definitely need to investigate what would be a better solution
assertCloseEnough
(
14.880001f
,
font
.
spacing
,
10e-5f
)
val
glyphs
=
font
.
getStringGlyphs
(
"ABCDE"
)
assertContentEquals
(
shortArrayOf
(
17
,
18
,
19
,
20
,
21
),
glyphs
)
assertEquals
(
6
,
font
.
getStringGlyphsCount
(
"EЙ를üẞ無"
))
assertCloseEnough
(
50.4f
,
font
.
measureTextWidth
(
"EЙ를üẞՇ無"
),
COARSE_EPSILON
)
assertContentCloseEnough
(
floatArrayOf
(
7.2f
,
7.2f
,
7.2f
,
7.2f
,
7.2f
),
font
.
getWidths
(
glyphs
),
COARSE_EPSILON
)
assertContentCloseEnough
(
floatArrayOf
(
0f
,
7.2f
,
14.4f
,
21.6f
,
28.8f
),
font
.
getXPositions
(
glyphs
),
COARSE_EPSILON
)
assertContentCloseEnough
(
floatArrayOf
(
3f
,
10.2f
,
17.4f
,
24.6f
,
31.8f
),
font
.
getXPositions
(
glyphs
,
3f
),
COARSE_EPSILON
)
val
firstGlyphPath
=
font
.
getPath
(
glyphs
[
0
])
!!
assertContentCloseEnough
(
listOf
(
Point
(
2.8798828f
,
-
8.639648f
),
Point
(
4.3916016f
,
-
8.639648f
),
Point
(
6.6708984f
,
0.0f
),
Point
(
5.5195312f
,
0.0f
),
Point
(
4.9189453f
,
-
2.4345703f
)
),
// TODO: investigate why we have nullable points at all
(
firstGlyphPath
.
points
.
toList
()
as
List
<
Point
>).
subList
(
0
,
5
),
10e-3f
)
assertContentCloseEnough
(
arrayOf
(
Point
(
0f
,
0f
),
Point
(
7.2f
,
0f
),
Point
(
14.4f
,
0f
),
Point
(
21.6f
,
0f
),
Point
(
28.8f
,
0f
),
),
font
.
getPositions
(
glyphs
),
COARSE_EPSILON
)
assertContentCloseEnough
(
arrayOf
(
Point
(
3f
,
2f
),
Point
(
10.2f
,
2f
),
Point
(
17.4f
,
2f
),
Point
(
24.6f
,
2f
),
Point
(
31.8f
,
2f
),
),
font
.
getPositions
(
glyphs
,
Point
(
3f
,
2f
)),
COARSE_EPSILON
)
val
expectedGlyphBounds
=
arrayOf
(
Rect
(-
1f
,
-
10.0f
,
8.0f
,
1.0f
),
Rect
(
0f
,
-
10.0f
,
8.0f
,
1.0f
),
Rect
(
0f
,
-
10.0f
,
8.0f
,
2.0f
),
Rect
(
0f
,
-
10.0f
,
8.0f
,
1.0f
),
Rect
(
0f
,
-
10.0f
,
8.0f
,
1.0f
),
)
expectedGlyphBounds
.
zip
(
font
.
getBounds
(
glyphs
)).
forEach
{
(
expected
,
actual
)
->
assertCloseEnough
(
expected
,
actual
,
COARSE_EPSILON
)
}
if
(
isLinuxOrJs
())
{
assertEquals
(
26
,
firstGlyphPath
.
pointsCount
)
assertCloseEnough
(
FontMetrics
(
-
11.64f
,
-
11.64f
,
3.2400002f
,
3.2400002f
,
0f
,
7.2000003f
,
29.460001f
,
-
20.880001f
,
8.58f
,
6.6000004f
,
8.64f
,
0.54f
,
1.4399999f
,
0.54f
,
-
3.8999999f
),
font
.
metrics
,
10e-3f
)
}
else
{
assertEquals
(
24
,
firstGlyphPath
.
pointsCount
)
// TODO: this cross-platform differences look very suspicious and need to be addressed separately
assertCloseEnough
(
FontMetrics
(
-
11.64f
,
-
11.64f
,
3.2400002f
,
3.2400002f
,
0f
,
if
(
isWin
())
0f
else
29.460001f
,
29.460001f
,
-
20.880001f
,
8.58f
,
6.6000004f
,
8.64f
,
0.54f
,
1.4399999f
,
if
(
isWin
())
0.54f
else
null
,
if
(
isWin
())
-
3.8999999f
else
null
),
font
.
metrics
,
10e-3f
)
}
// assertEquals(Rect(1f, -12f, 21f, 0f), font.measureText("ЕЁЫ"))
}
}
}
\ No newline at end of file
skiko/src/commonTest/kotlin/org/jetbrains/skia/util/assertCloseEnough.kt
View file @
b5e2a775
package
org.jetbrains.skia.tests
import
org.jetbrains.skia.Color4f
import
org.jetbrains.skia.FontMetrics
import
org.jetbrains.skia.Matrix33
import
org.jetbrains.skia.Point
import
org.jetbrains.skia.Rect
...
...
@@ -12,7 +13,9 @@ import kotlin.test.assertTrue
private
val
EPSILON
=
if
(
kotlinBackend
==
KotlinBackend
.
JS
)
0.00001f
else
0.00000001f
private
inline
fun
Float
.
isCloseEnoughTo
(
b
:
Float
,
epsilon
:
Float
)
=
abs
(
this
-
b
)
<
epsilon
private
inline
fun
Float
?.
isCloseEnoughTo
(
b
:
Float
?,
epsilon
:
Float
)
=
if
(
this
==
null
)
b
==
null
else
if
(
b
==
null
)
false
else
abs
(
this
-
b
)
<
epsilon
private
inline
fun
Point
.
isCloseEnoughTo
(
b
:
Point
,
epsilon
:
Float
)
=
x
.
isCloseEnoughTo
(
b
.
x
,
epsilon
)
&&
y
.
isCloseEnoughTo
(
b
.
y
,
epsilon
)
...
...
@@ -22,6 +25,22 @@ private inline fun Color4f.isCloseEnoughTo(otherColor: Color4f, epsilon: Float)
epsilon
)
&&
b
.
isCloseEnoughTo
(
otherColor
.
b
,
epsilon
)
&&
a
.
isCloseEnoughTo
(
otherColor
.
a
,
epsilon
)
private
inline
fun
FontMetrics
.
isCloseEnoughTo
(
b
:
FontMetrics
,
epsilon
:
Float
)
=
top
.
isCloseEnoughTo
(
b
.
top
,
epsilon
)
&&
ascent
.
isCloseEnoughTo
(
b
.
ascent
,
epsilon
)
&&
descent
.
isCloseEnoughTo
(
b
.
descent
,
epsilon
)
&&
bottom
.
isCloseEnoughTo
(
b
.
bottom
,
epsilon
)
&&
leading
.
isCloseEnoughTo
(
b
.
leading
,
epsilon
)
&&
avgCharWidth
.
isCloseEnoughTo
(
b
.
avgCharWidth
,
epsilon
)
&&
maxCharWidth
.
isCloseEnoughTo
(
b
.
maxCharWidth
,
epsilon
)
&&
xMin
.
isCloseEnoughTo
(
b
.
xMin
,
epsilon
)
&&
xHeight
.
isCloseEnoughTo
(
b
.
xHeight
,
epsilon
)
&&
capHeight
.
isCloseEnoughTo
(
b
.
capHeight
,
epsilon
)
&&
underlineThickness
.
isCloseEnoughTo
(
b
.
underlineThickness
,
epsilon
)
&&
underlinePosition
.
isCloseEnoughTo
(
b
.
underlinePosition
,
epsilon
)
&&
strikeoutThickness
.
isCloseEnoughTo
(
b
.
strikeoutThickness
,
epsilon
)
&&
strikeoutPosition
.
isCloseEnoughTo
(
b
.
strikeoutPosition
,
epsilon
)
private
inline
fun
Rect
.
isCloseEnoughTo
(
rect
:
Rect
,
epsilon
:
Float
):
Boolean
=
left
.
isCloseEnoughTo
(
rect
.
left
,
epsilon
)
&&
right
.
isCloseEnoughTo
(
rect
.
right
,
epsilon
)
&&
top
.
isCloseEnoughTo
(
rect
.
top
,
epsilon
)
&&
bottom
.
isCloseEnoughTo
(
rect
.
bottom
,
epsilon
)
...
...
@@ -42,6 +61,10 @@ internal fun assertCloseEnough(expected: TextBox, actual: TextBox, epsilon: Floa
assertTrue
(
expected
.
isCloseEnoughTo
(
actual
,
epsilon
),
message
=
"expected=$expected, actual=$actual, eps=$epsilon"
)
}
internal
fun
assertCloseEnough
(
expected
:
FontMetrics
,
actual
:
FontMetrics
,
epsilon
:
Float
=
EPSILON
)
{
assertTrue
(
expected
.
isCloseEnoughTo
(
actual
,
epsilon
),
message
=
"expected=$expected, actual=$actual, eps=$epsilon"
)
}
internal
fun
assertCloseEnough
(
expected
:
Matrix33
,
actual
:
Matrix33
,
epsilon
:
Float
=
EPSILON
)
{
assertTrue
(
expected
.
mat
.
zip
(
actual
.
mat
).
all
{
(
a
,
b
)
->
a
.
isCloseEnoughTo
(
b
,
epsilon
)
},
...
...
@@ -90,6 +113,10 @@ internal fun assertContentCloseEnough(expected: Array<Point>, actual: Array<Poin
assertContentEquivalent
(
expected
.
iterator
(),
actual
.
iterator
())
{
a
,
b
->
a
.
isCloseEnoughTo
(
b
,
epsilon
)
}
}
internal
fun
assertContentCloseEnough
(
expected
:
List
<
Point
>,
actual
:
List
<
Point
>,
epsilon
:
Float
=
EPSILON
)
{
assertContentEquivalent
(
expected
.
iterator
(),
actual
.
iterator
())
{
a
,
b
->
a
.
isCloseEnoughTo
(
b
,
epsilon
)
}
}
internal
fun
assertContentCloseEnough
(
expected
:
Array
<
TextBox
>,
actual
:
Array
<
TextBox
>,
epsilon
:
Float
=
EPSILON
)
{
assertContentEquivalent
(
expected
.
iterator
(),
actual
.
iterator
())
{
a
,
b
->
a
.
isCloseEnoughTo
(
b
,
epsilon
)
}
}
skiko/src/jvmMain/cpp/common/Font.cc
View file @
b5e2a775
...
...
@@ -208,26 +208,14 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_FontKt__1nSetSkewX
instance
->
setSkewX
(
value
);
}
extern
"C"
JNIEXPORT
jshortArray
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetStringGlyphs
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jstring
str
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
jsize
len
=
env
->
GetStringLength
(
str
);
const
jchar
*
chars
=
env
->
GetStringCritical
(
str
,
nullptr
);
int
count
=
instance
->
textToGlyphs
(
chars
,
len
*
sizeof
(
jchar
),
SkTextEncoding
::
kUTF16
,
nullptr
,
0
);
std
::
vector
<
short
>
glyphs
(
count
);
instance
->
textToGlyphs
(
chars
,
len
*
sizeof
(
jchar
),
SkTextEncoding
::
kUTF16
,
reinterpret_cast
<
SkGlyphID
*>
(
glyphs
.
data
()),
count
);
env
->
ReleaseStringCritical
(
str
,
chars
);
return
javaShortArray
(
env
,
glyphs
);
}
extern
"C"
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetUTF32Glyphs
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jintArray
uniArr
,
jint
uniArrLen
,
jshortArray
resultGlyphs
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
jshort
*
shorts
=
env
->
GetShortArrayElements
(
resultGlyphs
,
nullptr
);
std
::
vector
<
jshort
>
glyphs
(
uniArrLen
);
jint
*
uni
=
env
->
GetIntArrayElements
(
uniArr
,
nullptr
);
instance
->
unicharsToGlyphs
(
reinterpret_cast
<
SkUnichar
*>
(
uni
),
uniArrLen
,
reinterpret_cast
<
SkGlyphID
*>
(
shorts
));
instance
->
unicharsToGlyphs
(
reinterpret_cast
<
SkUnichar
*>
(
uni
),
uniArrLen
,
reinterpret_cast
<
SkGlyphID
*>
(
glyphs
.
data
()
));
env
->
ReleaseIntArrayElements
(
uniArr
,
uni
,
0
);
env
->
ReleaseShortArrayElements
(
resultGlyphs
,
shorts
,
0
);
env
->
SetShortArrayRegion
(
resultGlyphs
,
0
,
uniArrLen
,
glyphs
.
data
()
);
}
extern
"C"
JNIEXPORT
jshort
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetUTF32Glyph
...
...
@@ -237,90 +225,81 @@ extern "C" JNIEXPORT jshort JNICALL Java_org_jetbrains_skia_FontKt__1nGetUTF32Gl
}
extern
"C"
JNIEXPORT
jint
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetStringGlyphsCount
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jstring
str
)
{
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jstring
str
,
jint
len
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
jsize
len
=
env
->
GetStringLength
(
str
);
const
jchar
*
chars
=
env
->
GetStringCritical
(
str
,
nullptr
);
int
count
=
instance
->
countText
(
chars
,
len
*
sizeof
(
jchar
),
SkTextEncoding
::
kUTF16
);
env
->
ReleaseStringCritical
(
str
,
chars
);
return
count
;
return
instance
->
countText
(
skString
(
env
,
str
).
c_str
(),
len
*
sizeof
(
jchar
),
SkTextEncoding
::
kUTF16
);
}
extern
"C"
JNIEXPORT
jobject
JNICALL
Java_org_jetbrains_skia_FontKt__1nMeasureText
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jstring
str
,
j
long
paintPtr
)
{
extern
"C"
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skia_FontKt__1nMeasureText
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jstring
str
,
j
int
len
,
jlong
paintPtr
,
jfloatArray
res
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkPaint
*
paint
=
reinterpret_cast
<
SkPaint
*>
(
static_cast
<
uintptr_t
>
(
paintPtr
));
jsize
len
=
env
->
GetStringLength
(
str
);
const
jchar
*
chars
=
env
->
GetStringCritical
(
str
,
nullptr
);
SkRect
bounds
;
instance
->
measureText
(
chars
,
len
*
sizeof
(
jchar
),
SkTextEncoding
::
kUTF16
,
&
bounds
,
paint
);
env
->
ReleaseStringCritical
(
str
,
chars
);
return
skija
::
Rect
::
fromSkRect
(
env
,
bounds
);
jfloat
r
[
4
]
=
{
bounds
.
left
(),
bounds
.
top
(),
bounds
.
right
(),
bounds
.
bottom
()};
env
->
SetFloatArrayRegion
(
res
,
0
,
4
,
r
);
}
extern
"C"
JNIEXPORT
jfloat
JNICALL
Java_org_jetbrains_skia_FontKt__1nMeasureTextWidth
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jstring
str
,
jlong
paintPtr
)
{
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jstring
str
,
j
int
len
,
j
long
paintPtr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkPaint
*
paint
=
reinterpret_cast
<
SkPaint
*>
(
static_cast
<
uintptr_t
>
(
paintPtr
));
jsize
len
=
env
->
GetStringLength
(
str
);
const
jchar
*
chars
=
env
->
GetStringCritical
(
str
,
nullptr
);
float
width
=
instance
->
measureText
(
chars
,
len
*
sizeof
(
jchar
),
SkTextEncoding
::
kUTF16
,
nullptr
,
paint
);
env
->
ReleaseStringCritical
(
str
,
chars
);
return
width
;
return
instance
->
measureText
(
skString
(
env
,
str
).
c_str
(),
len
*
sizeof
(
jchar
),
SkTextEncoding
::
kUTF16
,
nullptr
,
paint
);
}
extern
"C"
JNIEXPORT
jfloatArray
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetWidths
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jshortArray
glyphsArr
)
{
extern
"C"
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetWidths
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jshortArray
glyphsArr
,
jint
count
,
jfloatArray
res
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
int
count
=
env
->
GetArrayLength
(
glyphsArr
);
std
::
vector
<
jfloat
>
widths
(
count
);
jshort
*
glyphs
=
env
->
GetShortArrayElements
(
glyphsArr
,
nullptr
);
instance
->
getWidths
(
reinterpret_cast
<
SkGlyphID
*>
(
glyphs
),
count
,
widths
.
data
());
env
->
ReleaseShortArrayElements
(
glyphsArr
,
glyphs
,
0
);
return
javaFloatArray
(
env
,
widths
);
env
->
SetFloatArrayRegion
(
res
,
0
,
count
,
widths
.
data
()
);
}
extern
"C"
JNIEXPORT
jobjectArray
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetBounds
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jshortArray
glyphsArr
,
j
long
paintPtr
)
{
extern
"C"
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetBounds
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jshortArray
glyphsArr
,
j
int
count
,
jlong
paintPtr
,
jfloatArray
res
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkPaint
*
paint
=
reinterpret_cast
<
SkPaint
*>
(
static_cast
<
uintptr_t
>
(
paintPtr
));
int
count
=
env
->
GetArrayLength
(
glyphsArr
);
std
::
vector
<
SkRect
>
bounds
(
count
);
jshort
*
glyphs
=
env
->
GetShortArrayElements
(
glyphsArr
,
nullptr
);
instance
->
getBounds
(
reinterpret_cast
<
SkGlyphID
*>
(
glyphs
),
count
,
bounds
.
data
(),
paint
);
env
->
ReleaseShortArrayElements
(
glyphsArr
,
glyphs
,
0
);
jobjectArray
res
=
env
->
NewObjectArray
(
count
,
skija
::
Rect
::
cls
,
nullptr
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
skija
::
AutoLocal
<
jobject
>
boundsObj
(
env
,
skija
::
Rect
::
fromSkRect
(
env
,
bounds
[
i
]));
env
->
SetObjectArrayElement
(
res
,
i
,
boundsObj
.
get
());
SkRect
b
=
bounds
[
i
];
float
r
[
4
]
=
{
b
.
left
(),
b
.
right
(),
b
.
top
(),
b
.
bottom
()};
env
->
SetFloatArrayRegion
(
res
,
4
*
i
,
4
,
r
);
}
return
res
;
}
extern
"C"
JNIEXPORT
jobjectArray
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetPositions
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jshortArray
glyphsArr
,
j
float
dx
,
jfloat
dy
)
{
extern
"C"
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetPositions
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jshortArray
glyphsArr
,
j
int
count
,
jfloat
dx
,
jfloat
dy
,
jfloatArray
res
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
int
count
=
env
->
GetArrayLength
(
glyphsArr
);
std
::
vector
<
SkPoint
>
positions
(
count
);
jshort
*
glyphs
=
env
->
GetShortArrayElements
(
glyphsArr
,
nullptr
);
instance
->
getPos
(
reinterpret_cast
<
SkGlyphID
*>
(
glyphs
),
count
,
positions
.
data
(),
{
dx
,
dy
});
env
->
ReleaseShortArrayElements
(
glyphsArr
,
glyphs
,
0
);
return
skija
::
Point
::
fromSkPoints
(
env
,
positions
);
std
::
vector
<
jfloat
>
r
(
count
*
2
);
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
r
[
2
*
i
]
=
positions
[
i
].
fX
;
r
[
2
*
i
+
1
]
=
positions
[
i
].
fY
;
}
env
->
SetFloatArrayRegion
(
res
,
0
,
count
*
2
,
r
.
data
());
}
extern
"C"
JNIEXPORT
jfloatArray
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetXPositions
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jshortArray
glyphsArr
,
jfloat
dx
)
{
extern
"C"
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetXPositions
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
jshortArray
glyphsArr
,
jfloat
dx
,
jint
count
,
jfloatArray
res
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
int
count
=
env
->
GetArrayLength
(
glyphsArr
);
std
::
vector
<
jfloat
>
positions
(
count
);
jshort
*
glyphs
=
env
->
GetShortArrayElements
(
glyphsArr
,
nullptr
);
instance
->
getXPos
(
reinterpret_cast
<
SkGlyphID
*>
(
glyphs
),
count
,
positions
.
data
(),
dx
);
env
->
ReleaseShortArrayElements
(
glyphsArr
,
glyphs
,
0
);
return
javaFloatArray
(
env
,
positions
);
env
->
SetFloatArrayRegion
(
res
,
0
,
count
,
positions
.
data
()
);
}
extern
"C"
JNIEXPORT
jlong
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetPath
...
...
@@ -360,12 +339,46 @@ extern "C" JNIEXPORT jobjectArray JNICALL Java_org_jetbrains_skia_FontKt__1nGetP
return
ctx
.
paths
;
}
extern
"C"
JNIEXPORT
jobject
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetMetrics
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
j
shortArray
glyphsArr
)
{
extern
"C"
JNIEXPORT
void
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetMetrics
(
JNIEnv
*
env
,
jclass
jclass
,
jlong
ptr
,
j
floatArray
res
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
static_cast
<
uintptr_t
>
(
ptr
));
SkFontMetrics
m
;
instance
->
getMetrics
(
&
m
);
return
skija
::
FontMetrics
::
toJava
(
env
,
m
);
float
f
[
15
]
=
{
m
.
fTop
,
m
.
fAscent
,
m
.
fDescent
,
m
.
fBottom
,
m
.
fLeading
,
m
.
fAvgCharWidth
,
m
.
fMaxCharWidth
,
m
.
fXMin
,
m
.
fXMax
,
m
.
fXHeight
,
m
.
fCapHeight
,
std
::
numeric_limits
<
float
>::
quiet_NaN
(),
std
::
numeric_limits
<
float
>::
quiet_NaN
(),
std
::
numeric_limits
<
float
>::
quiet_NaN
(),
std
::
numeric_limits
<
float
>::
quiet_NaN
()
};
SkScalar
thickness
;
SkScalar
position
;
if
(
m
.
hasUnderlineThickness
(
&
thickness
))
{
f
[
11
]
=
thickness
;
}
if
(
m
.
hasUnderlinePosition
(
&
position
))
{
f
[
12
]
=
position
;
}
if
(
m
.
hasStrikeoutThickness
(
&
thickness
))
{
f
[
13
]
=
thickness
;
}
if
(
m
.
hasStrikeoutPosition
(
&
position
))
{
f
[
14
]
=
position
;
}
env
->
SetFloatArrayRegion
(
res
,
0
,
15
,
f
);
}
extern
"C"
JNIEXPORT
jfloat
JNICALL
Java_org_jetbrains_skia_FontKt__1nGetSpacing
...
...
skiko/src/nativeJsMain/cpp/Font.cc
View file @
b5e2a775
...
...
@@ -13,7 +13,7 @@ static void deleteFont(SkFont* font) {
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_Font__1nGetFinalizer
()
{
return
reinterpret_cast
<
KNativePointer
>
(
(
&
deleteFont
)
);
return
reinterpret_cast
<
KNativePointer
>
(
&
deleteFont
);
}
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_Font__1nMakeDefault
...
...
@@ -24,212 +24,192 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_Font__1nMakeDefault
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_Font__1nMakeTypeface
(
KNativePointer
typefacePtr
)
{
SkTypeface
*
typeface
=
reinterpret_cast
<
SkTypeface
*>
(
(
typefacePtr
)
);
SkTypeface
*
typeface
=
reinterpret_cast
<
SkTypeface
*>
(
typefacePtr
);
SkFont
*
obj
=
new
SkFont
(
sk_ref_sp
<
SkTypeface
>
(
typeface
));
return
reinterpret_cast
<
KNativePointer
>
(
obj
);
}
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_Font__1nMakeTypefaceSize
(
KNativePointer
typefacePtr
,
KFloat
size
)
{
SkTypeface
*
typeface
=
reinterpret_cast
<
SkTypeface
*>
(
(
typefacePtr
)
);
SkTypeface
*
typeface
=
reinterpret_cast
<
SkTypeface
*>
(
typefacePtr
);
SkFont
*
obj
=
new
SkFont
(
sk_ref_sp
<
SkTypeface
>
(
typeface
),
size
);
return
reinterpret_cast
<
KNativePointer
>
(
obj
);
}
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_Font__1nMakeTypefaceSizeScaleSkew
(
KNativePointer
typefacePtr
,
KFloat
size
,
KFloat
scaleX
,
KFloat
skewX
)
{
SkTypeface
*
typeface
=
reinterpret_cast
<
SkTypeface
*>
(
(
typefacePtr
)
);
SkTypeface
*
typeface
=
reinterpret_cast
<
SkTypeface
*>
(
typefacePtr
);
SkFont
*
obj
=
new
SkFont
(
sk_ref_sp
<
SkTypeface
>
(
typeface
),
size
,
scaleX
,
skewX
);
return
reinterpret_cast
<
KNativePointer
>
(
obj
);
}
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_Font__1nMakeClone
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
SkFont
*
clone
=
new
SkFont
(
*
instance
);
return
reinterpret_cast
<
KNativePointer
>
(
clone
);
}
SKIKO_EXPORT
KBoolean
org_jetbrains_skia_Font__1nEquals
(
KNativePointer
ptr
,
KNativePointer
otherPtr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
other
=
reinterpret_cast
<
SkFont
*>
(
(
otherPtr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
SkFont
*
other
=
reinterpret_cast
<
SkFont
*>
(
otherPtr
);
return
*
instance
==
*
other
;
}
SKIKO_EXPORT
KBoolean
org_jetbrains_skia_Font__1nIsAutoHintingForced
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
instance
->
isForceAutoHinting
();
}
SKIKO_EXPORT
KBoolean
org_jetbrains_skia_Font__1nAreBitmapsEmbedded
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
instance
->
isEmbeddedBitmaps
();
}
SKIKO_EXPORT
KBoolean
org_jetbrains_skia_Font__1nIsSubpixel
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
instance
->
isSubpixel
();
}
SKIKO_EXPORT
KBoolean
org_jetbrains_skia_Font__1nAreMetricsLinear
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
instance
->
isLinearMetrics
();
}
SKIKO_EXPORT
KBoolean
org_jetbrains_skia_Font__1nIsEmboldened
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
instance
->
isEmbolden
();
}
SKIKO_EXPORT
KBoolean
org_jetbrains_skia_Font__1nIsBaselineSnapped
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
instance
->
isBaselineSnap
();
}
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nSetAutoHintingForced
(
KNativePointer
ptr
,
KBoolean
value
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
instance
->
setForceAutoHinting
(
value
);
}
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nSetBitmapsEmbedded
(
KNativePointer
ptr
,
KBoolean
value
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
instance
->
setEmbeddedBitmaps
(
value
);
}
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nSetSubpixel
(
KNativePointer
ptr
,
KBoolean
value
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
instance
->
setSubpixel
(
value
);
}
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nSetMetricsLinear
(
KNativePointer
ptr
,
KBoolean
value
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
instance
->
setLinearMetrics
(
value
);
}
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nSetEmboldened
(
KNativePointer
ptr
,
KBoolean
value
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
instance
->
setEmbolden
(
value
);
}
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nSetBaselineSnapped
(
KNativePointer
ptr
,
KBoolean
value
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
instance
->
setBaselineSnap
(
value
);
}
SKIKO_EXPORT
KInt
org_jetbrains_skia_Font__1nGetEdging
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
static_cast
<
KInt
>
(
instance
->
getEdging
());
}
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nSetEdging
(
KNativePointer
ptr
,
KInt
value
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
instance
->
setEdging
(
static_cast
<
SkFont
::
Edging
>
(
value
));
}
SKIKO_EXPORT
KInt
org_jetbrains_skia_Font__1nGetHinting
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
static_cast
<
KInt
>
(
instance
->
getHinting
());
}
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nSetHinting
(
KNativePointer
ptr
,
KInt
value
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
instance
->
setHinting
(
static_cast
<
SkFontHinting
>
(
value
));
}
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_Font__1nGetTypeface
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
SkTypeface
*
typeface
=
instance
->
refTypeface
().
release
();
return
reinterpret_cast
<
KNativePointer
>
(
typeface
);
}
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_Font__1nGetTypefaceOrDefault
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
SkTypeface
*
typeface
=
instance
->
refTypefaceOrDefault
().
release
();
return
reinterpret_cast
<
KNativePointer
>
(
typeface
);
}
SKIKO_EXPORT
KFloat
org_jetbrains_skia_Font__1nGetSize
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
instance
->
getSize
();
}
SKIKO_EXPORT
KFloat
org_jetbrains_skia_Font__1nGetScaleX
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
instance
->
getScaleX
();
}
SKIKO_EXPORT
KFloat
org_jetbrains_skia_Font__1nGetSkewX
(
KNativePointer
ptr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
instance
->
getSkewX
();
}
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nSetTypeface
(
KNativePointer
ptr
,
KNativePointer
typefacePtr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkTypeface
*
typeface
=
reinterpret_cast
<
SkTypeface
*>
(
(
typefacePtr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
SkTypeface
*
typeface
=
reinterpret_cast
<
SkTypeface
*>
(
typefacePtr
);
instance
->
setTypeface
(
sk_ref_sp
(
typeface
));
}
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nSetSize
(
KNativePointer
ptr
,
KFloat
value
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
instance
->
setSize
(
value
);
}
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nSetScaleX
(
KNativePointer
ptr
,
KFloat
value
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
instance
->
setScaleX
(
value
);
}
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nSetSkewX
(
KNativePointer
ptr
,
KFloat
value
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
instance
->
setSkewX
(
value
);
}
SKIKO_EXPORT
KShort
*
org_jetbrains_skia_Font__1nGetStringGlyphs
(
KNativePointer
ptr
,
KInteropPointer
str
)
{
TODO
(
"implement org_jetbrains_skia_Font__1nGetStringGlyphs"
);
}
#if 0
SKIKO_EXPORT KShort* org_jetbrains_skia_Font__1nGetStringGlyphs
(KNativePointer ptr, KInteropPointer str) {
SkFont* instance = reinterpret_cast<SkFont*>((ptr));
jsize len = env->GetStringLength(str);
const KChar* chars = env->GetStringCritical(str, nullptr);
int count = instance->textToGlyphs(chars, len * sizeof(KChar), SkTextEncoding::kUTF16, nullptr, 0);
std::vector<short> glyphs(count);
instance->textToGlyphs(chars, len * sizeof(KChar), SkTextEncoding::kUTF16, reinterpret_cast<SkGlyphID*>(glyphs.data()), count);
env->ReleaseStringCritical(str, chars);
return javaShortArray(env, glyphs);
}
#endif
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nGetUTF32Glyphs
(
KNativePointer
ptr
,
KInt
*
uniArr
,
KInt
uniArrLen
,
KShort
*
resultGlyphs
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
...
...
@@ -239,166 +219,84 @@ SKIKO_EXPORT void org_jetbrains_skia_Font__1nGetUTF32Glyphs
);
}
SKIKO_EXPORT
KShort
org_jetbrains_skia_Font__1nGetUTF32Glyph
(
KNativePointer
ptr
,
KInt
uni
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
instance
->
unicharToGlyph
(
uni
);
}
SKIKO_EXPORT
KInt
org_jetbrains_skia_Font__1nGetStringGlyphsCount
(
KNativePointer
ptr
,
KInteropPointer
str
)
{
TODO
(
"implement org_jetbrains_skia_Font__1nGetStringGlyphsCount"
);
}
#if 0
SKIKO_EXPORT
KInt
org_jetbrains_skia_Font__1nGetStringGlyphsCount
(KNativePointer ptr, KInteropPointer str) {
SkFont* instance = reinterpret_cast<SkFont*>((ptr));
jsize len = env->GetStringLength(str);
const KChar* chars = env->GetStringCritical(str, nullptr);
int count = instance->countText(chars, len * sizeof(KChar), SkTextEncoding::kUTF16);
env->ReleaseStringCritical(str, chars);
return count;
}
#endif
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_Font__1nMeasureText
(
KNativePointer
ptr
,
KInteropPointer
str
,
KNativePointer
paintPtr
)
{
TODO
(
"implement org_jetbrains_skia_Font__1nMeasureText"
);
(
KNativePointer
ptr
,
char
*
str
,
KInt
len
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
instance
->
countText
(
str
,
len
*
sizeof
(
KChar
),
SkTextEncoding
::
kUTF16
);
}
#if 0
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_Font__1nMeasureText
(KNativePointer ptr, KInteropPointer str, KNativePointer paintPtr) {
SkFont* instance = reinterpret_cast<SkFont*>((ptr));
SkPaint* paint = reinterpret_cast<SkPaint*>((paintPtr));
jsize len = env->GetStringLength(str);
const KChar* chars = env->GetStringCritical(str, nullptr);
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nMeasureText
(
KNativePointer
ptr
,
KInteropPointer
str
,
KInt
len
,
KNativePointer
paintPtr
,
KFloat
*
res
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
SkPaint
*
paint
=
reinterpret_cast
<
SkPaint
*>
(
paintPtr
);
SkRect
bounds
;
instance->measureText(chars, len * sizeof(KChar), SkTextEncoding::kUTF16, &bounds, paint);
env->ReleaseStringCritical(str, chars);
return skija::Rect::fromSkRect(env, bounds);
}
#endif
instance
->
measureText
(
str
,
len
*
sizeof
(
KChar
),
SkTextEncoding
::
kUTF16
,
&
bounds
,
paint
);
SKIKO_EXPORT
KFloat
org_jetbrains_skia_Font__1nMeasureTextWidth
(
KNativePointer
ptr
,
KInteropPointer
str
,
KNativePointer
paintPtr
)
{
TODO
(
"implement org_jetbrains_skia_Font__1nMeasureTextWidth"
);
res
[
0
]
=
bounds
.
left
();
res
[
1
]
=
bounds
.
top
();
res
[
2
]
=
bounds
.
right
();
res
[
3
]
=
bounds
.
bottom
(
);
}
#if 0
SKIKO_EXPORT KFloat org_jetbrains_skia_Font__1nMeasureTextWidth
(KNativePointer ptr, KInteropPointer str, KNativePointer paintPtr) {
SkFont* instance = reinterpret_cast<SkFont*>((ptr));
SkPaint* paint = reinterpret_cast<SkPaint*>((paintPtr));
jsize len = env->GetStringLength(str);
const KChar* chars = env->GetStringCritical(str, nullptr);
float width = instance->measureText(chars, len * sizeof(KChar), SkTextEncoding::kUTF16, nullptr, paint);
env->ReleaseStringCritical(str, chars);
return width;
}
#endif
SKIKO_EXPORT
KFloat
*
org_jetbrains_skia_Font__1nGetWidths
(
KNativePointer
ptr
,
KShort
*
glyphsArr
)
{
TODO
(
"implement org_jetbrains_skia_Font__1nGetWidths"
);
}
#if 0
SKIKO_EXPORT KFloat* org_jetbrains_skia_Font__1nGetWidths
(KNativePointer ptr, KShort* glyphsArr) {
SkFont* instance = reinterpret_cast<SkFont*>((ptr));
int count = env->GetArrayLength(glyphsArr);
std::vector<KFloat> widths(count);
KShort* glyphs = env->GetShortArrayElements(glyphsArr, nullptr);
instance->getWidths(reinterpret_cast<SkGlyphID*>(glyphs), count, widths.data());
env->ReleaseShortArrayElements(glyphsArr, glyphs, 0);
return javaFloatArray(env, widths);
SKIKO_EXPORT
KFloat
org_jetbrains_skia_Font__1nMeasureTextWidth
(
KNativePointer
ptr
,
char
*
str
,
KInt
len
,
KNativePointer
paintPtr
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
SkPaint
*
paint
=
reinterpret_cast
<
SkPaint
*>
(
paintPtr
);
return
instance
->
measureText
(
str
,
len
*
sizeof
(
KChar
),
SkTextEncoding
::
kUTF16
,
nullptr
,
paint
);
}
#endif
SKIKO_EXPORT
KInteropPointerArray
org_jetbrains_skia_Font__1nGetBounds
(
KNativePointer
ptr
,
KShort
*
glyphsArr
,
KNativePointer
paintPtr
)
{
TODO
(
"implement org_jetbrains_skia_Font__1nGetBounds"
);
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nGetWidths
(
KNativePointer
ptr
,
KShort
*
glyphs
,
KInt
count
,
KFloat
*
widths
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
instance
->
getWidths
(
reinterpret_cast
<
SkGlyphID
*>
(
glyphs
),
count
,
widths
);
}
#if 0
SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_Font__1nGetBounds
(KNativePointer ptr, KShort* glyphsArr, KNativePointer paintPtr) {
SkFont* instance = reinterpret_cast<SkFont*>((ptr));
SkPaint* paint = reinterpret_cast<SkPaint*>((paintPtr));
int count = env->GetArrayLength(glyphsArr);
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nGetBounds
(
KNativePointer
ptr
,
KShort
*
glyphs
,
KInt
count
,
KNativePointer
paintPtr
,
KFloat
*
res
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
SkPaint
*
paint
=
reinterpret_cast
<
SkPaint
*>
(
paintPtr
);
std
::
vector
<
SkRect
>
bounds
(
count
);
KShort* glyphs = env->GetShortArrayElements(glyphsArr, nullptr);
instance
->
getBounds
(
reinterpret_cast
<
SkGlyphID
*>
(
glyphs
),
count
,
bounds
.
data
(),
paint
);
env->ReleaseShortArrayElements(glyphsArr, glyphs, 0);
KInteropPointerArray res = env->NewObjectArray(count, skija::Rect::cls, nullptr);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
skija::AutoLocal<KInteropPointer> boundsObj(env, skija::Rect::fromSkRect(env, bounds[i]));
env->SetObjectArrayElement(res, i, boundsObj.get());
SkRect
b
=
bounds
[
i
];
res
[
4
*
i
]
=
b
.
left
();
res
[
4
*
i
+
1
]
=
b
.
right
();
res
[
4
*
i
+
2
]
=
b
.
top
();
res
[
4
*
i
+
3
]
=
b
.
bottom
();
}
return res;
}
#endif
SKIKO_EXPORT
KInteropPointerArray
org_jetbrains_skia_Font__1nGetPositions
(
KNativePointer
ptr
,
KShort
*
glyphsArr
,
KFloat
dx
,
KFloat
dy
)
{
TODO
(
"implement org_jetbrains_skia_Font__1nGetPositions"
);
}
#if 0
SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_Font__1nGetPositions
(KNativePointer ptr, KShort* glyphsArr, KFloat dx, KFloat dy) {
SkFont* instance = reinterpret_cast<SkFont*>((ptr));
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nGetPositions
(
KNativePointer
ptr
,
KShort
*
glyphs
,
KInt
count
,
KFloat
dx
,
KFloat
dy
,
KFloat
*
res
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
int count = env->GetArrayLength(glyphsArr);
std
::
vector
<
SkPoint
>
positions
(
count
);
KShort* glyphs = env->GetShortArrayElements(glyphsArr, nullptr);
instance
->
getPos
(
reinterpret_cast
<
SkGlyphID
*>
(
glyphs
),
count
,
positions
.
data
(),
{
dx
,
dy
});
env->ReleaseShortArrayElements(glyphsArr, glyphs, 0);
return skija::Point::fromSkPoints(env, positions);
}
#endif
SKIKO_EXPORT
KFloat
*
org_jetbrains_skia_Font__1nGetXPositions
(
KNativePointer
ptr
,
KShort
*
glyphsArr
,
KFloat
dx
)
{
TODO
(
"implement org_jetbrains_skia_Font__1nGetXPositions"
);
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
res
[
2
*
i
]
=
positions
[
i
].
fX
;
res
[
2
*
i
+
1
]
=
positions
[
i
].
fY
;
}
}
#if 0
SKIKO_EXPORT KFloat* org_jetbrains_skia_Font__1nGetXPositions
(KNativePointer ptr, KShort* glyphsArr, KFloat dx) {
SkFont* instance = reinterpret_cast<SkFont*>((ptr));
int count = env->GetArrayLength(glyphsArr);
std::vector<KFloat> positions(count);
KShort* glyphs = env->GetShortArrayElements(glyphsArr, nullptr);
instance->getXPos(reinterpret_cast<SkGlyphID*>(glyphs), count, positions.data(), dx);
env->ReleaseShortArrayElements(glyphsArr, glyphs, 0);
return javaFloatArray(env, positions);
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nGetXPositions
(
KNativePointer
ptr
,
KShort
*
glyphs
,
KFloat
dx
,
KInt
count
,
KFloat
*
positions
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
instance
->
getXPos
(
reinterpret_cast
<
SkGlyphID
*>
(
glyphs
),
count
,
positions
,
dx
);
}
#endif
SKIKO_EXPORT
KNativePointer
org_jetbrains_skia_Font__1nGetPath
(
KNativePointer
ptr
,
KShort
glyph
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
(
ptr
)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
SkPath
*
path
=
new
SkPath
();
instance
->
getPath
(
glyph
,
path
);
return
reinterpret_cast
<
KNativePointer
>
(
path
);
...
...
@@ -413,8 +311,7 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_Font__1nGetPaths
#if 0
SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_Font__1nGetPaths
(KNativePointer ptr, KShort* glyphsArr) {
SkFont* instance = reinterpret_cast<SkFont*>((ptr));
SkFont* instance = reinterpret_cast<SkFont*>(ptr);
int count = env->GetArrayLength(glyphsArr);
KShort* glyphs = env->GetShortArrayElements(glyphsArr, nullptr);
...
...
@@ -443,32 +340,47 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_Font__1nGetPaths
SKIKO_EXPORT
KInteropPointer
org_jetbrains_skia_Font__1nGetMetrics
(
KNativePointer
ptr
,
KShort
*
glyphsArr
)
{
TODO
(
"implement org_jetbrains_skia_Font__1nGetMetrics"
);
}
#if 0
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_Font__1nGetMetrics
(KNativePointer ptr, KShort* glyphsArr) {
SkFont* instance = reinterpret_cast<SkFont*>((ptr));
SKIKO_EXPORT
void
org_jetbrains_skia_Font__1nGetMetrics
(
KNativePointer
ptr
,
KFloat
*
fontMetrics
)
{
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
SkFontMetrics
m
;
instance
->
getMetrics
(
&
m
);
return skija::FontMetrics::toJava(env, m);
}
#endif
SKIKO_EXPORT
KFloat
org_jetbrains_skia_Font__1nGetSpacing
(
KNativePointer
ptr
,
KShort
*
glyphsArr
)
{
TODO
(
"implement org_jetbrains_skia_Font__1nGetSpacing"
);
fontMetrics
[
0
]
=
m
.
fTop
;
fontMetrics
[
1
]
=
m
.
fAscent
;
fontMetrics
[
2
]
=
m
.
fDescent
;
fontMetrics
[
3
]
=
m
.
fBottom
;
fontMetrics
[
4
]
=
m
.
fLeading
;
fontMetrics
[
5
]
=
m
.
fAvgCharWidth
;
fontMetrics
[
6
]
=
m
.
fMaxCharWidth
;
fontMetrics
[
7
]
=
m
.
fXMin
;
fontMetrics
[
8
]
=
m
.
fXMax
;
fontMetrics
[
9
]
=
m
.
fXHeight
;
fontMetrics
[
10
]
=
m
.
fCapHeight
;
fontMetrics
[
11
]
=
std
::
numeric_limits
<
float
>::
quiet_NaN
();
fontMetrics
[
12
]
=
std
::
numeric_limits
<
float
>::
quiet_NaN
();
fontMetrics
[
13
]
=
std
::
numeric_limits
<
float
>::
quiet_NaN
();
fontMetrics
[
14
]
=
std
::
numeric_limits
<
float
>::
quiet_NaN
();
SkScalar
thickness
;
SkScalar
position
;
if
(
m
.
hasUnderlineThickness
(
&
thickness
))
{
fontMetrics
[
11
]
=
thickness
;
}
if
(
m
.
hasUnderlinePosition
(
&
position
))
{
fontMetrics
[
12
]
=
position
;
}
if
(
m
.
hasStrikeoutThickness
(
&
thickness
))
{
fontMetrics
[
13
]
=
thickness
;
}
if
(
m
.
hasStrikeoutPosition
(
&
position
))
{
fontMetrics
[
14
]
=
position
;
}
}
#if 0
SKIKO_EXPORT
KFloat
org_jetbrains_skia_Font__1nGetSpacing
(
KNativePointer
ptr
,
KShort
*
glyphsArr
)
{
SkFont* instance = reinterpret_cast<SkFont*>(
(ptr)
);
SkFont
*
instance
=
reinterpret_cast
<
SkFont
*>
(
ptr
);
return
instance
->
getSpacing
();
}
#endif
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