mirror of https://github.com/axmolengine/axmol.git
[hot fixed]closed issue#4999:fixed label is unsharp if it's created by smaller font.
This commit is contained in:
parent
c91f94fa5c
commit
e412f91103
|
@ -1079,7 +1079,10 @@ bool Texture2D::initWithString(const char *text, const std::string& fontName, fl
|
||||||
bool Texture2D::initWithString(const char *text, const FontDefinition& textDefinition)
|
bool Texture2D::initWithString(const char *text, const FontDefinition& textDefinition)
|
||||||
{
|
{
|
||||||
if(!text || 0 == strlen(text))
|
if(!text || 0 == strlen(text))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
// cache the texture data
|
// cache the texture data
|
||||||
VolatileTextureMgr::addStringTexture(this, text, textDefinition);
|
VolatileTextureMgr::addStringTexture(this, text, textDefinition);
|
||||||
|
@ -1127,9 +1130,11 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
|
||||||
textDef._stroke._strokeSize *= contentScaleFactor;
|
textDef._stroke._strokeSize *= contentScaleFactor;
|
||||||
textDef._shadow._shadowEnabled = false;
|
textDef._shadow._shadowEnabled = false;
|
||||||
|
|
||||||
Data outData = Device::getTextureDataForText(text,textDef,align,imageWidth,imageHeight);
|
Data outData = Device::getTextureDataForText(text, textDef, align, imageWidth, imageHeight, _hasPremultipliedAlpha);
|
||||||
if(outData.isNull())
|
if(outData.isNull())
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Size imageSize = Size((float)imageWidth, (float)imageHeight);
|
Size imageSize = Size((float)imageWidth, (float)imageHeight);
|
||||||
pixelFormat = convertDataToFormat(outData.getBytes(), imageWidth*imageHeight*4, PixelFormat::RGBA8888, pixelFormat, &outTempData, &outTempDataLen);
|
pixelFormat = convertDataToFormat(outData.getBytes(), imageWidth*imageHeight*4, PixelFormat::RGBA8888, pixelFormat, &outTempData, &outTempDataLen);
|
||||||
|
@ -1140,11 +1145,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
|
||||||
{
|
{
|
||||||
free(outTempData);
|
free(outTempData);
|
||||||
}
|
}
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
|
|
||||||
_hasPremultipliedAlpha = true;
|
|
||||||
#else
|
|
||||||
_hasPremultipliedAlpha = false;
|
|
||||||
#endif
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ public:
|
||||||
*/
|
*/
|
||||||
static void setAccelerometerInterval(float interval);
|
static void setAccelerometerInterval(float interval);
|
||||||
|
|
||||||
static Data getTextureDataForText(const char * text,const FontDefinition& textDefinition,TextAlign align,int &widht,int &height);
|
static Data getTextureDataForText(const char * text, const FontDefinition& textDefinition, TextAlign align, int &width, int &height, bool& hasPremultipliedAlpha);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_IMPLICIT_CONSTRUCTORS(Device);
|
CC_DISALLOW_IMPLICIT_CONSTRUCTORS(Device);
|
||||||
|
|
|
@ -167,7 +167,7 @@ static BitmapDC& sharedBitmapDC()
|
||||||
return s_BmpDC;
|
return s_BmpDC;
|
||||||
}
|
}
|
||||||
|
|
||||||
Data Device::getTextureDataForText(const char * text,const FontDefinition& textDefinition,TextAlign align,int &width,int &height)
|
Data Device::getTextureDataForText(const char * text, const FontDefinition& textDefinition, TextAlign align, int &width, int &height, bool& hasPremultipliedAlpha)
|
||||||
{
|
{
|
||||||
Data ret;
|
Data ret;
|
||||||
do
|
do
|
||||||
|
@ -196,6 +196,7 @@ Data Device::getTextureDataForText(const char * text,const FontDefinition& textD
|
||||||
width = dc._width;
|
width = dc._width;
|
||||||
height = dc._height;
|
height = dc._height;
|
||||||
ret.fastSet(dc._data,width * height * 4);
|
ret.fastSet(dc._data,width * height * 4);
|
||||||
|
hasPremultipliedAlpha = true;
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -452,7 +452,7 @@ static bool _initWithString(const char * text, cocos2d::Device::TextAlign align,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Data Device::getTextureDataForText(const char * text,const FontDefinition& textDefinition,TextAlign align,int &width,int &height)
|
Data Device::getTextureDataForText(const char * text, const FontDefinition& textDefinition, TextAlign align, int &width, int &height, bool& hasPremultipliedAlpha)
|
||||||
{
|
{
|
||||||
Data ret;
|
Data ret;
|
||||||
|
|
||||||
|
@ -481,6 +481,7 @@ Data Device::getTextureDataForText(const char * text,const FontDefinition& textD
|
||||||
height = (short)info.height;
|
height = (short)info.height;
|
||||||
width = (short)info.width;
|
width = (short)info.width;
|
||||||
ret.fastSet(info.data,width * height * 4);
|
ret.fastSet(info.data,width * height * 4);
|
||||||
|
hasPremultipliedAlpha = true;
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -480,7 +480,7 @@ static BitmapDC& sharedBitmapDC()
|
||||||
return s_BmpDC;
|
return s_BmpDC;
|
||||||
}
|
}
|
||||||
|
|
||||||
Data Device::getTextureDataForText(const char * text,const FontDefinition& textDefinition,TextAlign align,int &width,int &height)
|
Data Device::getTextureDataForText(const char * text, const FontDefinition& textDefinition, TextAlign align, int &width, int &height, bool& hasPremultipliedAlpha)
|
||||||
{
|
{
|
||||||
Data ret;
|
Data ret;
|
||||||
do
|
do
|
||||||
|
@ -493,6 +493,7 @@ Data Device::getTextureDataForText(const char * text,const FontDefinition& textD
|
||||||
height = dc.iMaxLineHeight;
|
height = dc.iMaxLineHeight;
|
||||||
dc.reset();
|
dc.reset();
|
||||||
ret.fastSet(dc._data,width * height * 4);
|
ret.fastSet(dc._data,width * height * 4);
|
||||||
|
hasPremultipliedAlpha = true;
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -224,7 +224,7 @@ static bool _initWithString(const char * text, Device::TextAlign align, const ch
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Data Device::getTextureDataForText(const char * text,const FontDefinition& textDefinition,TextAlign align,int &width,int &height)
|
Data Device::getTextureDataForText(const char * text, const FontDefinition& textDefinition, TextAlign align, int &width, int &height, bool& hasPremultipliedAlpha)
|
||||||
{
|
{
|
||||||
Data ret;
|
Data ret;
|
||||||
do {
|
do {
|
||||||
|
@ -239,6 +239,7 @@ Data Device::getTextureDataForText(const char * text,const FontDefinition& textD
|
||||||
height = (short)info.height;
|
height = (short)info.height;
|
||||||
width = (short)info.width;
|
width = (short)info.width;
|
||||||
ret.fastSet(info.data,width * height * 4);
|
ret.fastSet(info.data,width * height * 4);
|
||||||
|
hasPremultipliedAlpha = true;
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -377,7 +377,7 @@ static BitmapDC& sharedBitmapDC()
|
||||||
return s_BmpDC;
|
return s_BmpDC;
|
||||||
}
|
}
|
||||||
|
|
||||||
Data Device::getTextureDataForText(const char * text,const FontDefinition& textDefinition,TextAlign align,int &width,int &height)
|
Data Device::getTextureDataForText(const char * text, const FontDefinition& textDefinition, TextAlign align, int &width, int &height, bool& hasPremultipliedAlpha)
|
||||||
{
|
{
|
||||||
Data ret;
|
Data ret;
|
||||||
do
|
do
|
||||||
|
@ -429,7 +429,9 @@ Data Device::getTextureDataForText(const char * text,const FontDefinition& textD
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.fastSet(dataBuf,dataLen);
|
ret.fastSet(dataBuf,dataLen);
|
||||||
|
hasPremultipliedAlpha = false;
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ void Device::setAccelerometerInterval(float interval)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Data Device::getTextureDataForText(const char * text,const FontDefinition& textDefinition,TextAlign align,int &width,int &height)
|
Data Device::getTextureDataForText(const char * text, const FontDefinition& textDefinition, TextAlign align, int &width, int &height, bool& hasPremultipliedAlpha)
|
||||||
{
|
{
|
||||||
Data ret;
|
Data ret;
|
||||||
ssize_t dataLen;
|
ssize_t dataLen;
|
||||||
|
@ -157,6 +157,7 @@ Data Device::getTextureDataForText(const char * text,const FontDefinition& textD
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
ret.fastSet(data, dataLen);
|
ret.fastSet(data, dataLen);
|
||||||
|
hasPremultipliedAlpha = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue