Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

SkTextBox problems #14

Open
micrcx opened this issue Mar 26, 2012 · 2 comments
Open

SkTextBox problems #14

micrcx opened this issue Mar 26, 2012 · 2 comments

Comments

@micrcx
Copy link

micrcx commented Mar 26, 2012

I added to SkiaSample is another test. Called him TestTextBox. In principle, it repeats the same test to Windows, but somewhat simpler. I want to create two text boxes.One of them occupies half the screen vertically, the second - quarter of the screen. That is, there is room for navigation buttons. Areas have a different background colors, to distinguish them:

void TextBoxDemo::drawTest(SkCanvas* canvas, SkScalar w, SkScalar h, SkColor fg, SkColor bg)
{
SkAutoCanvasRestore acr(canvas, true);
canvas->clipRect(SkRect::MakeWH(w, h));
canvas->drawColor(bg);
SkScalar margin = 20;
textBox_.setMode(SkTextBox::kLineBreak_Mode);
textBox_.setBox(margin, margin,
w - margin, h - margin);
textBox_.setSpacing(SkIntToScalar(3)/3, 0);

textPaint_.setAntiAlias(true);
textPaint_.setLCDRenderText(true);
textPaint_.setColor(fg);
    textBox_.setText(gText, strlen(gText), textPaint_);

for (int i = 16; i < 24; i += 2)
{
    textPaint_.setTextSize(SkIntToScalar(i));
    textBox_.draw(canvas);
    canvas->translate(0, textBox_.getTextHeight() + textPaint_.getFontSpacing());
}

}

void TextBoxDemo::draw()
{
SkScalar width = w_;
canvas->translate(0, 0);
drawTest(canvas, width, h_/2, SK_ColorBLACK, SK_ColorLTGRAY);
canvas->translate(0, h_/2);
drawTest(canvas, width, h_/4, SK_ColorRED, SK_ColorBLACK);
}

In that case, if the option #define USE_SKIA_OPENGL 1 is selected, then for the first time after the selection test you may seen two areas, but then the second area disappears. And along with the navigation buttons. It only remains to close the application and stop the experiment. If the option #define USE_SKIA_OPENGL 0 is selected, you can see two text boxes, but the screen is starts to blinking. Conclusion. If you draw one text box size 3/4 screen, it's no problems . After a few tests I've come to the conclusion that the error occurs when the number of displayed text box objects exceeds unity. In short at the moment, you can use a one text box. Is that true?

@asimonov-im
Copy link
Contributor

We do not use the SkTextBox class internally (we do not even build it). Therefore, I am not sure why you're only able to use one text box. I will investigate when I get some spare time and get back to you.

@micrcx
Copy link
Author

micrcx commented Mar 30, 2012

Thank you for reply. I hope the problem can be solved. Good luck.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants