Java Code Examples for android.graphics.Typeface#MONOSPACE
The following examples show how to use
android.graphics.Typeface#MONOSPACE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Switch.java From MCPELauncher with Apache License 2.0 | 6 votes |
private void setSwitchTypefaceByIndex(int typefaceIndex, int styleIndex) { Typeface tf = null; switch (typefaceIndex) { case SANS: tf = Typeface.SANS_SERIF; break; case SERIF: tf = Typeface.SERIF; break; case MONOSPACE: tf = Typeface.MONOSPACE; break; } setSwitchTypeface(tf, styleIndex); }
Example 2
Source File: Switch.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void setSwitchTypefaceByIndex(int typefaceIndex, int styleIndex) { Typeface tf = null; switch (typefaceIndex) { case SANS: tf = Typeface.SANS_SERIF; break; case SERIF: tf = Typeface.SERIF; break; case MONOSPACE: tf = Typeface.MONOSPACE; break; } setSwitchTypeface(tf, styleIndex); }
Example 3
Source File: IndicatorSeekBar.java From IndicatorSeekBar with Apache License 2.0 | 6 votes |
/** * initial both the tick texts' and thumb text's typeface,just has 4 type to choose, * but you can set the CUSTOM typeface you want by java code. * <p> * usage like: * indicatorSeekbar.customTickTextsTypeface(Typeface.xxx); */ private void initTextsTypeface(int typeface, Typeface defaultTypeface) { switch (typeface) { case 0: mTextsTypeface = Typeface.DEFAULT; break; case 1: mTextsTypeface = Typeface.MONOSPACE; break; case 2: mTextsTypeface = Typeface.SANS_SERIF; break; case 3: mTextsTypeface = Typeface.SERIF; break; default: if (defaultTypeface == null) { mTextsTypeface = Typeface.DEFAULT; break; } mTextsTypeface = defaultTypeface; break; } }
Example 4
Source File: Switch.java From PreferenceFragment with Apache License 2.0 | 6 votes |
private void setSwitchTypefaceByIndex(int typefaceIndex, int styleIndex) { Typeface tf = null; switch (typefaceIndex) { case SANS: tf = Typeface.SANS_SERIF; break; case SERIF: tf = Typeface.SERIF; break; case MONOSPACE: tf = Typeface.MONOSPACE; break; } setSwitchTypeface(tf, styleIndex); }
Example 5
Source File: PCanvas.java From PHONK with GNU General Public License v3.0 | 6 votes |
public void typeface(String type) { Typeface selectedType; switch (type) { case "monospace": selectedType = Typeface.MONOSPACE; break; case "sans": selectedType = Typeface.SANS_SERIF; break; case "serif": selectedType = Typeface.SERIF; break; default: selectedType = Typeface.DEFAULT; } mPaintFill.setTypeface(selectedType); }
Example 6
Source File: AccentSwitch.java From holoaccent with Apache License 2.0 | 6 votes |
private void setSwitchTypefaceByIndex(int typefaceIndex, int styleIndex) { Typeface tf = null; switch (typefaceIndex) { case SANS: tf = Typeface.SANS_SERIF; break; case SERIF: tf = Typeface.SERIF; break; case MONOSPACE: tf = Typeface.MONOSPACE; break; } setSwitchTypeface(tf, styleIndex); }
Example 7
Source File: TypefaceUtils.java From openboard with GNU General Public License v3.0 | 5 votes |
private static int getCharGeometryCacheKey(final char referenceChar, final Paint paint) { final int labelSize = (int)paint.getTextSize(); final Typeface face = paint.getTypeface(); final int codePointOffset = referenceChar << 15; if (face == Typeface.DEFAULT) { return codePointOffset + labelSize; } else if (face == Typeface.DEFAULT_BOLD) { return codePointOffset + labelSize + 0x1000; } else if (face == Typeface.MONOSPACE) { return codePointOffset + labelSize + 0x2000; } else { return codePointOffset + labelSize; } }
Example 8
Source File: Key.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
@Nonnull public final Typeface selectTypeface(final KeyDrawParams params) { switch (mLabelFlags & LABEL_FLAGS_FONT_MASK) { case LABEL_FLAGS_FONT_NORMAL: return Typeface.DEFAULT; case LABEL_FLAGS_FONT_MONO_SPACE: return Typeface.MONOSPACE; case LABEL_FLAGS_FONT_DEFAULT: default: // The type-face is specified by keyTypeface attribute. return params.mTypeface; } }
Example 9
Source File: TextStyleSpan.java From Telegram with GNU General Public License v2.0 | 5 votes |
public Typeface getTypeface() { if ((flags & FLAG_STYLE_MONO) != 0 || (flags & FLAG_STYLE_QUOTE) != 0) { return Typeface.MONOSPACE; } else if ((flags & FLAG_STYLE_BOLD) != 0 && (flags & FLAG_STYLE_ITALIC) != 0) { return AndroidUtilities.getTypeface("fonts/rmediumitalic.ttf"); } else if ((flags & FLAG_STYLE_BOLD) != 0) { return AndroidUtilities.getTypeface("fonts/rmedium.ttf"); } else if ((flags & FLAG_STYLE_ITALIC) != 0) { return AndroidUtilities.getTypeface("fonts/ritalic.ttf"); } else { return null; } }
Example 10
Source File: PromptUtils.java From styT with Apache License 2.0 | 5 votes |
/** * Based on setTypefaceFromAttrs in android TextView, Copyright (C) 2006 The Android Open * Source Project. https://android.googlesource.com/platform/frameworks/base.git/+/master/core/java/android/widget/TextView.java */ @NonNull public static Typeface setTypefaceFromAttrs(@Nullable String familyName, int typefaceIndex, int styleIndex) { Typeface tf = null; if (familyName != null) { tf = Typeface.create(familyName, styleIndex); if (tf != null) { return tf; } } switch (typefaceIndex) { case 1: tf = Typeface.SANS_SERIF; break; case 2: tf = Typeface.SERIF; break; case 3: tf = Typeface.MONOSPACE; break; } return Typeface.create(tf, styleIndex); }
Example 11
Source File: PromptUtils.java From MaterialTapTargetPrompt with Apache License 2.0 | 5 votes |
/** * Based on setTypefaceFromAttrs in android TextView, Copyright (C) 2006 The Android Open * Source Project. https://android.googlesource.com/platform/frameworks/base.git/+/master/core/java/android/widget/TextView.java */ @NonNull public static Typeface setTypefaceFromAttrs(@Nullable String familyName, int typefaceIndex, int styleIndex) { Typeface tf = null; if (familyName != null) { tf = Typeface.create(familyName, styleIndex); if (tf != null) { return tf; } } switch (typefaceIndex) { case 1: tf = Typeface.SANS_SERIF; break; case 2: tf = Typeface.SERIF; break; case 3: tf = Typeface.MONOSPACE; break; } return Typeface.create(tf, styleIndex); }
Example 12
Source File: Key.java From simple-keyboard with Apache License 2.0 | 5 votes |
public final Typeface selectTypeface(final KeyDrawParams params) { switch (mLabelFlags & LABEL_FLAGS_FONT_MASK) { case LABEL_FLAGS_FONT_NORMAL: return Typeface.DEFAULT; case LABEL_FLAGS_FONT_MONO_SPACE: return Typeface.MONOSPACE; case LABEL_FLAGS_FONT_DEFAULT: default: // The type-face is specified by keyTypeface attribute. return params.mTypeface; } }
Example 13
Source File: TypefaceUtils.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
private static int getCharGeometryCacheKey(final char referenceChar, final Paint paint) { final int labelSize = (int)paint.getTextSize(); final Typeface face = paint.getTypeface(); final int codePointOffset = referenceChar << 15; if (face == Typeface.DEFAULT) { return codePointOffset + labelSize; } else if (face == Typeface.DEFAULT_BOLD) { return codePointOffset + labelSize + 0x1000; } else if (face == Typeface.MONOSPACE) { return codePointOffset + labelSize + 0x2000; } else { return codePointOffset + labelSize; } }
Example 14
Source File: Key.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
@Nonnull public final Typeface selectTypeface(final KeyDrawParams params) { switch (mLabelFlags & LABEL_FLAGS_FONT_MASK) { case LABEL_FLAGS_FONT_NORMAL: return Typeface.DEFAULT; case LABEL_FLAGS_FONT_MONO_SPACE: return Typeface.MONOSPACE; case LABEL_FLAGS_FONT_DEFAULT: default: // The type-face is specified by keyTypeface attribute. return params.mTypeface; } }
Example 15
Source File: TextDrawable.java From CryptoBuddy with GNU Affero General Public License v3.0 | 4 votes |
public TextDrawable(Context context) { super(); //Used to load and scale resource items mResources = context.getResources(); //Definition of this drawables size mTextBounds = new Rect(); //Paint to use for the text mTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); mTextPaint.density = mResources.getDisplayMetrics().density; mTextPaint.setDither(true); int textSize = 15; ColorStateList textColor = null; int styleIndex = -1; int typefaceIndex = -1; //Set default parameters from the current theme TypedArray a = context.getTheme().obtainStyledAttributes(themeAttributes); int appearanceId = a.getResourceId(0, -1); a.recycle(); TypedArray ap = null; if (appearanceId != -1) { ap = context.obtainStyledAttributes(appearanceId, appearanceAttributes); } if (ap != null) { for (int i=0; i < ap.getIndexCount(); i++) { int attr = ap.getIndex(i); switch (attr) { case 0: //Text Size textSize = a.getDimensionPixelSize(attr, textSize); break; case 1: //Typeface typefaceIndex = a.getInt(attr, typefaceIndex); break; case 2: //Text Style styleIndex = a.getInt(attr, styleIndex); break; case 3: //Text Color textColor = a.getColorStateList(attr); break; default: break; } } ap.recycle(); } setTextColor(textColor != null ? textColor : ColorStateList.valueOf(0xFF000000)); setRawTextSize(textSize); Typeface tf = null; switch (typefaceIndex) { case SANS: tf = Typeface.SANS_SERIF; break; case SERIF: tf = Typeface.SERIF; break; case MONOSPACE: tf = Typeface.MONOSPACE; break; } setTypeface(tf, styleIndex); }
Example 16
Source File: CodeSpan.java From mimi-reader with Apache License 2.0 | 4 votes |
public CodeSpan() { super("regular"); this.newType = Typeface.MONOSPACE; }
Example 17
Source File: Font.java From J2ME-Loader with Apache License 2.0 | 4 votes |
public static Font getFont(int face, int style, int size) { int index = getFontIndex(face, style, size); if (fonts[index] == null) { Typeface typeface; int tfstyle = Typeface.NORMAL; boolean underline; float fsize; switch (face) { case FACE_MONOSPACE: typeface = Typeface.MONOSPACE; break; case FACE_PROPORTIONAL: typeface = Typeface.SANS_SERIF; break; default: case FACE_SYSTEM: typeface = Typeface.DEFAULT; break; } if ((style & STYLE_BOLD) != 0) { tfstyle |= Typeface.BOLD; } if ((style & STYLE_ITALIC) != 0) { tfstyle |= Typeface.ITALIC; } underline = (style & STYLE_UNDERLINED) != 0; switch (size) { case SIZE_SMALL: fsize = sizes[0]; break; default: case SIZE_MEDIUM: fsize = sizes[1]; break; case SIZE_LARGE: fsize = sizes[2]; break; } fonts[index] = new Font(typeface, tfstyle, fsize, underline); fonts[index].face = face; fonts[index].style = style; fonts[index].size = size; } return fonts[index]; }
Example 18
Source File: TypefaceSpan.java From Telegram with GNU General Public License v2.0 | 4 votes |
public boolean isMono() { return typeface == Typeface.MONOSPACE; }
Example 19
Source File: RadioRealButton.java From RadioRealButton with Apache License 2.0 | 4 votes |
/*** * GET ATTRIBUTES FROM XML */ private void getAttributes(AttributeSet attrs) { TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.RadioRealButton); drawable = ta.getResourceId(R.styleable.RadioRealButton_rrb_drawable, -1); drawableTint = ta.getColor(R.styleable.RadioRealButton_rrb_drawableTint, 0); drawableTintTo = ta.getColor(R.styleable.RadioRealButton_rrb_drawableTintTo, 0); drawableWidth = ta.getDimensionPixelSize(R.styleable.RadioRealButton_rrb_drawableWidth, -1); drawableHeight = ta.getDimensionPixelSize(R.styleable.RadioRealButton_rrb_drawableHeight, -1); hasDrawable = ta.hasValue(R.styleable.RadioRealButton_rrb_drawable); hasDrawableTint = ta.hasValue(R.styleable.RadioRealButton_rrb_drawableTint); hasDrawableTintTo = ta.hasValue(R.styleable.RadioRealButton_rrb_drawableTintTo); hasDrawableWidth = ta.hasValue(R.styleable.RadioRealButton_rrb_drawableWidth); hasDrawableHeight = ta.hasValue(R.styleable.RadioRealButton_rrb_drawableHeight); text = ta.getString(R.styleable.RadioRealButton_rrb_text); hasText = ta.hasValue(R.styleable.RadioRealButton_rrb_text); textColor = ta.getColor(R.styleable.RadioRealButton_rrb_textColor, Color.BLACK); textColorTo = ta.getColor(R.styleable.RadioRealButton_rrb_textColorTo, Color.BLACK); hasTextColor = ta.hasValue(R.styleable.RadioRealButton_rrb_textColor); hasTextColorTo = ta.hasValue(R.styleable.RadioRealButton_rrb_textColorTo); textSize = ta.getDimensionPixelSize(R.styleable.RadioRealButton_rrb_textSize, -1); hasTextSize = ta.hasValue(R.styleable.RadioRealButton_rrb_textSize); textStyle = ta.getInt(R.styleable.RadioRealButton_rrb_textStyle, -1); hasTextStyle = ta.hasValue(R.styleable.RadioRealButton_rrb_textStyle); int typeface = ta.getInt(R.styleable.RadioRealButton_rrb_textTypeface, -1); switch (typeface) { case 0: textTypeface = Typeface.MONOSPACE; break; case 1: textTypeface = Typeface.DEFAULT; break; case 2: textTypeface = Typeface.SANS_SERIF; break; case 3: textTypeface = Typeface.SERIF; break; } textTypefacePath = ta.getString(R.styleable.RadioRealButton_rrb_textTypefacePath); hasTextTypefacePath = ta.hasValue(R.styleable.RadioRealButton_rrb_textTypefacePath); hasRipple = ta.getBoolean(R.styleable.RadioRealButton_rrb_ripple, true); rippleColor = ta.getColor(R.styleable.RadioRealButton_rrb_rippleColor, Color.GRAY); hasRippleColor = ta.hasValue(R.styleable.RadioRealButton_rrb_rippleColor); backgroundColor = ta.getColor(R.styleable.RadioRealButton_rrb_backgroundColor, Color.TRANSPARENT); int defaultPadding = ConversionHelper.dpToPx(getContext(), 10); padding = ta.getDimensionPixelSize(R.styleable.RadioRealButton_android_padding, defaultPadding); paddingLeft = ta.getDimensionPixelSize(R.styleable.RadioRealButton_android_paddingLeft, 0); paddingRight = ta.getDimensionPixelSize(R.styleable.RadioRealButton_android_paddingRight, 0); paddingTop = ta.getDimensionPixelSize(R.styleable.RadioRealButton_android_paddingTop, 0); paddingBottom = ta.getDimensionPixelSize(R.styleable.RadioRealButton_android_paddingBottom, 0); hasPaddingLeft = ta.hasValue(R.styleable.RadioRealButton_android_paddingLeft); hasPaddingRight = ta.hasValue(R.styleable.RadioRealButton_android_paddingRight); hasPaddingTop = ta.hasValue(R.styleable.RadioRealButton_android_paddingTop); hasPaddingBottom = ta.hasValue(R.styleable.RadioRealButton_android_paddingBottom); drawablePadding = ta.getDimensionPixelSize(R.styleable.RadioRealButton_rrb_drawablePadding, 4); drawableGravity = DrawableGravity.getById(ta.getInteger(R.styleable.RadioRealButton_rrb_drawableGravity, 0)); checked = ta.getBoolean(R.styleable.RadioRealButton_rrb_checked, false); enabled = ta.getBoolean(R.styleable.RadioRealButton_android_enabled, true); hasEnabled = ta.hasValue(R.styleable.RadioRealButton_android_enabled); clickable = ta.getBoolean(R.styleable.RadioRealButton_android_clickable, true); hasClickable = ta.hasValue(R.styleable.RadioRealButton_android_clickable); textGravity = ta.getInt(R.styleable.RadioRealButton_rrb_textGravity, Gravity.NO_GRAVITY); textFillSpace = ta.getBoolean(R.styleable.RadioRealButton_rrb_textFillSpace, false); selectorColor = ta.getColor(R.styleable.RadioRealButton_rrb_selectorColor, Color.TRANSPARENT); hasSelectorColor = ta.hasValue(R.styleable.RadioRealButton_rrb_selectorColor); ta.recycle(); }
Example 20
Source File: TypefaceSpan.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public boolean isMono() { return typeface == Typeface.MONOSPACE; }