twitter/twui — Issue #86: TUIAttributtedString: CTParagraphStyle not kept
Author: erndev
Created: 2011-12-04 16:28:35+00:00
State: open

I am using a TUIAttributted string, and i found a problem. When i set the lineheight, the Alignment/linebreak properties was ignored, and the text is drawn using the default properties.

I located the problem in these functions:

- (void)setLineHeight:(CGFloat)f inRange:(NSRange)range
- (void)setAlignment:(TUITextAlignment)alignment lineBreakMode:(TUILineBreakMode)lineBreakMode

In those methods, a new CTParagraphStyle object is created, but each method only sets the values for the values received, ignoring the values previously set.

The solution would be to recreate the CTParagrahStyleRef object with all the expected properties.
I could fix it, but my doubt is how to implement it .
The easiest way seemed to keep ivars for those values and recreate the CTParagraphStyle object, but currently, those methods belong to the NSMutableAttributedString (TUIAdditions) category, and categories cannot have ivars.

I can see other two options:
- Moving those methods to the TUIAttributtedString class, and adding ivars for those values.
- Reading current CTParagrahStyleRef and changing only the modified values, but i think this solution is worse.

any suggestion?