blob: b36b4e60e33ae2f3212e797ac6ee46ee99f3edba [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>
22
Seigo Nonakaa1c21c02018-07-20 15:57:39 -070023#include <minikin/Font.h>
24
Seigo Nonakac7064142017-02-10 16:53:31 +090025namespace minikin {
26class FontFamily;
27} // namespace minikin
Seigo Nonaka9ff994d2016-11-30 14:04:21 -080028
29namespace android {
30
Seigo Nonakac7064142017-02-10 16:53:31 +090031struct FontFamilyWrapper {
Chih-Hung Hsieh0727be12018-12-20 13:43:46 -080032 explicit FontFamilyWrapper(std::shared_ptr<minikin::FontFamily>&& family) : family(family) {}
Seigo Nonakac7064142017-02-10 16:53:31 +090033 std::shared_ptr<minikin::FontFamily> family;
34};
35
Seigo Nonakaa1c21c02018-07-20 15:57:39 -070036struct FontWrapper {
37 FontWrapper(minikin::Font&& font) : font(std::move(font)) {}
38 minikin::Font font;
39};
40
Seigo Nonaka9ff994d2016-11-30 14:04:21 -080041// Utility wrapper for java.util.List
42class ListHelper {
43public:
44 ListHelper(JNIEnv* env, jobject list) : mEnv(env), mList(list) {}
45
46 jint size() const;
47 jobject get(jint index) const;
48
49private:
50 JNIEnv* mEnv;
51 jobject mList;
52};
53
54// Utility wrapper for android.graphics.FontConfig$Axis
55class AxisHelper {
56public:
57 AxisHelper(JNIEnv* env, jobject axis) : mEnv(env), mAxis(axis) {}
58
59 jint getTag() const;
60 jfloat getStyleValue() const;
61
62private:
63 JNIEnv* mEnv;
64 jobject mAxis;
65};
66
67void init_FontUtils(JNIEnv* env);
68
69}; // namespace android
70
71#endif // _ANDROID_GRAPHICS_FONT_UTILS_H_