Merge pull request #514 from linshun/iss724

fixed #724, different results of CCLabelTTF on android & win32
This commit is contained in:
minggo 2011-09-19 03:13:56 -07:00
commit 371d4e646a
3 changed files with 18 additions and 9 deletions

View File

@ -63,16 +63,19 @@ public class Cocos2dxBitmap{
Paint paint = newPaint(fontName, fontSize, alignment);
TextProperty textProperty = computeTextProperty(content, paint, width, height);
int BitMapTotalHeight = (height == 0 ? textProperty.totalHeight:height);
// Draw text to bitmap
Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth,
textProperty.totalHeight, Bitmap.Config.ARGB_8888);
BitMapTotalHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
// Draw string
FontMetricsInt fm = paint.getFontMetricsInt();
int x = 0;
int y = -fm.ascent;
int y = height == 0 ?(-fm.ascent):
(-fm.ascent + (height - textProperty.totalHeight)/2);
String[] lines = textProperty.lines;
for (String line : lines){
x = computeX(paint, line, textProperty.maxWidth, alignment);

View File

@ -63,16 +63,19 @@ public class Cocos2dxBitmap{
Paint paint = newPaint(fontName, fontSize, alignment);
TextProperty textProperty = computeTextProperty(content, paint, width, height);
int BitMapTotalHeight = (height == 0 ? textProperty.totalHeight:height);
// Draw text to bitmap
Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth,
textProperty.totalHeight, Bitmap.Config.ARGB_8888);
BitMapTotalHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
// Draw string
FontMetricsInt fm = paint.getFontMetricsInt();
int x = 0;
int y = -fm.ascent;
int y = height == 0 ?(-fm.ascent):
(-fm.ascent + (height - textProperty.totalHeight)/2);
String[] lines = textProperty.lines;
for (String line : lines){
x = computeX(paint, line, textProperty.maxWidth, alignment);

View File

@ -63,16 +63,19 @@ public class Cocos2dxBitmap{
Paint paint = newPaint(fontName, fontSize, alignment);
TextProperty textProperty = computeTextProperty(content, paint, width, height);
int BitMapTotalHeight = (height == 0 ? textProperty.totalHeight:height);
// Draw text to bitmap
Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth,
textProperty.totalHeight, Bitmap.Config.ARGB_8888);
BitMapTotalHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
// Draw string
FontMetricsInt fm = paint.getFontMetricsInt();
int x = 0;
int y = -fm.ascent;
int y = height == 0 ?(-fm.ascent):
(-fm.ascent + (height - textProperty.totalHeight)/2);
String[] lines = textProperty.lines;
for (String line : lines){
x = computeX(paint, line, textProperty.maxWidth, alignment);