User Tag List

Results 1 to 6 of 6

Thread: [BUG 256.34] Calculate Text Rect gives crazy values on iOS (fine on PC)

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [BUG 256.34] Calculate Text Rect gives crazy values on iOS (fine on PC)

    Not sure if this is a new thing with one of the Betas as I haven't used the Calculate Text Rect object before.

    Basically works as it should on PC, but just gives values in the millions on iOS (and they can keep changing even when the text it is calculating doesn't, perhaps they're pointing to random memory somehow?)
    I've included a simple example file for others to try requires the Calculate Text Rect object.

    Maybe it's just my system: using XCode 4.3.3 on OSX Lion and iPod touch 4G iOS 5.1.1

    I'd love to get a fix for this soon, as I can't see any other way to calculate size of text.
    Thanks!
    Attached files Attached files

  2. #2
    Clickteam Clickteam
    Anders's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Århus
    Posts
    3,456
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)
    Thanks, will look into it

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anders - Thanks!

    After a bit of digging it looks like there have been some changes to CServices.m in one of the more recent betas/releases, in particular the drawText routine and I don't think the calcRect has been taken into account (since 3rd party extension).

    I've found that this couple of changes to calcRect help get the correct height, but not width:

    Code:
    -(void)CalcRect
    {
    	// CRect rc;
    	CRect rc=CRectNil(); //This gives slightly better values, not huge (but still wrong)
        rc.right=maxWidth; //This gives correct height but width is always maxWidth
    Hopefully it will save you a bit of time

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anders - Just wondering if there's any update on this (I haven't seen a fix mentioned in any of the Betas)?

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleUnicode Add-on
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    AyreGuitar's Avatar
    Join Date
    Jan 2011
    Location
    Wales, UK
    Posts
    1,113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anders - Anything? I'd fix this myself if I could figure out how!

  6. #6
    Clickteam Clickteam
    Anders's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Århus
    Posts
    3,456
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)
    Ah, sorry I must have missed your reply here.

    This bug is fixed and will be in the next patch.

    You can replace the method "CalcRect" in the CRunCalcRect extension with this code snippet:

    Code:
    -(void)CalcRect
    {
    	//Font
    	CFontInfo* fontInfo = [[CFontInfo alloc] init];
    	fontInfo->lfFaceName = [[NSString alloc] initWithString:fontName];
    	fontInfo->lfHeight = fontHeight;
    	fontInfo->lfItalic = (unsigned char)(fontItalic ? 1 : 0);
    	fontInfo->lfUnderline = (unsigned char) (fontUnderline ? 1 : 0);
    	CFont* font=[CFont createFromFontInfo:fontInfo];
    
    	//Size
    	CGSize size = [text sizeWithFont:[font createFont] constrainedToSize:CGSizeMake(maxWidth, 100000) lineBreakMode:0];
    	calcWidth = (int)size.width;
    	calcHeight = (int)size.height;
    
    	[fontInfo release];
    	[font release];
    }

Similar Threads

  1. Calculate Text Rect. Object
    By Bipolar_Games in forum Android Export Module Version 2.0
    Replies: 12
    Last Post: 4th March 2016, 03:06 PM
  2. Calc text rect object
    By richardh in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 1st July 2012, 05:17 PM
  3. Date & Time and Calculate Text Rect
    By Fanotherpg in forum XNA Export Module Version 2.0
    Replies: 2
    Last Post: 15th May 2011, 04:25 PM
  4. [Request] Object similar to Text Rect
    By Dines in forum Extension Development
    Replies: 2
    Last Post: 14th January 2008, 03:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •