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


Java Typeface.BOLD_ITALIC屬性代碼示例

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


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

示例1: checkGenericFont

private Typeface checkGenericFont(String fontName, Integer fontWeight,
		FontStyle fontStyle) {
	Typeface font = null;
	int typefaceStyle;

	boolean italic = (fontStyle == Style.FontStyle.Italic);
	typefaceStyle = (fontWeight > 500) ? (italic ? Typeface.BOLD_ITALIC
			: Typeface.BOLD) : (italic ? Typeface.ITALIC : Typeface.NORMAL);

	if (fontName.equals("serif")) {
		font = Typeface.create(Typeface.SERIF, typefaceStyle);
	} else if (fontName.equals("sans-serif")) {
		font = Typeface.create(Typeface.SANS_SERIF, typefaceStyle);
	} else if (fontName.equals("monospace")) {
		font = Typeface.create(Typeface.MONOSPACE, typefaceStyle);
	} else if (fontName.equals("cursive")) {
		font = Typeface.create(Typeface.SANS_SERIF, typefaceStyle);
	} else if (fontName.equals("fantasy")) {
		font = Typeface.create(Typeface.SANS_SERIF, typefaceStyle);
	}
	return font;
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:22,代碼來源:SVGAndroidRenderer.java

示例2: applyTypeface

public static void applyTypeface(TextView v) {
    if (v.getTypeface() == null) {
        v.setTypeface(getNormal(v.getContext()));
        return;
    }
    switch (v.getTypeface().getStyle()) {
        case Typeface.BOLD:
            v.setTypeface(getNormal(v.getContext()));
            v.getPaint().setFakeBoldText(true);
            break;
        default:
            v.setTypeface(getNormal(v.getContext()));
            break;
        case Typeface.ITALIC:
            v.setTypeface(getNormal(v.getContext()));
            v.getPaint().setTextSkewX(-0.25f);
            break;
        case Typeface.BOLD_ITALIC:
            v.setTypeface(getNormal(v.getContext()));
            v.getPaint().setFakeBoldText(true);
            v.getPaint().setTextSkewX(-0.25f);
            break;
    }

}
 
開發者ID:iPanelkegy,項目名稱:MobileMedia,代碼行數:25,代碼來源:Icon.java

示例3: getTypefaceStyle

private int getTypefaceStyle(boolean flgBold, boolean flgItalic) {
	if (flgBold && flgItalic) {
		return Typeface.BOLD_ITALIC;
	} else if (flgBold) {
		return Typeface.BOLD;
	} else if (flgItalic) {
		return Typeface.ITALIC;
	} else {
		return Typeface.NORMAL;
	}
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:DynamicExampleActivity.java

示例4: validateTypefaceStyle

private static void validateTypefaceStyle(int typefaceStyle) {
	switch (typefaceStyle) {
	case Typeface.NORMAL:
	case Typeface.BOLD:
	case Typeface.ITALIC:
	case Typeface.BOLD_ITALIC:
		break;
	default:
		throw new IllegalArgumentException("Invalid typeface style! Have to be one of " +
				"Typeface.NORMAL, Typeface.BOLD, Typeface.ITALIC or Typeface.BOLD_ITALIC");
	}
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:TypefaceCollection.java

示例5: checkTypefaceStyleThrowing

/**
 * Check if typeface style int is one of:
 * <ul>
 *      <li>{@link android.graphics.Typeface#NORMAL}</li>
 *      <li>{@link android.graphics.Typeface#BOLD}</li>
 *      <li>{@link android.graphics.Typeface#ITALIC}</li>
 *      <li>{@link android.graphics.Typeface#BOLD_ITALIC}</li>
 * </ul>
 * @param style
 */
private static void checkTypefaceStyleThrowing(int style) {
	switch (style) {
	case Typeface.NORMAL:
	case Typeface.BOLD:
	case Typeface.ITALIC:
	case Typeface.BOLD_ITALIC:
		break;
	default:
		throw new IllegalArgumentException("Style have to be in (Typeface.NORMAL, Typeface.BOLD, Typeface.ITALIC, Typeface.BOLD_ITALIC)");
	}
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:TypefaceHelper.java

示例6: getTextStyle

private int getTextStyle(boolean chat, boolean out, boolean read) {
    if (chat) {
        return read || out ? Typeface.ITALIC : Typeface.BOLD_ITALIC;
    } else {
        return read || out ? Typeface.NORMAL : Typeface.BOLD;
    }
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:7,代碼來源:DialogsAdapter.java

示例7: createByName

/**
 * 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,代碼行數:18,代碼來源:TypefaceUtil.java

示例8: getFont

/**
 * 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,代碼行數:18,代碼來源:BaseTextView.java

示例9: getFont

/**
 * Get the font based on the text style.
 *
 * @return font file name.
 */
String getFont(@Nullable 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");
        default:
        case Typeface.NORMAL:
            return String.format(Locale.US, "fonts/%s", "OpenSans-Regular.ttf");
    }
}
 
開發者ID:kevalpatel2106,項目名稱:smart-lens,代碼行數:18,代碼來源:BaseButton.java

示例10: setTypeface

/**
 * Sets the typeface size used by this view.
 *
 * @param typeface the typeface to use on the text.
 */
public void setTypeface(Typeface typeface) {
    if (textStyle == Typeface.BOLD_ITALIC) {
        typeface = Typeface.create(typeface, Typeface.BOLD_ITALIC);
    } else if (textStyle == Typeface.BOLD) {
        typeface = Typeface.create(typeface, Typeface.BOLD);
    } else if (textStyle == Typeface.ITALIC) {
        typeface = Typeface.create(typeface, Typeface.ITALIC);
    }

    textPaint.setTypeface(typeface);
    onTextPaintMeasurementChanged();
}
 
開發者ID:whoislxy,項目名稱:ticker_up,代碼行數:17,代碼來源:TickerView.java

示例11: getTypeface

private int getTypeface() {
    int typeface = Typeface.NORMAL;

    if (mLabel.getBold() && mLabel.getItalic())
        typeface = Typeface.BOLD_ITALIC;
    else {
        if (mLabel.getBold())
            typeface = Typeface.BOLD;
        else if (mLabel.getItalic())
            typeface = Typeface.ITALIC;
    }
    return typeface;
}
 
開發者ID:olgamiller,項目名稱:SSTVEncoder2,代碼行數:13,代碼來源:LabelPainter.java

示例12: getTextStyle

private static int getTextStyle(boolean isBold, boolean isItalic) {
    int style = Typeface.NORMAL;
    if (isBold && isItalic) {
        style = Typeface.BOLD_ITALIC;
    } else if (isBold) {
        style = Typeface.BOLD;
    } else if (isItalic) {
        style = Typeface.ITALIC;
    }
    return style;
}
 
開發者ID:shazam,項目名稱:reflow-animator,代碼行數:11,代碼來源:AdvancedSampleActivity.java

示例13: initSpannableStringBuilder

private void initSpannableStringBuilder(LuaValue text, LuaValue config) {
    SpannableStringBuilder spannableStringBuilder = getSpannableStringBuilder();
    if (text != null && text.isstring()) {
        spannableStringBuilder = spannableStringBuilder.append(text.tojstring());
    }

    if (spannableStringBuilder.length() > 0) {
        if (config != null && config.istable()) {
            final int end = spannableStringBuilder.length();
            final int fontSize = DimenUtil.spToPx(config.get("fontSize").optint(-1));
            final Integer fontColor = ColorUtil.parse(LuaUtil.getValue(config, "fontColor"));
            final String fontName = config.get("fontName").optjstring(null);

            final LuaValue weightValue = config.get("fontWeight");
            final int fontWeight = LuaUtil.isNumber(weightValue) ? weightValue.optint(UDFontWeight.WEIGHT_NORMAL_INT) : UDFontWeight.getValue(weightValue.optjstring(UDFontWeight.WEIGHT_NORMAL));

            final LuaValue styleValue = config.get("fontStyle");
            final int fontStyle = LuaUtil.isNumber(styleValue) ? styleValue.optint(Typeface.NORMAL) : UDFontStyle.getValue(styleValue.optjstring(UDFontStyle.STYLE_NORMAL));

            final Integer backgroundColor = ColorUtil.parse(LuaUtil.getValue(config, "backgroundColor"));
            final boolean strikethrough = config.get("strikethrough").optboolean(false);
            final boolean underline = config.get("underline").optboolean(false);

            if (fontSize != -1) {//字體大小
                spannableStringBuilder.setSpan(new AbsoluteSizeSpan(fontSize), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (fontColor != null) {//字體顏色
                spannableStringBuilder.setSpan(new ForegroundColorSpan(fontColor), 0, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (fontName != null && getLuaResourceFinder() != null) {//字體
                spannableStringBuilder.setSpan(new CustomTypefaceSpan(fontName, getLuaResourceFinder().findTypeface(fontName)), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (fontWeight != -1 && fontWeight > UDFontWeight.WEIGHT_NORMAL_INT) {//文字Weight
                spannableStringBuilder.setSpan(new WeightStyleSpan(fontWeight), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (fontStyle != -1 && (fontStyle >= Typeface.NORMAL && fontStyle <= Typeface.BOLD_ITALIC)) {//文字樣式
                spannableStringBuilder.setSpan(new StyleSpan(fontStyle), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (backgroundColor != null) {//背景色
                spannableStringBuilder.setSpan(new BackgroundColorSpan(backgroundColor), 0, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (strikethrough) {//刪除線
                spannableStringBuilder.setSpan(new StrikethroughSpan(), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            if (underline) {//下劃線
                spannableStringBuilder.setSpan(new UnderlineSpan(), 0, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
    }
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:57,代碼來源:UDSpannableString.java

示例14: boldItalic

public static Node boldItalic(Object... nodes) {
    return new SpanNode(new StyleSpan(Typeface.BOLD_ITALIC), nodes);
}
 
開發者ID:SimonMarquis,項目名稱:Android-Spans,代碼行數:3,代碼來源:Span.java

示例15: boldItalic

/**
 * @see android.text.style.StyleSpan
 */
public static Span boldItalic() {
    return new Span(new StyleSpanBuilder(Typeface.BOLD_ITALIC));
}
 
開發者ID:neworld,項目名稱:spanner,代碼行數:6,代碼來源:Spans.java


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