Re: Underline Text

56 views
Skip to first unread message

Julia Lavrova

unread,
Dec 7, 2022, 10:22:30 AM12/7/22
to skia-d...@googlegroups.com
You forgot to set the color for decoration, it shows as white and it's hard to see.
        textStyle.setDecorationColor(SK_ColorRED); // Now it shows as red


On Wed, Dec 7, 2022 at 12:36 AM Priya <priyapus...@gmail.com> wrote:
Hi ,
     I want to draw underline for my text. I have set TextDecoration::kUnderline in Textstyle. I can get desired text with properties set in Textstyle like fontsize, foregroundcolor but underline alone is not drawn. Am i missing something?below is my code.

SkPaint paint = SkPaint();

paint.setColor(SkColorSetRGB(0, 0, 25));

paint.setStyle(SkPaint::kFill_Style);

ParagraphStyle paraStyle;

TextStyle textStyle;

textStyle.setForegroundColor(paint);

textStyle.setFontSize(13*scale);

textStyle.setDecoration(TextDecoration::kUnderline); paraStyle.setTextAlign(skia::textlayout::TextAlign::kCenter);

auto fontCollection = sk_make_sp<FontCollection>();

fontCollection->setDefaultFontManager(SkFontMgr::RefDefault());

auto builder = ParagraphBuilderImpl::make(paraStyle, fontCollection);

builder->pushStyle(textStyle);

std::string text = "Hellobuddy";

builder->addText(text.c_str(), text.length());

auto para = builder->Build();

para.get()->layout(80);

auto rect = SkRect();

rect.fTop = y;

rect.fLeft = x;

rect.fBottom = y+rowHt;

rect.fRight = x+colWidth-1;

canvas->save();

canvas->clipRect(rect);

para.get()->paint(canvas, x, y);

canvas->restore();


Thanks in advance

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/4ec28eb5-123a-450b-9d20-2cf9266bf467n%40googlegroups.com.

Priya

unread,
Dec 8, 2022, 1:14:39 AM12/8/22
to skia-discuss
yeah ,got it.Thank you
Reply all
Reply to author
Forward
0 new messages