當前位置: 首頁>>代碼示例>>Java>>正文


Java Typeface.getStyle方法代碼示例

本文整理匯總了Java中android.graphics.Typeface.getStyle方法的典型用法代碼示例。如果您正苦於以下問題:Java Typeface.getStyle方法的具體用法?Java Typeface.getStyle怎麽用?Java Typeface.getStyle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Typeface的用法示例。


在下文中一共展示了Typeface.getStyle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: apply

import android.graphics.Typeface; //導入方法依賴的package包/類
private void apply(Paint paint, Typeface tf) {
    int oldStyle;
    Typeface old = paint.getTypeface();
    if (old == null) {
        oldStyle = 0;
    } else {
        oldStyle = old.getStyle();
    }

    int fake = oldStyle & ~tf.getStyle();
    if ((fake & Typeface.BOLD) != 0) {
        paint.setFakeBoldText(true);
    }

    if ((fake & Typeface.ITALIC) != 0) {
        paint.setTextSkewX(-0.25f);
    }

    paint.getShader();

    paint.setTypeface(tf);
}
 
開發者ID:pan2yong22,項目名稱:AndroidUtilCode-master,代碼行數:23,代碼來源:SpanUtils.java

示例2: updateTypeface

import android.graphics.Typeface; //導入方法依賴的package包/類
private void updateTypeface(TextPaint ds) {
  Typeface typeface = ds.getTypeface();

  int oldStyle = (typeface == null) ? 0 : typeface.getStyle();
  int newStyle = getNewStyle(oldStyle);

  if (oldStyle == newStyle && mFontFamily == null) {
    // nothing to do
    return;
  }

  if (mFontFamily != null) {
    typeface = TypefaceCache.getTypeface(mFontFamily, newStyle);
  } else {
    typeface = TypefaceCache.getTypeface(typeface, newStyle);
  }

  ds.setTypeface(typeface);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:20,代碼來源:FontStylingSpan.java

示例3: setFontStyle

import android.graphics.Typeface; //導入方法依賴的package包/類
/**
/* This code was taken from the method setFontStyle of the class ReactTextShadowNode
/* TODO: Factor into a common place they can both use
*/
@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);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:22,代碼來源:ReactTextInputManager.java

示例4: apply

import android.graphics.Typeface; //導入方法依賴的package包/類
private void apply(final Paint paint)
{
    final Typeface oldTypeface = paint.getTypeface();
    final int oldStyle = oldTypeface != null ? oldTypeface.getStyle() : 0;
    final int fakeStyle = oldStyle & ~typeface.getStyle();

    if ((fakeStyle & Typeface.BOLD) != 0)
    {
        paint.setFakeBoldText(true);
    }

    if ((fakeStyle & Typeface.ITALIC) != 0)
    {
        paint.setTextSkewX(-0.25f);
    }

    paint.setTypeface(typeface);
}
 
開發者ID:cdjalel,項目名稱:QuranKeyboard,代碼行數:19,代碼來源:CustomTypefaceSpan.java

示例5: apply

