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


Java Paint.setTypeface方法代码示例

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


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

示例1: draw

import android.graphics.Paint; //导入方法依赖的package包/类
public void draw(Canvas g2, float x, float y) {
		drawDebug(g2, x, y);
//		Paint st=AjLatexMath.getPaint();
//		st.setTextSize(AjLatexMath.getTextSize());
		Paint st =new Paint();
		float w = st.getStrokeWidth();
		Style s = st.getStyle();
		Typeface f = st.getTypeface();
		st.setStrokeWidth(0);//
		st.setStyle(Style.FILL_AND_STROKE);
		st.setTypeface(font);
		g2.save();
		g2.translate(x, y);
		g2.scale(0.5f * size, 0.5f * size);
//		g2.drawText(str, x, y, st);
		g2.drawText(str, 0, 0, st);
		g2.restore();
		st.setStyle(s);
		st.setStrokeWidth(w);
		st.setTypeface(f);
	}
 
开发者ID:daquexian,项目名称:FlexibleRichTextView,代码行数:22,代码来源:JavaFontRenderingBox.java

示例2: createBall

import android.graphics.Paint; //导入方法依赖的package包/类
public static Bitmap createBall(int radius, int ballColor, int letterColor, String letter) {
    letter = letter.toUpperCase();
    Bitmap bitmap = Bitmap.createBitmap(radius*2, radius*2, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint2 = new Paint();
    paint2.setColor(ballColor);
    canvas.drawCircle(radius, radius, (float) radius, paint2);
    Paint paint = new Paint();
    paint.setColor(letterColor);
    paint.setTextSize(120);
    paint.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));

    Rect textBounds = new Rect();
    paint.getTextBounds(letter, 0, letter.length(), textBounds);
    canvas.drawText(letter, radius - textBounds.exactCenterX(), radius - textBounds.exactCenterY(), paint);
    return bitmap;
}
 
开发者ID:ruuvi,项目名称:com.ruuvi.station,代码行数:18,代码来源:Utils.java

示例3: applyCustomTypeFace

import android.graphics.Paint; //导入方法依赖的package包/类
private 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:nordfalk,项目名称:EsperantoRadio,代码行数:21,代码来源:EgenTypefaceSpan.java

示例4: applyCustomTypeFace

import android.graphics.Paint; //导入方法依赖的package包/类
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,代码行数:21,代码来源:CustomTypefaceSpan.java

示例5: c

import android.graphics.Paint; //导入方法依赖的package包/类
protected float c(Paint paint) {
    float f = 0.0f;
    if (!TextUtils.isEmpty(this.text)) {
        Typeface d = d(paint);
        if ((this.useDefaultFont || !this.useHanyiColorFont) && (paint instanceof ETPaint)) {
            paint = ((ETPaint) paint).a();
        }
        int length = this.text.length();
        int i = 0;
        while (i < length) {
            int charCount = Character.charCount(this.text.codePointAt(i));
            float measureText = paint.measureText(this.text, i, i + charCount) + f;
            i += charCount;
            f = measureText;
        }
        if (d != null) {
            paint.setTypeface(d);
        }
    }
    return f;
}
 
开发者ID:xieyangxuejun,项目名称:CommentView,代码行数:22,代码来源:TextCell.java

示例6: getShadowTextPaintByName

import android.graphics.Paint; //导入方法依赖的package包/类
static public Paint getShadowTextPaintByName(String name) {
	if (name == null) {
		return getDefShadowTextPaint();
	}
	TypefaceInfo typefaceInfo = _font_map.get(name);
	if (typefaceInfo == null) {
		return getDefShadowTextPaint();
	}
	Paint paint = typefaceInfo.paint;
	if (paint == null) {
		typefaceInfo.paint = paint = new Paint();
		paint.setTypeface(typefaceInfo.typeface);
		paint.setAntiAlias(true);
		paint.setSubpixelText(true);
		paint.setShadowLayer(3, 0, 0, Color.BLACK);
	}
	return paint;
}
 
