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

Commonize TextStyle (#366)

parent dd5b7902
package org.jetbrains.skia
import org.jetbrains.skia.impl.InteropPointer
import org.jetbrains.skia.impl.InteropScope
import org.jetbrains.skia.impl.withResult
class FontMetrics(
/**
* greatest extent above origin of any glyph bounding box, typically negative; deprecated with variable fonts
......@@ -154,4 +158,29 @@ class FontMetrics(
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)"
}
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
import org.jetbrains.skia.impl.InteropPointer
import org.jetbrains.skia.impl.InteropScope
import org.jetbrains.skia.impl.withResult
class DecorationStyle(
val _underline: Boolean,
val _overline: Boolean,
......@@ -26,7 +30,7 @@ class DecorationStyle(
lineThrough,
gaps,
color,
DecorationLineStyle.values().get(lineStyle),
DecorationLineStyle.values()[lineStyle],
thicknessMultiplier
) {
}
......@@ -173,3 +177,20 @@ class DecorationStyle(
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
}
}
var decorationStyle: org.jetbrains.skia.paragraph.DecorationStyle
var decorationStyle: DecorationStyle
get() = try {
Stats.onNativeCall()
_nGetDecorationStyle(_ptr)
DecorationStyle.fromInteropPointer {
_nGetDecorationStyle(_ptr, it)
}
} finally {
reachabilityBarrier(this)
}
......@@ -252,7 +254,8 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz
var height: Float?
get() = try {
Stats.onNativeCall()
TextStyle_nGetHeight(_ptr)
val height = TextStyle_nGetHeight(_ptr)
if (height.isNaN()) null else height
} finally {
reachabilityBarrier(this)
}
......@@ -328,7 +331,9 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz
var locale: String
get() = try {
Stats.onNativeCall()
withStringResult {
_nGetLocale(_ptr)
}
} finally {
reachabilityBarrier(this)
}
......@@ -338,7 +343,9 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz
fun setLocale(locale: String?): TextStyle {
Stats.onNativeCall()
_nSetLocale(_ptr, locale)
interopScope {
_nSetLocale(_ptr, toInterop(locale))
}
return this
}
......@@ -359,10 +366,13 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz
return this
}
val fontMetrics: FontMetrics
get() = try {
Stats.onNativeCall()
_nGetFontMetrics(_ptr)
FontMetrics.fromInteropPointer {
_nGetFontMetrics(_ptr, it)
}
} finally {
reachabilityBarrier(this)
}
......@@ -386,7 +396,6 @@ class TextStyle internal constructor(ptr: NativePointer) : Managed(ptr, _Finaliz
}
}
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetFinalizer")
private external fun TextStyle_nGetFinalizer(): NativePointer
......@@ -412,7 +421,7 @@ private external fun TextStyle_nSetFontSize(ptr: NativePointer, size: Float)
private external fun TextStyle_nGetFontFamilies(ptr: NativePointer): Array<String>
@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")
private external fun TextStyle_nSetHeight(ptr: NativePointer, override: Boolean, height: Float)
......@@ -439,7 +448,7 @@ private external fun _nGetBackground(ptr: NativePointer): NativePointer
private external fun _nSetBackground(ptr: NativePointer, paintPtr: NativePointer)
@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")
private external fun _nSetDecorationStyle(
......@@ -496,10 +505,10 @@ private external fun _nGetTypeface(ptr: NativePointer): NativePointer
private external fun _nSetTypeface(ptr: NativePointer, typefacePtr: NativePointer)
@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")
private external fun _nSetLocale(ptr: NativePointer, locale: String?)
private external fun _nSetLocale(ptr: NativePointer, locale: InteropPointer)
@ExternalSymbolName("org_jetbrains_skia_paragraph_TextStyle__1nGetBaselineMode")
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)
@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")
private external fun _nIsPlaceholder(ptr: NativePointer): Boolean
......
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.paragraph.DecorationLineStyle
import org.jetbrains.skia.paragraph.DecorationStyle
import org.jetbrains.skia.paragraph.TextStyle
import org.jetbrains.skia.paragraph.TextStyleAttribute
import org.jetbrains.skiko.tests.SkipJsTarget
import org.jetbrains.skiko.tests.SkipNativeTarget
import kotlin.test.*
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 <limits>
#include <jni.h>
#include <vector>
#include "../interop.hh"
......@@ -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
(JNIEnv* env, jclass jclass, jlong ptr) {
extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nGetDecorationStyle
(JNIEnv* env, jclass jclass, jlong ptr, jintArray res) {
TextStyle* instance = reinterpret_cast<TextStyle*>(static_cast<uintptr_t>(ptr));
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,
jint r[4] = {
0,
static_cast<jint>(d.fColor),
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
......@@ -204,10 +222,10 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_
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) {
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
......@@ -254,10 +272,10 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_
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) {
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
......@@ -278,12 +296,45 @@ extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt_
instance->setTextBaseline(static_cast<TextBaseline>(baselineModeValue));
}
extern "C" JNIEXPORT jobject JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nGetFontMetrics
(JNIEnv* env, jclass jclass, jlong ptr) {
extern "C" JNIEXPORT void JNICALL Java_org_jetbrains_skia_paragraph_TextStyleKt__1nGetFontMetrics
(JNIEnv* env, jclass jclass, jlong ptr, jfloatArray fontMetrics) {
TextStyle* instance = reinterpret_cast<TextStyle*>(static_cast<uintptr_t>(ptr));
SkFontMetrics 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
......
......@@ -2,6 +2,7 @@
// This file has been auto generated.
#include <iostream>
#include <limits>
#include <vector>
#include "TextStyle.h"
using namespace std;
......@@ -25,14 +26,14 @@ SKIKO_EXPORT KNativePointer org_jetbrains_skia_paragraph_TextStyle__1nGetFinaliz
SKIKO_EXPORT KBoolean org_jetbrains_skia_paragraph_TextStyle__1nEquals
(KNativePointer ptr, KNativePointer otherPtr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
TextStyle* other = reinterpret_cast<TextStyle*>((otherPtr));
return instance->equals(*other);
}
SKIKO_EXPORT KBoolean org_jetbrains_skia_paragraph_TextStyle__1nAttributeEquals
(KNativePointer ptr, KInt attribute, KNativePointer otherPtr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
TextStyle* other = reinterpret_cast<TextStyle*>((otherPtr));
if (attribute == static_cast<KInt>(StyleType::kWordSpacing) + 1) // FONT_EXACT
return instance->equalsByFonts(*other);
......@@ -42,25 +43,25 @@ SKIKO_EXPORT KBoolean org_jetbrains_skia_paragraph_TextStyle__1nAttributeEquals
SKIKO_EXPORT KInt org_jetbrains_skia_paragraph_TextStyle__1nGetColor
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->getColor();
}
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetColor
(KNativePointer ptr, KInt color) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setColor(color);
}
SKIKO_EXPORT KNativePointer org_jetbrains_skia_paragraph_TextStyle__1nGetForeground
(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;
}
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetForeground
(KNativePointer ptr, KNativePointer paintPtr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
if (paintPtr == 0)
instance->clearForegroundColor();
else {
......@@ -71,13 +72,13 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetForeground
SKIKO_EXPORT KNativePointer org_jetbrains_skia_paragraph_TextStyle__1nGetBackground
(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;
}
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetBackground
(KNativePointer ptr, KNativePointer paintPtr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
if (paintPtr == 0)
instance->clearBackgroundColor();
else {
......@@ -87,31 +88,36 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetBackground
}
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_paragraph_TextStyle__1nGetDecorationStyle
(KNativePointer ptr) {
TODO("implement org_jetbrains_skia_paragraph_TextStyle__1nGetDecorationStyle");
}
#if 0
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_paragraph_TextStyle__1nGetDecorationStyle
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nGetDecorationStyle
(KNativePointer ptr, KInt* res) {
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
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
(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;
if (underline) typeMask |= TextDecoration::kUnderline;
if (overline) typeMask |= TextDecoration::kOverline;
......@@ -125,13 +131,13 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetDecorationStyle
SKIKO_EXPORT KInt org_jetbrains_skia_paragraph_TextStyle__1nGetFontStyle
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return skija::FontStyle::toKotlin(instance->getFontStyle());
}
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetFontStyle
(KNativePointer ptr, KInt fontStyleValue) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setFontStyle(skija::FontStyle::fromKotlin(fontStyleValue));
}
......@@ -143,7 +149,7 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetS
#if 0
SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetShadows
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
std::vector<TextShadow> shadows = instance->getShadows();
KInteropPointerArray shadowsArr = env->NewObjectArray((jsize) shadows.size(), skija::paragraph::Shadow::cls, nullptr);
for (int i = 0; i < shadows.size(); ++i) {
......@@ -158,13 +164,13 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetS
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nAddShadow
(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});
}
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nClearShadows
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->resetShadows();
}
......@@ -177,7 +183,7 @@ SKIKO_EXPORT KInt org_jetbrains_skia_paragraph_TextStyle__1nGetFontFeaturesSize
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nGetFontFeatures
(KNativePointer ptr, KInt* resultArr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
std::vector<FontFeature> fontFeatures = instance->getFontFeatures();
skija::FontFeature::writeToIntArray(fontFeatures, resultArr);
}
......@@ -191,7 +197,7 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nAddFontFeature
#if 0
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nAddFontFeature
(KNativePointer ptr, KInteropPointer nameStr, KInt value) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->addFontFeature(skString(env, nameStr), value);
}
#endif
......@@ -199,19 +205,19 @@ SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nAddFontFeature
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nClearFontFeatures
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->resetFontFeatures();
}
SKIKO_EXPORT KFloat org_jetbrains_skia_paragraph_TextStyle__1nGetFontSize
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->getFontSize();
}
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetFontSize
(KNativePointer ptr, KFloat size) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setFontSize(size);
}
......@@ -224,7 +230,7 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetF
#if 0
SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetFontFamilies
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return javaStringArray(env, instance->getFontFamilies());
}
#endif
......@@ -233,137 +239,133 @@ SKIKO_EXPORT KInteropPointerArray org_jetbrains_skia_paragraph_TextStyle__1nGetF
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetFontFamilies
(KNativePointer ptr, KInteropPointerArray familiesArray, KInt familiesArraySize) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setFontFamilies(skStringVector(familiesArray, familiesArraySize));
}
SKIKO_EXPORT KInteropPointer 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
SKIKO_EXPORT KFloat org_jetbrains_skia_paragraph_TextStyle__1nGetHeight
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
return instance->getHeightOverride() ? javaFloat(env, instance->getHeight()) : nullptr;
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->getHeightOverride() ? instance->getHeight() : std::numeric_limits<KFloat>::quiet_NaN();
}
#endif
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetHeight
(KNativePointer ptr, KBoolean override, KFloat height) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setHeightOverride(override);
instance->setHeight(height);
}
SKIKO_EXPORT KFloat org_jetbrains_skia_paragraph_TextStyle__1nGetLetterSpacing
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->getLetterSpacing();
}
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetLetterSpacing
(KNativePointer ptr, KFloat letterSpacing) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setLetterSpacing(letterSpacing);
}
SKIKO_EXPORT KFloat org_jetbrains_skia_paragraph_TextStyle__1nGetWordSpacing
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->getWordSpacing();
}
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetWordSpacing
(KNativePointer ptr, KFloat wordSpacing) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setWordSpacing(wordSpacing);
}
SKIKO_EXPORT KNativePointer org_jetbrains_skia_paragraph_TextStyle__1nGetTypeface
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return reinterpret_cast<KNativePointer>(instance->refTypeface().release());
}
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetTypeface
(KNativePointer ptr, KNativePointer typefacePtr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
SkTypeface* typeface = reinterpret_cast<SkTypeface*>((typefacePtr));
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) {
TODO("implement org_jetbrains_skia_paragraph_TextStyle__1nGetLocale");
}
#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");
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return reinterpret_cast<KNativePointer>(new SkString(instance->getLocale()));
}
#if 0
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetLocale
(KNativePointer ptr, KInteropPointer locale) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
instance->setLocale(skString(env, locale));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setLocale(skString(locale));
}
#endif
SKIKO_EXPORT KInt org_jetbrains_skia_paragraph_TextStyle__1nGetBaselineMode
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return static_cast<KInt>(instance->getTextBaseline());
}
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetBaselineMode
(KNativePointer ptr, KInt baselineModeValue) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
instance->setTextBaseline(static_cast<TextBaseline>(baselineModeValue));
}
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_paragraph_TextStyle__1nGetFontMetrics
(KNativePointer ptr) {
TODO("implement org_jetbrains_skia_paragraph_TextStyle__1nGetFontMetrics");
}
#if 0
SKIKO_EXPORT KInteropPointer org_jetbrains_skia_paragraph_TextStyle__1nGetFontMetrics
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nGetFontMetrics
(KNativePointer ptr, KFloat* fontMetrics) {
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
SkFontMetrics 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
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
return instance->isPlaceholder();
}
SKIKO_EXPORT void org_jetbrains_skia_paragraph_TextStyle__1nSetPlaceholder
(KNativePointer ptr) {
TextStyle* instance = reinterpret_cast<TextStyle*>((ptr));
TextStyle* instance = reinterpret_cast<TextStyle*>(ptr);
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