Seigo Nonaka | 9ff994d | 2016-11-30 14:04:21 -0800 | [diff] [blame] | 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> |
Seigo Nonaka | c706414 | 2017-02-10 16:53:31 +0900 | [diff] [blame] | 21 | #include <memory> |
| 22 | |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 23 | #include <minikin/Font.h> |
| 24 | |
Seigo Nonaka | c706414 | 2017-02-10 16:53:31 +0900 | [diff] [blame] | 25 | namespace minikin { |
| 26 | class FontFamily; |
| 27 | } // namespace minikin |
Seigo Nonaka | 9ff994d | 2016-11-30 14:04:21 -0800 | [diff] [blame] | 28 | |
| 29 | namespace android { |
| 30 | |
Seigo Nonaka | c706414 | 2017-02-10 16:53:31 +0900 | [diff] [blame] | 31 | struct FontFamilyWrapper { |
Chih-Hung Hsieh | 0727be1 | 2018-12-20 13:43:46 -0800 | [diff] [blame] | 32 | explicit FontFamilyWrapper(std::shared_ptr<minikin::FontFamily>&& family) : family(family) {} |
Seigo Nonaka | c706414 | 2017-02-10 16:53:31 +0900 | [diff] [blame] | 33 | std::shared_ptr<minikin::FontFamily> family; |
| 34 | }; |
| 35 | |
Seigo Nonaka | a1c21c0 | 2018-07-20 15:57:39 -0700 | [diff] [blame] | 36 | struct FontWrapper { |
| 37 | FontWrapper(minikin::Font&& font) : font(std::move(font)) {} |
| 38 | minikin::Font font; |
| 39 | }; |
| 40 | |
Seigo Nonaka | 9ff994d | 2016-11-30 14:04:21 -0800 | [diff] [blame] | 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_ |