blob: ba4e56e4c7f78fc27efd5634ac7833f87d2c8b5a [file] [log] [blame]
Seigo Nonaka9ff994d2016-11-30 14:04:21 -08001/*
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 Nonakac7064142017-02-10 16:53:31 +090021#include <memory>
Seigo Nonaka760d3512020-10-01 12:29:03 -070022#include <utility>
Seigo Nonakac7064142017-02-10 16:53:31 +090023
Seigo Nonakaa1c21c02018-07-20 15:57:39 -070024#include <minikin/Font.h>
25
Seigo Nonakac7064142017-02-10 16:53:31 +090026namespace minikin {
27class FontFamily;
28} // namespace minikin
Seigo Nonaka9ff994d2016-11-30 14:04:21 -080029
30namespace android {
31
Seigo Nonakac7064142017-02-10 16:53:31 +090032struct FontFamilyWrapper {
Chih-Hung Hsieh0727be12018-12-20 13:43:46 -080033 explicit FontFamilyWrapper(std::shared_ptr<minikin::FontFamily>&& family) : family(family) {}
Seigo Nonakac7064142017-02-10 16:53:31 +090034 std::shared_ptr<minikin::FontFamily> family;
35};
36
Seigo Nonakaa1c21c02018-07-20 15:57:39 -070037struct FontWrapper {
Seigo Nonaka760d3512020-10-01 12:29:03 -070038 explicit FontWrapper(std::shared_ptr<minikin::Font>&& font) : font(font) {}
39 std::shared_ptr<minikin::Font> font;
Seigo Nonakaa1c21c02018-07-20 15:57:39 -070040};
41
Seigo Nonaka9ff994d2016-11-30 14:04:21 -080042// Utility wrapper for java.util.List
43class ListHelper {
44public:
45 ListHelper(JNIEnv* env, jobject list) : mEnv(env), mList(list) {}
46
47 jint size() const;
48 jobject get(jint index) const;
49
50private:
51 JNIEnv* mEnv;
52 jobject mList;
53};
54
55// Utility wrapper for android.graphics.FontConfig$Axis
56class AxisHelper {
57public:
58 AxisHelper(JNIEnv* env, jobject axis) : mEnv(env), mAxis(axis) {}
59
60 jint getTag() const;
61 jfloat getStyleValue() const;
62
63private:
64 JNIEnv* mEnv;
65 jobject mAxis;
66};
67
68void init_FontUtils(JNIEnv* env);
69
70}; // namespace android
71
72#endif // _ANDROID_GRAPHICS_FONT_UTILS_H_