本文整理汇总了Java中android.graphics.Typeface.BOLD属性的典型用法代码示例。如果您正苦于以下问题:Java Typeface.BOLD属性的具体用法?Java Typeface.BOLD怎么用?Java Typeface.BOLD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.graphics.Typeface
的用法示例。
在下文中一共展示了Typeface.BOLD属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateAdditionalHeadersView
/**
* Set up the additional headers text view with the supplied header data.
*
* @param additionalHeaders List of header entries. Each entry consists of a header
* name and a header value. Header names may appear multiple
* times.
* <p/>
* This method is always called from within the UI thread by
* {@link #showAdditionalHeaders()}.
*/
private void populateAdditionalHeadersView(final List<HeaderEntry> additionalHeaders) {
SpannableStringBuilder sb = new SpannableStringBuilder();
boolean first = true;
for (HeaderEntry additionalHeader : additionalHeaders) {
if (!first) {
sb.append("\n");
} else {
first = false;
}
StyleSpan boldSpan = new StyleSpan(Typeface.BOLD);
SpannableString label = new SpannableString(additionalHeader.label + ": ");
label.setSpan(boldSpan, 0, label.length(), 0);
sb.append(label);
sb.append(MimeUtility.unfoldAndDecode(additionalHeader.value));
}
mAdditionalHeadersView.setText(sb);
}
示例2: applyCustomTypeFace
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);
}
示例3: setFontWeight
/**
/* This code is duplicated in ReactTextInputManager
/* TODO: Factor into a common place they can both use
*/
@ReactProp(name = ViewProps.FONT_WEIGHT)
public void setFontWeight(@Nullable String fontWeightString) {
int fontWeightNumeric = fontWeightString != null ?
parseNumericFontWeight(fontWeightString) : -1;
int fontWeight = UNSET;
if (fontWeightNumeric >= 500 || "bold".equals(fontWeightString)) {
fontWeight = Typeface.BOLD;
} else if ("normal".equals(fontWeightString) ||
(fontWeightNumeric != -1 && fontWeightNumeric < 500)) {
fontWeight = Typeface.NORMAL;
}
if (fontWeight != mFontWeight) {
mFontWeight = fontWeight;
markUpdated();
}
}
示例4: applyTypeface
public static void applyTypeface(Context context, Paint v) {
if (v.getTypeface() == null) {
v.setTypeface(getNormal(context));
return;
}
switch (v.getTypeface().getStyle()) {
case Typeface.BOLD:
v.setTypeface(getNormal(context));
v.setFakeBoldText(true);
break;
default:
v.setTypeface(getNormal(context));
break;
case Typeface.ITALIC:
v.setTypeface(getNormal(context));
v.setTextSkewX(-0.25f);
break;
case Typeface.BOLD_ITALIC:
v.setTypeface(getNormal(context));
v.setFakeBoldText(true);
v.setTextSkewX(-0.25f);
break;
}
}
示例5: setFontWeight
@ReactProp(name = ViewProps.FONT_WEIGHT)
public void setFontWeight(@Nullable String fontWeightString) {
final int fontWeight;
if (fontWeightString == null) {
fontWeight = -1;
} else if (BOLD.equals(fontWeightString)) {
fontWeight = Typeface.BOLD;
} else if (NORMAL.equals(fontWeightString)) {
fontWeight = Typeface.NORMAL;
} else {
int fontWeightNumeric = parseNumericFontWeight(fontWeightString);
if (fontWeightNumeric == -1) {
throw new RuntimeException("invalid font weight " + fontWeightString);
}
fontWeight = fontWeightNumeric >= 500 ? Typeface.BOLD : Typeface.NORMAL;
}
if (mFontStylingSpan.getFontWeight() != fontWeight) {
getSpan().setFontWeight(fontWeight);
notifyChanged(true);
}
}
示例6: 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;
}
示例7: apply
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);
}
示例8: applyCustomTypeFace
private 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);
}
示例9: getFontWeight
public static int getFontWeight(Map<String, Object> style) {
int typeface = android.graphics.Typeface.NORMAL;
if (style != null) {
Object temp = style.get(Constants.Name.FONT_WEIGHT);
if (temp != null) {
String fontWeight = temp.toString();
switch (fontWeight){
case "600":
case "700":
case "800":
case "900":
case Constants.Value.BOLD:
typeface=Typeface.BOLD;
break;
}
}
}
return typeface;
}
示例10: setText
public void setText(Recipients recipients, boolean read) {
int attributes[] = new int[]{R.attr.conversation_list_item_count_color};
TypedArray colors = getContext().obtainStyledAttributes(attributes);
String fromString = recipients.toShortString();
int typeface;
if (!read) {
typeface = Typeface.BOLD;
} else {
typeface = Typeface.NORMAL;
}
SpannableStringBuilder builder = new SpannableStringBuilder(fromString);
builder.setSpan(new StyleSpan(typeface), 0, builder.length(),
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
colors.recycle();
setText(builder);
if (recipients.isBlocked()) setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_block_grey600_18dp, 0, 0, 0);
else if (recipients.isMuted()) setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_volume_off_grey600_18dp, 0, 0, 0);
else setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
}
示例11: apply
private void apply(TextPaint paint) {
int oldStyle;
Typeface old = paint.getTypeface();
if (old == null) {
oldStyle = 0;
} else {
oldStyle = old.getStyle();
}
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);
}
示例12: applyFontStyle
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));
}
}
示例13: 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");
}
}
示例14: 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");
}
}
示例15: getName
public static String getName(int type) {
switch (type) {
case Typeface.ITALIC:
return STYLE_ITALIC;
case Typeface.BOLD:
return STYLE_BOLD;
default:
return STYLE_NORMAL;
}
}