1 /* 2 * Copyright (C) 2017 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 17 #ifndef _ANDROID_GRAPHICS_FONT_UTILS_H_ 18 #define _ANDROID_GRAPHICS_FONT_UTILS_H_ 19 20 #include <jni.h> 21 #include <memory> 22 23 #include <minikin/Font.h> 24 25 namespace minikin { 26 class FontFamily; 27 } // namespace minikin 28 29 namespace android { 30 31 struct FontFamilyWrapper { 32 explicit FontFamilyWrapper(std::shared_ptr<minikin::FontFamily>&& family) : family(family) {} 33 std::shared_ptr<minikin::FontFamily> family; 34 }; 35 36 struct FontWrapper { 37 FontWrapper(minikin::Font&& font) : font(std::move(font)) {} 38 minikin::Font font; 39 }; 40 41 // Utility wrapper for java.util.List 42 class ListHelper { 43 public: 44 ListHelper(JNIEnv* env, jobject list) : mEnv(env), mList(list) {} 45 46 jint size() const; 47 jobject get(jint index) const; 48 49 private: 50 JNIEnv* mEnv; 51 jobject mList; 52 }; 53 54 // Utility wrapper for android.graphics.FontConfig$Axis 55 class AxisHelper { 56 public: 57 AxisHelper(JNIEnv* env, jobject axis) : mEnv(env), mAxis(axis) {} 58 59 jint getTag() const; 60 jfloat getStyleValue() const; 61 62 private: 63 JNIEnv* mEnv; 64 jobject mAxis; 65 }; 66 67 void init_FontUtils(JNIEnv* env); 68 69 }; // namespace android 70 71 #endif // _ANDROID_GRAPHICS_FONT_UTILS_H_ 72