mirror of https://github.com/axmolengine/axmol.git
Merge pull request #514 from linshun/iss724
fixed #724, different results of CCLabelTTF on android & win32
This commit is contained in:
commit
371d4e646a
|
@ -64,15 +64,18 @@ public class Cocos2dxBitmap{
|
||||||
|
|
||||||
TextProperty textProperty = computeTextProperty(content, paint, width, height);
|
TextProperty textProperty = computeTextProperty(content, paint, width, height);
|
||||||
|
|
||||||
|
int BitMapTotalHeight = (height == 0 ? textProperty.totalHeight:height);
|
||||||
|
|
||||||
// Draw text to bitmap
|
// Draw text to bitmap
|
||||||
Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth,
|
Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth,
|
||||||
textProperty.totalHeight, Bitmap.Config.ARGB_8888);
|
BitMapTotalHeight, Bitmap.Config.ARGB_8888);
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
|
|
||||||
// Draw string
|
// Draw string
|
||||||
FontMetricsInt fm = paint.getFontMetricsInt();
|
FontMetricsInt fm = paint.getFontMetricsInt();
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = -fm.ascent;
|
int y = height == 0 ?(-fm.ascent):
|
||||||
|
(-fm.ascent + (height - textProperty.totalHeight)/2);
|
||||||
String[] lines = textProperty.lines;
|
String[] lines = textProperty.lines;
|
||||||
for (String line : lines){
|
for (String line : lines){
|
||||||
x = computeX(paint, line, textProperty.maxWidth, alignment);
|
x = computeX(paint, line, textProperty.maxWidth, alignment);
|
||||||
|
|
|
@ -64,15 +64,18 @@ public class Cocos2dxBitmap{
|
||||||
|
|
||||||
TextProperty textProperty = computeTextProperty(content, paint, width, height);
|
TextProperty textProperty = computeTextProperty(content, paint, width, height);
|
||||||
|
|
||||||
|
int BitMapTotalHeight = (height == 0 ? textProperty.totalHeight:height);
|
||||||
|
|
||||||
// Draw text to bitmap
|
// Draw text to bitmap
|
||||||
Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth,
|
Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth,
|
||||||
textProperty.totalHeight, Bitmap.Config.ARGB_8888);
|
BitMapTotalHeight, Bitmap.Config.ARGB_8888);
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
|
|
||||||
// Draw string
|
// Draw string
|
||||||
FontMetricsInt fm = paint.getFontMetricsInt();
|
FontMetricsInt fm = paint.getFontMetricsInt();
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = -fm.ascent;
|
int y = height == 0 ?(-fm.ascent):
|
||||||
|
(-fm.ascent + (height - textProperty.totalHeight)/2);
|
||||||
String[] lines = textProperty.lines;
|
String[] lines = textProperty.lines;
|
||||||
for (String line : lines){
|
for (String line : lines){
|
||||||
x = computeX(paint, line, textProperty.maxWidth, alignment);
|
x = computeX(paint, line, textProperty.maxWidth, alignment);
|
||||||
|
|
|
@ -64,15 +64,18 @@ public class Cocos2dxBitmap{
|
||||||
|
|
||||||
TextProperty textProperty = computeTextProperty(content, paint, width, height);
|
TextProperty textProperty = computeTextProperty(content, paint, width, height);
|
||||||
|
|
||||||
|
int BitMapTotalHeight = (height == 0 ? textProperty.totalHeight:height);
|
||||||
|
|
||||||
// Draw text to bitmap
|
// Draw text to bitmap
|
||||||
Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth,
|
Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth,
|
||||||
textProperty.totalHeight, Bitmap.Config.ARGB_8888);
|
BitMapTotalHeight, Bitmap.Config.ARGB_8888);
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
|
|
||||||
// Draw string
|
// Draw string
|
||||||
FontMetricsInt fm = paint.getFontMetricsInt();
|
FontMetricsInt fm = paint.getFontMetricsInt();
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = -fm.ascent;
|
int y = height == 0 ?(-fm.ascent):
|
||||||
|
(-fm.ascent + (height - textProperty.totalHeight)/2);
|
||||||
String[] lines = textProperty.lines;
|
String[] lines = textProperty.lines;
|
||||||
for (String line : lines){
|
for (String line : lines){
|
||||||
x = computeX(paint, line, textProperty.maxWidth, alignment);
|
x = computeX(paint, line, textProperty.maxWidth, alignment);
|
||||||
|
|
Loading…
Reference in New Issue