本文整理了Java中android.graphics.Paint.getTextPath()
方法的一些代码示例,展示了Paint.getTextPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Paint.getTextPath()
方法的具体详情如下:
包路径:android.graphics.Paint
类名称:Paint
方法名:getTextPath
暂无
代码示例来源:origin: JadynAi/LoadingLovely
private Path getDefPath() {
Path textPath = new Path();
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.RED);
paint.setTextSize(50);
String s = "空的";
paint.getTextPath(s, 0, s.length(), 0, 50, textPath);
textPath.close();
return textPath;
}
代码示例来源:origin: kazy1991/FontDrawable
private Path createTextPathBase() {
Path path = new Path();
Rect viewBounds = getBounds();
float textSize = (float) viewBounds.height();
paint.setTextSize(textSize);
paint.getTextPath(String.valueOf(fontCode), 0, 1, 0, viewBounds.height(), path);
return path;
}
代码示例来源:origin: JadynAi/LoadingLovely
private Path getPath() {
Path textPath = new Path();
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.RED);
paint.setTextSize(120);
paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD_ITALIC));
String s = mEditText.getText().toString().length() <= 0 ? "cece" : mEditText.getText().toString();
paint.getTextPath(s, 0, s.length(), 0, 200, textPath);
textPath.close();
return textPath;
}
}
代码示例来源:origin: com.caverock/androidsvg
@Override
public void processText(String text)
{
if (visible())
{
//state.fillPaint.getTextPath(text, 0, text.length(), x, y, textAsPath);
Path spanPath = new Path();
state.fillPaint.getTextPath(text, 0, text.length(), x, y, spanPath);
textAsPath.addPath(spanPath);
}
// Update the current text position
x += state.fillPaint.measureText(text);
}
}
代码示例来源:origin: Leaking/WeGit
private void updateTextSize(Rect viewBounds) {
float textSize = (float) viewBounds.height() * 2;
mIconPaint.setTextSize(textSize);
mIconPaint.getTextPath(mIconUtfChars, 0, mIconUtfChars.length,
0, viewBounds.height(), mPath);
mPath.computeBounds(mPathBounds, true);
float deltaWidth = ((float) mPaddingBounds.width() / mPathBounds.width());
float deltaHeight = ((float) mPaddingBounds.height() / mPathBounds.height());
float delta = (deltaWidth < deltaHeight) ? deltaWidth : deltaHeight;
textSize *= delta;
mIconPaint.setTextSize(textSize);
mIconPaint.getTextPath(mIconUtfChars, 0, mIconUtfChars.length,
0, viewBounds.height(), mPath);
mPath.computeBounds(mPathBounds, true);
}
代码示例来源:origin: mkulesh/microMathematics
@Override
public void processText(String text)
{
if (visible())
{
//state.fillPaint.getTextPath(text, 0, text.length(), x, y, textAsPath);
Path spanPath = new Path();
state.fillPaint.getTextPath(text, 0, text.length(), x, y, spanPath);
textAsPath.addPath(spanPath);
}
// Update the current text position
x += state.fillPaint.measureText(text);
}
}
代码示例来源:origin: kazy1991/FontDrawable
private void applyPadding(Path path, RectF textBounds, Rect paddingBounds) {
final Rect viewBounds = getBounds();
float deltaWidth = ((float) paddingBounds.width() / textBounds.width());
float deltaHeight = ((float) paddingBounds.height() / textBounds.height());
float attenuate = (deltaWidth < deltaHeight) ? deltaWidth : deltaHeight;
float textSize = paint.getTextSize();
textSize *= attenuate;
paint.setTextSize(textSize);
paint.getTextPath(String.valueOf(fontCode), 0, 1, 0, viewBounds.height(), path);
path.computeBounds(textBounds, true);
}
代码示例来源:origin: org.arakhne.afc.ui/vector-android
@Override
public Shape2f getOutline() {
AndroidPath p = (this.globalPath==null) ? null : this.globalPath.get();
if (p==null) {
Path path = new Path();
Paint paint = getPaint();
paint.getTextPath(this.characters, 0, this.characters.length, 0, 0, path);
p = new AndroidPath(path);
this.globalPath = new SoftReference<>(p);
}
return p;
}
代码示例来源:origin: johnkil/Print
@Override
public void draw(Canvas canvas) {
if (mIconText != null && !mInEditMode) {
final Rect bounds = getBounds();
mPaint.getTextPath(mIconText.toString(), 0, mIconText.length(), 0, bounds.height(), mPath);
mPath.computeBounds(mPathBounds, true);
offsetIcon(bounds);
mPath.close();
canvas.drawPath(mPath, mPaint);
}
}
代码示例来源:origin: org.arakhne.afc.ui/vector-android
@Override
public Shape2f getOutline(float x, float y) {
Path path = new Path();
Paint paint = getPaint();
paint.getTextPath(this.characters, 0, this.characters.length, 0, 0, path);
return new AndroidPath(path);
}
代码示例来源:origin: org.arakhne.afc.ui/vector-android
@Override
public Shape2f getOutlineAt(int index) {
Path path = new Path();
Paint paint = getPaint();
paint.getTextPath(this.characters, index, 1, 0, 0, path);
return new AndroidPath(path);
}
代码示例来源:origin: org.arakhne.afc.ui/vector-android
@Override
public Shape2f getOutlineAt(int index, float x, float y) {
Path path = new Path();
Paint paint = getPaint();
paint.getTextPath(this.characters, index, 1, x, y, path);
return new AndroidPath(path);
}
代码示例来源:origin: douzifly/clear-todolist
/**
* Update the TextSize
*
* @param viewBounds
*/
private void updateTextSize(Rect viewBounds) {
float textSize = (float) viewBounds.height() * 2;
mIconPaint.setTextSize(textSize);
String textValue = String.valueOf(mIcon.getCharacter());
mIconPaint.getTextPath(textValue, 0, 1,
0, viewBounds.height(), mPath);
mPath.computeBounds(mPathBounds, true);
float deltaWidth = ((float) mPaddingBounds.width() / mPathBounds.width());
float deltaHeight = ((float) mPaddingBounds.height() / mPathBounds.height());
float delta = (deltaWidth < deltaHeight) ? deltaWidth : deltaHeight;
textSize *= delta;
mIconPaint.setTextSize(textSize);
mIconPaint.getTextPath(textValue, 0, 1,
0, viewBounds.height(), mPath);
mPath.computeBounds(mPathBounds, true);
}
代码示例来源:origin: playn/playn
void draw(Canvas canvas, float x, float y, Paint paint) {
boolean oldAA = paint.isAntiAlias();
paint.setAntiAlias(format.antialias);
try {
paint.setTypeface(font.typeface);
paint.setTextSize(font.size);
paint.setSubpixelText(true);
// if we're drawing REALLY BIG TEXT, draw to a path rather than directly drawing text to work
// around KitKat bug: https://code.google.com/p/android/issues/detail?id=62800
if (font.size > 250) {
Path path = new Path();
paint.getTextPath(text, 0, text.length(), x, y - metrics.ascent, path);
canvas.drawPath(path, paint);
} else {
canvas.drawText(text, x, y-metrics.ascent, paint);
}
} finally {
paint.setAntiAlias(oldAA);
}
}
代码示例来源:origin: rakshakhegde/Diffre
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
paint.getTextBounds(textString, 0, textString.length(), textBounds);
final int textWidth = textBounds.width();
final int textHeight = textBounds.height();
width = textWidth + textPadding;
height = textHeight + textPadding;
final int cx = width / 2;
final int cy = (height + textHeight) / 2;
paint.getTextPath(textString, 0, textString.length(), cx, cy, textPath);
progressStrokePath = getRoundRectPath(0, 0, width, height, radius);
computePaths();
// Adding 1 to prevent artifacts
setMeasuredDimension(width + 1, height + 1);
}
代码示例来源:origin: com.googlecode.playn/playn-android
void draw(Canvas canvas, float x, float y, Paint paint) {
boolean oldAA = paint.isAntiAlias();
paint.setAntiAlias(format.antialias);
try {
paint.setTypeface(font.typeface);
paint.setTextSize(font.size());
paint.setSubpixelText(true);
// if we're drawing REALLY BIG TEXT, draw to a path rather than directly drawing text to work
// around KitKat bug: https://code.google.com/p/android/issues/detail?id=62800
if (font.size() > 250) {
Path path = new Path();
paint.getTextPath(text, 0, text.length(), x, y - metrics.ascent, path);
canvas.drawPath(path, paint);
} else {
canvas.drawText(text, x, y-metrics.ascent, paint);
}
} finally {
paint.setAntiAlias(oldAA);
}
}
代码示例来源:origin: threerings/playn
void draw(Canvas canvas, float x, float y, Paint paint) {
boolean oldAA = paint.isAntiAlias();
paint.setAntiAlias(format.antialias);
try {
paint.setTypeface(font.typeface);
paint.setTextSize(font.size());
paint.setSubpixelText(true);
// if we're drawing REALLY BIG TEXT, draw to a path rather than directly drawing text to work
// around KitKat bug: https://code.google.com/p/android/issues/detail?id=62800
if (font.size() > 250) {
Path path = new Path();
paint.getTextPath(text, 0, text.length(), x, y - metrics.ascent, path);
canvas.drawPath(path, paint);
} else {
canvas.drawText(text, x, y-metrics.ascent, paint);
}
} finally {
paint.setAntiAlias(oldAA);
}
}
代码示例来源:origin: pavel163/FilledView
paint.getTextPath(text, 0, text.length(), cx, cy, textPath);
代码示例来源:origin: stackoverflow.com
Path path = new Path();
String s = "my text" + String.valueOf(i);
mPaint.getTextPath(s, 0, s.length(), mMainCirclRadius * 2 / 3, mMainCircleCentr - 4, path);
代码示例来源:origin: 7heaven/UILibrary
paint.getTextPath(text, 0, text.length(), 0, paint.getTextSize(), animatePath);
PathProgressProvider.PathDesc animateDesc = new PathProgressProvider.PathDesc(animatePath, Gravity.CENTER, true, false, false);
内容来源于网络,如有侵权,请联系作者删除!