List of usage examples for android.graphics Typeface getStyle
public @Style int getStyle()
From source file:com.taobao.weex.utils.TypefaceUtil.java
public static void applyFontStyle(Paint paint, int style, int weight, String family) { int oldStyle; Typeface typeface = paint.getTypeface(); if (typeface == null) { oldStyle = 0;/*from w w w. ja v a 2 s. c o m*/ } else { oldStyle = typeface.getStyle(); } int want = 0; if ((weight == Typeface.BOLD) || ((oldStyle & Typeface.BOLD) != 0 && weight == WXStyle.UNSET)) { want |= Typeface.BOLD; } if ((style == Typeface.ITALIC) || ((oldStyle & Typeface.ITALIC) != 0 && style == WXStyle.UNSET)) { want |= Typeface.ITALIC; } if (family != null) { typeface = getOrCreateTypeface(family, want); } if (typeface != null) { paint.setTypeface(Typeface.create(typeface, want)); } else { paint.setTypeface(Typeface.defaultFromStyle(want)); } }
From source file:de.vanita5.twittnuker.util.ThemeUtils.java
public static Typeface getUserTypeface(final Context context, final Typeface defTypeface) { if (context == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return Typeface.DEFAULT; final int fontStyle = defTypeface != null ? defTypeface.getStyle() : Typeface.NORMAL; final String fontFamily = getThemeFontFamily(context); final Typeface tf = Typeface.create(fontFamily, fontStyle); if (tf != null) return tf; return Typeface.create(Typeface.DEFAULT, fontStyle); }
From source file:org.mariotaku.twidere.util.ThemeUtils.java
public static Typeface getUserTypeface(final Context context, final String fontFamily, final Typeface defTypeface) { if (context == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return Typeface.DEFAULT; final int fontStyle = defTypeface != null ? defTypeface.getStyle() : Typeface.NORMAL; final Typeface tf = Typeface.create(fontFamily, fontStyle); if (tf != null) return tf; return Typeface.create(Typeface.DEFAULT, fontStyle); }
From source file:com.facebook.react.views.textinput.ReactTextInputManager.java
/** /* This code was taken from the method setFontStyle of the class ReactTextShadowNode /* TODO: Factor into a common place they can both use *///from w w w . j a va2 s .c o m @ReactProp(name = ViewProps.FONT_STYLE) public void setFontStyle(ReactEditText view, @Nullable String fontStyleString) { int fontStyle = UNSET; if ("italic".equals(fontStyleString)) { fontStyle = Typeface.ITALIC; } else if ("normal".equals(fontStyleString)) { fontStyle = Typeface.NORMAL; } Typeface currentTypeface = view.getTypeface(); if (currentTypeface == null) { currentTypeface = Typeface.DEFAULT; } if (fontStyle != currentTypeface.getStyle()) { view.setTypeface(currentTypeface, fontStyle); } }
From source file:com.facebook.react.views.textinput.ReactTextInputManager.java
/** /* This code was taken from the method setFontWeight of the class ReactTextShadowNode /* TODO: Factor into a common place they can both use *///from www .j ava 2 s. c o m @ReactProp(name = ViewProps.FONT_WEIGHT) public void setFontWeight(ReactEditText view, @Nullable String fontWeightString) { int fontWeightNumeric = fontWeightString != null ? parseNumericFontWeight(fontWeightString) : -1; int fontWeight = UNSET; if (fontWeightNumeric >= 500 || "bold".equals(fontWeightString)) { fontWeight = Typeface.BOLD; } else if ("normal".equals(fontWeightString) || (fontWeightNumeric != -1 && fontWeightNumeric < 500)) { fontWeight = Typeface.NORMAL; } Typeface currentTypeface = view.getTypeface(); if (currentTypeface == null) { currentTypeface = Typeface.DEFAULT; } if (fontWeight != currentTypeface.getStyle()) { view.setTypeface(currentTypeface, fontWeight); } }
From source file:android.support.v7.widget.SwitchCompat.java
/** * Sets the typeface and style in which the text should be displayed on the * switch, and turns on the fake bold and italic bits in the Paint if the * Typeface that you provided does not have all the bits in the * style that you specified.// w ww . j a v a 2s. c om */ public void setSwitchTypeface(Typeface tf, int style) { if (style > 0) { if (tf == null) { tf = Typeface.defaultFromStyle(style); } else { tf = Typeface.create(tf, style); } setSwitchTypeface(tf); // now compute what (if any) algorithmic styling is needed int typefaceStyle = tf != null ? tf.getStyle() : 0; int need = style & ~typefaceStyle; mTextPaint.setFakeBoldText((need & Typeface.BOLD) != 0); mTextPaint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0); } else { mTextPaint.setFakeBoldText(false); mTextPaint.setTextSkewX(0); setSwitchTypeface(tf); } }
From source file:com.albedinsky.android.ui.widget.SeekBarWidget.java
/** * Returns the style of the typeface used to draw the discrete indicator's text. * * @return Typeface style.//www . ja v a2s . c o m * @see #getDiscreteIndicatorTypeface() * @see #setDiscreteIndicatorTypeface(Typeface, int) */ @TextAppearance.TextStyle @SuppressWarnings("ResourceType") public int getDiscreteIndicatorTypefaceStyle() { final Typeface typeface = DISCRETE_INDICATOR_TEXT_INFO.paint.getTypeface(); return typeface != null ? typeface.getStyle() : Typeface.NORMAL; }