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


Java Paint.getTypeface方法代碼示例

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


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

示例1: apply

import android.graphics.Paint; //導入方法依賴的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: applyCustomTypeFace

import android.graphics.Paint; //導入方法依賴的package包/類
private static void applyCustomTypeFace(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:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:CustomTypefaceSpan.java

示例3: apply

import android.graphics.Paint; //導入方法依賴的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

示例4: apply

import android.graphics.Paint; //導入方法依賴的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

示例5: applyCustomTypeFace

import android.graphics.Paint; //導入方法依賴的package包/類
private static void applyCustomTypeFace(Paint paint, @Nullable Typeface tf) {
    if (tf == null) {
        return;
    }

    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:coopese,項目名稱:qmui,代碼行數:25,代碼來源:QMUICustomTypefaceSpan.java

示例6: draw

import android.graphics.Paint; //導入方法依賴的package包/類
public void draw(Canvas g2, float x, float y) {
		drawDebug(g2, x, y);
//		Paint st=AjLatexMath.getPaint();
//		st.setTextSize(AjLatexMath.getTextSize());
		Paint st =new Paint();
		float w = st.getStrokeWidth();
		Style s = st.getStyle();
		Typeface f = st.getTypeface();
		st.setStrokeWidth(0);//
		st.setStyle(Style.FILL_AND_STROKE);
		st.setTypeface(font);
		g2.save();
		g2.translate(x, y);
		g2.scale(0.5f * size, 0.5f * size);
//		g2.drawText(str, x, y, st);
		g2.drawText(str, 0, 0, st);
		g2.restore();
		st.setStyle(s);
		st.setStrokeWidth(w);
		st.setTypeface(f);
	}
 
開發者ID:daquexian,項目名稱:FlexibleRichTextView,代碼行數:22,代碼來源:JavaFontRenderingBox.java

示例7: apply

import android.graphics.Paint; //導入方法依賴的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

示例8: applyFontStyle

import android.graphics.Paint; //導入方法依賴的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

示例9: apply

import android.graphics.Paint; //導入方法依賴的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:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:CalligraphyTypefaceSpan.java

示例10: getCharGeometryCacheKey

import android.graphics.Paint; //導入方法依賴的package包/類
private static int getCharGeometryCacheKey(final char referenceChar, final Paint paint) {
    final int labelSize = (int)paint.getTextSize();
    final Typeface face = paint.getTypeface();
    final int codePointOffset = referenceChar << 15;
    if (face == Typeface.DEFAULT) {
        return codePointOffset + labelSize;
    } else if (face == Typeface.DEFAULT_BOLD) {
        return codePointOffset + labelSize + 0x1000;
    } else if (face == Typeface.MONOSPACE) {
        return codePointOffset + labelSize + 0x2000;
    } else {
        return codePointOffset + labelSize;
    }
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:15,代碼來源:TypefaceUtils.java

示例11: apply

import android.graphics.Paint; //導入方法依賴的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

示例12: d

import android.graphics.Paint; //導入方法依賴的package包/類
protected Typeface d(Paint paint) {
    Object obj;
    Typeface typeface;
    Paint paint2;
    if (this.useHanyiColorFont || !(paint instanceof ETPaint)) {
        obj = null;
        typeface = null;
        paint2 = paint;
    } else {
        paint = ((ETPaint) paint).a();
        Typeface typeface2 = paint.getTypeface();
        paint.setTypeface(null);
        typeface = typeface2;
        obj = 1;
        paint2 = paint;
    }
    if (!this.useDefaultFont) {
        return typeface;
    }
    if (paint2 instanceof ETPaint) {
        paint2 = ((ETPaint) paint2).a();
    }
    if (obj != null) {
        return typeface;
    }
    typeface = paint2.getTypeface();
    paint2.setTypeface(null);
    return typeface;
}
 
開發者ID:xieyangxuejun,項目名稱:CommentView,代碼行數:30,代碼來源:TextCell.java


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