RTL LTR Attributed String Addition Requested


#1

I added some code in juce_mac_Fonts.mm to handle the reading direction from an AttributedString.

Would it be possible to put this into the code base?  

In  static CFAttributedStringRef createCFAttributedString (const AttributedString& text) the following was added.

 

  CTWritingDirection ctWritingDirection = kCTWritingDirectionNatural;

        switch (text.getReadingDirection()){

            case AttributedString::ReadingDirection::natural: break;

            case AttributedString::ReadingDirection::rightToLeft:  ctWritingDirection = kCTWritingDirectionRightToLeft;  break;

            case AttributedString::ReadingDirection::leftToRight:  ctWritingDirection = kCTWritingDirectionLeftToRight;  break;

        }


        CTParagraphStyleSetting settings[] =

        {

            { kCTParagraphStyleSpecifierAlignment,              sizeof (CTTextAlignment), &ctTextAlignment },

            { kCTParagraphStyleSpecifierLineBreakMode,          sizeof (CTLineBreakMode), &ctLineBreakMode },

            { kCTParagraphStyleSpecifierBaseWritingDirection,   sizeof (CTWritingDirection), &ctWritingDirection},

            

           #if defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7

            { kCTParagraphStyleSpecifierLineSpacingAdjustment,  sizeof (CGFloat),         &ctLineSpacing }

           #else

            { kCTParagraphStyleSpecifierLineSpacing,            sizeof (CGFloat),         &ctLineSpacing }

           #endif

        };

Thanks,

Darren

 


#2

Thanks, sounds like a sensible addition, I'll take a look at that today!


#3

Hello,

In juce_max_Fonts.mm, could this be changed to:

    static CTWritingDirection getWritingDirection (const AttributedString& text)
    {
        switch (text.getReadingDirection())
        {
            case AttributedString::rightToLeft:   return kCTWritingDirectionRightToLeft;
            case AttributedString::leftToRight:   return kCTWritingDirectionLeftToRight;
            default:                              return kCTWritingDirectionNatural;
        }
    }

Removing  "::ReadingDirection"  ?

This is only thing that prevents building on Mac with less than C++11 (and consistent with the other use of enums).

Best,

Martin


#4

Sure, will do, thanks Martin!