当前位置: 首页>>代码示例>>Java>>正文


Java Typeface.NORMAL属性代码示例

本文整理汇总了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);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:23,代码来源:ReactTextInputManager.java

示例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);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:21,代码来源:ReactTextInputManager.java

示例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);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:RCTVirtualText.java

示例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);
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:22,代码来源:RCTVirtualText.java

示例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();
        }
    }
 
开发者ID:AppHero2,项目名称:Raffler-Android,代码行数:22,代码来源:AEditText.java

示例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();
        }
    }
 
开发者ID:AppHero2,项目名称:Raffler-Android,代码行数:26,代码来源:ATextView.java

示例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);
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:TypefaceHelper.java

示例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;
}
 
开发者ID:shazam,项目名称:reflow-animator,代码行数:11,代码来源:AdvancedSampleActivity.java

示例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;
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:12,代码来源:UDFontStyle.java

示例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");
    }
}
 
开发者ID:kevalpatel2106,项目名称:smart-lens,代码行数:18,代码来源:BaseButton.java

示例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();
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:17,代码来源:ReactTextShadowNode.java

示例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));
      }
    }
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:42,代码来源:ARTTextShadowNode.java

示例13: getFontStyle

/**
 * Returns font style for this node.
 */
protected final int getFontStyle() {
  int style = mFontStylingSpan.getFontStyle();
  return style >= 0 ? style : Typeface.NORMAL;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:7,代码来源:RCTVirtualText.java

示例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);
            }
        }
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:57,代码来源:UDSpannableString.java

示例15: jlmText_macro

public static final Atom jlmText_macro(final TeXParser tp,
		final String[] args) throws ParseException {
	return new JavaFontRenderingAtom(args[1], Typeface.NORMAL);
}
 
开发者ID:daquexian,项目名称:FlexibleRichTextView,代码行数:4,代码来源:PredefMacros.java


注:本文中的android.graphics.Typeface.NORMAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。