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


Java Typeface.ITALIC属性代码示例

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

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

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

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

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

示例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));
  }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:30,代码来源:TypefaceUtil.java

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

示例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);
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:39,代码来源:TextFormatBar.java

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

示例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);
}
 
开发者ID:takahirom,项目名称:DownloadableCalligraphy,代码行数:15,代码来源:CalligraphyTypefaceSpan.java

示例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;
    }
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:7,代码来源:DialogsAdapter.java

示例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;
}
 
开发者ID:olgamiller,项目名称:SSTVEncoder2,代码行数:13,代码来源:LabelPainter.java

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

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

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


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