Bug 8940 - NSMutableAttributedString ParagraphStyle property doesn't work
Summary: NSMutableAttributedString ParagraphStyle property doesn't work
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 6.0.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-12-14 11:04 UTC by Maxim
Modified: 2012-12-17 03:28 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Maxim 2012-12-14 11:04:11 UTC
Base Obj-C code:
CGFloat leading = 25.0;
CTTextAlignment alignment = kCTRightTextAlignment; // just for test purposes
const CTParagraphStyleSetting styleSettings[] = {
    {kCTParagraphStyleSpecifierLineSpacingAdjustment, sizeof(CGFloat), &leading},
    {kCTParagraphStyleSpecifierAlignment, sizeof(CTTextAlignment), &alignment}
CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(styleSettings, 2));
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
                            (id)ctFont, (id)kCTFontAttributeName,
                            (id)cgColor, (id)kCTForegroundColorAttributeName,
                            (id)paragraphStyle, (id)kCTParagraphStyleAttributeName,

NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] 

Our C# code:
var attributes = new CTStringAttributes();
            attributes.Font = new CTFont(base.Font.Name, base.Font.PointSize);
            attributes.ForegroundColor = base.TextColor.CGColor;

            var pt = new CTParagraphStyleSettings();
            pt.LineSpacingAdjustment = 40;
            pt.Alignment = CTTextAlignment.Right;
            pt.BaseWritingDirection = CTWritingDirection.RightToLeft;
            attributes.ParagraphStyle = new CTParagraphStyle();

var attrStr = new NSAttributedString(base.Text, attributes);

This code should make attributed string with specified line spacing, but in MonoTouch it doesn't work. It seems that NSAttributedString ignores CTStringAttributes.ParagraphStyle.
Comment 1 Maxim 2012-12-14 11:06:02 UTC
* Code
    pt.BaseWritingDirection = CTWritingDirection.RightToLeft;
is not important.
Comment 2 Rolf Bjarne Kvinge [MSFT] 2012-12-14 18:04:35 UTC
You're not passing 'pt' to the CTParagraphStyle ctor.
Comment 3 Maxim 2012-12-17 03:28:50 UTC
Shame on me.