Methods Summary |
---|
public static android.graphics.Typeface_Delegate | getDelegate(long nativeTypeface)
// ---- Public Helper methods ----
return sManager.getDelegate(nativeTypeface);
|
public java.util.List | getFonts(android.graphics.FontFamily_Delegate.FontVariant variant)Return a list of fonts that match the style and variant. The list is ordered according to
preference of fonts.
The list may contain null when the font failed to load. If null is reached when trying to
render with this list of fonts, then a warning should be logged letting the user know that
some font failed to load.
assert variant != FontVariant.NONE;
// Calculate the required weight based on style and weight of this typeface.
int weight = mWeight + ((mStyle & Font.BOLD) == 0 ? 0 : FontFamily_Delegate.BOLD_FONT_WEIGHT_DELTA);
if (weight > 900) {
weight = 900;
}
final boolean isItalic = (mStyle & Font.ITALIC) != 0;
List<Font> fonts = new ArrayList<Font>(mFontFamilies.length);
for (int i = 0; i < mFontFamilies.length; i++) {
FontFamily_Delegate ffd = mFontFamilies[i];
if (ffd != null && ffd.isValid()) {
Font font = ffd.getFont(weight, isItalic);
if (font != null) {
FontVariant ffdVariant = ffd.getVariant();
if (ffdVariant == FontVariant.NONE) {
fonts.add(font);
continue;
}
// We cannot open each font and get locales supported, etc to match the fonts.
// As a workaround, we hardcode certain assumptions like Elegant and Compact
// always appear in pairs.
assert i < mFontFamilies.length - 1;
FontFamily_Delegate ffd2 = mFontFamilies[++i];
assert ffd2 != null;
FontVariant ffd2Variant = ffd2.getVariant();
Font font2 = ffd2.getFont(weight, isItalic);
assert ffd2Variant != FontVariant.NONE && ffd2Variant != ffdVariant
&& font2 != null;
// Add the font with the matching variant to the list.
if (variant == ffd.getVariant()) {
fonts.add(font);
} else {
fonts.add(font2);
}
} else {
// The FontFamily is valid but doesn't contain any matching font. This means
// that the font failed to load. We add null to the list of fonts. Don't throw
// the warning just yet. If this is a non-english font, we don't want to warn
// users who are trying to render only english text.
fonts.add(null);
}
}
}
return fonts;
|
static java.io.File | getSystemFontConfigLocation()
return new File(getFontLocation());
|
static synchronized long | nativeCreateFromArray(long[] familyArray)
FontFamily_Delegate[] fontFamilies = new FontFamily_Delegate[familyArray.length];
for (int i = 0; i < familyArray.length; i++) {
fontFamilies[i] = FontFamily_Delegate.getDelegate(familyArray[i]);
}
Typeface_Delegate delegate = new Typeface_Delegate(fontFamilies, Typeface.NORMAL);
return sManager.addNewDelegate(delegate);
|
static synchronized long | nativeCreateFromTypeface(long native_instance, int style)
Typeface_Delegate delegate = sManager.getDelegate(native_instance);
if (delegate == null) {
delegate = sManager.getDelegate(sDefaultTypeface);
}
if (delegate == null) {
return 0;
}
return sManager.addNewDelegate(new Typeface_Delegate(delegate.mFontFamilies, style,
delegate.mWeight));
|
static long | nativeCreateWeightAlias(long native_instance, int weight)
Typeface_Delegate delegate = sManager.getDelegate(native_instance);
if (delegate == null) {
delegate = sManager.getDelegate(sDefaultTypeface);
}
if (delegate == null) {
return 0;
}
Typeface_Delegate weightAlias =
new Typeface_Delegate(delegate.mFontFamilies, delegate.mStyle, weight);
return sManager.addNewDelegate(weightAlias);
|
static int | nativeGetStyle(long native_instance)
Typeface_Delegate delegate = sManager.getDelegate(native_instance);
if (delegate == null) {
return 0;
}
return delegate.mStyle;
|
static void | nativeSetDefault(long native_instance)
sDefaultTypeface = native_instance;
|
static void | nativeUnref(long native_instance)
sManager.removeJavaReferenceFor(native_instance);
|
public static void | resetDefaults()Clear the default typefaces when disposing bridge.
// Sometimes this is called before the Bridge is initialized. In that case, we don't want to
// initialize Typeface because the SDK fonts location hasn't been set.
if (FontFamily_Delegate.getFontLocation() != null) {
Typeface.sDefaults = null;
}
|