4

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

enter image description here

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

enter image description here

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.

Deep
  • 5,772
  • 2
  • 26
  • 36

2 Answers2

1

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

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

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.

Yugandhar Babu
  • 10,311
  • 9
  • 42
  • 67
  • Thought it still paint character as shape, but thin text font gave the illusion of line. I found a thin text font [here](http://www.dafont.com/bird-cherry.font) – Deep Jan 29 '12 at 09:22
0

You increase strokewidth, then thin is increased like so:

dPaint.setStrokeWidth(5);
Anthony
  • 12,177
  • 9
  • 69
  • 105
NagarjunaReddy
  • 8,621
  • 10
  • 63
  • 98