SkTextBox problems #14

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

Comments

Projects
None yet
2 participants

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?

Contributor

asimonov-im commented Mar 29, 2012

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 commented Mar 30, 2012

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment