Search code examples
ioscocos2d-iphone

cocos2d: since iOS 7.1 the haligment of CCLabelTTF broken when i switch my phone to hebrew


since iOS 7.1 i have the haligment of CCLabelTTF broken when i switch my phone to hebrew. (it's always aligned to the right no matter what) When my phone is in english it's working fine.


Solution

  • I fixed it by changing:

    [string drawInRect:drawArea withFont:uifont lineBreakMode:linebreaks[lineBreakMode] alignment:alignments[hAlignment]];
    

    in CCtexture2D.m

    to:

    /// Make a copy of the default paragraph style
    NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
    /// Set line break mode
    paragraphStyle.lineBreakMode = linebreaks[lineBreakMode];
    /// Set text alignment
    paragraphStyle.alignment = alignments[hAlignment];
    
    NSDictionary *attributes = @{ NSFontAttributeName: uifont,
                                  NSParagraphStyleAttributeName: paragraphStyle,
                                  NSForegroundColorAttributeName:[UIColor colorWithRed:255
                                                                                 green:255
                                                                                  blue:255
                                                                                 alpha:1.0f]
    
                                  };
    
    [string drawInRect:drawArea withAttributes:attributes];