System.Drawing.Drawing2D.GraphicsPath.buildAttributedString C# (CSharp) Method

buildAttributedString() private static method

private static buildAttributedString ( string text, Font font, Color fontColor = null ) : NSMutableAttributedString
text string
font Font
fontColor Color
return NSMutableAttributedString
        private static NSMutableAttributedString buildAttributedString(string text, Font font, 
		                                                        Color? fontColor=null)
        {
            // Create a new attributed string definition
            var ctAttributes = new CTStringAttributes ();

            // Font attribute
            ctAttributes.Font = font.nativeFont;
            // -- end font

            if (fontColor.HasValue) {

                // Font color
                var fc = fontColor.Value;
                var cgColor = new CGColor(fc.R / 255f,
                                          fc.G / 255f,
                                          fc.B / 255f,
                                          fc.A / 255f);

                ctAttributes.ForegroundColor = cgColor;
                ctAttributes.ForegroundColorFromContext = false;
                // -- end font Color
            }

            if (font.Underline) {
                // Underline
            #if MONOMAC
                int single = (int)AppKit.NSUnderlineStyle.Single;
                int solid = (int)AppKit.NSUnderlinePattern.Solid;
                var attss = single | solid;
                ctAttributes.UnderlineStyleValue = attss;
            #else
                ctAttributes.UnderlineStyleValue = 1;
            #endif
                // --- end underline
            }

            if (font.Strikeout) {
                // StrikeThrough
                //				NSColor bcolor = NSColor.Blue;
                //				NSObject bcolorObject = new NSObject(bcolor.Handle);
                //				attsDic.Add(NSAttributedString.StrikethroughColorAttributeName, bcolorObject);
                //				#if MACOS
                //				int stsingle = (int)MonoMac.AppKit.NSUnderlineStyle.Single;
                //				int stsolid = (int)MonoMac.AppKit.NSUnderlinePattern.Solid;
                //				var stattss = stsingle | stsolid;
                //				var stunderlineObject = NSNumber.FromInt32(stattss);
                //				#else
                //				var stunderlineObject = NSNumber.FromInt32 (1);
                //				#endif
                //
                //				attsDic.Add(StrikethroughStyleAttributeName, stunderlineObject);
                // --- end underline
            }

            // Text alignment
            var alignment = CTTextAlignment.Left;
            var alignmentSettings = new CTParagraphStyleSettings();
            alignmentSettings.Alignment = alignment;
            var paragraphStyle = new CTParagraphStyle(alignmentSettings);

            ctAttributes.ParagraphStyle = paragraphStyle;
            // end text alignment

            NSMutableAttributedString atts =
                new NSMutableAttributedString(text,ctAttributes.Dictionary);

            return atts;
        }