{"id":274,"date":"2017-04-04T08:36:35","date_gmt":"2017-04-04T08:36:35","guid":{"rendered":"http:\/\/ootips.org\/yonat\/?p=274"},"modified":"2022-04-10T12:03:14","modified_gmt":"2022-04-10T12:03:14","slug":"bold-part-of-an-nsattributedstring-without-changing-the-font","status":"publish","type":"post","link":"https:\/\/ootips.org\/yonat\/bold-part-of-an-nsattributedstring-without-changing-the-font\/","title":{"rendered":"Bold part of an NSAttributedString without changing the font"},"content":{"rendered":"<p>If you bold by changing the `NSFontAttributeName` you&#8217;ll have to specify the font face. If you don&#8217;t want to change the font face, use the `NSStrokeWidthAttributeName` with a negative value:<\/p>\n<pre class=\"lang:swift decode:true\">let s = NSMutableAttributedString(string: \"Text with some bold part\")\ns.addAttribute(.strokeWidth, value: NSNumber(value: -3.0), range: NSRange(15..&lt;20))\n<\/pre>\n<p>Result:<\/p>\n<blockquote><p>Text with some <b>bold<\/b> part<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>If you bold by changing the `NSFontAttributeName` you&#8217;ll have to specify the font face. If you don&#8217;t want to change the font face, use the `NSStrokeWidthAttributeName` with a negative value: let s = NSMutableAttributedString(string: &#8220;Text with some bold part&#8221;) s.addAttribute(.strokeWidth, &hellip; <a href=\"https:\/\/ootips.org\/yonat\/bold-part-of-an-nsattributedstring-without-changing-the-font\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[1],"tags":[18,7,6,21,14,17],"class_list":["post-274","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-cocoa","tag-ios","tag-iphone","tag-nsattributedstring","tag-sample-code","tag-swift"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2aEUP-4q","_links":{"self":[{"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/posts\/274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/comments?post=274"}],"version-history":[{"count":7,"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/posts\/274\/revisions"}],"predecessor-version":[{"id":399,"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/posts\/274\/revisions\/399"}],"wp:attachment":[{"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/media?parent=274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/categories?post=274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ootips.org\/yonat\/wp-json\/wp\/v2\/tags?post=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}