Unverified Commit 82342b34 authored by Shagen Ogandzhanian's avatar Shagen Ogandzhanian Committed by GitHub

Commonize TextStyle (#366)

parent dd5b7902
package org.jetbrains.skia package org.jetbrains.skia
import org.jetbrains.skia.impl.InteropPointer
import org.jetbrains.skia.impl.InteropScope
import org.jetbrains.skia.impl.withResult
class FontMetrics( class FontMetrics(
/** /**
* greatest extent above origin of any glyph bounding box, typically negative; deprecated with variable fonts * greatest extent above origin of any glyph bounding box, typically negative; deprecated with variable fonts
...@@ -154,4 +158,29 @@ class FontMetrics( ...@@ -154,4 +158,29 @@ class FontMetrics(
override fun toString(): String { override fun toString(): String {
return "FontMetrics(_top=$top, _ascent=$ascent, _descent=$descent, _bottom=$bottom, _leading=$leading, _avgCharWidth=$avgCharWidth, _maxCharWidth=$maxCharWidth, _xMin=$xMin, _xMax=$xMax, _xHeight=$xHeight, _capHeight=$capHeight, _underlineThickness=$underlineThickness, _underlinePosition=$underlinePosition, _strikeoutThickness=$strikeoutThickness, _strikeoutPosition=$strikeoutPosition)" return "FontMetrics(_top=$top, _ascent=$ascent, _descent=$descent, _bottom=$bottom, _leading=$leading, _avgCharWidth=$avgCharWidth, _maxCharWidth=$maxCharWidth, _xMin=$xMin, _xMax=$xMax, _xHeight=$xHeight, _capHeight=$capHeight, _underlineThickness=$underlineThickness, _underlinePosition=$underlinePosition, _strikeoutThickness=$strikeoutThickness, _strikeoutPosition=$strikeoutPosition)"
} }
companion object
} }
private inline fun Float.asNumberOrNull(): Float? = if (isNaN()) null else this
private fun FontMetrics.Companion.fromRawData(rawData: FloatArray) = FontMetrics(
rawData[0],
rawData[1],
rawData[2],
rawData[3],
rawData[4],
rawData[5],
rawData[6],
rawData[7],
rawData[8],
rawData[9],
rawData[10],
rawData[11].asNumberOrNull(),
rawData[12].asNumberOrNull(),
rawData[13].asNumberOrNull(),
rawData[14].asNumberOrNull()
)
internal fun FontMetrics.Companion.fromInteropPointer(block: InteropScope.(InteropPointer) -> Unit) = fromRawData(withResult(FloatArray(15), block))
\ No newline at end of file
package org.jetbrains.skia.paragraph package org.jetbrains.skia.paragraph
import org.jetbrains.skia.impl.InteropPointer
import org.jetbrains.skia.impl.InteropScope
import org.jetbrains.skia.impl.withResult
class DecorationStyle( class DecorationStyle(
val _underline: Boolean, val _underline: Boolean,
val _overline: Boolean, val _overline: Boolean,
...@@ -26,7 +30,7 @@ class DecorationStyle( ...@@ -26,7 +30,7 @@ class DecorationStyle(
lineThrough, lineThrough,
gaps, gaps,
color, color,
DecorationLineStyle.values().get(lineStyle), DecorationLineStyle.values()[lineStyle],
thicknessMultiplier thicknessMultiplier
) { ) {
} }
...@@ -173,3 +177,20 @@ class DecorationStyle( ...@@ -173,3 +177,20 @@ class DecorationStyle(
this.thicknessMultiplier = thicknessMultiplier this.thicknessMultiplier = thicknessMultiplier
} }
} }
private fun DecorationStyle.Companion.fromRawData(rawData: IntArray): DecorationStyle {
val decorationStyleFlags = rawData[0]
return DecorationStyle(
underline = ((decorationStyleFlags shr 0) and 1) == 1,
overline = ((decorationStyleFlags shr 1) and 1) == 1,
lineThrough = ((decorationStyleFlags shr 2) and 1) == 1,
gaps = ((decorationStyleFlags shr 3) and 1) == 1,
color = rawData[1],
lineStyle = rawData[2],
thicknessMultiplier = Float.fromBits(rawData[3])
)
}
internal fun DecorationStyle.Companion.fromInteropPointer(block: InteropScope.(InteropPointer) -> Unit) = fromRawData(withResult(IntArray(4), block))
...@@ -110,10 +110,12 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz ...@@ -110,10 +110,12 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz
} }
} }
var decorationStyle: org.jetbrains.skia.paragraph.DecorationStyle var decorationStyle: DecorationStyle
get() = try { get() = try {
Stats.onNativeCall() Stats.onNativeCall()
_nGetDecorationStyle(_ptr) DecorationStyle.fromInteropPointer {
_nGetDecorationStyle(_ptr, it)
}
} finally { } finally {
reachabilityBarrier(this) reachabilityBarrier(this)
} }
...@@ -252,7 +254,8 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz ...@@ -252,7 +254,8 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz
var height: Float? var height: Float?
get() = try { get() = try {
Stats.onNativeCall() Stats.onNativeCall()
TextStyle_nGetHeight(_ptr) val height = TextStyle_nGetHeight(_ptr)
if (height.isNaN()) null else height
} finally { } finally {
reachabilityBarrier(this) reachabilityBarrier(this)
} }
...@@ -328,7 +331,9 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz ...@@ -328,7 +331,9 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz
var locale: String var locale: String
get() = try { get() = try {
Stats.onNativeCall() Stats.onNativeCall()
withStringResult {
_nGetLocale(_ptr) _nGetLocale(_ptr)
}
} finally { } finally {
reachabilityBarrier(this) reachabilityBarrier(this)
} }
...@@ -338,7 +343,9 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz ...@@ -338,7 +343,9 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz
fun setLocale(locale: String?): TextStyle { fun setLocale(locale: String?): TextStyle {
Stats.onNativeCall() Stats.onNativeCall()
_nSetLocale(_ptr, locale) interopScope {
_nSetLocale(_ptr, toInterop(locale))
}
return this return this
} }
...@@ -359,10 +366,13 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz ...@@ -359,10 +366,13 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz
return this return this
} }
val fontMetrics: FontMetrics val fontMetrics: FontMetrics
get() = try { get() = try {
Stats.onNativeCall() Stats.onNativeCall()
_nGetFontMetrics(_ptr) FontMetrics.fromInteropPointer {
_nGetFontMetrics(_ptr, it)
}
} finally { } finally {
reachabilityBarrier(this) reachabilityBarrier(this)
} }
...@@ -386,7 +396,6 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz ...@@ -386,7 +396,6 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz
} }
} }
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetFinalizer") @ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetFinalizer")
private external fun TextStyle_nGetFinalizer(): NativePointer private external fun TextStyle_nGetFinalizer(): NativePointer
...@@ -412,7 +421,7 @@ private external fun TextStyle_nSetFontSize(ptr: NativePointer, size: Float) ...@@ -412,7 +421,7 @@ private external fun TextStyle_nSetFontSize(ptr: NativePointer, size: Float)
private external fun TextStyle_nGetFontFamilies(ptr: NativePointer): Array<String> private external fun TextStyle_nGetFontFamilies(ptr: NativePointer): Array<String>
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetHeight") @ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetHeight")
private external fun TextStyle_nGetHeight(ptr: NativePointer): Float? private external fun TextStyle_nGetHeight(ptr: NativePointer): Float
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nSetHeight") @ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nSetHeight")
private external fun TextStyle_nSetHeight(ptr: NativePointer, override: Boolean, height: Float) private external fun TextStyle_nSetHeight(ptr: NativePointer, override: Boolean, height: Float)
...@@ -439,7 +448,7 @@ private external fun _nGetBackground(ptr: NativePointer): NativePointer ...@@ -439,7 +448,7 @@ private external fun _nGetBackground(ptr: NativePointer): NativePointer
private external fun _nSetBackground(ptr: NativePointer, paintPtr: NativePointer) private external fun _nSetBackground(ptr: NativePointer, paintPtr: NativePointer)
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetDecorationStyle") @ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetDecorationStyle")
private external fun _nGetDecorationStyle(ptr: NativePointer): DecorationStyle private external fun _nGetDecorationStyle(ptr: NativePointer, decorationStyle: InteropPointer)
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nSetDecorationStyle") @ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nSetDecorationStyle")
private external fun _nSetDecorationStyle( private external fun _nSetDecorationStyle(
...@@ -496,10 +505,10 @@ private external fun _nGetTypeface(ptr: NativePointer): NativePointer ...@@ -496,10 +505,10 @@ private external fun _nGetTypeface(ptr: NativePointer): NativePointer
private external fun _nSetTypeface(ptr: NativePointer, typefacePtr: NativePointer) private external fun _nSetTypeface(ptr: NativePointer, typefacePtr: NativePointer)
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetLocale") @ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetLocale")
private external fun _nGetLocale(ptr: NativePointer): String private external fun _nGetLocale(ptr: NativePointer): NativePointer
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nSetLocale") @ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nSetLocale")
private external fun _nSetLocale(ptr: NativePointer, locale: String?) private external fun _nSetLocale(ptr: NativePointer, locale: InteropPointer)
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetBaselineMode") @ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetBaselineMode")
private external fun _nGetBaselineMode(ptr: NativePointer): Int private external fun _nGetBaselineMode(ptr: NativePointer): Int
...@@ -508,7 +517,7 @@ private external fun _nGetBaselineMode(ptr: NativePointer): Int ...@@ -508,7 +517,7 @@ private external fun _nGetBaselineMode(ptr: NativePointer): Int
private external fun _nSetBaselineMode(ptr: NativePointer, mode: Int) private external fun _nSetBaselineMode(ptr: NativePointer, mode: Int)
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetFontMetrics") @ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetFontMetrics")
private external fun _nGetFontMetrics(ptr: NativePointer): FontMetrics private external fun _nGetFontMetrics(ptr: NativePointer, fontMetrics: InteropPointer)
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nIsPlaceholder") @ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nIsPlaceholder")
private external fun _nIsPlaceholder(ptr: NativePointer): Boolean private external fun _nIsPlaceholder(ptr: NativePointer): Boolean
......
package org.jetbrains.skiko.paragraph package org.jetbrains.skiko.paragraph
import org.jetbrains.skia.Color
import org.jetbrains.skia.FontMetrics
import org.jetbrains.skia.impl.use import org.jetbrains.skia.impl.use
import org.jetbrains.skia.paragraph.DecorationLineStyle
import org.jetbrains.skia.paragraph.DecorationStyle
import org.jetbrains.skia.paragraph.TextStyle import org.jetbrains.skia.paragraph.TextStyle
import org.jetbrains.skia.paragraph.TextStyleAttribute import org.jetbrains.skia.paragraph.TextStyleAttribute
import org.jetbrains.skiko.tests.SkipJsTarget
import org.jetbrains.skiko.tests.SkipNativeTarget
import kotlin.test.* import kotlin.test.*
class TextStyleTest { class TextStyleTest {
...@@ -48,4 +54,49 @@ class TextStyleTest { ...@@ -48,4 +54,49 @@ class TextStyleTest {
} }
} }
} }
@Test
fun textStyleLocaleTest() {
TextStyle().use { textStyle ->
textStyle.locale = "fr_FR.UTF-8"
assertEquals("fr_FR.UTF-8", textStyle.locale)
}
}
@Test
fun textDecorationStyleTest() {
TextStyle().use { textStyle ->
textStyle.decorationStyle = DecorationStyle(
underline = true,
overline = true,
lineThrough = false,
gaps = true,
color = Color.BLUE,
lineStyle = DecorationLineStyle.DASHED.ordinal,
thicknessMultiplier = 2f
)
val expectedTextStyle = DecorationStyle(
underline = true,
overline = true,
lineThrough = false,
gaps = true,
color = Color.BLUE,
lineStyle = DecorationLineStyle.DASHED.ordinal,
thicknessMultiplier = 2f
)
assertEquals(expectedTextStyle, textStyle.decorationStyle)
}
}
@Test
fun textStyleHeightTest() {
TextStyle().use { textStyle ->
assertNull(textStyle.height)
textStyle.height = 4f
assertEquals(4f, textStyle.height)
}
}
} }
#include <iostream> #include <iostream>
#include <limits>
#include <jni.h> #include <jni.h>
#include <vector> #include <vector>
#include "../interop.hh" #include "../interop.hh"
...@@ -86,18 +87,35 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_ ...@@ -86,18 +87,35 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_
} }
} }
extern "C" JNIEXPORT jobject JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nGetDecorationStyle extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nGetDecorationStyle
(JNIEnv* env, jclass jclass, jlong ptr) { (JNIEnv* env, jclass jclass, jlong ptr, jintArray res) {
TextStyle* instance = reinterpret_cast<TextStyle*>(static_cast<uintptr_t>(ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(static_cast<uintptr_t>(ptr));
Decoration d = instance->getDecoration(); Decoration d = instance->getDecoration();
return env->NewObject(skija::paragraph::DecorationStyle::cls, skija::paragraph::DecorationStyle::ctor,
(d.fType & TextDecoration::kUnderline) != 0, jint r[4] = {
(d.fType & TextDecoration::kOverline) != 0, 0,
(d.fType & TextDecoration::kLineThrough) != 0, static_cast<jint>(d.fColor),
d.fMode == TextDecorationMode::kGaps,
d.fColor,
static_cast<jint>(d.fStyle), static_cast<jint>(d.fStyle),
d.fThicknessMultiplier); rawBits(d.fThicknessMultiplier)
};
if ((d.fType & TextDecoration::kUnderline) != 0) {
r[0] = r[0] | (1 << 0);
}
if ((d.fType & TextDecoration::kOverline) != 0) {
r[0] = r[0] | (1 << 1);
}
if ((d.fType & TextDecoration::kLineThrough) != 0) {
r[0] = r[0] | (1 << 2);
}
if (d.fMode == TextDecorationMode::kGaps) {
r[0] = r[0] | (1 << 3);
}
env->SetIntArrayRegion(res, 0, 4, r);
} }
extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nSetDecorationStyle extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nSetDecorationStyle
...@@ -204,10 +222,10 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_ ...@@ -204,10 +222,10 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_
instance->setFontFamilies(skStringVector(env, familiesArray)); instance->setFontFamilies(skStringVector(env, familiesArray));
} }
extern "C" JNIEXPORT jobject JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_TextStyle_1nGetHeight extern "C" JNIEXPORT jfloat JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_TextStyle_1nGetHeight
(JNIEnv* env, jclass jclass, jlong ptr) { (JNIEnv* env, jclass jclass, jlong ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>(static_cast<uintptr_t>(ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(static_cast<uintptr_t>(ptr));
return instance->getHeightOverride() ? javaFloat(env, instance->getHeight()) : nullptr; return instance->getHeightOverride() ? static_cast<jfloat>(instance->getHeight()) : std::numeric_limits<jfloat>::quiet_NaN();
} }
extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_TextStyle_1nSetHeight extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_TextStyle_1nSetHeight
...@@ -254,10 +272,10 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_ ...@@ -254,10 +272,10 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_
instance->setTypeface(sk_ref_sp(typeface)); instance->setTypeface(sk_ref_sp(typeface));
} }
extern "C" JNIEXPORT jstring JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nGetLocale extern "C" JNIEXPORT jlong JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nGetLocale
(JNIEnv* env, jclass jclass, jlong ptr) { (JNIEnv* env, jclass jclass, jlong ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>(static_cast<uintptr_t>(ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(static_cast<uintptr_t>(ptr));
return javaString(env, instance->getLocale()); return reinterpret_cast<jlong>(new SkString(instance->getLocale()));
} }
extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nSetLocale extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nSetLocale
...@@ -278,12 +296,45 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_ ...@@ -278,12 +296,45 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_
instance->setTextBaseline(static_cast<TextBaseline>(baselineModeValue)); instance->setTextBaseline(static_cast<TextBaseline>(baselineModeValue));
} }
extern "C" JNIEXPORT jobject JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nGetFontMetrics extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nGetFontMetrics
(JNIEnv* env, jclass jclass, jlong ptr) { (JNIEnv* env, jclass jclass, jlong ptr, jfloatArray fontMetrics) {
TextStyle* instance = reinterpret_cast<TextStyle*>(static_cast<uintptr_t>(ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(static_cast<uintptr_t>(ptr));
SkFontMetrics m; SkFontMetrics m;
instance->getFontMetrics(&m); instance->getFontMetrics(&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(fontMetrics, 0, 15, f);
} }
extern "C" JNIEXPORT jboolean JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nIsPlaceholder extern "C" JNIEXPORT jboolean JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nIsPlaceholder
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// This file has been auto generated. // This file has been auto generated.
#include <iostream> #include <iostream>
#include <limits>
#include <vector> #include <vector>
#include "TextStyle.h" #include "TextStyle.h"
using namespace std; using namespace std;
...@@ -25,14 +26,14 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_paragraph_TextStyle__1nGetFinaliz ...@@ -25,14 +26,14 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_paragraph_TextStyle__1nGetFinaliz
SKIKO_EXPORT KBoolean org_jetbrains_skia_paragraph_TextStyle__1nEquals SKIKO_EXPORT KBoolean org_jetbrains_skia_paragraph_TextStyle__1nEquals
(KNativePointer ptr, KNativePointer otherPtr) { (KNativePointer ptr, KNativePointer otherPtr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
TextStyle* other = reinterpret_cast<TextStyle*>((otherPtr)); TextStyle* other = reinterpret_cast<TextStyle*>((otherPtr));
return instance->equals(*other); return instance->equals(*other);
} }
SKIKO_EXPORT KBoolean org_jetbrains_skia_paragraph_TextStyle__1nAttributeEquals SKIKO_EXPORT KBoolean org_jetbrains_skia_paragraph_TextStyle__1nAttributeEquals
(KNativePointer ptr, KInt attribute, KNativePointer otherPtr) { (KNativePointer ptr, KInt attribute, KNativePointer otherPtr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
TextStyle* other = reinterpret_cast<TextStyle*>((otherPtr)); TextStyle* other = reinterpret_cast<TextStyle*>((otherPtr));
if (attribute == static_cast<KInt>(StyleType::kWordSpacing) + 1) // FONT_EXACT if (attribute == static_cast<KInt>(StyleType::kWordSpacing) + 1) // FONT_EXACT
return instance->equalsByFonts(*other); return instance->equalsByFonts(*other);
...@@ -42,25 +43,25 @@ SKIKO_EXPORT KBoolean org_jetbrains_skia_paragraph_TextStyle__1nAttributeEquals ...@@ -42,25 +43,25 @@ SKIKO_EXPORT KBoolean org_jetbrains_skia_paragraph_TextStyle__1nAttributeEquals
SKIKO_EXPORT KInt org_jetbrains_skia_paragraph_TextStyle__1nGetColor SKIKO_EXPORT KInt org_jetbrains_skia_paragraph_TextStyle__1nGetColor
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->getColor(); return instance->getColor();
} }
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetColor SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetColor
(KNativePointer ptr, KInt color) { (KNativePointer ptr, KInt color) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setColor(color); instance->setColor(color);
} }
SKIKO_EXPORT KNativePointer org_jetbrains_skia_paragraph_TextStyle__1nGetForeground SKIKO_EXPORT KNativePointer org_jetbrains_skia_paragraph_TextStyle__1nGetForeground
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->hasForeground() ? reinterpret_cast<KNativePointer>(new SkPaint(instance->getForeground())) : 0; return instance->hasForeground() ? reinterpret_cast<KNativePointer>(new SkPaint(instance->getForeground())) : 0;
} }
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetForeground SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetForeground
(KNativePointer ptr, KNativePointer paintPtr) { (KNativePointer ptr, KNativePointer paintPtr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
if (paintPtr == 0) if (paintPtr == 0)
instance->clearForegroundColor(); instance->clearForegroundColor();
else { else {
...@@ -71,13 +72,13 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetForeground ...@@ -71,13 +72,13 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetForeground
SKIKO_EXPORT KNativePointer org_jetbrains_skia_paragraph_TextStyle__1nGetBackground SKIKO_EXPORT KNativePointer org_jetbrains_skia_paragraph_TextStyle__1nGetBackground
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->hasBackground() ? reinterpret_cast<KNativePointer>(new SkPaint(instance->getBackground())) : 0; return instance->hasBackground() ? reinterpret_cast<KNativePointer>(new SkPaint(instance->getBackground())) : 0;
} }
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetBackground SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetBackground
(KNativePointer ptr, KNativePointer paintPtr) { (KNativePointer ptr, KNativePointer paintPtr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
if (paintPtr == 0) if (paintPtr == 0)
instance->clearBackgroundColor(); instance->clearBackgroundColor();
else { else {
...@@ -87,31 +88,36 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetBackground ...@@ -87,31 +88,36 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetBackground
} }
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_paragraph_TextStyle__1nGetDecorationStyle SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nGetDecorationStyle
(KNativePointer ptr) { (KNativePointer ptr, KInt* res) {
TODO("implement org_jetbrains_skia_paragraph_TextStyle__1nGetDecorationStyle"); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
}
#if 0
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_paragraph_TextStyle__1nGetDecorationStyle
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
Decoration d = instance->getDecoration(); Decoration d = instance->getDecoration();
return env->NewObject(skija::paragraph::DecorationStyle::cls, skija::paragraph::DecorationStyle::ctor,
(d.fType & TextDecoration::kUnderline) != 0,
(d.fType & TextDecoration::kOverline) != 0,
(d.fType & TextDecoration::kLineThrough) != 0,
d.fMode == TextDecorationMode::kGaps,
d.fColor,
static_cast<KInt>(d.fStyle),
d.fThicknessMultiplier);
}
#endif
res[0] = 0;
if ((d.fType & TextDecoration::kUnderline) != 0) {
res[0] = res[0] | (1 << 0);
}
if ((d.fType & TextDecoration::kOverline) != 0) {
res[0] = res[0] | (1 << 1);
}
if ((d.fType & TextDecoration::kLineThrough) != 0) {
res[0] = res[0] | (1 << 2);
}
if (d.fMode == TextDecorationMode::kGaps) {
res[0] = res[0] | (1 << 3);
}
res[1] = static_cast<KInt>(d.fColor);
res[2] = static_cast<KInt>(d.fStyle);
res[3] = rawBits(d.fThicknessMultiplier);
}
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetDecorationStyle SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetDecorationStyle
(KNativePointer ptr, KBoolean underline, KBoolean overline, KBoolean lineThrough, KBoolean gaps, KInt color, KInt style, KFloat thicknessMultiplier) { (KNativePointer ptr, KBoolean underline, KBoolean overline, KBoolean lineThrough, KBoolean gaps, KInt color, KInt style, KFloat thicknessMultiplier) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
int typeMask = 0; int typeMask = 0;
if (underline) typeMask |= TextDecoration::kUnderline; if (underline) typeMask |= TextDecoration::kUnderline;
if (overline) typeMask |= TextDecoration::kOverline; if (overline) typeMask |= TextDecoration::kOverline;
...@@ -125,13 +131,13 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetDecorationStyle ...@@ -125,13 +131,13 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetDecorationStyle
SKIKO_EXPORT KInt org_jetbrains_skia_paragraph_TextStyle__1nGetFontStyle SKIKO_EXPORT KInt org_jetbrains_skia_paragraph_TextStyle__1nGetFontStyle
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return skija::FontStyle::toKotlin(instance->getFontStyle()); return skija::FontStyle::toKotlin(instance->getFontStyle());
} }
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetFontStyle SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetFontStyle
(KNativePointer ptr, KInt fontStyleValue) { (KNativePointer ptr, KInt fontStyleValue) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setFontStyle(skija::FontStyle::fromKotlin(fontStyleValue)); instance->setFontStyle(skija::FontStyle::fromKotlin(fontStyleValue));
} }
...@@ -143,7 +149,7 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetS ...@@ -143,7 +149,7 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetS
#if 0 #if 0
SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetShadows SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetShadows
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
std::vector<TextShadow> shadows = instance->getShadows(); std::vector<TextShadow> shadows = instance->getShadows();
KInteropPointerArray shadowsArr = env->NewObjectArray((jsize) shadows.size(), skija::paragraph::Shadow::cls, nullptr); KInteropPointerArray shadowsArr = env->NewObjectArray((jsize) shadows.size(), skija::paragraph::Shadow::cls, nullptr);
for (int i = 0; i < shadows.size(); ++i) { for (int i = 0; i < shadows.size(); ++i) {
...@@ -158,13 +164,13 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetS ...@@ -158,13 +164,13 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetS
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nAddShadow SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nAddShadow
(KNativePointer ptr, KInt color, KFloat offsetX, KFloat offsetY, KDouble blurSigma) { (KNativePointer ptr, KInt color, KFloat offsetX, KFloat offsetY, KDouble blurSigma) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->addShadow({static_cast<SkColor>(color), {offsetX, offsetY}, blurSigma}); instance->addShadow({static_cast<SkColor>(color), {offsetX, offsetY}, blurSigma});
} }
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nClearShadows SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nClearShadows
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->resetShadows(); instance->resetShadows();
} }
...@@ -177,7 +183,7 @@ SKIKO_EXPORT KInt org_jetbrains_skia_paragraph_TextStyle__1nGetFontFeaturesSize ...@@ -177,7 +183,7 @@ SKIKO_EXPORT KInt org_jetbrains_skia_paragraph_TextStyle__1nGetFontFeaturesSize
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nGetFontFeatures SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nGetFontFeatures
(KNativePointer ptr, KInt* resultArr) { (KNativePointer ptr, KInt* resultArr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
std::vector<FontFeature> fontFeatures = instance->getFontFeatures(); std::vector<FontFeature> fontFeatures = instance->getFontFeatures();
skija::FontFeature::writeToIntArray(fontFeatures, resultArr); skija::FontFeature::writeToIntArray(fontFeatures, resultArr);
} }
...@@ -191,7 +197,7 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nAddFontFeature ...@@ -191,7 +197,7 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nAddFontFeature
#if 0 #if 0
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nAddFontFeature SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nAddFontFeature
(KNativePointer ptr, KInteropPointer nameStr, KInt value) { (KNativePointer ptr, KInteropPointer nameStr, KInt value) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->addFontFeature(skString(env, nameStr), value); instance->addFontFeature(skString(env, nameStr), value);
} }
#endif #endif
...@@ -199,19 +205,19 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nAddFontFeature ...@@ -199,19 +205,19 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nAddFontFeature
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nClearFontFeatures SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nClearFontFeatures
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->resetFontFeatures(); instance->resetFontFeatures();
} }
SKIKO_EXPORT KFloat org_jetbrains_skia_paragraph_TextStyle__1nGetFontSize SKIKO_EXPORT KFloat org_jetbrains_skia_paragraph_TextStyle__1nGetFontSize
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->getFontSize(); return instance->getFontSize();
} }
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetFontSize SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetFontSize
(KNativePointer ptr, KFloat size) { (KNativePointer ptr, KFloat size) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setFontSize(size); instance->setFontSize(size);
} }
...@@ -224,7 +230,7 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetF ...@@ -224,7 +230,7 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetF
#if 0 #if 0
SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetFontFamilies SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetFontFamilies
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return javaStringArray(env, instance->getFontFamilies()); return javaStringArray(env, instance->getFontFamilies());
} }
#endif #endif
...@@ -233,137 +239,133 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetF ...@@ -233,137 +239,133 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetF
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetFontFamilies SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetFontFamilies
(KNativePointer ptr, KInteropPointerArray familiesArray, KInt familiesArraySize) { (KNativePointer ptr, KInteropPointerArray familiesArray, KInt familiesArraySize) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setFontFamilies(skStringVector(familiesArray, familiesArraySize)); instance->setFontFamilies(skStringVector(familiesArray, familiesArraySize));
} }
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_paragraph_TextStyle__1nGetHeight SKIKO_EXPORT KFloat org_jetbrains_skia_paragraph_TextStyle__1nGetHeight
(KNativePointer ptr) {
TODO("implement org_jetbrains_skia_paragraph_TextStyle__1nGetHeight");
}
#if 0
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_paragraph_TextStyle__1nGetHeight
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->getHeightOverride() ? javaFloat(env, instance->getHeight()) : nullptr; return instance->getHeightOverride() ? instance->getHeight() : std::numeric_limits<KFloat>::quiet_NaN();
} }
#endif
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetHeight SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetHeight
(KNativePointer ptr, KBoolean override, KFloat height) { (KNativePointer ptr, KBoolean override, KFloat height) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setHeightOverride(override); instance->setHeightOverride(override);
instance->setHeight(height); instance->setHeight(height);
} }
SKIKO_EXPORT KFloat org_jetbrains_skia_paragraph_TextStyle__1nGetLetterSpacing SKIKO_EXPORT KFloat org_jetbrains_skia_paragraph_TextStyle__1nGetLetterSpacing
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->getLetterSpacing(); return instance->getLetterSpacing();
} }
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetLetterSpacing SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetLetterSpacing
(KNativePointer ptr, KFloat letterSpacing) { (KNativePointer ptr, KFloat letterSpacing) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setLetterSpacing(letterSpacing); instance->setLetterSpacing(letterSpacing);
} }
SKIKO_EXPORT KFloat org_jetbrains_skia_paragraph_TextStyle__1nGetWordSpacing SKIKO_EXPORT KFloat org_jetbrains_skia_paragraph_TextStyle__1nGetWordSpacing
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->getWordSpacing(); return instance->getWordSpacing();
} }
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetWordSpacing SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetWordSpacing
(KNativePointer ptr, KFloat wordSpacing) { (KNativePointer ptr, KFloat wordSpacing) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setWordSpacing(wordSpacing); instance->setWordSpacing(wordSpacing);
} }
SKIKO_EXPORT KNativePointer org_jetbrains_skia_paragraph_TextStyle__1nGetTypeface SKIKO_EXPORT KNativePointer org_jetbrains_skia_paragraph_TextStyle__1nGetTypeface
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return reinterpret_cast<KNativePointer>(instance->refTypeface().release()); return reinterpret_cast<KNativePointer>(instance->refTypeface().release());
} }
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetTypeface SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetTypeface
(KNativePointer ptr, KNativePointer typefacePtr) { (KNativePointer ptr, KNativePointer typefacePtr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
SkTypeface* typeface = reinterpret_cast<SkTypeface*>((typefacePtr)); SkTypeface* typeface = reinterpret_cast<SkTypeface*>((typefacePtr));
instance->setTypeface(sk_ref_sp(typeface)); instance->setTypeface(sk_ref_sp(typeface));
} }
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_paragraph_TextStyle__1nGetLocale SKIKO_EXPORT KNativePointer org_jetbrains_skia_paragraph_TextStyle__1nGetLocale
(KNativePointer ptr) { (KNativePointer ptr) {
TODO("implement org_jetbrains_skia_paragraph_TextStyle__1nGetLocale"); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
} return reinterpret_cast<KNativePointer>(new SkString(instance->getLocale()));
#if 0
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_paragraph_TextStyle__1nGetLocale
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
return javaString(env, instance->getLocale());
}
#endif
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetLocale
(KNativePointer ptr, KInteropPointer locale) {
TODO("implement org_jetbrains_skia_paragraph_TextStyle__1nSetLocale");
} }
#if 0
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetLocale SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetLocale
(KNativePointer ptr, KInteropPointer locale) { (KNativePointer ptr, KInteropPointer locale) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setLocale(skString(env, locale)); instance->setLocale(skString(locale));
} }
#endif
SKIKO_EXPORT KInt org_jetbrains_skia_paragraph_TextStyle__1nGetBaselineMode SKIKO_EXPORT KInt org_jetbrains_skia_paragraph_TextStyle__1nGetBaselineMode
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return static_cast<KInt>(instance->getTextBaseline()); return static_cast<KInt>(instance->getTextBaseline());
} }
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetBaselineMode SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetBaselineMode
(KNativePointer ptr, KInt baselineModeValue) { (KNativePointer ptr, KInt baselineModeValue) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setTextBaseline(static_cast<TextBaseline>(baselineModeValue)); instance->setTextBaseline(static_cast<TextBaseline>(baselineModeValue));
} }
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_paragraph_TextStyle__1nGetFontMetrics SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nGetFontMetrics
(KNativePointer ptr) { (KNativePointer ptr, KFloat* fontMetrics) {
TODO("implement org_jetbrains_skia_paragraph_TextStyle__1nGetFontMetrics"); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
}
#if 0
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_paragraph_TextStyle__1nGetFontMetrics
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
SkFontMetrics m; SkFontMetrics m;
instance->getFontMetrics(&m); instance->getFontMetrics(&m);
return skija::FontMetrics::toJava(env, m); 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;
}
} }
#endif
SKIKO_EXPORT KBoolean org_jetbrains_skia_paragraph_TextStyle__1nIsPlaceholder SKIKO_EXPORT KBoolean org_jetbrains_skia_paragraph_TextStyle__1nIsPlaceholder
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->isPlaceholder(); return instance->isPlaceholder();
} }
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetPlaceholder SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetPlaceholder
(KNativePointer ptr) { (KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr)); TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setPlaceholder(); instance->setPlaceholder();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment