@@ -663,7 +663,7 @@ void Label::reset()
663
663
_lineDrawNode = nullptr ;
664
664
}
665
665
_strikethroughEnabled = false ;
666
- _underlineEnabled = false ;
666
+ _underlineEnabled = false ;
667
667
setRotationSkewX (0 ); // reverse italics
668
668
}
669
669
@@ -1067,9 +1067,11 @@ void Label::updateLabelLetters()
1067
1067
letterSprite->setAtlasIndex (_lettersInfo[letterIndex].atlasIndex );
1068
1068
}
1069
1069
1070
- auto px = letterInfo.positionX + letterDef.width / 2 + _linesOffsetX[letterInfo.lineIndex ];
1071
- auto py = letterInfo.positionY - letterDef.height / 2 + _letterOffsetY;
1070
+ auto px =
1071
+ letterInfo.positionX + _fontScale * uvRect.size .width / 2 + _linesOffsetX[letterInfo.lineIndex ];
1072
+ auto py = letterInfo.positionY - _fontScale * uvRect.size .height / 2 + _letterOffsetY;
1072
1073
letterSprite->setPosition (px, py);
1074
+ letterSprite->setOpacity (_realOpacity);
1073
1075
}
1074
1076
else
1075
1077
{
@@ -1507,7 +1509,7 @@ void Label::enableUnderline()
1507
1509
_lineDrawNode->setGlobalZOrder (getGlobalZOrder ());
1508
1510
_lineDrawNode->setOpacity (_displayedOpacity);
1509
1511
_lineDrawNode->properties .setFactor (_lineDrawNode->properties .getFactor () *
1510
- 2 .0f ); // 2.0f: Makes the line smaller
1512
+ 2 .0f ); // 2.0f: Makes the line smaller
1511
1513
addChild (_lineDrawNode, 100000 );
1512
1514
}
1513
1515
}
@@ -1526,8 +1528,8 @@ void Label::enableStrikethrough()
1526
1528
_lineDrawNode->setGlobalZOrder (getGlobalZOrder ());
1527
1529
_lineDrawNode->setOpacity (_displayedOpacity);
1528
1530
_lineDrawNode->properties .setFactor (_lineDrawNode->properties .getFactor () *
1529
- 2 .0f ); // 2.0f: Makes the line smaller
1530
- addChild (_lineDrawNode, 100000 );
1531
+ 2 .0f ); // 2.0f: Makes the line smaller
1532
+ addChild (_lineDrawNode, 100000 );
1531
1533
}
1532
1534
}
1533
1535
@@ -1811,12 +1813,13 @@ void Label::updateContent()
1811
1813
nextY -= lineHeight + lineSpacing;
1812
1814
}
1813
1815
}
1814
- else if (_textSprite) // ...and is the logic for System fonts
1816
+ else if (_textSprite) // ...and is the logic for System fonts
1815
1817
{
1816
1818
computeStringNumLines ();
1817
1819
const auto spriteSize = _textSprite->getContentSize ();
1818
1820
1819
- // FIXME: system fonts don't report the height of the font correctly. only the size of the texture, which is POT
1821
+ // FIXME: system fonts don't report the height of the font correctly. only the size of the texture, which is
1822
+ // POT
1820
1823
// FIXME: Might not work with different vertical alignments
1821
1824
const auto lineSize = spriteSize.height / static_cast <float >(_numberOfLines);
1822
1825
const auto thickness = std::max (std::ceil (lineSize * 0 .12f * 2 ) / 2 .f , 2 .f );
@@ -1832,9 +1835,9 @@ void Label::updateContent()
1832
1835
}
1833
1836
1834
1837
if (_strikethroughEnabled)
1835
- {
1838
+ {
1836
1839
const auto baseY = lineSize - lineSize / 2 ;
1837
-
1840
+
1838
1841
for (int i = 0 ; i < _numberOfLines; ++i)
1839
1842
{
1840
1843
float y = baseY + lineSize * i;
@@ -2495,8 +2498,8 @@ void Label::setTextColor(const Color4B& color)
2495
2498
_textColorF.a = _textColor.a / 255 .0f ;
2496
2499
2497
2500
// System font and TTF using setColor for Outline/Glow!");
2498
- if (_currentLabelType != LabelType::TTF && _currentLabelType != LabelType::STRING_TEXTURE)
2499
- setColor (Color3B (color));
2501
+ if (_currentLabelType != LabelType::TTF && _currentLabelType != LabelType::STRING_TEXTURE)
2502
+ setColor (Color3B (color));
2500
2503
}
2501
2504
2502
2505
void Label::updateColor ()
@@ -2968,7 +2971,7 @@ bool Label::multilineTextWrap(bool breakOnChar, bool ignoreOverflow)
2968
2971
{
2969
2972
recordPlaceholderInfo (letterIndex, character);
2970
2973
AXLOGW (" LabelTextFormatter error: can't find letter definition in font file for letter: 0x{:x}" ,
2971
- static_cast <uint32_t >(character));
2974
+ static_cast <uint32_t >(character));
2972
2975
continue ;
2973
2976
}
2974
2977
@@ -3015,7 +3018,7 @@ bool Label::multilineTextWrap(bool breakOnChar, bool ignoreOverflow)
3015
3018
nextChangeSize = true ;
3016
3019
3017
3020
tokenHighestY = std::max (tokenHighestY, letterPosition.y );
3018
- tokenLowestY = std::min (tokenLowestY, letterPosition.y - letterDef.height * _fontScale);
3021
+ tokenLowestY = std::min (tokenLowestY, letterPosition.y - letterDef.height * _fontScale);
3019
3022
}
3020
3023
3021
3024
if (newLine)
@@ -3025,8 +3028,8 @@ bool Label::multilineTextWrap(bool breakOnChar, bool ignoreOverflow)
3025
3028
3026
3029
nextTokenX = nextLetterX;
3027
3030
letterRight = tokenRight;
3028
- highestY = std::max (highestY, tokenHighestY);
3029
- lowestY = std::min (lowestY, tokenLowestY);
3031
+ highestY = std::max (highestY, tokenHighestY);
3032
+ lowestY = std::min (lowestY, tokenLowestY);
3030
3033
3031
3034
index += tokenLen;
3032
3035
}
@@ -3134,18 +3137,23 @@ bool Label::isHorizontalClamp()
3134
3137
return letterClamp;
3135
3138
}
3136
3139
3137
- void Label::recordLetterInfo (const ax::Vec2& point, char32_t utf32Char, int letterIndex, int lineIndex, float offsetX, float offsetY)
3140
+ void Label::recordLetterInfo (const ax::Vec2& point,
3141
+ char32_t utf32Char,
3142
+ int letterIndex,
3143
+ int lineIndex,
3144
+ float offsetX,
3145
+ float offsetY)
3138
3146
{
3139
3147
if (static_cast <std::size_t >(letterIndex) >= _lettersInfo.size ())
3140
3148
{
3141
3149
LetterInfo tmpInfo;
3142
3150
_lettersInfo.emplace_back (tmpInfo);
3143
3151
}
3144
- _lettersInfo[letterIndex].lineIndex = lineIndex;
3145
- _lettersInfo[letterIndex].utf32Char = utf32Char;
3146
- _lettersInfo[letterIndex].valid = _fontAtlas->_letterDefinitions [utf32Char].validDefinition && utf32Char != ' ' ;
3147
- _lettersInfo[letterIndex].positionX = point.x ;
3148
- _lettersInfo[letterIndex].positionY = point.y ;
3152
+ _lettersInfo[letterIndex].lineIndex = lineIndex;
3153
+ _lettersInfo[letterIndex].utf32Char = utf32Char;
3154
+ _lettersInfo[letterIndex].valid = _fontAtlas->_letterDefinitions [utf32Char].validDefinition && utf32Char != ' ' ;
3155
+ _lettersInfo[letterIndex].positionX = point.x ;
3156
+ _lettersInfo[letterIndex].positionY = point.y ;
3149
3157
_lettersInfo[letterIndex].atlasIndex = -1 ;
3150
3158
_lettersInfo[letterIndex].offsetX = offsetX;
3151
3159
_lettersInfo[letterIndex].offsetY = offsetY;
@@ -3162,4 +3170,4 @@ void Label::recordPlaceholderInfo(int letterIndex, char32_t utf32Char)
3162
3170
_lettersInfo[letterIndex].valid = false ;
3163
3171
}
3164
3172
3165
- }
3173
+ } // namespace ax
0 commit comments