Home | History | Annotate | Download | only in graphics
      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 namespace minikin {
     24 class FontFamily;
     25 }  // namespace minikin
     26 
     27 namespace android {
     28 
     29 struct FontFamilyWrapper {
     30   FontFamilyWrapper(std::shared_ptr<minikin::FontFamily>&& family) : family(family) {}
     31   std::shared_ptr<minikin::FontFamily> family;
     32 };
     33 
     34 // Utility wrapper for java.util.List
     35 class ListHelper {
     36 public:
     37   ListHelper(JNIEnv* env, jobject list) : mEnv(env), mList(list) {}
     38 
     39   jint size() const;
     40   jobject get(jint index) const;
     41 
     42 private:
     43   JNIEnv* mEnv;
     44   jobject mList;
     45 };
     46 
     47 // Utility wrapper for android.graphics.FontConfig$Axis
     48 class AxisHelper {
     49 public:
     50   AxisHelper(JNIEnv* env, jobject axis) : mEnv(env), mAxis(axis) {}
     51 
     52   jint getTag() const;
     53   jfloat getStyleValue() const;
     54 
     55 private:
     56   JNIEnv* mEnv;
     57   jobject mAxis;
     58 };
     59 
     60 void init_FontUtils(JNIEnv* env);
     61 
     62 }; // namespace android
     63 
     64 #endif  // _ANDROID_GRAPHICS_FONT_UTILS_H_
     65