本文整理汇总了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;
}
示例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;
}
}
示例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;
}
}
示例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");
}
}
示例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)");
}
}
示例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;
}
}
示例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;
}
}
示例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");
}
}
示例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");
}
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例14: boldItalic
public static Node boldItalic(Object... nodes) {
return new SpanNode(new StyleSpan(Typeface.BOLD_ITALIC), nodes);
}
示例15: boldItalic
/**
* @see android.text.style.StyleSpan
*/
public static Span boldItalic() {
return new Span(new StyleSpanBuilder(Typeface.BOLD_ITALIC));
}