如何在android中绘制又大又细的文本
我需要在视图上绘制单个字符作为大的细文本,如下图所示(文本只是简单的线条)
我下面的代码给了我以下图像(文本作为形状)
Paint dPaint = new Paint();
dPaint.setAntiAlias(true);
dPaint.setDither(true);
dPaint.setColor(Color.RED);
dPaint.setTextSize(getWidth()*.8F);
dPaint.setStyle(Paint.Style.STROKE);
dPaint.setStrokeWidth(1);
canvas.drawText("A",getWidth()*.3F, getHeight()*.6F, dPaint);
我尝试了各种绘画和描边属性,但没有一个成功。我还读到java 2D 文本被绘制为形状。
有没有办法将文本(特别是字符)绘制为线条而不是形状。另外,向下的文字尺寸应该很大。
I need to draw single character on my view as BIG thin text as shown in image below (text as just simple lines)
But my code below gives me following image (text as shape)
Paint dPaint = new Paint();
dPaint.setAntiAlias(true);
dPaint.setDither(true);
dPaint.setColor(Color.RED);
dPaint.setTextSize(getWidth()*.8F);
dPaint.setStyle(Paint.Style.STROKE);
dPaint.setStrokeWidth(1);
canvas.drawText("A",getWidth()*.3F, getHeight()*.6F, dPaint);
I tried various paint and stroke properties but none worked out. Also I read the in java 2D text is drawn as shape.
Is there a way to draw text (character in particular) as lines rather then shape. Also text down should be BIG in size.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为只有两种方法可以达到你的要求。
使用具有您的字体样式的自定义字体类型,并在您的应用程序中使用它,如下所示
另一种技术是您必须通过计算绘制字母或数字的路径中所需的坐标来将给定字符的形状绘制为线条。
我希望它可以帮助你。
I think only two ways to achieve your requirement.
Use a custom font-type with your font style and use it in your application as below
Another technique is you have to draw the shape of give character as lines by calculating the coordinates required in the path to draw that alphabet or digit.
I hope it may help you.
您增加
描边宽度
,然后细度也会增加,如下所示:You increase
strokewidth
, then thin is increased like so: