issue #5277:Label:It could be possible that for using outline and invoking 'Director::setContentScaleFactor' cause label show nothing.

This commit is contained in:
Dhilan007 2014-05-21 14:08:30 +08:00
parent ac258439b0
commit d13ed93fc1
2 changed files with 8 additions and 7 deletions

View File

@ -102,9 +102,10 @@ FontFreeType::FontFreeType(bool distanceFieldEnabled /* = false */,int outline /
{ {
if (_outlineSize > 0) if (_outlineSize > 0)
{ {
_outlineSize *= CC_CONTENT_SCALE_FACTOR();
FT_Stroker_New(FontFreeType::getFTLibrary(), &_stroker); FT_Stroker_New(FontFreeType::getFTLibrary(), &_stroker);
FT_Stroker_Set(_stroker, FT_Stroker_Set(_stroker,
(int)(_outlineSize * 64 * CC_CONTENT_SCALE_FACTOR()), (int)(_outlineSize * 64),
FT_STROKER_LINECAP_ROUND, FT_STROKER_LINECAP_ROUND,
FT_STROKER_LINEJOIN_ROUND, FT_STROKER_LINEJOIN_ROUND,
0); 0);
@ -305,8 +306,8 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid
auto blendImage = new unsigned char[blendWidth * blendHeight * 2]; auto blendImage = new unsigned char[blendWidth * blendHeight * 2];
memset(blendImage, 0, blendWidth * blendHeight * 2); memset(blendImage, 0, blendWidth * blendHeight * 2);
int px = blendWidth == outlineWidth ? 0 : _outlineSize; int px = (blendWidth - outlineWidth) / 2;
int py = blendHeight == outlineHeight ? 0 : _outlineSize; int py = (blendHeight - outlineHeight) / 2;
for (int x = 0; x < outlineWidth; ++x) for (int x = 0; x < outlineWidth; ++x)
{ {
for (int y = 0; y < outlineHeight; ++y) for (int y = 0; y < outlineHeight; ++y)
@ -317,8 +318,8 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid
} }
} }
px = blendWidth == outWidth ? 0 : _outlineSize; px = (blendWidth - outWidth) / 2;
py = blendHeight == outHeight ? 0 : _outlineSize; py = (blendHeight - outHeight) / 2;
for (int x = 0; x < outWidth; ++x) for (int x = 0; x < outWidth; ++x)
{ {
for (int y = 0; y < outHeight; ++y) for (int y = 0; y < outHeight; ++y)

View File

@ -58,7 +58,7 @@ public:
static void shutdownFreeType(); static void shutdownFreeType();
bool isDistanceFieldEnabled() const { return _distanceFieldEnabled;} bool isDistanceFieldEnabled() const { return _distanceFieldEnabled;}
int getOutlineSize() const { return _outlineSize; } float getOutlineSize() const { return _outlineSize; }
void renderCharAt(unsigned char *dest,int posX, int posY, unsigned char* bitmap,long bitmapWidth,long bitmapHeight); void renderCharAt(unsigned char *dest,int posX, int posY, unsigned char* bitmap,long bitmapWidth,long bitmapHeight);
virtual FontAtlas * createFontAtlas() override; virtual FontAtlas * createFontAtlas() override;
@ -89,7 +89,7 @@ private:
FT_Stroker _stroker; FT_Stroker _stroker;
std::string _fontName; std::string _fontName;
bool _distanceFieldEnabled; bool _distanceFieldEnabled;
int _outlineSize; float _outlineSize;
}; };
NS_CC_END NS_CC_END