Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Font size too large to fit in cache

So i recently switched to android 3.0 (honeycomb) and i'm having some issues with hardware rendering, specifically at a certain custom view i've written where I use a font size of 200 to display some text.

Unfortunately it seems the openGLRenderer doesn't like that kind of rather large font sizes very much, given the error i'm getting in the log:

06-06 16:22:00.080: ERROR/OpenGLRenderer(2503): Font size to large to fit in cache. width, height = 97, 145

Are there ways around this (or ways to fix it) such that I can get the text displayed at the wanted font size?

like image 239
MrJre Avatar asked Jun 06 '11 14:06

MrJre


3 Answers

It is really a bug in the Android OS inside the Hardware Acceleration modules. I think that the best way is to ask the system to avoid HW acceleration on TextViews that contain large size text. To do so, just add in the code:

TextView bigText = (TextView) findViewById(R.id.bigtext);
bigText.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
like image 163
Shaish81 Avatar answered Nov 17 '22 22:11

Shaish81


Just an idea: Perhaps you can convert the font to an outline using Paint.getTextPath(...) and use this path to render the text. This should allow you to resize the path as needed.

like image 25
Stefan Mücke Avatar answered Nov 17 '22 22:11

Stefan Mücke


The setLayerType method is useful, but unfortunately it is supported just for API >= 11. Developing for API = 8 or less it will become unusable.

If you can, a simple solution is disabling the hardware acceleration just for the activity that is giving you problems. I had this very problem and solved it this way:

<application
    android:...
    android:hardwareAccelerated="true" >
    <activity ...>
        ...
    </activity>

    <activity
        ...
        android:hardwareAccelerated="false">
        ...
    </activity>
</application>

This solution will disable the hardware acceleration just for the activities where you do not need it and where you aren't able to display large texts.

like image 4
marzapower Avatar answered Nov 17 '22 22:11

marzapower