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