Drawing hollow text/deboss effect by using Canvas

272 Views Asked by At

I am trying to achieve this look in my android app.

anvas

It is called deboss effect where the text looks hollow. I have to do this using Canvas so TextView isn't an option.

My first thought was to somehow add an inner show in the text. But I couldn't find a way to do it. I tried to look a lot but couldn't find a way to achieve this. Anybody have any ideas? Thanks!

1

There are 1 best solutions below

0
On

Creating the effect in Photoshop is itself a complex mathematical thing under the hood and involves creating a drop shadow at different points along the font's glyph.

Maybe you can find a custom font file that already has the drop shadow added to the glyphs. That would be idea and most practical.

If you can get the font file you need you can load the font into your Paint as a typeface and set the custom Typeface for your font.

Typeface plain = Typeface.createFromAsset(assetManager, pathToFont); 
Typeface bold = Typeface.create(plain, Typeface.DEFAULT_BOLD)
Paint paint = new Paint();
paint.setTypeface(bold);
canvas.drawText("Sample text in bold",0,0,paint);