amulyakhare/TextDrawable

two lines text with different size is possible?

Opened this issue · 7 comments

selection_084

I'm looking for easy solution for the above multi-line requirement !!

Keyboard app. Text app. Cammands and code.:-)
Hole lot of hours.

Hey @LOG-TAG were u able to achieve that superscript (th) above 15 using this library...Please do let me know if its possible...Thnks

@LOG-TAG i did this but it not working on textdrawable

Hi guys, i trying to make it:

  @Override
   public void draw(Canvas canvas) {

    // this is already on the lib
    int width = this.width < 0 ? r.width() : this.width;
    int height = this.height < 0 ? r.height() : this.height;
    int fontSize = this.fontSize < 0 ? (Math.min(width, height) / 2) : this.fontSize;
    textPaint.setTextSize(fontSize);


       //this draw one line below another
        int yHeight = 10;
        canvas.drawText(text, width / 2, yHeight, textPaint);
        yHeight += textPaint.descent() - textPaint.ascent();
        canvas.drawText(text2, width / 2, yHeight, textPaint);

}

If you wish to draw with 2 diferents fontsizes, just create another textPaint and set another TextSize.

The problem there is that i dont know how to calculate the text size to draw it on the center of the circle. Can anyone help? Thanks in advance.

Same issue, this ignores \n or line separators

Yes, you have to use split in yours " " and use a for loop to draw each line. I got a new idea, you can create a canvas copy, draw everything and get its size to draw centered on the real one.