Home | History | Annotate | Download | only in graphics
      1 /*
      2  * Copyright (C) 2013 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 
     18 #ifndef ANDROID_TYPEFACE_IMPL_H
     19 #define ANDROID_TYPEFACE_IMPL_H
     20 
     21 #include "jni.h"  // for jlong, eventually remove
     22 #include "SkTypeface.h"
     23 #include <androidfw/AssetManager.h>
     24 
     25 #include <minikin/FontCollection.h>
     26 
     27 namespace android {
     28 
     29 struct TypefaceImpl {
     30     FontCollection *fFontCollection;
     31 
     32     // style used for constructing and querying Typeface objects
     33     SkTypeface::Style fSkiaStyle;
     34     // base weight in CSS-style units, 100..900
     35     int fBaseWeight;
     36 
     37     // resolved style actually used for rendering
     38     FontStyle fStyle;
     39 };
     40 
     41 // Note: it would be cleaner if the following functions were member
     42 // functions (static or otherwise) of the TypefaceImpl class. However,
     43 // that can't be easily accommodated in the case where TypefaceImpl
     44 // is just a pointer to SkTypeface, in the non-USE_MINIKIN case.
     45 // TODO: when #ifdef USE_MINIKIN is removed, move to member functions.
     46 
     47 TypefaceImpl* TypefaceImpl_resolveDefault(TypefaceImpl* src);
     48 
     49 TypefaceImpl* TypefaceImpl_createFromTypeface(TypefaceImpl* src, SkTypeface::Style style);
     50 
     51 TypefaceImpl* TypefaceImpl_createWeightAlias(TypefaceImpl* src, int baseweight);
     52 
     53 // When we remove the USE_MINIKIN ifdef, probably a good idea to move the casting
     54 // (from jlong to FontFamily*) to the caller in Typeface.cpp.
     55 TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size);
     56 
     57 void TypefaceImpl_unref(TypefaceImpl* face);
     58 
     59 int TypefaceImpl_getStyle(TypefaceImpl* face);
     60 
     61 void TypefaceImpl_setDefault(TypefaceImpl* face);
     62 
     63 }
     64 
     65 #endif  // ANDROID_TYPEFACE_IMPL_H