开发者ID:starcor-company,项目名称:starcor.xul,代码行数:19,代码来源:XulRenderContext.java

示例7: TabSwitcherDrawable

import android.graphics.Paint; //导入方法依赖的package包/类
/**
 * Creates a new drawable, which allows to display the number of tabs, which are currently
 * contained by a {@link TabSwitcher}.
 *
 * @param context
 *         The context, which should be used by the drawable, as an instance of the class {@link
 *         Context}. The context may not be null
 */
public TabSwitcherDrawable(@NonNull final Context context) {
    ensureNotNull(context, "The context may not be null");
    Resources resources = context.getResources();
    size = resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_size);
    textSizeNormal =
            resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_normal);
    textSizeSmall =
            resources.getDimensionPixelSize(R.dimen.tab_switcher_drawable_font_size_small);
    background =
            ContextCompat.getDrawable(context, R.drawable.tab_switcher_drawable_background)
                    .mutate();
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.WHITE);
    paint.setTextAlign(Align.CENTER);
    paint.setTextSize(textSizeNormal);
    paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
    label = Integer.toString(0);
    int tint = ThemeUtil.getColor(context, android.R.attr.textColorPrimary);
    setColorFilter(tint, PorterDuff.Mode.MULTIPLY);
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:29,代码来源:TabSwitcherDrawable.java

示例8: initPaints

import android.graphics.Paint; //导入方法依赖的package包/类
private void initPaints() {
    paintOuterText = new Paint();
    paintOuterText.setAntiAlias(true);
    paintOuterText.setColor(textColorOuter);
    paintOuterText.setTypeface(typeface);
    paintOuterText.setTextSize(textSize);
    paintCenterText = new Paint();
    paintCenterText.setAntiAlias(true);
    paintCenterText.setColor(textColorCenter);
    paintCenterText.setTextScaleX(1.1F);
    paintCenterText.setTypeface(typeface);
    paintCenterText.setTextSize(textSize);
    paintIndicator = new Paint();
    paintIndicator.setAntiAlias(true);
    paintIndicator.setColor(dividerConfig.color);
    paintIndicator.setStrokeWidth(dividerConfig.thick);
    paintIndicator.setAlpha(dividerConfig.alpha);
    paintShadow = new Paint();
    paintShadow.setAntiAlias(true);
    paintShadow.setColor(dividerConfig.shadowColor);
    paintShadow.setAlpha(dividerConfig.shadowAlpha);
    setLayerType(LAYER_TYPE_SOFTWARE, null);
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:24,代码来源:WheelView.java

示例9: BadgeDrawable

import android.graphics.Paint; //导入方法依赖的package包/类
public BadgeDrawable(Context context) {
    mTextSize = 15F;
    myColor = context.getResources().getColor(R.color.theme_primary_dark_badge);
    mBadgePaint = new Paint();
    mBadgePaint.setColor(myColor);
    mBadgePaint.setAntiAlias(true);
    mBadgePaint.setStyle(Paint.Style.FILL);

    mTextPaint = new Paint();
    mTextPaint.setColor(Color.YELLOW);
    mTextPaint.setTypeface(Typeface.DEFAULT_BOLD);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setAntiAlias(true);
    mTextPaint.setTextAlign(Paint.Align.CENTER);
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:16,代码来源:BadgeDrawable.java

示例10: createTextPaint

import android.graphics.Paint; //导入方法依赖的package包/类
private Paint createTextPaint(int textColor) {
    Paint paint = new Paint();
    paint.setColor(textColor);
    paint.setTypeface(NORMAL_TYPEFACE);
    paint.setAntiAlias(true);
    return paint;
}
 
开发者ID:gmontoya2483,项目名称:GoUbiquitous,代码行数:8,代码来源:DigitalWatchFaceService.java

示例11: drawIconGlyph

import android.graphics.Paint; //导入方法依赖的package包/类
private static void drawIconGlyph(Context context, String iconChar, int size, Canvas canvas, int color) {
    Paint textPaint = new Paint();
    textPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextAlign(Paint.Align.CENTER);
    textPaint.setColor(color);
    textPaint.setTextSize(size);
    textPaint.setTypeface(Typeface.createFromAsset(context.getResources().getAssets(), "SalesforceDesignSystemIcons.ttf"));
    float y = (size / 2.0f) - ((textPaint.descent() + textPaint.ascent()) / 2.0f);
    canvas.drawText(iconChar, (size / 2.0f), y, textPaint);
}
 
开发者ID:salesforce-ux,项目名称:design-system-android,代码行数:11,代码来源:Icons.java

示例12: drawTextElements

import android.graphics.Paint; //导入方法依赖的package包/类
/**
 * Draw the 12 text values at the positions specified by the textGrid parameters.
 */
private void drawTextElements(Canvas canvas, float textSize, Typeface typeface,
        ColorStateList textColor, String[] texts, float[] textX, float[] textY, Paint paint,
        int alpha, boolean showActivated, int activatedDegrees, boolean activatedOnly) {
    paint.setTextSize(textSize);
    paint.setTypeface(typeface);

    // The activated index can touch a range of elements.
    final float activatedIndex = activatedDegrees / (360.0f / NUM_POSITIONS);
    final int activatedFloor = (int) activatedIndex;
    final int activatedCeil = ((int) Math.ceil(activatedIndex)) % NUM_POSITIONS;

    for (int i = 0; i < 12; i++) {
        final boolean activated = (activatedFloor == i || activatedCeil == i);
        if (activatedOnly && !activated) {
            continue;
        }

        final int stateMask = StateSet.VIEW_STATE_ENABLED
                | (showActivated && activated ? StateSet.VIEW_STATE_ACTIVATED : 0);
        final int color = textColor.getColorForState(StateSet.get(stateMask), 0);
        paint.setColor(color);
        paint.setAlpha(getMultipliedAlpha(color, alpha));

        canvas.drawText(texts[i], textX[i], textY[i], paint);
    }
}
 
开发者ID:Gericop,项目名称:DateTimePicker,代码行数:30,代码来源:RadialTimePickerView.java

示例13: apply

import android.graphics.Paint; //导入方法依赖的package包/类
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,代码行数:39,代码来源:CustomStyleSpan.java

示例14: applyFontStyle

import android.graphics.Paint; //导入方法依赖的package包/类
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,代码行数:31,代码来源:TypefaceUtil.java

示例15: drawLanguageOnSpacebar

import android.graphics.Paint; //导入方法依赖的package包/类
private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) {
    final Keyboard keyboard = getKeyboard();
    if (keyboard == null) {
        return;
    }
    final int width = key.getWidth();
    final int height = key.getHeight();
    paint.setTextAlign(Align.CENTER);
    paint.setTypeface(Typeface.DEFAULT);
    paint.setTextSize(mLanguageOnSpacebarTextSize);
    final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width);
    // Draw language text with shadow
    final float descent = paint.descent();
    final float textHeight = -paint.ascent() + descent;
    final float baseline = height / 2 + textHeight / 2;
    if (mLanguageOnSpacebarTextShadowRadius > 0.0f) {
        paint.setShadowLayer(mLanguageOnSpacebarTextShadowRadius, 0, 0,
                mLanguageOnSpacebarTextShadowColor);
    } else {
        paint.clearShadowLayer();
    }
    paint.setColor(mLanguageOnSpacebarTextColor);
    paint.setAlpha(mLanguageOnSpacebarAnimAlpha);
    canvas.drawText(language, width / 2, baseline - descent, paint);
    paint.clearShadowLayer();
    paint.setTextScaleX(1.0f);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:28,代码来源:MainKeyboardView.java


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