import android.graphics.Typeface; //導入方法依賴的package包/類
private static void apply(Paint paint, Typeface tf) {
    int oldStyle;
    Typeface old = paint.getTypeface();
    if (old == null) {
        oldStyle = 0;
    } else {
        oldStyle = old.getStyle();
    }

    int fake = oldStyle & ~tf.getStyle();
    if ((fake & Typeface.BOLD) != 0) {
        paint.setFakeBoldText(true);
    }

    if ((fake & Typeface.ITALIC) != 0) {
        paint.setTextSkewX(-0.25f);
    }

    paint.setTypeface(tf);
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:21,代碼來源:SpannableStringUtils.java

示例6: apply

import android.graphics.Typeface; //導入方法依賴的package包/類
private void apply(final Paint paint, final Typeface tf) {
    int oldStyle;
    Typeface old = paint.getTypeface();
    if (old == null) {
        oldStyle = 0;
    } else {
        oldStyle = old.getStyle();
    }

    int fake = oldStyle & ~tf.getStyle();
    if ((fake & Typeface.BOLD) != 0) {
        paint.setFakeBoldText(true);
    }

    if ((fake & Typeface.ITALIC) != 0) {
        paint.setTextSkewX(-0.25f);
    }

    paint.getShader();

    paint.setTypeface(tf);
}
 
開發者ID:Wilshion,項目名稱:HeadlineNews,代碼行數:23,代碼來源:SpanUtils.java

示例7: apply

import android.graphics.Typeface; //導入方法依賴的package包/類
private static void apply(
    Paint paint,
    int style,
    int weight,
    @Nullable String family,
    AssetManager assetManager) {
  int oldStyle;
  Typeface typeface = paint.getTypeface();
  if (typeface == null) {
    oldStyle = 0;
  } else {
    oldStyle = typeface.getStyle();
  }

  int want = 0;
  if ((weight == Typeface.BOLD) ||
      ((oldStyle & Typeface.BOLD) != 0 && weight == ReactTextShadowNode.UNSET)) {
    want |= Typeface.BOLD;
  }

  if ((style == Typeface.ITALIC) ||
      ((oldStyle & Typeface.ITALIC) != 0 && style == ReactTextShadowNode.UNSET)) {
    want |= Typeface.ITALIC;
  }

  if (family != null) {
    typeface = ReactFontManager.getInstance().getTypeface(family, want, assetManager);
  } else if (typeface != null) {
    // TODO(t9055065): Fix custom fonts getting applied to text children with different style
    typeface = Typeface.create(typeface, want);
  }

  if (typeface != null) {
    paint.setTypeface(typeface);
  } else {
    paint.setTypeface(Typeface.defaultFromStyle(want));
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:39,代碼來源:CustomStyleSpan.java

示例8: getTypeface

import android.graphics.Typeface; //導入方法依賴的package包/類
/**
 * Returns a derivative of a given Typeface with a different style.
 */
public static Typeface getTypeface(Typeface typeface, int style) {
  if (typeface == null) {
    return Typeface.defaultFromStyle(style);
  }

  Typeface[] cache = TYPEFACE_CACHE.get(typeface);
  if (cache == null) {
    // This should not happen because all Typefaces are coming from TypefaceCache,
    // and thus should be registered in TYPEFACE_CACHE.
    // If we get here, it's a bug and one of the 2 scenarios happened:
    // a) TypefaceCache created a Typeface and didn't put it into TYPEFACE_CACHE.
    // b) someone else created a Typeface bypassing TypefaceCache so it's not registered here.
    //
    // If it's not registered, we can just register it manually for consistency, and so that
    // next time someone requests a un unknown Typeface, it's already cached and we don't create
    // extra copies.
    cache = new Typeface[MAX_STYLES];
    cache[typeface.getStyle()] = typeface;
  } else if (cache[style] != null) {
    // return cached value.
    return cache[style];
  }

  typeface = Typeface.create(typeface, style);
  cache[style] = typeface;
  TYPEFACE_CACHE.put(typeface, cache);
  return typeface;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:32,代碼來源:TypefaceCache.java

示例9: getFont

import android.graphics.Typeface; //導入方法依賴的package包/類
/**
 * Get the font based on the text style.
 *
 * @return font file name.
 */
String getFont(Typeface typeface) {
    switch (typeface != null ? typeface.getStyle() : Typeface.NORMAL) {
        case Typeface.BOLD_ITALIC:
            return String.format(Locale.US, "fonts/%s", "OpenSans-BoldItalic.ttf");
        case Typeface.ITALIC:
            return String.format(Locale.US, "fonts/%s", "OpenSans-Italic.ttf");
        case Typeface.BOLD:
            return String.format(Locale.US, "fonts/%s", "OpenSans-Bold.ttf");
        case Typeface.NORMAL:
        default:
            return String.format(Locale.US, "fonts/%s", "OpenSans-Regular.ttf");
    }
}
 
開發者ID:kevalpatel2106,項目名稱:smart-lens,代碼行數:19,代碼來源:BaseEditText.java

示例10: apply

import android.graphics.Typeface; //導入方法依賴的package包/類
private void apply(final Paint paint) {
    final Typeface oldTypeface = paint.getTypeface();
    final int oldStyle = oldTypeface != null ? oldTypeface.getStyle() : 0;
    final int fakeStyle = oldStyle & ~typeface.getStyle();

    if ((fakeStyle & Typeface.BOLD) != 0) {
        paint.setFakeBoldText(true);
    }

    if ((fakeStyle & Typeface.ITALIC) != 0) {
        paint.setTextSkewX(-0.25f);
    }

    paint.setTypeface(typeface);
}
 
開發者ID:takahirom,項目名稱:DownloadableCalligraphy,代碼行數:16,代碼來源:CalligraphyTypefaceSpan.java

示例11: createByName

import android.graphics.Typeface; //導入方法依賴的package包/類
/**
 * create typeface by name or path
 *
 * @param fontName
 * @return
 */
private static Typeface createByName(final String fontName) {
    try {
        final Typeface typeface = Typeface.create(fontName, Typeface.BOLD_ITALIC);
        if (typeface != null && Typeface.BOLD_ITALIC == typeface.getStyle()) {//得到的是默認字體則返回null
            return null;
        }
        return typeface;
    } catch (Exception e) {
        LogUtil.e("create typeface " + fontName + " by name failed", e);
        return null;
    }
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:19,代碼來源:TypefaceUtil.java

示例12: setSwitchTypeface

import android.graphics.Typeface; //導入方法依賴的package包/類
public void setSwitchTypeface(Typeface tf, int style) {
    boolean z = false;
    if (style > 0) {
        int typefaceStyle;
        float f;
        if (tf == null) {
            tf = Typeface.defaultFromStyle(style);
        } else {
            tf = Typeface.create(tf, style);
        }
        setSwitchTypeface(tf);
        if (tf != null) {
            typefaceStyle = tf.getStyle();
        } else {
            typefaceStyle = 0;
        }
        int need = style & (typefaceStyle ^ -1);
        TextPaint textPaint = this.mTextPaint;
        if ((need & 1) != 0) {
            z = true;
        }
        textPaint.setFakeBoldText(z);
        textPaint = this.mTextPaint;
        if ((need & 2) != 0) {
            f = -0.25f;
        } else {
            f = 0.0f;
        }
        textPaint.setTextSkewX(f);
        return;
    }
    this.mTextPaint.setFakeBoldText(false);
    this.mTextPaint.setTextSkewX(0.0f);
    setSwitchTypeface(tf);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:36,代碼來源:SwitchCompat.java

示例13: applyFontStyle

import android.graphics.Typeface; //導入方法依賴的package包/類
public static void applyFontStyle(Paint paint, int style, int weight, String family) {
  int oldStyle;
  Typeface typeface = paint.getTypeface();
  if (typeface == null) {
    oldStyle = 0;
  } 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));
  }
}
 
開發者ID:erguotou520,項目名稱:weex-uikit,代碼行數:31,代碼來源:TypefaceUtil.java

示例14: getDiscreteIndicatorTypefaceStyle

import android.graphics.Typeface; //導入方法依賴的package包/類
/**
 * Returns the style of the typeface used to draw the discrete indicator's text.
 *
 * @return Typeface style.
 * @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;
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:14,代碼來源:SeekBarWidget.java

示例15: getTitleTypefaceStyle

import android.graphics.Typeface; //導入方法依賴的package包/類
/**
 * Returns the style of the typeface used to draw the title text.
 *
 * @return Typeface style.
 * @see #getTitleTypeface()
 * @see #setTitleTypeface(Typeface, int)
 */
@TextAppearance.TextStyle
@SuppressWarnings("ResourceType")
public int getTitleTypefaceStyle() {
	final Typeface typeface = TITLE_TEXT_INFO.paint.getTypeface();
	return typeface != null ? typeface.getStyle() : Typeface.NORMAL;
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:14,代碼來源:MonthView.java


注:本文中的android.graphics.Typeface.getStyle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。