本文整理汇总了Java中android.graphics.Paint.setTextSkewX方法的典型用法代码示例。如果您正苦于以下问题:Java Paint.setTextSkewX方法的具体用法?Java Paint.setTextSkewX怎么用?Java Paint.setTextSkewX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Paint
的用法示例。
在下文中一共展示了Paint.setTextSkewX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import android.graphics.Paint; //导入方法依赖的package包/类
private void apply(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.getShader();
paint.setTypeface(tf);
}
示例2: apply
import android.graphics.Paint; //导入方法依赖的package包/类
private void apply(final Paint paint, final 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.getShader();
paint.setTypeface(tf);
}
示例3: updatePaintTypeface
import android.graphics.Paint; //导入方法依赖的package包/类
/**
* Updates typeface setting for the given <var>paint</var> to the specified one.
*
* @param paint The paint to be updated.
* @param typeface The desired typeface. May be {@code null} to resolve instance of typeface
* from the specified style.
* @param style The desired text style used to resolve proper instance of typeface.
* @return {@code True} if paint's typeface setting has changed, {@code false} otherwise.
* @see Paint#setTypeface(Typeface)
*/
public static boolean updatePaintTypeface(@NonNull Paint paint, @Nullable Typeface typeface, @TextStyle int style) {
if (style > 0) {
if (typeface == null) {
typeface = Typeface.defaultFromStyle(style);
} else {
typeface = Typeface.create(typeface, style);
}
final int typefaceStyle = typeface != null ? typeface.getStyle() : 0;
final int need = style & ~typefaceStyle;
paint.setFakeBoldText((need & Typeface.BOLD) != 0);
paint.setTextSkewX((need & Typeface.ITALIC) != 0 ? -0.25f : 0);
paint.setTypeface(typeface);
} else {
paint.setFakeBoldText(false);
paint.setTextSkewX(0);
paint.setTypeface(typeface);
}
return true;
}
示例4: apply
import android.graphics.Paint; //导入方法依赖的package包/类
private static void apply(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);
}
示例5: 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);
}
示例6: 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);
}
示例7: applyCustomTypeFace
import android.graphics.Paint; //导入方法依赖的package包/类
private static void applyCustomTypeFace(Paint paint, @Nullable Typeface tf) {
if (tf == null) {
return;
}
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);
}
示例8: applyTypeface
import android.graphics.Paint; //导入方法依赖的package包/类
public static void applyTypeface(Context context, Paint v) {
if (v.getTypeface() == null) {
v.setTypeface(getNormal(context));
return;
}
switch (v.getTypeface().getStyle()) {
case Typeface.BOLD:
v.setTypeface(getNormal(context));
v.setFakeBoldText(true);
break;
default:
v.setTypeface(getNormal(context));
break;
case Typeface.ITALIC:
v.setTypeface(getNormal(context));
v.setTextSkewX(-0.25f);
break;
case Typeface.BOLD_ITALIC:
v.setTypeface(getNormal(context));
v.setFakeBoldText(true);
v.setTextSkewX(-0.25f);
break;
}
}
示例9: applyCustomTypeFace
import android.graphics.Paint; //导入方法依赖的package包/类
private void applyCustomTypeFace(Paint paint, FontFamily tf) {
paint.setAntiAlias(true);
paint.setTypeface(tf.getDefaultTypeface());
if (bold) {
if (tf.isFakeBold()) {
paint.setFakeBoldText(true);
} else {
paint.setTypeface(tf.getBoldTypeface());
}
}
if (italic) {
if (tf.isFakeItalic()) {
paint.setTextSkewX(-0.25f);
} else {
paint.setTypeface(tf.getItalicTypeface());
}
}
if (bold && italic && tf.getBoldItalicTypeface() != null) {
paint.setTypeface(tf.getBoldItalicTypeface());
}
}
示例10: _getTextPaint
import android.graphics.Paint; //导入方法依赖的package包/类
private Paint _getTextPaint(float fontSizeScale) {
Paint defPaint = _ctx.getTextPaintByName(_fontFace);
if (!(_fontShadowSize == 0 || (_fontShadowColor & 0xFF000000) == 0)) {
defPaint = _ctx.getShadowTextPaintByName(_fontFace);
defPaint.setShadowLayer(_fontShadowSize, _fontShadowX, _fontShadowY, _fontShadowColor);
}
defPaint.setColor(_fontColor);
if (Math.abs(fontSizeScale - 1.0f) > 0.01f) {
defPaint.setTextSize(_fontSize * fontSizeScale);
} else {
defPaint.setTextSize(_fontSize);
}
//defPaint.setStrokeWidth(_fontWeight / 2.0f);
if (_fontWeight > 1.0) {
defPaint.setFakeBoldText(true);
} else {
defPaint.setFakeBoldText(false);
}
defPaint.setUnderlineText(_fontUnderline);
defPaint.setTextSkewX(_fontItalic ? -0.25f : 0);
defPaint.setTextAlign(Paint.Align.LEFT);
return defPaint;
}
示例11: _getTextPaint
import android.graphics.Paint; //导入方法依赖的package包/类
protected Paint _getTextPaint(float fontSizeScale) {
XulRenderContext ctx = _render.getRenderContext();
Paint defPaint = ctx.getTextPaintByName(_fontFace);
if (!(_fontShadowSize == 0 || (_fontShadowColor & 0xFF000000) == 0)) {
defPaint = ctx.getShadowTextPaintByName(_fontFace);
defPaint.setShadowLayer(_fontShadowSize, _fontShadowX, _fontShadowY, _fontShadowColor);
}
defPaint.setColor(_fontColor);
if (Math.abs(fontSizeScale - 1.0f) > 0.01f) {
defPaint.setTextSize(_fontSize * fontSizeScale);
} else {
defPaint.setTextSize(_fontSize);
}
if (_fontWeight > 1.0) {
if (_fontWeight > 2.5) {
defPaint.setStrokeWidth(_fontWeight*fontSizeScale/2);
} else {
defPaint.setFakeBoldText(true);
}
} else {
defPaint.setFakeBoldText(false);
}
defPaint.setTextScaleX(_fontScaleX);
defPaint.setUnderlineText(_fontUnderline);
defPaint.setStrikeThruText(_fontStrikeThrough);
defPaint.setTextSkewX(_fontItalic ? -0.25f : 0);
defPaint.setTextAlign(Paint.Align.LEFT);
return defPaint;
}
示例12: getPaint
import android.graphics.Paint; //导入方法依赖的package包/类
public Paint getPaint(Context context, float scale, boolean outline) {
float textSize = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
this.textSize,
context.getResources().getDisplayMetrics()) * scale;
Paint textPaint = new Paint();
if (typeface != null) {
textPaint.setTypeface(typeface);
}
textPaint.setStyle(Paint.Style.FILL_AND_STROKE);
textPaint.setTextSize(textSize);
textPaint.setAntiAlias(true);
if (outline == false) {
textPaint.setStrokeWidth(textSize * textStrokeRatio);
textPaint.setColor(textColor);
} else {
textPaint.setStrokeWidth(textSize * textStrokeRatio + textSize * textOutlineRatio);
textPaint.setColor(outlineColor);
}
// skew
textPaint.setTextSkewX(skewX);
// scaleX
textPaint.setTextScaleX(scaleX);
if (Build.VERSION.SDK_INT >= 21) {
textPaint.setLetterSpacing(letterSpacing);
}
return textPaint;
}
示例13: draw
import android.graphics.Paint; //导入方法依赖的package包/类
@Override
public void draw(@NonNull Canvas canvas, CharSequence text, @IntRange(from = 0) int start, @IntRange(from = 0) int end, float x, int top, int y, int bottom, @NonNull Paint paint) {
canvas.save();
float preTextSkewX = paint.getTextSkewX();
paint.setTextSkewX(mTextSkewX);
canvas.drawText(text, start, end, x, y, paint);
paint.setTextSkewX(preTextSkewX);
canvas.restore();
}
示例14: randomTextStyle
import android.graphics.Paint; //导入方法依赖的package包/类
private void randomTextStyle(Paint paint) {
int color = randomColor();
paint.setColor(color);
paint.setFakeBoldText(mRandom.nextBoolean()); //true为粗体,false为非粗体
float skewX = mRandom.nextInt(11) / 10;
skewX = mRandom.nextBoolean() ? skewX : -skewX;
paint.setTextSkewX(skewX); //float类型参数,负数表示右斜,整数左斜
// paint.setUnderlineText(true); //true为下划线,false为非下划线
// paint.setStrikeThruText(true); //true为删除线,false为非删除线
}
示例15: getSize
import android.graphics.Paint; //导入方法依赖的package包/类
/**
* Returns the width of the span. Extending classes can set the height of the span by updating
* attributes of {@link android.graphics.Paint.FontMetricsInt}. If the span covers the whole
* text, and the height is not set,
* {@link #draw(Canvas, CharSequence, int, int, float, int, int, int, Paint)} will not be
* called for the span.
*
* @param paint Paint instance.
* @param text Current text.
* @param start Start character index for span.
* @param end End character index for span.
* @param fm Font metrics, can be null.
* @return Width of the span.
*/
@Override
public int getSize(@NonNull Paint paint, CharSequence text, @IntRange(from = 0) int start, @IntRange(from = 0) int end, @Nullable Paint.FontMetricsInt fm) {
float preTextSkewX = paint.getTextSkewX();
paint.setTextSkewX(mTextSkewX);
TextMeasureUtil.getTextBounds(paint, text, start, end, mRect);
paint.setTextSkewX(preTextSkewX);
setHeightIfNeed(text, start, end, fm);
return mRect.width();
}