How to draw big thin text in android

I need to draw a single character in my view as BIG thin text, as shown in the image below (text as simple lines)

enter image description here

But my code below gives me the following image (text as form)

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); 

enter image description here

I tried various properties of paint and stroke, but none worked. I also read in java 2D text drawn as a form.

Is there a way to draw text (character in particular) as lines, not form. Also, the text should be large.

+4
source share
2 answers

I think there are only two ways to achieve your requirement.

Use your own font with your font style and use it in your application as shown below

  TextView text = (TextView) findViewById(R.id.textView); Typeface customFont = Typeface.createFromAsset(getAssets(), "ThinText.ttf"); text.setTypeface(customFont); 

Another method is to draw a figure that indicates the symbol as a line by calculating the coordinates needed on the path to draw this alphabet or number.

I hope this can help you.

+1
source

You increase strokewidth , then fineness increases like this:

 dPaint.setStrokeWidth(5); 
0
source

Source: https://habr.com/ru/post/1393483/


All Articles