当前位置: 首页>>代码示例>>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;未经允许,请勿转载。