本文整理汇总了Java中android.graphics.Typeface.ITALIC属性的典型用法代码示例。如果您正苦于以下问题:Java Typeface.ITALIC属性的具体用法?Java Typeface.ITALIC怎么用?Java Typeface.ITALIC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.graphics.Typeface
的用法示例。
在下文中一共展示了Typeface.ITALIC属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: setItalic
void setItalic(boolean isItalic, int index) {
if (index >= 0 && index < mSections.size()) {
mSections.get(index).setItalic(isItalic);
}
Editable edit = getEditableText();
int star = getSectionStart();
int end = getSectionEnd();
if (isItalic) {
edit.setSpan(new StyleSpan(Typeface.ITALIC),
star,
end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
StyleSpan[] styleSpans = edit.getSpans(star,
end, StyleSpan.class);
for (CharacterStyle span : styleSpans) {
if (span instanceof StyleSpan && ((StyleSpan) span).getStyle() == Typeface.ITALIC)
edit.removeSpan(span);
}
}
}
示例4: 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);
}
}
示例5: 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();
}
}
示例6: 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));
}
}
示例7: 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");
}
}
示例8: updateFormattingAtCursor
public void updateFormattingAtCursor() {
if (mEditText == null)
return;
Editable text = mEditText.getText();
int start = mEditText.getSelectionStart();
int end = mEditText.getSelectionEnd();
Object[] spans = text.getSpans(start, end, Object.class);
mBoldButton.setSelected(false);
mItalicButton.setSelected(false);
mUnderlineButton.setSelected(false);
int fgColor = -1;
int bgColor = -1;
for (Object span : spans) {
if (!SpannableStringHelper.checkSpanInclude(text, span, start, end) ||
(text.getSpanFlags(span) & Spanned.SPAN_COMPOSING) != 0)
continue;
if (span instanceof StyleSpan) {
int style = ((StyleSpan) span).getStyle();
if (style == Typeface.BOLD)
mBoldButton.setSelected(true);
else if (style == Typeface.ITALIC)
mItalicButton.setSelected(true);
} else if (span instanceof UnderlineSpan) {
mUnderlineButton.setSelected(true);
} else if (span instanceof ForegroundColorSpan) {
fgColor = ((ForegroundColorSpan) span).getForegroundColor();
} else if (span instanceof BackgroundColorSpan) {
bgColor = ((BackgroundColorSpan) span).getBackgroundColor();
}
}
ImageViewCompat.setImageTintList(mTextColorValue, fgColor != -1
? ColorStateList.valueOf(fgColor) : mTextColorValueDefault);
ImageViewCompat.setImageTintList(mFillColorValue, bgColor != -1
? ColorStateList.valueOf(bgColor) : mFillColorValueDefault);
}
示例9: apply
private static void apply(
Paint paint,
int style,
int weight,
@Nullable String family,
AssetManager assetManager) {
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 == ReactTextShadowNode.UNSET)) {
want |= Typeface.BOLD;
}
if ((style == Typeface.ITALIC) ||
((oldStyle & Typeface.ITALIC) != 0 && style == ReactTextShadowNode.UNSET)) {
want |= Typeface.ITALIC;
}
if (family != null) {
typeface = ReactFontManager.getInstance().getTypeface(family, want, assetManager);
} else if (typeface != null) {
// TODO(t9055065): Fix custom fonts getting applied to text children with different style
typeface = Typeface.create(typeface, want);
}
if (typeface != null) {
paint.setTypeface(typeface);
} else {
paint.setTypeface(Typeface.defaultFromStyle(want));
}
}
示例10: apply
private void apply(final Paint paint) {
final Typeface oldTypeface = paint.getTypeface();
final int oldStyle = oldTypeface != null ? oldTypeface.getStyle() : 0;
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);
}
示例11: 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;
}
}
示例12: 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;
}
示例13: 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;
}
}
示例14: 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();
}
示例15: 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");
}
}