Forum Libraries, Components, and Plugins

CCLabelTtf problem in new version 1.1.0.0 (IOS)

DomiBDomiB BEBeta, University ✭✭

Hi,

I've been playing with the new version and I've noticed that there's a problem with CCLabelTtf in it. First I thought it was because I was building the lib myself, but I can reproduce the problem with the Nuget package as well. I have this simple app built with the previous Nuget package (IOS, visual studio) and it displays a label and a sprite with this code :

var label = new CCLabelTtf("Tap This Label!", "arial", 22) { Position = VisibleBoundsWorldspace.Center + new CCPoint(0, ContentSize.Height/5), Color = CCColor3B.Green, HorizontalAlignment = CCTextAlignment.Center, VerticalAlignment = CCVerticalTextAlignment.Center, AnchorPoint = CCPoint.AnchorMiddle, Dimensions = ContentSize, }; AddChild(label);

        var sprite = new CCSprite("balls")
        {
            Position = VisibleBoundsWorldspace.Center,
            AnchorPoint = CCPoint.AnchorMiddle
        };`

With the previous nuget package it looks like the first attached screenshot.

If I remove the package reference and replace it with the new nuget & recompile I get the second attached screenshot. (in the scaled down version you might not see it but there is a very thin label line)

If I then set the scale of the label to 10 I get the third screenshot. So the label is still being drawn, but there is some funky distortion going on?

Dominique

Posts

  • DomiBDomiB BEBeta, University ✭✭

    It seems to be related to the 'Dimensions' property of the label. I was setting this to 'ContentSize'. Not setting Dimensions makes the problem go away. Setting the Dimension to something smaller than ContentSize (e.g. new CCSize(ContentSize.Width / 2, ContentSize.Height / 20) still shows the label scaled down, but less than when the label is as big as the screen. So it looks like setting the Dimensions scales the text of the label.

  • RamiTabbaraRamiTabbara AUMember, Xamarin Team Xamurai

    Hi Dominique,

    Yes, setting the Dimensions property is to force a particular bounds on the label. However, if you're after the natural Dimensions that are dictated by the font size then there is no need to manually set this property.

  • DomiBDomiB BEBeta, University ✭✭

    Thanks for the reply.

    I was expecting the Dimensions to constraint the label size, but I wasn't expecting it to affect the scale. (especially not scaling down when sizing up :-) )

    Ok, so setting Dimensions makes the text scale. So what would I do if I'd need to limit the label's region, clipping it to a max rectangle? (e.g. if the text is dynamic)

    Also, setting the Dimension to ContentSize is actually something I copied from the GoneBananas walkthrough, so that should be fixed...

  • kjpou1kjpou1 LUMember, Xamarin Team Xamurai

    @DominiqueBiesmans‌

    Have a look at the following FontTest source. I think this is doing what you are asking to do.

Sign In or Register to comment.