cocos2d-x / cocos2dx-win8

102 stars 66 forks source link

Bug fix for text drawing on displays with ResolutionScale #13

Closed mingulov closed 12 years ago

mingulov commented 12 years ago

Sometime due to floating point accuracy problem - it was possible that the finally calculated metric for the text layout will be less than originally retrieved one.

Reproducible on the current cocos2dx-win8 master branch, on 10.6" 2560x1440 simulator (180% resolution scale) - for 'InputTextTest" label + some other labels.

For example: 1) text width (T) = 157.122391, ResolutionScale = 180 2) A = T * (180 / 100) (calculating size in pixels for the bitmap) 3) B = A / (180 / 100) (calculating size for the layout from bitmap size) B = 157.122335. Very small difference, but metrics provides the minimal size, so text will be incorrectly divided in 2 lines.

Fixed by using the originally received metrics, and re-calculating it when needed only.