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