本文整理匯總了Java中android.graphics.Typeface.NORMAL屬性的典型用法代碼示例。如果您正苦於以下問題:Java Typeface.NORMAL屬性的具體用法?Java Typeface.NORMAL怎麽用?Java Typeface.NORMAL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.graphics.Typeface
的用法示例。
在下文中一共展示了Typeface.NORMAL屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setFontWeight
/**
/* This code was taken from the method setFontWeight of the class ReactTextShadowNode
/* TODO: Factor into a common place they can both use
*/
@ReactProp(name = ViewProps.FONT_WEIGHT)
public void setFontWeight(ReactEditText view, @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;
}
Typeface currentTypeface = view.getTypeface();
if (currentTypeface == null) {
currentTypeface = Typeface.DEFAULT;
}
if (fontWeight != currentTypeface.getStyle()) {
view.setTypeface(currentTypeface, fontWeight);
}
}
示例2: setFontStyle
/**
/* This code was taken from the method setFontStyle of the class ReactTextShadowNode
/* TODO: Factor into a common place they can both use
*/
@ReactProp(name = ViewProps.FONT_STYLE)
public void setFontStyle(ReactEditText view, @Nullable String fontStyleString) {
int fontStyle = UNSET;
if ("italic".equals(fontStyleString)) {
fontStyle = Typeface.ITALIC;
} else if ("normal".equals(fontStyleString)) {
fontStyle = Typeface.NORMAL;
}
Typeface currentTypeface = view.getTypeface();
if (currentTypeface == null) {
currentTypeface = Typeface.DEFAULT;
}
if (fontStyle != currentTypeface.getStyle()) {
view.setTypeface(currentTypeface, fontStyle);
}
}
示例3: setFontStyle
@ReactProp(name = ViewProps.FONT_STYLE)
public void setFontStyle(@Nullable String fontStyleString) {
final int fontStyle;
if (fontStyleString == null) {
fontStyle = -1;
} else if (ITALIC.equals(fontStyleString)) {
fontStyle = Typeface.ITALIC;
} else if (NORMAL.equals(fontStyleString)) {
fontStyle = Typeface.NORMAL;
} else {
throw new RuntimeException("invalid font style " + fontStyleString);
}
if (mFontStylingSpan.getFontStyle() != fontStyle) {
getSpan().setFontStyle(fontStyle);
notifyChanged(true);
}
}
示例4: 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);
}
}
示例5: setTextStyle
public void setTextStyle(int style) {
String font;
switch (style) {
case Typeface.BOLD:
font = Stylish.FONT_BOLD;
break;
case Typeface.ITALIC:
font = Stylish.FONT_ITALIC;
break;
case Typeface.NORMAL:
font = Stylish.FONT_REGULAR;
break;
default:
font = Stylish.FONT_REGULAR;
}
try {
setTypeface(Stylish.getInstance().getTypeface(getContext(), font, getTypeface()));
} catch (Exception e) {
// e.printStackTrace();
}
}
示例6: setTextStyle
public void setTextStyle(int style) {
if(isInEditMode())
return;
String font;
switch (style) {
case Typeface.BOLD:
font = Stylish.FONT_BOLD;
break;
case Typeface.ITALIC:
font = Stylish.FONT_ITALIC;
break;
case Typeface.NORMAL:
font = Stylish.FONT_REGULAR;
break;
default:
font = Stylish.FONT_REGULAR;
}
try {
setTypeface(Stylish.getInstance().getTypeface(getContext(), font, getTypeface()));
} catch (Exception e) {
// e.printStackTrace();
}
}
示例7: applyForView
/**
* Apply typeface to single view
*
* @param view to typeface typeface
* @param typefaceCollection typeface collection
*/
private static void applyForView(View view, TypefaceCollection typefaceCollection) {
if (view instanceof TextView) {
TextView textView = (TextView) view;
Typeface oldTypeface = textView.getTypeface();
final int style = oldTypeface == null ? Typeface.NORMAL : oldTypeface.getStyle();
textView.setTypeface(typefaceCollection.getTypeface(style));
textView.setPaintFlags(textView.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
}
}
示例8: 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;
}
示例9: getValue
public static int getValue(final String name) {
if (!TextUtils.isEmpty(name)) {
if (STYLE_NORMAL.equalsIgnoreCase(name)) {
return Typeface.NORMAL;
} else if (STYLE_BOLD.equalsIgnoreCase(name)) {
return Typeface.BOLD;
} else if (STYLE_ITALIC.equalsIgnoreCase(name)) {
return Typeface.ITALIC;
}
}
return Typeface.NORMAL;
}
示例10: 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");
}
}
示例11: setFontStyle
/**
/* This code is duplicated in ReactTextInputManager
/* TODO: Factor into a common place they can both use
*/
@ReactProp(name = ViewProps.FONT_STYLE)
public void setFontStyle(@Nullable String fontStyleString) {
int fontStyle = UNSET;
if ("italic".equals(fontStyleString)) {
fontStyle = Typeface.ITALIC;
} else if ("normal".equals(fontStyleString)) {
fontStyle = Typeface.NORMAL;
}
if (fontStyle != mFontStyle) {
mFontStyle = fontStyle;
markUpdated();
}
}
示例12: applyTextPropertiesToPaint
private void applyTextPropertiesToPaint(Paint paint) {
int alignment = mTextAlignment;
switch (alignment) {
case TEXT_ALIGNMENT_LEFT:
paint.setTextAlign(Paint.Align.LEFT);
break;
case TEXT_ALIGNMENT_RIGHT:
paint.setTextAlign(Paint.Align.RIGHT);
break;
case TEXT_ALIGNMENT_CENTER:
paint.setTextAlign(Paint.Align.CENTER);
break;
}
if (mFrame != null) {
if (mFrame.hasKey(PROP_FONT)) {
ReadableMap font = mFrame.getMap(PROP_FONT);
if (font != null) {
float fontSize = DEFAULT_FONT_SIZE;
if (font.hasKey(PROP_FONT_SIZE)) {
fontSize = (float) font.getDouble(PROP_FONT_SIZE);
}
paint.setTextSize(fontSize * mScale);
boolean isBold =
font.hasKey(PROP_FONT_WEIGHT) && "bold".equals(font.getString(PROP_FONT_WEIGHT));
boolean isItalic =
font.hasKey(PROP_FONT_STYLE) && "italic".equals(font.getString(PROP_FONT_STYLE));
int fontStyle;
if (isBold && isItalic) {
fontStyle = Typeface.BOLD_ITALIC;
} else if (isBold) {
fontStyle = Typeface.BOLD;
} else if (isItalic) {
fontStyle = Typeface.ITALIC;
} else {
fontStyle = Typeface.NORMAL;
}
// NB: if the font family is null / unsupported, the default one will be used
paint.setTypeface(Typeface.create(font.getString(PROP_FONT_FAMILY), fontStyle));
}
}
}
}
示例13: getFontStyle
/**
* Returns font style for this node.
*/
protected final int getFontStyle() {
int style = mFontStylingSpan.getFontStyle();
return style >= 0 ? style : Typeface.NORMAL;
}
示例14: 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);
}
}
}
}
示例15: jlmText_macro
public static final Atom jlmText_macro(final TeXParser tp,
final String[] args) throws ParseException {
return new JavaFontRenderingAtom(args[1], Typeface.NORMAL);
}