KB-20071217-034

From Triled Wiki

Jump to: navigation, search

Code is taken from original post

private void testTextBreak(float textSize) {
        Paint paint = new Paint();
        paint.setSubpixelText(true);
        paint.setTextSize(textSize);
        //we expect to fit approximately 10 X's into this space, no?
        int i = paint.breakText("XXXXXXXXXX", true, textSize * 10, null);
        Log.i("test", String.format("At text size %3.3f we accommodated %d Xs", textSize, i));
} 

...
        testTextBreak(100f);
        testTextBreak(10f);
        testTextBreak(1f);
        testTextBreak(0.1f);
        testTextBreak(0.01f); 
...

Expected behaviour: value returned by breakText() is near 10.

but output:

I/test(1039): At text size 100.000 we accommodated 10 Xs
I/test(1039): At text size 10.000 we accommodated 10 Xs
I/test(1039): At text size 1.000 we accommodated 10 Xs
I/test(1039): At text size 0.100 we accommodated 1 Xs
I/test(1039): At text size 0.010 we accommodated 0 Xs 

For small text sizes textBreak() returns incorrect values.

Personal tools