當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。