private Bitmap createTextBitmap(Configuration config){
  Bitmap bitmap=Bitmap.createBitmap(TEXTURE_SIZE,TEXTURE_SIZE,Bitmap.Config.ARGB_4444);
  Canvas canvas=new Canvas(bitmap);
  bitmap.eraseColor(0x00000000);
  Paint textPaint=new Paint();
  Typeface typeface=Typeface.defaultFromStyle(Typeface.BOLD);
  textPaint.setTypeface(typeface);
  textPaint.setTextSize(TEXT_SIZE);
  textPaint.setAntiAlias(true);
  int startX=0;
  int startY=0;
  int lineHeight=0;
  for (int i=0; i < STRING_COUNT; i++) {
    String str=config.getTextString(i);
    textPaint.setColor(0xff000000 | config.getTextColor(i));
    if (config.getTextShadow(i)) {
      textPaint.setShadowLayer(SHADOW_RADIUS,SHADOW_OFFSET,SHADOW_OFFSET,0xff000000);
    }
 else {
      textPaint.setShadowLayer(0,0,0,0);
    }
    Rect boundsRect=new Rect();
    textPaint.getTextBounds(str,0,str.length(),boundsRect);
    if (config.getTextShadow(i)) {
      boundsRect.right+=SHADOW_RADIUS + SHADOW_OFFSET;
      boundsRect.bottom+=SHADOW_RADIUS + SHADOW_OFFSET;
    }
    if (boundsRect.width() > TEXTURE_SIZE || boundsRect.height() > TEXTURE_SIZE) {
      Log.w(TAG,"HEY: text string '" + str + "' is too big: "+ boundsRect);
    }
    if (startX != 0 && startX + boundsRect.width() > TEXTURE_SIZE) {
      startX=0;
      startY+=lineHeight;
      lineHeight=0;
      if (startY >= TEXTURE_SIZE) {
        Log.w(TAG,"HEY: fell off the bottom of the message texture");
      }
    }
    canvas.drawText(str,startX - boundsRect.left,startY - boundsRect.top,textPaint);
    boundsRect.offsetTo(startX,startY);
    mTextPositions[i]=boundsRect;
    lineHeight=Math.max(lineHeight,boundsRect.height() + 1);
    startX+=boundsRect.width() + 1;
  }
  return bitmap;
}

private Bitmap createTextBitmap ( Configuration config ) { Bitmap bitmap = Bitmap . createBitmap ( TEXTURE_SIZE , TEXTURE_SIZE , Bitmap . Config . ARGB_4444 ) ; Canvas canvas = new Canvas ( bitmap ) ; bitmap . eraseColor ( 0x00000000 ) ; Paint textPaint = new Paint ( ) ; Typeface typeface = Typeface . defaultFromStyle ( Typeface . BOLD ) ; textPaint . setTypeface ( typeface ) ; textPaint . setTextSize ( TEXT_SIZE ) ; textPaint . setAntiAlias ( true ) ; int startX = 0 ; int startY = 0 ; int lineHeight = 0 ; for ( int i = 0 ; i < STRING_COUNT ; i ++ ) { String str = config . getTextString ( i ) ; textPaint . setColor ( 0xff000000 | config . getTextColor ( i ) ) ; if ( config . getTextShadow ( i ) ) { textPaint . setShadowLayer ( SHADOW_RADIUS , SHADOW_OFFSET , SHADOW_OFFSET , 0xff000000 ) ; } else { textPaint . setShadowLayer ( 0 , 0 , 0 , 0 ) ; } Rect boundsRect = new Rect ( ) ; textPaint . getTextBounds ( str , 0 , str . length ( ) , boundsRect ) ; if ( config . getTextShadow ( i ) ) { boundsRect . right += SHADOW_RADIUS + SHADOW_OFFSET ; boundsRect . bottom += SHADOW_RADIUS + SHADOW_OFFSET ; } if ( boundsRect . width ( ) > TEXTURE_SIZE || boundsRect . height ( ) > TEXTURE_SIZE ) { Log . w ( TAG , "HEY: text string '" + str + "' is too big: " + boundsRect ) ; } if ( startX != 0 && startX + boundsRect . width ( ) > TEXTURE_SIZE ) { startX = 0 ; startY += lineHeight ; lineHeight = 0 ; if ( startY >= TEXTURE_SIZE ) { Log . w ( TAG , "HEY: fell off the bottom of the message texture" ) ; } } canvas . drawText ( str , startX - boundsRect . left , startY - boundsRect . top , textPaint ) ; boundsRect . offsetTo ( startX , startY ) ; mTextPositions [ i ] = boundsRect ; lineHeight = Math . max ( lineHeight , boundsRect . height ( ) + 1 ) ; startX += boundsRect . width ( ) + 1 ; } return bitmap ; }
creates a bitmap with the various strings .
