Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Derek Sollenberger | 5368eda | 2019-10-25 11:20:03 -0400 | [diff] [blame] | 17 | #undef LOG_TAG |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 18 | #define LOG_TAG "Minikin" |
| 19 | |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 20 | #include "SkData.h" |
Seigo Nonaka | 1ed4f64 | 2020-09-10 17:19:34 -0700 | [diff] [blame] | 21 | #include "SkFont.h" |
| 22 | #include "SkFontMetrics.h" |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 23 | #include "SkFontMgr.h" |
| 24 | #include "SkRefCnt.h" |
| 25 | #include "SkTypeface.h" |
| 26 | #include "GraphicsJNI.h" |
| 27 | #include <nativehelper/ScopedUtfChars.h> |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 28 | #include "Utils.h" |
| 29 | #include "FontUtils.h" |
| 30 | |
| 31 | #include <hwui/MinikinSkia.h> |
Seigo Nonaka | 1ed4f64 | 2020-09-10 17:19:34 -0700 | [diff] [blame] | 32 | #include <hwui/Paint.h> |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 33 | #include <hwui/Typeface.h> |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 34 | #include <minikin/FontFamily.h> |
Jagadeesh Pakaravoor | b624af3 | 2020-05-01 00:01:40 +0000 | [diff] [blame] | 35 | #include <ui/FatVector.h> |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 36 | |
| 37 | #include <memory> |
| 38 | |
| 39 | namespace android { |
| 40 | |
| 41 | struct NativeFontBuilder { |
| 42 | std::vector<minikin::FontVariation> axes; |
| 43 | }; |
| 44 | |
| 45 | static inline NativeFontBuilder* toBuilder(jlong ptr) { |
| 46 | return reinterpret_cast<NativeFontBuilder*>(ptr); |
| 47 | } |
| 48 | |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 49 | static void releaseFont(jlong font) { |
| 50 | delete reinterpret_cast<FontWrapper*>(font); |
| 51 | } |
| 52 | |
| 53 | static void release_global_ref(const void* /*data*/, void* context) { |
Derek Sollenberger | c5882c4 | 2019-10-25 11:11:32 -0400 | [diff] [blame] | 54 | JNIEnv* env = GraphicsJNI::getJNIEnv(); |
| 55 | bool needToAttach = (env == nullptr); |
| 56 | if (needToAttach) { |
| 57 | env = GraphicsJNI::attachJNIEnv("release_font_data"); |
| 58 | if (env == nullptr) { |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 59 | ALOGE("failed to attach to thread to release global ref."); |
| 60 | return; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | jobject obj = reinterpret_cast<jobject>(context); |
| 65 | env->DeleteGlobalRef(obj); |
| 66 | } |
| 67 | |
| 68 | // Regular JNI |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 69 | static jlong Font_Builder_initBuilder(JNIEnv*, jobject) { |
| 70 | return reinterpret_cast<jlong>(new NativeFontBuilder()); |
| 71 | } |
| 72 | |
| 73 | // Critical Native |
Jerome Gaillard | 21e7e2d | 2019-05-14 14:34:46 +0100 | [diff] [blame] | 74 | static void Font_Builder_addAxis(CRITICAL_JNI_PARAMS_COMMA jlong builderPtr, jint tag, jfloat value) { |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 75 | toBuilder(builderPtr)->axes.emplace_back(static_cast<minikin::AxisTag>(tag), value); |
| 76 | } |
| 77 | |
| 78 | // Regular JNI |
| 79 | static jlong Font_Builder_build(JNIEnv* env, jobject clazz, jlong builderPtr, jobject buffer, |
Seigo Nonaka | 54c6a27 | 2018-10-25 15:44:32 -0700 | [diff] [blame] | 80 | jstring filePath, jint weight, jboolean italic, jint ttcIndex) { |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 81 | NPE_CHECK_RETURN_ZERO(env, buffer); |
| 82 | std::unique_ptr<NativeFontBuilder> builder(toBuilder(builderPtr)); |
| 83 | const void* fontPtr = env->GetDirectBufferAddress(buffer); |
| 84 | if (fontPtr == nullptr) { |
| 85 | jniThrowException(env, "java/lang/IllegalArgumentException", "Not a direct buffer"); |
| 86 | return 0; |
| 87 | } |
| 88 | jlong fontSize = env->GetDirectBufferCapacity(buffer); |
| 89 | if (fontSize <= 0) { |
| 90 | jniThrowException(env, "java/lang/IllegalArgumentException", |
| 91 | "buffer size must not be zero or negative"); |
| 92 | return 0; |
| 93 | } |
Seigo Nonaka | 54c6a27 | 2018-10-25 15:44:32 -0700 | [diff] [blame] | 94 | ScopedUtfChars fontPath(env, filePath); |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 95 | jobject fontRef = MakeGlobalRefOrDie(env, buffer); |
| 96 | sk_sp<SkData> data(SkData::MakeWithProc(fontPtr, fontSize, |
| 97 | release_global_ref, reinterpret_cast<void*>(fontRef))); |
| 98 | |
Ben Wagner | 78d58fd | 2020-07-14 16:52:13 +0000 | [diff] [blame] | 99 | FatVector<SkFontArguments::VariationPosition::Coordinate, 2> skVariation; |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 100 | for (const auto& axis : builder->axes) { |
Ben Wagner | 78d58fd | 2020-07-14 16:52:13 +0000 | [diff] [blame] | 101 | skVariation.push_back({axis.axisTag, axis.value}); |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | std::unique_ptr<SkStreamAsset> fontData(new SkMemoryStream(std::move(data))); |
| 105 | |
Ben Wagner | 78d58fd | 2020-07-14 16:52:13 +0000 | [diff] [blame] | 106 | SkFontArguments args; |
| 107 | args.setCollectionIndex(ttcIndex); |
| 108 | args.setVariationDesignPosition({skVariation.data(), static_cast<int>(skVariation.size())}); |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 109 | |
| 110 | sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); |
Ben Wagner | 78d58fd | 2020-07-14 16:52:13 +0000 | [diff] [blame] | 111 | sk_sp<SkTypeface> face(fm->makeFromStream(std::move(fontData), args)); |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 112 | if (face == nullptr) { |
| 113 | jniThrowException(env, "java/lang/IllegalArgumentException", |
| 114 | "Failed to create internal object. maybe invalid font data."); |
| 115 | return 0; |
| 116 | } |
| 117 | std::shared_ptr<minikin::MinikinFont> minikinFont = |
Seigo Nonaka | 54c6a27 | 2018-10-25 15:44:32 -0700 | [diff] [blame] | 118 | std::make_shared<MinikinFontSkia>(std::move(face), fontPtr, fontSize, |
| 119 | std::string_view(fontPath.c_str(), fontPath.size()), |
| 120 | ttcIndex, builder->axes); |
Seigo Nonaka | 760d351 | 2020-10-01 12:29:03 -0700 | [diff] [blame] | 121 | std::shared_ptr<minikin::Font> font = minikin::Font::Builder(minikinFont).setWeight(weight) |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 122 | .setSlant(static_cast<minikin::FontStyle::Slant>(italic)).build(); |
| 123 | return reinterpret_cast<jlong>(new FontWrapper(std::move(font))); |
| 124 | } |
| 125 | |
Seigo Nonaka | 1ed4f64 | 2020-09-10 17:19:34 -0700 | [diff] [blame] | 126 | // Fast Native |
| 127 | static jlong Font_Builder_clone(JNIEnv* env, jobject clazz, jlong fontPtr, jlong builderPtr, |
| 128 | jint weight, jboolean italic, jint ttcIndex) { |
| 129 | FontWrapper* font = reinterpret_cast<FontWrapper*>(fontPtr); |
Seigo Nonaka | 760d351 | 2020-10-01 12:29:03 -0700 | [diff] [blame] | 130 | MinikinFontSkia* minikinSkia = static_cast<MinikinFontSkia*>(font->font->typeface().get()); |
Seigo Nonaka | 1ed4f64 | 2020-09-10 17:19:34 -0700 | [diff] [blame] | 131 | std::unique_ptr<NativeFontBuilder> builder(toBuilder(builderPtr)); |
| 132 | |
| 133 | // Reconstruct SkTypeface with different arguments from existing SkTypeface. |
| 134 | FatVector<SkFontArguments::VariationPosition::Coordinate, 2> skVariation; |
| 135 | for (const auto& axis : builder->axes) { |
| 136 | skVariation.push_back({axis.axisTag, axis.value}); |
| 137 | } |
| 138 | SkFontArguments args; |
| 139 | args.setCollectionIndex(ttcIndex); |
| 140 | args.setVariationDesignPosition({skVariation.data(), static_cast<int>(skVariation.size())}); |
| 141 | |
| 142 | sk_sp<SkTypeface> newTypeface = minikinSkia->GetSkTypeface()->makeClone(args); |
| 143 | |
| 144 | std::shared_ptr<minikin::MinikinFont> newMinikinFont = std::make_shared<MinikinFontSkia>( |
| 145 | std::move(newTypeface), |
| 146 | minikinSkia->GetFontData(), |
| 147 | minikinSkia->GetFontSize(), |
| 148 | minikinSkia->getFilePath(), |
| 149 | minikinSkia->GetFontIndex(), |
| 150 | builder->axes); |
Seigo Nonaka | 760d351 | 2020-10-01 12:29:03 -0700 | [diff] [blame] | 151 | std::shared_ptr<minikin::Font> newFont = minikin::Font::Builder(newMinikinFont) |
| 152 | .setWeight(weight) |
| 153 | .setSlant(static_cast<minikin::FontStyle::Slant>(italic)) |
| 154 | .build(); |
Seigo Nonaka | 1ed4f64 | 2020-09-10 17:19:34 -0700 | [diff] [blame] | 155 | return reinterpret_cast<jlong>(new FontWrapper(std::move(newFont))); |
| 156 | } |
| 157 | |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 158 | // Critical Native |
Jerome Gaillard | 21e7e2d | 2019-05-14 14:34:46 +0100 | [diff] [blame] | 159 | static jlong Font_Builder_getReleaseNativeFont(CRITICAL_JNI_PARAMS) { |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 160 | return reinterpret_cast<jlong>(releaseFont); |
| 161 | } |
| 162 | |
| 163 | /////////////////////////////////////////////////////////////////////////////// |
| 164 | |
Seigo Nonaka | 1ed4f64 | 2020-09-10 17:19:34 -0700 | [diff] [blame] | 165 | // Fast Native |
| 166 | static jfloat Font_getGlyphBounds(JNIEnv* env, jobject, jlong fontHandle, jint glyphId, |
| 167 | jlong paintHandle, jobject rect) { |
| 168 | FontWrapper* font = reinterpret_cast<FontWrapper*>(fontHandle); |
Seigo Nonaka | 760d351 | 2020-10-01 12:29:03 -0700 | [diff] [blame] | 169 | MinikinFontSkia* minikinSkia = static_cast<MinikinFontSkia*>(font->font->typeface().get()); |
Seigo Nonaka | 1ed4f64 | 2020-09-10 17:19:34 -0700 | [diff] [blame] | 170 | Paint* paint = reinterpret_cast<Paint*>(paintHandle); |
| 171 | |
| 172 | SkFont* skFont = &paint->getSkFont(); |
| 173 | // We don't use populateSkFont since it is designed to be used for layout result with addressing |
| 174 | // auto fake-bolding. |
| 175 | skFont->setTypeface(minikinSkia->RefSkTypeface()); |
| 176 | |
| 177 | uint16_t glyph16 = glyphId; |
| 178 | SkRect skBounds; |
| 179 | SkScalar skWidth; |
| 180 | skFont->getWidthsBounds(&glyph16, 1, &skWidth, &skBounds, nullptr); |
| 181 | GraphicsJNI::rect_to_jrectf(skBounds, env, rect); |
| 182 | return SkScalarToFloat(skWidth); |
| 183 | } |
| 184 | |
| 185 | // Fast Native |
| 186 | static jfloat Font_getFontMetrics(JNIEnv* env, jobject, jlong fontHandle, jlong paintHandle, |
| 187 | jobject metricsObj) { |
| 188 | FontWrapper* font = reinterpret_cast<FontWrapper*>(fontHandle); |
Seigo Nonaka | 760d351 | 2020-10-01 12:29:03 -0700 | [diff] [blame] | 189 | MinikinFontSkia* minikinSkia = static_cast<MinikinFontSkia*>(font->font->typeface().get()); |
Seigo Nonaka | 1ed4f64 | 2020-09-10 17:19:34 -0700 | [diff] [blame] | 190 | Paint* paint = reinterpret_cast<Paint*>(paintHandle); |
| 191 | |
| 192 | SkFont* skFont = &paint->getSkFont(); |
| 193 | // We don't use populateSkFont since it is designed to be used for layout result with addressing |
| 194 | // auto fake-bolding. |
| 195 | skFont->setTypeface(minikinSkia->RefSkTypeface()); |
| 196 | |
| 197 | SkFontMetrics metrics; |
| 198 | SkScalar spacing = skFont->getMetrics(&metrics); |
| 199 | GraphicsJNI::set_metrics(env, metricsObj, metrics); |
| 200 | return spacing; |
| 201 | } |
| 202 | |
Seigo Nonaka | f3a1915 | 2020-09-14 15:29:42 -0700 | [diff] [blame] | 203 | // Critical Native |
| 204 | static jlong Font_getFontInfo(CRITICAL_JNI_PARAMS_COMMA jlong fontHandle) { |
Seigo Nonaka | 760d351 | 2020-10-01 12:29:03 -0700 | [diff] [blame] | 205 | const minikin::Font* font = reinterpret_cast<minikin::Font*>(fontHandle); |
| 206 | MinikinFontSkia* minikinSkia = static_cast<MinikinFontSkia*>(font->typeface().get()); |
Seigo Nonaka | f3a1915 | 2020-09-14 15:29:42 -0700 | [diff] [blame] | 207 | |
Seigo Nonaka | 760d351 | 2020-10-01 12:29:03 -0700 | [diff] [blame] | 208 | uint64_t result = font->style().weight(); |
| 209 | result |= font->style().slant() == minikin::FontStyle::Slant::ITALIC ? 0x10000 : 0x00000; |
Seigo Nonaka | f3a1915 | 2020-09-14 15:29:42 -0700 | [diff] [blame] | 210 | result |= ((static_cast<uint64_t>(minikinSkia->GetFontIndex())) << 32); |
| 211 | result |= ((static_cast<uint64_t>(minikinSkia->GetAxes().size())) << 48); |
| 212 | return result; |
| 213 | } |
| 214 | |
| 215 | // Critical Native |
| 216 | static jlong Font_getAxisInfo(CRITICAL_JNI_PARAMS_COMMA jlong fontHandle, jint index) { |
Seigo Nonaka | 760d351 | 2020-10-01 12:29:03 -0700 | [diff] [blame] | 217 | const minikin::Font* font = reinterpret_cast<minikin::Font*>(fontHandle); |
| 218 | MinikinFontSkia* minikinSkia = static_cast<MinikinFontSkia*>(font->typeface().get()); |
Seigo Nonaka | f3a1915 | 2020-09-14 15:29:42 -0700 | [diff] [blame] | 219 | const minikin::FontVariation& var = minikinSkia->GetAxes().at(index); |
| 220 | uint32_t floatBinary = *reinterpret_cast<const uint32_t*>(&var.value); |
| 221 | return (static_cast<uint64_t>(var.axisTag) << 32) | static_cast<uint64_t>(floatBinary); |
| 222 | } |
| 223 | |
Seigo Nonaka | c519ed8 | 2020-10-09 12:00:07 -0700 | [diff] [blame] | 224 | // FastNative |
| 225 | static jstring Font_getFontPath(JNIEnv* env, jobject, jlong fontHandle) { |
| 226 | const minikin::Font* font = reinterpret_cast<minikin::Font*>(fontHandle); |
| 227 | MinikinFontSkia* minikinSkia = static_cast<MinikinFontSkia*>(font->typeface().get()); |
| 228 | const std::string& filePath = minikinSkia->getFilePath(); |
| 229 | if (filePath.empty()) { |
| 230 | return nullptr; |
| 231 | } |
| 232 | return env->NewStringUTF(filePath.c_str()); |
| 233 | } |
| 234 | |
Seigo Nonaka | 760d351 | 2020-10-01 12:29:03 -0700 | [diff] [blame] | 235 | // Critical Native |
| 236 | static jlong Font_getNativeFontPtr(CRITICAL_JNI_PARAMS_COMMA jlong fontHandle) { |
| 237 | FontWrapper* font = reinterpret_cast<FontWrapper*>(fontHandle); |
| 238 | return reinterpret_cast<jlong>(font->font.get()); |
| 239 | } |
| 240 | |
Seigo Nonaka | f3a1915 | 2020-09-14 15:29:42 -0700 | [diff] [blame] | 241 | /////////////////////////////////////////////////////////////////////////////// |
| 242 | |
| 243 | struct FontBufferWrapper { |
| 244 | FontBufferWrapper(const std::shared_ptr<minikin::MinikinFont>& font) : minikinFont(font) {} |
| 245 | // MinikinFont holds a shared pointer of SkTypeface which has reference to font data. |
| 246 | std::shared_ptr<minikin::MinikinFont> minikinFont; |
| 247 | }; |
| 248 | |
| 249 | static void unrefBuffer(jlong nativePtr) { |
| 250 | FontBufferWrapper* wrapper = reinterpret_cast<FontBufferWrapper*>(nativePtr); |
| 251 | delete wrapper; |
| 252 | } |
| 253 | |
| 254 | // Critical Native |
| 255 | static jlong FontBufferHelper_refFontBuffer(CRITICAL_JNI_PARAMS_COMMA jlong fontHandle) { |
Seigo Nonaka | 760d351 | 2020-10-01 12:29:03 -0700 | [diff] [blame] | 256 | const minikin::Font* font = reinterpret_cast<minikin::Font*>(fontHandle); |
| 257 | return reinterpret_cast<jlong>(new FontBufferWrapper(font->typeface())); |
Seigo Nonaka | f3a1915 | 2020-09-14 15:29:42 -0700 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | // Fast Native |
| 261 | static jobject FontBufferHelper_wrapByteBuffer(JNIEnv* env, jobject, jlong nativePtr) { |
| 262 | FontBufferWrapper* wrapper = reinterpret_cast<FontBufferWrapper*>(nativePtr); |
| 263 | return env->NewDirectByteBuffer( |
| 264 | const_cast<void*>(wrapper->minikinFont->GetFontData()), |
| 265 | wrapper->minikinFont->GetFontSize()); |
| 266 | } |
| 267 | |
| 268 | // Critical Native |
| 269 | static jlong FontBufferHelper_getReleaseFunc(CRITICAL_JNI_PARAMS) { |
| 270 | return reinterpret_cast<jlong>(unrefBuffer); |
| 271 | } |
| 272 | |
Seigo Nonaka | 1ed4f64 | 2020-09-10 17:19:34 -0700 | [diff] [blame] | 273 | /////////////////////////////////////////////////////////////////////////////// |
| 274 | |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 275 | static const JNINativeMethod gFontBuilderMethods[] = { |
| 276 | { "nInitBuilder", "()J", (void*) Font_Builder_initBuilder }, |
| 277 | { "nAddAxis", "(JIF)V", (void*) Font_Builder_addAxis }, |
Seigo Nonaka | 54c6a27 | 2018-10-25 15:44:32 -0700 | [diff] [blame] | 278 | { "nBuild", "(JLjava/nio/ByteBuffer;Ljava/lang/String;IZI)J", (void*) Font_Builder_build }, |
Seigo Nonaka | 1ed4f64 | 2020-09-10 17:19:34 -0700 | [diff] [blame] | 279 | { "nClone", "(JJIZI)J", (void*) Font_Builder_clone }, |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 280 | { "nGetReleaseNativeFont", "()J", (void*) Font_Builder_getReleaseNativeFont }, |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 281 | }; |
| 282 | |
Seigo Nonaka | 1ed4f64 | 2020-09-10 17:19:34 -0700 | [diff] [blame] | 283 | static const JNINativeMethod gFontMethods[] = { |
| 284 | { "nGetGlyphBounds", "(JIJLandroid/graphics/RectF;)F", (void*) Font_getGlyphBounds }, |
| 285 | { "nGetFontMetrics", "(JJLandroid/graphics/Paint$FontMetrics;)F", (void*) Font_getFontMetrics }, |
Seigo Nonaka | f3a1915 | 2020-09-14 15:29:42 -0700 | [diff] [blame] | 286 | { "nGetFontInfo", "(J)J", (void*) Font_getFontInfo }, |
| 287 | { "nGetAxisInfo", "(JI)J", (void*) Font_getAxisInfo }, |
Seigo Nonaka | c519ed8 | 2020-10-09 12:00:07 -0700 | [diff] [blame] | 288 | { "nGetFontPath", "(J)Ljava/lang/String;", (void*) Font_getFontPath }, |
Seigo Nonaka | 760d351 | 2020-10-01 12:29:03 -0700 | [diff] [blame] | 289 | { "nGetNativeFontPtr", "(J)J", (void*) Font_getNativeFontPtr }, |
Seigo Nonaka | f3a1915 | 2020-09-14 15:29:42 -0700 | [diff] [blame] | 290 | }; |
| 291 | |
| 292 | static const JNINativeMethod gFontBufferHelperMethods[] = { |
| 293 | { "nRefFontBuffer", "(J)J", (void*) FontBufferHelper_refFontBuffer }, |
| 294 | { "nWrapByteBuffer", "(J)Ljava/nio/ByteBuffer;", (void*) FontBufferHelper_wrapByteBuffer }, |
| 295 | { "nGetReleaseFunc", "()J", (void*) FontBufferHelper_getReleaseFunc }, |
Seigo Nonaka | 1ed4f64 | 2020-09-10 17:19:34 -0700 | [diff] [blame] | 296 | }; |
| 297 | |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 298 | int register_android_graphics_fonts_Font(JNIEnv* env) { |
| 299 | return RegisterMethodsOrDie(env, "android/graphics/fonts/Font$Builder", gFontBuilderMethods, |
Seigo Nonaka | 1ed4f64 | 2020-09-10 17:19:34 -0700 | [diff] [blame] | 300 | NELEM(gFontBuilderMethods)) + |
| 301 | RegisterMethodsOrDie(env, "android/graphics/fonts/Font", gFontMethods, |
Seigo Nonaka | f3a1915 | 2020-09-14 15:29:42 -0700 | [diff] [blame] | 302 | NELEM(gFontMethods)) + |
| 303 | RegisterMethodsOrDie(env, "android/graphics/fonts/NativeFontBufferHelper", |
| 304 | gFontBufferHelperMethods, NELEM(gFontBufferHelperMethods)); |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | } |