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


Java Typeface.MONOSPACE属性代码示例

本文整理汇总了Java中android.graphics.Typeface.MONOSPACE属性的典型用法代码示例。如果您正苦于以下问题:Java Typeface.MONOSPACE属性的具体用法?Java Typeface.MONOSPACE怎么用?Java Typeface.MONOSPACE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.graphics.Typeface的用法示例。


在下文中一共展示了Typeface.MONOSPACE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ensureTypeface

/**
 * Ensures that the typeface is initialized (if possible).
 */
private void ensureTypeface() {
	if (mTypeface == null || mInvalidateTypeface) {
		this.mInvalidateTypeface = false;
		if (!TextUtils.isEmpty(mFontFamily)) {
			this.mTypeface = Typeface.create(mFontFamily, mTextStyle);
		} else {
			switch (mTypefaceIndex) {
				case SANS_SERIF:
					this.mTypeface = Typeface.SANS_SERIF;
					break;
				case SERIF:
					this.mTypeface = Typeface.SERIF;
					break;
				case MONOSPACE:
					this.mTypeface = Typeface.MONOSPACE;
					break;
			}
		}
	}
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:23,代码来源:TextAppearance.java

示例2: getTypeface

private Typeface getTypeface() {
    String textTypeface = PreferenceManager.getDefaultSharedPreferences(getBaseContext()).getString("textTypeface", "1");

    switch (Integer.parseInt(textTypeface)) {
        default:
            return Typeface.DEFAULT;
        case 2:
            return Typeface.DEFAULT_BOLD;
        case 3:
            return Typeface.MONOSPACE;
        case 4:
            return Typeface.SANS_SERIF;
        case 5:
            return Typeface.SERIF;
    }
}
 
开发者ID:jajasuperman,项目名称:HexColorTime,代码行数:16,代码来源:Wallpaper.java

示例3: getFontFromAsset

public synchronized static Typeface getFontFromAsset(Context context, String name) {
    try {
        if (name.equalsIgnoreCase(context.getString(R.string.font_consolas))) {
            return get(context, PATH_TO_FONT + "consolas.ttf");
        } else if (name.equalsIgnoreCase(context.getString(R.string.font_courier_new))) {
            return get(context, PATH_TO_FONT + "courier_new.ttf");
        } else if (name.equalsIgnoreCase(context.getString(R.string.font_lucida_sans_typewriter))) {
            return get(context, PATH_TO_FONT + "lucida_sans_typewriter_regular.ttf");
        } else if (name.equalsIgnoreCase(context.getString(R.string.font_monospace))) {
            return Typeface.MONOSPACE;
        } else if (name.equalsIgnoreCase(context.getString(R.string.font_source_code_pro))) {
            return get(context, PATH_TO_FONT + "source_code_pro.ttf");
        } else {
            return get(context, PATH_TO_FONT + name);
        }
    } catch (Exception e) {

    }
    return Typeface.MONOSPACE;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:20,代码来源:FontManager.java

示例4: getChatFont

public Typeface getChatFont() {
    if (mCachedFont != null)
        return mCachedFont;
    String font = mPreferences.getString(PREF_CHAT_FONT, "default");
    if (ListWithCustomSetting.isPrefCustomValue(font)) {
        File file = ListWithCustomSetting.getCustomFile(mContext, PREF_CHAT_FONT, font);
        try {
            mCachedFont = Typeface.createFromFile(file);
            return mCachedFont;
        } catch (Exception ignored) {
        }
    }
    if (font.equals("monospace"))
        return Typeface.MONOSPACE;
    else if (font.equals("serif"))
        return Typeface.SERIF;
    else
        return Typeface.DEFAULT;
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:19,代码来源:SettingsHelper.java

示例5: getFontFamily

private FontFamily getFontFamily(String fontKey, String defaultVal) {

        String fontFace = settings.getString(fontKey, defaultVal);

        if (!fontCache.containsKey(fontFace)) {

            // TODO add font
            if ("gen_book_bas".equals(fontFace)) {
                fontCache.put(fontFace,
                        loadFamilyFromAssets(fontFace, "GentiumBookBasic"));
            } else {

                Typeface face = Typeface.SANS_SERIF;
                if ("sans".equals(fontFace)) {
                    face = Typeface.SANS_SERIF;
                } else if ("serif".equals(fontFace)) {
                    face = Typeface.SERIF;
                } else if ("mono".equals(fontFace)) {
                    face = Typeface.MONOSPACE;
                } else if ("default".equals(fontFace)) {
                    face = Typeface.DEFAULT;
                }

                fontCache.put(fontFace, new FontFamily(fontFace, face));
            }
        }

        return fontCache.get(fontFace);
    }
 
开发者ID:ceji-longquan,项目名称:ceji_android,代码行数:29,代码来源:Configuration.java

示例6: getCharGeometryCacheKey

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;
    }
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:14,代码来源:TypefaceUtils.java

示例7: selectTypeface

@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;
    }
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:13,代码来源:Key.java

示例8: setSwitchTypefaceByIndex

private void setSwitchTypefaceByIndex(int typefaceIndex, int styleIndex) {
    Typeface tf = null;
    switch (typefaceIndex) {
        case 1:
            tf = Typeface.SANS_SERIF;
            break;
        case 2:
            tf = Typeface.SERIF;
            break;
        case 3:
            tf = Typeface.MONOSPACE;
            break;
    }
    setSwitchTypeface(tf, styleIndex);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:SwitchCompat.java

示例9: setFontTypeface

/**
 * Sets the font typeface for a {@link TextView}.
 *
 * @param textview   text view instance
 * @param typeface  one of @link Component#TYPEFACE_DEFAULT},
 *                  {@link Component#TYPEFACE_SERIF},
 *                  {@link Component#TYPEFACE_SANSSERIF} or
 *                  {@link Component#TYPEFACE_MONOSPACE}
 * @param bold true for bold, false for not bold
 * @param italic true for italic, false for not italic
 */
public static void setFontTypeface(TextView textview, int typeface,
    boolean bold, boolean italic) {
  Typeface tf;
  switch (typeface) {
    default:
      throw new IllegalArgumentException();

    case Component.TYPEFACE_DEFAULT:
      tf = Typeface.DEFAULT;
      break;

    case Component.TYPEFACE_SERIF:
      tf = Typeface.SERIF;
      break;

    case Component.TYPEFACE_SANSSERIF:
      tf = Typeface.SANS_SERIF;
      break;

    case Component.TYPEFACE_MONOSPACE:
      tf = Typeface.MONOSPACE;
      break;
  }

  int style = 0;
  if (bold) {
    style |= Typeface.BOLD;
  }
  if (italic) {
    style |= Typeface.ITALIC;
  }
  textview.setTypeface(Typeface.create(tf, style));
  textview.requestLayout();
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:45,代码来源:TextViewUtil.java

示例10: initConfig

private void initConfig()
{
	SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

	showBottomBarFlag = sharedPreferences.getBoolean(getString(R.string.prefShowButtonsKey), true);

	fontSize = sharedPreferences.getFloat(getString(R.string.prefFontSizeKey), fontSize);

	filepath = Environment.getExternalStorageDirectory().getAbsolutePath();

	String typefaceString = sharedPreferences.getString(getString(R.string.prefTypefaceKey), "DEFAULT");
	if(typefaceString.equalsIgnoreCase("DEFAULT"))
	{
		mTypeface = Typeface.DEFAULT;
	}
	else if(typefaceString.equalsIgnoreCase("MONOSPACE"))
	{
		mTypeface = Typeface.MONOSPACE;
	}
	else if(typefaceString.equalsIgnoreCase("SANS_SERIF"))
	{
		mTypeface = Typeface.SANS_SERIF;
	}
	else if(typefaceString.equalsIgnoreCase("SERIF"))
	{
		mTypeface = Typeface.SERIF;
	}

	boolean noTitleBarFlag = sharedPreferences.getBoolean(getString(R.string.prefNoTitleBarKey), false);
	if(noTitleBarFlag) requestWindowFeature(Window.FEATURE_NO_TITLE);


}
 
开发者ID:monolifed,项目名称:mininoteview,代码行数:33,代码来源:TextEdit.java

示例11: onRestoreInstanceState

@Override
protected void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        for (int i = 0; i < bundle.getInt("drawMoveHistorySize"); i++) {
            mDrawMoveHistory.add((DrawMove) bundle.getSerializable("mDrawMoveHistory" + i));
        }
        mDrawMoveHistoryIndex = bundle.getInt("mDrawMoveHistoryIndex");
        mDrawMoveBackgroundIndex = bundle.getInt("mDrawMoveBackgroundIndex");
        mDrawingMode = (DrawingMode) bundle.getSerializable("mDrawingMode");
        mDrawingTool = (DrawingTool) bundle.getSerializable("mDrawingTool");
        mInitialDrawingOrientation = (DrawingOrientation) bundle.getSerializable("mInitialDrawingOrientation");

        mDrawColor = bundle.getInt("mDrawColor");
        mDrawWidth = bundle.getInt("mDrawWidth");
        mDrawAlpha = bundle.getInt("mDrawAlpha");
        mBackgroundColor = bundle.getInt("mBackgroundColor");
        mAntiAlias = bundle.getBoolean("mAntiAlias");
        mDither = bundle.getBoolean("mDither");
        mFontSize = bundle.getFloat("mFontSize");
        mPaintStyle = (SerializablePaint.Style) bundle.getSerializable("mPaintStyle");
        mLineCap = (SerializablePaint.Cap) bundle.getSerializable("mLineCap");
        mFontFamily =
                bundle.getInt("mFontFamily") == 0 ? Typeface.DEFAULT :
                        bundle.getInt("mFontFamily") == 1 ? Typeface.MONOSPACE :
                                bundle.getInt("mFontFamily") == 2 ? Typeface.SANS_SERIF :
                                        bundle.getInt("mFontFamily") == 3 ? Typeface.SERIF : Typeface.DEFAULT;
        state = bundle.getParcelable("superState");
    }
    super.onRestoreInstanceState(state);
}
 
开发者ID:rosenpin,项目名称:QuickDrawEverywhere,代码行数:31,代码来源:DrawView.java

示例12: selectTypeface

@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;
    }
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:13,代码来源:Key.java

示例13: getMonospace

public Typeface getMonospace() {
    return Typeface.MONOSPACE;
}
 
开发者ID:Light-Team,项目名称:ModPE-IDE-Source,代码行数:3,代码来源:TypefaceManager.java

示例14: SystemFontResolver

public SystemFontResolver() {
    this.defaultFont = new FontFamily("default", Typeface.DEFAULT);
    this.serifFont = new FontFamily("serif", Typeface.SERIF);
    this.sansSerifFont = new FontFamily("sans-serif", Typeface.SANS_SERIF);
    this.monoSpaceFont = new FontFamily("monospace", Typeface.MONOSPACE );
}
 
开发者ID:SysdataSpA,项目名称:SDHtmlTextView,代码行数:6,代码来源:SystemFontResolver.java

示例15: initAttributes

/**
 * Initialize view attributes
 *
 * @param context
 * @param attrs
 */
private void initAttributes(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.getTheme().obtainStyledAttributes(
            attrs, R.styleable.DrawView, 0, 0);
    try {
        mDrawColor = typedArray.getColor(R.styleable.DrawView_dv_draw_color, Color.BLACK);
        mDrawWidth = typedArray.getInteger(R.styleable.DrawView_dv_draw_width, 3);
        mDrawAlpha = typedArray.getInteger(R.styleable.DrawView_dv_draw_alpha, 255);
        mAntiAlias = typedArray.getBoolean(R.styleable.DrawView_dv_draw_anti_alias, true);
        mDither = typedArray.getBoolean(R.styleable.DrawView_dv_draw_dither, true);
        int paintStyle = typedArray.getInteger(R.styleable.DrawView_dv_draw_style, 2);
        if (paintStyle == 0)
            mPaintStyle = SerializablePaint.Style.FILL;
        else if (paintStyle == 1)
            mPaintStyle = SerializablePaint.Style.FILL_AND_STROKE;
        else if (paintStyle == 2)
            mPaintStyle = SerializablePaint.Style.STROKE;
        int cap = typedArray.getInteger(R.styleable.DrawView_dv_draw_corners, 2);
        if (cap == 0)
            mLineCap = SerializablePaint.Cap.BUTT;
        else if (cap == 1)
            mLineCap = SerializablePaint.Cap.ROUND;
        else if (cap == 2)
            mLineCap = SerializablePaint.Cap.SQUARE;
        int typeface = typedArray.getInteger(R.styleable.DrawView_dv_draw_font_family, 0);
        if (typeface == 0)
            mFontFamily = Typeface.DEFAULT;
        else if (typeface == 1)
            mFontFamily = Typeface.MONOSPACE;
        else if (typeface == 2)
            mFontFamily = Typeface.SANS_SERIF;
        else if (typeface == 3)
            mFontFamily = Typeface.SERIF;
        mFontSize = typedArray.getInteger(R.styleable.DrawView_dv_draw_font_size, 12);
        isForCamera = typedArray.getBoolean(R.styleable.DrawView_dv_draw_is_camera, false);
        int orientation = typedArray.getInteger(R.styleable.DrawView_dv_draw_orientation,
                getWidth() > getHeight() ? 1 : 0);
        mInitialDrawingOrientation = DrawingOrientation.values()[orientation];
        if (getBackground() != null && !isForCamera)
            try {
                mBackgroundColor = ((ColorDrawable) getBackground()).getColor();
                setBackgroundColor(Color.TRANSPARENT);
            } catch (Exception e) {
                e.printStackTrace();
                setBackgroundColor(Color.TRANSPARENT);
                mBackgroundColor = ((ColorDrawable) getBackground()).getColor();
                setBackgroundResource(R.drawable.drawable_transparent_pattern);
            }
        else {
            setBackgroundColor(Color.TRANSPARENT);
            mBackgroundColor = ((ColorDrawable) getBackground()).getColor();
            if (!isForCamera)
                setBackgroundResource(R.drawable.drawable_transparent_pattern);
        }

        mBackgroundPaint = new SerializablePaint();
        mBackgroundPaint.setStyle(SerializablePaint.Style.FILL);
        mBackgroundPaint.setColor(mBackgroundColor != -1 ? mBackgroundColor : Color.TRANSPARENT);

        mDrawingTool = DrawingTool.values()[typedArray.getInteger(R.styleable.DrawView_dv_draw_tool, 0)];
        mDrawingMode = DrawingMode.values()[typedArray.getInteger(R.styleable.DrawView_dv_draw_mode, 0)];
        mZoomEnabled = typedArray.getBoolean(R.styleable.DrawView_dv_draw_enable_zoom, false);
        mZoomRegionScale = typedArray.getFloat(R.styleable.DrawView_dv_draw_zoomregion_scale, mZoomRegionScale);
        mZoomRegionScaleMin = typedArray.getFloat(R.styleable.DrawView_dv_draw_zoomregion_minscale, mZoomRegionScaleMin);
        mZoomRegionScaleMax = typedArray.getFloat(R.styleable.DrawView_dv_draw_zoomregion_maxscale, mZoomRegionScaleMax);
    } finally {
        typedArray.recycle();
    }
}
 
开发者ID:rosenpin,项目名称:QuickDrawEverywhere,代码行数:74,代码来源:DrawView.java


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