Cocos2DXNA / cocos2d-xna

XNA Port of Cocos2d-X
www.cocos2dxna.com
226 stars 123 forks source link

CCLabelTTF does not work right with CCDirector.SharedDirector.ContentScaleFactor #410

Closed grishaandrianov closed 10 years ago

grishaandrianov commented 10 years ago

I think there is a bug in the CCLabelTTF class:

https://github.com/Cocos2DXNA/cocos2d-xna/blob/master/cocos2d/label_nodes/CCLabelTTF.cs#L245

    private void updateTexture()
    {
        CCTexture2D tex;

        // Dump the old one
        if (Texture != null)
        {
            Texture.Dispose();
        }

        // let system compute label's width or height when its value is 0
        // refer to cocos2d-x issue #1430
        tex = new CCTexture2D();

        var result = tex.InitWithString(m_pString,
                           m_tDimensions.PointsToPixels(),
                           m_hAlignment,
                           m_vAlignment,
                           m_pFontName,
                           m_fFontSize * CCMacros.CCContentScaleFactor());

(last one line)

If I have for example CCLabelTFF with font size 50 (and arial-50.spritefont (or xnb) for this label) and I have CCContentScaleFactor = 2.22f, then m_fFontSize * CCMacros.CCContentScaleFactor() = 111, then I need arial-111.spritefont. But this is not good. I think it should work by the other way.

totallyeviljake commented 10 years ago

Here was @gena-m response to this issue:

https://cocos2dxna.codeplex.com/discussions/543902#post1240163