Imagesharp: DrawText with border?

Created on 20 Dec 2017  路  2Comments  路  Source: SixLabors/ImageSharp

Hi guys,

This is more of a doubt (by the way, is there a specific forum for question or something?):

I have dynamic text over dynamic backgrounds. Im always writing the text in white but depending on the background and text length it may cause some issues writing white text over white background.

I was wondering: is there a simple way to add borders to my text? Or maybe some shadow or some kind of filter to highlight my text over the background?

I have searched on the TextGraphicsOptions and Font but couldnt find nothing.

The only way I can think of is first drawing the text in a black font with a slightly bigger size and then writing it in white, so it would be like a black-bordered white text.

Thanks,

question

Most helpful comment

Hi @Menighin

Yeah we do have a forum for general chat. It's highlighted in the contribution guidelines that pop up when you raise an issue. You're not the first to miss it so no worries 馃槃

https://github.com/SixLabors/ImageSharp/blob/deb1c9c8a6c0e09219e36edc12c49cb1aaf4fc60/.github/CONTRIBUTING.md#do-you-have-questions-about-consuming-the-library-or-the-source-code

In answer to your question. Yes we can. You need the overload that accepts a pen that creates an outline

c# image.Mutate(x => x.DrawText("ImageSharp", font, Brushes.Solid(Rgba32.Black), Pens.Solid(Rgba32.Red, 2), Vector2.Zero));

car

Hope that helps

Cheers

James

All 2 comments

Hi @Menighin

Yeah we do have a forum for general chat. It's highlighted in the contribution guidelines that pop up when you raise an issue. You're not the first to miss it so no worries 馃槃

https://github.com/SixLabors/ImageSharp/blob/deb1c9c8a6c0e09219e36edc12c49cb1aaf4fc60/.github/CONTRIBUTING.md#do-you-have-questions-about-consuming-the-library-or-the-source-code

In answer to your question. Yes we can. You need the overload that accepts a pen that creates an outline

c# image.Mutate(x => x.DrawText("ImageSharp", font, Brushes.Solid(Rgba32.Black), Pens.Solid(Rgba32.Red, 2), Vector2.Zero));

car

Hope that helps

Cheers

James

Hi Jim, sorry to bother again. This time I tried the Gitter but didnt get any response... Can you answer me?

Hi everyone,
Can anybody help me with drawing text with an outline stroke? Is it possible?
Right now I am able to draw it with the stroke but it is inset:
_image.DrawText(quote, font, Brushes.Solid(Rgba32.White), Pens.Solid(Rgba32.Black, 1), new Vector2(X_TRANSLATE, yDraw), textOptions)
Thanks!

Was this page helpful?
0 / 5 - 0 ratings