Implement better text rendering for the titles #46
Comments
Today I have also noticed that most of the selected page title poor quality comes from the fact that the text is being drawn twice, one on top of the other. I couldn't fix that issue per se but I changed the code enough to see how it would look like if the title were to be drawn only once and looked much better (but not as good as a TextView render). |
Here's a simple fix for the issue: #48 |
Just to make it clear, that fix does not exactly fix the issue here described. It's only for the "double title drawing", not for the general poor text rendering quality. |
It's not the perfect solution but like you already said, still much better than before... I thought it would be a good temporary solution until the control has been rewritten to use TextViews. |
Yes, but that's just for the selected title, the other ones don't have this "double drawing" problem. But this is just a feature request to rewrite the control with TextViews, @JakeWharton hasn't pitched in yet so we don't know what he feels about such rewrite... |
See #34 for my view on the subject :) |
Alright. For people in need of a quick fix it might still be helpful ;) |
Agreed. Will merge tonight and probably release as well. I want to get this out before sweeping changes start happening. |
Didn't notice #34, sorry... I guess this issue can be closed then? |
Closed... but not dead. |
As soon as I tried ViewPagerIndicator on my app, I noticed the title text rendering didn't look that great. I looked into the code to understand how the titles were being drawn and what could I do about it. They are being rendered on a Canvas using the Paint object.
There's nothing more it can be done about it, anti-aliasing is already enabled on the Paint object. The only thing it could be done is to change this:
Into this:
And also remove
mPaintText.setAntiAlias(true);
, but this does not give a better solution. Instead, we get a "different" solution. The rendering is just different. If it's better or worse, it really depends on the eye of the beholder.If you don't know, the meaning of
LINEAR_TEXT_FLAG
, in the words of Android Developer Roman Guy, is this:"Text rendering uses a font cache containing bitmap representations of each glyph the application needs. Linear text basically lets you skip the font cache."
So, my suggestion is this:
Get rid of the Paint object and use TextViews instead for each title. The TextView rendering is much better, here's an example on my app's implementation of the ViewPagerIndicator:
I understand that this requires a big rewrite to the code, but in the end, the rendering will look much better and more consistent with the rest of the UI.
The text was updated successfully, but these errors were encountered: