<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Mick F</title><description>Notes for myself and fellow programmers, with a focus on iOS, Swift and web frontend development. Since 2009.</description><link>https://www.mickf.net/tech/</link><item><title>Pixel-Perfect Line Height With UIKit</title><link>https://www.mickf.net/tech/line-height-with-uikit/</link><guid isPermaLink="true">https://www.mickf.net/tech/line-height-with-uikit/</guid><description>In this post, I will show you my attempts to render a card component exactly as it was designed, and why it might be worth negotiating an approximation with a smaller footprint.</description><pubDate>Thu, 04 Feb 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;According to Matthew Butterick, the author of the excellent &lt;a href=&quot;https://practicaltypography.com/&quot;&gt;&lt;em&gt;Practical
Typography&lt;/em&gt;&lt;/a&gt;, the &lt;a href=&quot;https://practicaltypography.com/summary-of-key-rules.html&quot;&gt;number one key rule&lt;/a&gt; of good typography is:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The four most important typographic considerations for body text are &lt;em&gt;point
size&lt;/em&gt;, &lt;em&gt;line spacing&lt;/em&gt;, &lt;em&gt;line length&lt;/em&gt;, and &lt;em&gt;font&lt;/em&gt;, because those choices
determine how the body text looks.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;While point sizes, line lengths and fonts are easy to control with UIKit, line
spacing is a little trickier.&lt;/p&gt;
&lt;p&gt;In this article, I will first describe in detail a clever helper to meet
challenging line spacing requirements with pixel-perfect precision. Your design
team will love you.&lt;/p&gt;
&lt;p&gt;I will then explain why I actually wouldn’t recommend implementing the solution
for every context, and instead provide a much sturdier &lt;em&gt;pixel-pretty-close&lt;/em&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-5&quot; id=&quot;user-content-fnref-5&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;
alternative. Your design team will still love you. I promise.&lt;/p&gt;
&lt;p&gt;Let’s dive in.&lt;/p&gt;
&lt;h2 id=&quot;the-designer-input&quot;&gt;The Designer Input&lt;/h2&gt;
&lt;p&gt;Say our design team gives us the following specs for a &lt;strong&gt;card&lt;/strong&gt; view component:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;title&lt;/strong&gt; with a point size of 28pt and a line height of 38pt&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;body&lt;/strong&gt; with a point size of 17pt and a line height of 24pt&lt;/li&gt;
&lt;li&gt;Both the title and body are 8pt apart on the Y-axis, and 8pt away from the
edges of the card on the X-axis.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The export from Sketch looks like this&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;The card as designed by the design team.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;375&quot; width=&quot;375&quot; height=&quot;182&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fcard-as-designed.2rb5-5vE.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;And here is a version with colored backgrounds for labels, to better understand
the layout and where line heights should be considered:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;The card as designed by the design team, with boxes for better understanding of the structure.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;375&quot; width=&quot;375&quot; height=&quot;182&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fcard-as-designed-with-boxes.BJhqYNF3.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Next, we will iterate to reach a pixel-perfect translation of this design into
UIKit code.&lt;/p&gt;
&lt;h2 id=&quot;step-1-laying-out-the-labels&quot;&gt;Step 1: Laying out the labels&lt;/h2&gt;
&lt;p&gt;Let’s head over to a playground, create our 2 labels and position them with auto
layout with the following constraints:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;NSLayoutConstraint.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;activate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;([&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    // X-avis: 8pt padding between card and title:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    titleLabel.leadingAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalToSystemSpacingAfter&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: view.safeAreaLayoutGuide.leadingAnchor, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;multiplier&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1.0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    titleLabel.centerXAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: view.safeAreaLayoutGuide.centerXAnchor),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    // Y-axis: 8pt padding between card and title: ⚠️&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    titleLabel.topAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalToSystemSpacingBelow&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: view.safeAreaLayoutGuide.topAnchor, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;multiplier&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1.0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    // Y-axis: 8pt padding between title and label:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    bodyLabel.firstBaselineAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalToSystemSpacingBelow&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: titleLabel.lastBaselineAnchor, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;multiplier&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1.0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    bodyLabel.leadingAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: titleLabel.leadingAnchor),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    bodyLabel.trailingAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: titleLabel.trailingAnchor)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;])&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you noticed this little warning in the comment ⚠️, bear with me: we will
address it further down.&lt;/p&gt;
&lt;p&gt;We haven’t written any code related to the line height just yet, but for the
sake of getting an idea of where we are at this point, here is a &lt;em&gt;ghost
snapshot&lt;/em&gt; of what our view looks like if we place the Sketch design, with a low
opacity, below our labels:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Pixel-wise comparison of the Sketch design and iOS view after Step 1.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;375&quot; width=&quot;375&quot; height=&quot;182&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fcard-step-1.D-zxr8Z9.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;step-2-adding-some-paragraph-style&quot;&gt;Step 2: Adding some paragraph style&lt;/h2&gt;
&lt;p&gt;Now, let’s address the line spacing.&lt;/p&gt;
&lt;p&gt;The most standard approach to add line spacing is to use &lt;a href=&quot;https://developer.apple.com/documentation/uikit/uilabel/1620542-attributedtext&quot;&gt;&lt;code&gt;UILabel&lt;/code&gt;’s
&lt;code&gt;attributedText&lt;/code&gt;&lt;/a&gt; instead of the simpler &lt;code&gt;text&lt;/code&gt; attribute:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; attributedString &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; NSMutableAttributedString&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: bodyText)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// See the reason behind this substraction below&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; lineSpacing &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 24.0&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; res.font.lineHeight&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; paragraphStyle &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; NSMutableParagraphStyle&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;paragraphStyle.lineSpacing &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; lineSpacing&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;attributedString.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;addAttribute&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    .paragraphStyle,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    value&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: paragraphStyle,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    range&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSRange&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;location&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: attributedString.length)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;res.attributedText &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; attributedString&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here we create an attributed string with a paragraph style attribute. It can
control the &lt;em&gt;line spacing&lt;/em&gt;, ie the numbers of points between two lines of text
that should be added, or subtracted, to the default layout using the font
metrics&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
&lt;p&gt;The line spacing is the difference between the line height &lt;em&gt;of the design&lt;/em&gt; and
the line height &lt;em&gt;of the font being used&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;With line spacing added to both the title and the body labels, our &lt;em&gt;ghost
snapshot&lt;/em&gt; now looks like this.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Pixel-wise comparison of the Sketch design and iOS view after Step 2.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;375&quot; width=&quot;375&quot; height=&quot;182&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fcard-step-2.D0UuKh4b.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;A little better but not quite great yet. While the body text line spacing
appears to be in line with the requirements from the design team — in the sense
that it looks just a little translated upwards — the card is still far from a
pixel-perfect result. What is going on?&lt;/p&gt;
&lt;p&gt;The paragraph style’s line spacing contributes to the &lt;strong&gt;inner&lt;/strong&gt; part of the line
height on a given paragraph — so, effectively, on strings spanning on more than
1 line which, in our example, is the body only. However, the labels don’t apply
the necessary extra &lt;strong&gt;outer&lt;/strong&gt; part of the line height.&lt;/p&gt;
&lt;h2 id=&quot;step-3-applying-outer-padding&quot;&gt;Step 3: Applying outer-padding&lt;/h2&gt;
&lt;p&gt;To meet our pixel-perfect superposition objective, we need to apply some extra
Y-axis &lt;strong&gt;padding&lt;/strong&gt;&lt;sup&gt;&lt;a href=&quot;#user-content-fn-3&quot; id=&quot;user-content-fnref-3&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;4&lt;/a&gt;&lt;/sup&gt; to our labels. Unfortunately, if we want to stay in the
peaceful UIKit realm and not cross the border to scary &lt;a href=&quot;https://developer.apple.com/documentation/coretext&quot;&gt;Core Text&lt;/a&gt; territory,
we need to wrap our labels with a view that will be in charge of this extra
padding.&lt;/p&gt;
&lt;p&gt;I’ll spare you the steps and repetition of code to fast forward to a convenient
&lt;code&gt;UIView&lt;/code&gt; helper subclass that will do the job:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;/// Let&apos;s keep font metrics and line height metrics together.s&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;struct&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; TextStyle&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; font: UIFont&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; lineHeight: CGFloat&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; LineHeightedLabel&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;UIView &lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;textStyle&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: TextStyle) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.wrappedLabel &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; UILabel&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.textStyle &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; textStyle&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        super&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;frame&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .zero)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        translatesAutoresizingMaskIntoConstraints &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; false&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        setupViewAndConstraints&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        setText&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: text)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    @available&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;unavailable&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    required&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; init?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;coder&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; _: NSCoder) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        fatalError&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;init(coder:) has not been implemented&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    // MARK: - Inspecting the view&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; wrappedLabel: UILabel&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; textStyle: TextStyle&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    var&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; text: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        get&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            return&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; wrappedLabel.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;text&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        set&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            setText&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: newValue)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    private&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; var&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; topYAxisConstraint: NSLayoutConstraint&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    private&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; setupViewAndConstraints&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        wrappedLabel.translatesAutoresizingMaskIntoConstraints &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; false&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        wrappedLabel.font &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; textStyle.font&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;        addSubview&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(wrappedLabel)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // We apply the line height contribution to this constraint.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // Since its constant might evolve over time, let&apos;s keep a reference.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; safeTopYAxisConstraint &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; topAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: wrappedLabel.topAnchor)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        topYAxisConstraint &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; safeTopYAxisConstraint&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        NSLayoutConstraint.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;activate&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;([&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            safeTopYAxisConstraint,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            leadingAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: wrappedLabel.leadingAnchor),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            trailingAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: wrappedLabel.trailingAnchor),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            centerYAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;equalTo&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: wrappedLabel.centerYAnchor)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        ])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; setText&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        guard&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; text &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; text &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;            // No text? Then no padding either.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            topYAxisConstraint&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.constant &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 0.0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            wrappedLabel.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; nil&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            return&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // This is the extra padding we want.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // Half of it will go on top of the label.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // The other half will go at the bottom of the label.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; lineSpacing &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; textStyle.lineHeight &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; textStyle.font.lineHeight&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; paragraphStyle &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; NSMutableParagraphStyle&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        paragraphStyle.lineSpacing &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; lineSpacing&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        paragraphStyle.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;alignment&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; wrappedLabel.textAlignment&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;        // Build an attributed string&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; attributedString &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; NSMutableAttributedString&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: text)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        attributedString.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;addAttribute&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            .paragraphStyle,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            value&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: paragraphStyle,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            range&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;NSRange&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;location&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: attributedString.length)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        topYAxisConstraint&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;.constant &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(lineSpacing &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; 2.0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        wrappedLabel.attributedText &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; attributedString&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Where are we now? Let’s look at our &lt;em&gt;ghost snapshot&lt;/em&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Pixel-wise comparison of the Sketch design and iOS view after Step 3.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;375&quot; width=&quot;375&quot; height=&quot;182&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fcard-step-3.DRSlfFIJ.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Even though the mysteries of text-layout algorithms led Sketch and Xcode to make
different decisions about when to break lines, it seems like our code does a
good job respecting the designed layout so, tada 🎉, we’re done! All that’s left
to do is to copy paste this little helper everywhere.&lt;/p&gt;
&lt;p&gt;Well… sure, but be careful. While this wrapper does a good job in the context of
this exercise and its API&lt;sup&gt;&lt;a href=&quot;#user-content-fn-4&quot; id=&quot;user-content-fnref-4&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;5&lt;/a&gt;&lt;/sup&gt; is considerably stable, I actually wouldn’t take
this approach. Let’s see why.&lt;/p&gt;
&lt;h2 id=&quot;a-sturdier-alternative-using-font-descriptors-and-text-constraints&quot;&gt;A sturdier alternative using font descriptors and text constraints&lt;/h2&gt;
&lt;p&gt;The major drawbacks about this little helper are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;While it’s not super fragile, it is still not a great API since it only
handles two attributes (line spacing and text alignment);&lt;/li&gt;
&lt;li&gt;It adds an extra wrapping view for every label in our design. While this might
not be really expensive to lay out, it is not very intellectually satisfying;&lt;/li&gt;
&lt;li&gt;It requires to bend Apple’s own rules to do your thing. If more than 12 years
of iOS development has taught me one thing, it is that following Apple’s
guidelines will end up being a great return on investment either whenever
Apple launches its next big thing or when you discover your app had a blind
spot (accessibility being the usual suspect).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So what rule are we bending? Remember the little ⚠️ from above? Well if you
replace this constraint:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// The origin of the titleLabel frame will be 8pt below the view&apos;s.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;titleLabel.topAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  equalToSystemSpacingBelow&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: view.safeAreaLayoutGuide.topAnchor,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  multiplier&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1.0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;by this one — which is likely what Apple wants you to do when you are handling
labels constraints:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;// The origin of the titleLabel frame will be 11pt below the view&apos;s.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;titleLabel.firstBaselineAnchor.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;constraint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  equalToSystemSpacingBelow&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: view.safeAreaLayoutGuide.topAnchor,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;  multiplier&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;1.0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You end up with a slightly different result: the title label will be laid out
3pt further down if you use the text-specific constraint. Since the system knows
that &lt;code&gt;titleLabel&lt;/code&gt; is a &lt;code&gt;title1&lt;/code&gt; it will add additional padding that will look
quite better, without any design cost.&lt;/p&gt;
&lt;p&gt;Apple is very thoughtful about system font sizes and line heights, as
demonstrated in the &lt;a href=&quot;https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/typography/&quot;&gt;Typography section of their Human Interfaces
Guidelines&lt;/a&gt;. If the designer in your team still wants to make adjustments on
point sizes and line spacings, a sturdier alternative to using &lt;code&gt;lineSpacing&lt;/code&gt;
might be to leverage font descriptors to slightly alter the font metrics so that
they better match your designs. You could use either &lt;a href=&quot;https://developer.apple.com/documentation/uikit/uifontdescriptor/symbolictraits/1616689-traitlooseleading&quot;&gt;&lt;code&gt;traitLooseLeading&lt;/code&gt;&lt;/a&gt; or
&lt;a href=&quot;https://developer.apple.com/documentation/uikit/uifontdescriptor/symbolictraits/1616694-traittightleading&quot;&gt;&lt;code&gt;traitTightLeading&lt;/code&gt;&lt;/a&gt; to slightly modify the line spacing of fonts.&lt;/p&gt;
&lt;p&gt;For our specific line height situation, we want &lt;code&gt;traitLooseLeading&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; font: UIFont &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;init&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    descriptor&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: UIFontDescriptor&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;preferredFontDescriptor&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;withTextStyle&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: .body)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;withSymbolicTraits&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(.traitLooseLeading)&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;    size&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is another ghost snapshot that doesn’t require to wrap &lt;code&gt;UILabel&lt;/code&gt; or use
attributed strings. Instead, it uses just the adequate constraints, a font with
a looser leading, and a simple tweak to use a multiplier of &lt;code&gt;1.4&lt;/code&gt; for the space
constraint between the title and the body.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;Pixel-wise comparison of the Sketch design and a sturdier iOS view.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;375&quot; width=&quot;375&quot; height=&quot;182&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Fcard-sturdier-option.D76oeD98.png&amp;amp;w=400&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;While this solution will give you less control to get a perfect ghost snapshot
(see how the card’s total height is not as high as the Sketch design?), I think
it is the best option for most cases, that should be negotiated with your design
team.&lt;/p&gt;
&lt;p&gt;Check out &lt;a href=&quot;https://github.com/dirtyhenry/xcode-playgrounds/tree/main/line-height.playground&quot;&gt;⛹️ the playground&lt;/a&gt; to run the code in Xcode.&lt;/p&gt;
&lt;h2 id=&quot;related-links&quot;&gt;Related Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://medium.com/mobimeo-technology/what-if-your-designers-want-a-baseline-grid-on-ios-d5234c7b52c0&quot;&gt;What If Your Designers Want a Baseline Grid on iOS?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-5&quot;&gt;
&lt;p&gt;Credits for this awesome adjective go to &lt;a href=&quot;https://www.joshwcomeau.com/css/pixel-perfection/&quot;&gt;Josh W. Comeau&lt;/a&gt; &lt;a href=&quot;#user-content-fnref-5&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;I know it looks like 💩 that is not the point 😉. &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;Every font has a lot of metrics. Apple’s &lt;a href=&quot;https://developer.apple.com/library/archive/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/CustomTextProcessing/CustomTextProcessing.html#//apple_ref/doc/uid/TP40009542-CH4-SW66&quot;&gt;&lt;em&gt;Using Text Kit to Draw and Manage
Text&lt;/em&gt; document&lt;/a&gt; is very helpful to learn about them, especially the &lt;em&gt;Font
Metrics&lt;/em&gt; figure that is a good recap of the most important ones. &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-3&quot;&gt;
&lt;p&gt;Since we’re exploring multi-platform design — that, let’s face it, is
heavily influenced by the web lingo —, we might as well just start using it
here. &lt;a href=&quot;#user-content-fnref-3&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 4&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-4&quot;&gt;
&lt;p&gt;Updating the text, for instance, will not break the layout, even if you set
the text directly on the wrapped label. &lt;a href=&quot;#user-content-fnref-4&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 5&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>iOS</category><category>UIKit</category><category>Typography</category></item><item><title>How to Use OpenType Features with a Custom Font in UIKit</title><link>https://www.mickf.net/tech/activating-open-type-features-ios/</link><guid isPermaLink="true">https://www.mickf.net/tech/activating-open-type-features-ios/</guid><description>On the web, OpenType features are one line of CSS. On iOS, a custom font needs the right feature type and selector IDs. How I enabled Inter&apos;s open digits.</description><pubDate>Sun, 03 Jan 2021 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://rsms.me/inter/&quot;&gt;Inter&lt;/a&gt; is an awesome typeface. It is free, open-source, and on top of
looking great by default, it provides &lt;a href=&quot;https://rsms.me/inter/#features&quot;&gt;many OpenType features&lt;/a&gt; that are
really easy to use on a website. The &lt;a href=&quot;https://rsms.me/inter/#features/ss01&quot;&gt;alternate digits feature&lt;/a&gt; is one of
them. Just add the following to a CSS style and you’re done.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;font-feature-settings: &quot;ss01&quot;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;How can we benefit from the same optional features with UIKit?&lt;/strong&gt; This post
will recap my journey to activate the alternate digits feature on an iOS app.&lt;/p&gt;
&lt;h2 id=&quot;adding-a-custom-font-and-using-it&quot;&gt;Adding a custom font and using it&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app/&quot;&gt;Adding a custom font to your app&lt;/a&gt; is now pretty easy, compared to the old
days. From there, the most obvious next step is to run &lt;a href=&quot;https://github.com/dirtyhenry/swift-blocks/blob/main/Sources/Blocks/Extensions/Font.swift&quot;&gt;a piece of code&lt;/a&gt;
that I include in every project that use custom fonts. It simply prints a list
of the font names that are available from your app.&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; UIFont&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; allFontNames&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;] {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        familyNames.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;sorted&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { UIFont.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;fontNames&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;forFamilyName&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;$0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;sorted&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;flatMap&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;$0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;listing-features-of-a-font&quot;&gt;Listing features of a font&lt;/h2&gt;
&lt;p&gt;Activating features with UIKit is described in the &lt;a href=&quot;https://developer.apple.com/library/archive/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/CustomTextProcessing/CustomTextProcessing.html#//apple_ref/doc/uid/TP40009542-CH4-SW6&quot;&gt;&lt;em&gt;Activating Font Features&lt;/em&gt;
section of the Text Programming Guide for iOS&lt;/a&gt;. The code that is presented
there relies on Objective-C Core Text that you can wrap in modern Swift.&lt;/p&gt;
&lt;p&gt;To list the features that are supported by a font, you can use the following
code:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;extension&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; UIFont&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    typealias&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; FontFeatureInfo&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Any&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; listFeatures&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;        guard&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; fontFeatures &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; CTFontCopyFeatures&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;as?&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [FontFeatureInfo] &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;else&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            debugPrint&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#9ECBFF&quot;&gt;&quot;Could not copy font features.&quot;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;            return&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        fontFeatures.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;forEach&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; { fontFeatureInfo &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;            print&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(fontFeatureInfo)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is hard to predict how large the output of this command will be and really
depends on the font. For the Inter font, &lt;a href=&quot;https://gist.github.com/dirtyhenry/875ebeac13882c5dad710f22f17be5c5&quot;&gt;the output looks pretty intense&lt;/a&gt;.
It is not the most pleasant prose to read for humans, but scanning for the
features we want will be pretty straightforward.&lt;/p&gt;
&lt;p&gt;In my context, the part I was interested in was the following:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;[&quot;CTFeatureTypeName&quot;: Alternative Stylistic Sets, &quot;CTFeatureTypeIdentifier&quot;: 35, &quot;CTFeatureTypeSelectors&quot;: &amp;lt;__NSArrayM 0x600002179f20&amp;gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    CTFeatureSelectorIdentifier = 2;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    CTFeatureSelectorName = &quot;Open digits&quot;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;},&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To activate the &lt;em&gt;Open digits&lt;/em&gt; feature, I had to use the &lt;strong&gt;feature type
identifier 35&lt;/strong&gt;, with the &lt;strong&gt;feature selector identifier 2&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id=&quot;enabling-the-font-features-you-want&quot;&gt;Enabling the font features you want&lt;/h2&gt;
&lt;p&gt;So far, the code I showed was to get your app in the starting blocks. It helps
you to prepare for the big stage moment: &lt;strong&gt;actually&lt;/strong&gt; enabling the font
features.&lt;/p&gt;
&lt;p&gt;So I wrapped these 35 and 2 &lt;em&gt;magic numbers&lt;/em&gt; into something more meaningful: a
simple struct trying to make sense of Apple’s documentation&lt;sup&gt;&lt;a href=&quot;#user-content-fn-1&quot; id=&quot;user-content-fnref-1&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. It is pretty
basic, aimed to be built on in the future, and I made use of this incredible
&lt;a href=&quot;https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html&quot;&gt;Font Feature Registry&lt;/a&gt; resource&lt;sup&gt;&lt;a href=&quot;#user-content-fn-2&quot; id=&quot;user-content-fnref-2&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; to find inspiration for an adequate
naming:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; enum&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; FeatureTypeSelectorPair&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    typealias&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; PairDescriptor&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Int&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;Int&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; stylisticAlternativesStylisticAltOne: PairDescriptor &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;35&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    static&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt; func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; attributeValue&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; pairDescriptor: PairDescriptor) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; Any&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            UIFontDescriptor.FeatureKey.featureIdentifier&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; pairDescriptor.0,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            UIFontDescriptor.FeatureKey.typeIdentifier&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; pairDescriptor.1,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        ]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once there, I was able to instanciate the &lt;code&gt;UIFont&lt;/code&gt; including the option I wanted
like so:&lt;/p&gt;
&lt;pre class=&quot;astro-code github-dark&quot; style=&quot;background-color:#24292e;color:#e1e4e8; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;swift&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;func&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt; createFontWithOptions&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;fontName&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color:#B392F0&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: CGFloat) &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; UIFont {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; resultFont &lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; UIFontDescriptor&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: fontName, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: size)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        .&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;addingAttributes&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;([&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            .featureSettings&lt;/span&gt;&lt;span style=&quot;color:#F97583&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;                FeatureTypeSelectorPair.&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;attributeValue&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;                    for&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: FeatureTypeSelectorPair.stylisticAlternativesStylisticAltOne&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;                ),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;            ],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;        ])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A737D&quot;&gt;    // 0.0 means the size from the descriptor will prevail.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#F97583&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt; UIFont&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;descriptor&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: resultFont, &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color:#79B8FF&quot;&gt;0.0&lt;/span&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;the-outcome-an-alternative-digits-style&quot;&gt;The outcome: an alternative digits style&lt;/h2&gt;
&lt;p&gt;🎉 Tada! I was done. Here is what it looks like in the end: a label with the
default Inter Bold font appears first, and the label with the Inter Bold with
the alternate digits feature enabled appears last.&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;A screenshot comparing the string ‘0123456789’ with or without the option&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; inputtedWidth=&quot;471&quot; width=&quot;471&quot; height=&quot;205&quot; src=&quot;https://www.mickf.net/_vercel/image?url=build%2Finter-font-with-or-without-options.ZRVP-q9l.png&amp;amp;w=512&amp;amp;q=100&quot;&gt;&lt;/p&gt;
&lt;p&gt;Check out &lt;a href=&quot;https://github.com/dirtyhenry/xcode-playgrounds/tree/master/activating-opentype-features.playground&quot;&gt;⛹️ the playground&lt;/a&gt; to run the code in Xcode.&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-1&quot;&gt;
&lt;p&gt;⚠️ Note:
&lt;a href=&quot;https://developer.apple.com/documentation/uikit/uifontdescriptor/featurekey&quot;&gt;the documentation of &lt;code&gt;UIFontDescriptor.FeatureKey&lt;/code&gt;&lt;/a&gt;
was one of the most confusing I met. It said (1) that &lt;code&gt;featureIdentifier&lt;/code&gt;
was a key for identifying a font feature type such as ligature or character
shape and (2) &lt;code&gt;typeIdentifier&lt;/code&gt; was a key for identifying the font feature
selector. So &lt;code&gt;featureIdentifier&lt;/code&gt; refers to &lt;code&gt;CTFeatureTypeIdentifier&lt;/code&gt; while
&lt;code&gt;typeIdentifier&lt;/code&gt; refers to &lt;code&gt;CTFeatureSelectorIdentifier&lt;/code&gt;. Of course, I had
it switched the wrong way the first time I ran the code. Confusing you said?
🤯 &lt;a href=&quot;#user-content-fnref-1&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-2&quot;&gt;
&lt;p&gt;I never considered myself an expert in typefaces or fonts design and
abilities but this resource was so humbling that I definitely decreased the
perception of my own level in that skill by quite some orders of magnitude
😂 &lt;a href=&quot;#user-content-fnref-2&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded><category>iOS</category><category>Swift</category><category>UIKit</category><category>Typography</category></item><item><title>Le bilan du Morning Coffee</title><link>https://www.mickf.net/tech/le-bilan-du-morning-coffee/</link><guid isPermaLink="true">https://www.mickf.net/tech/le-bilan-du-morning-coffee/</guid><pubDate>Sun, 26 Dec 2010 00:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;incident&quot;&gt;Incident&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;https://imgs.xkcd.com/comics/incident.png&quot; alt=&quot;Incident by xkcd&quot;&gt;&lt;/p&gt;
&lt;p&gt;(via &lt;a href=&quot;https://xkcd.com/838/&quot;&gt;xkcd&lt;/a&gt;)&lt;/p&gt;
&lt;h2 id=&quot;comic-sans-criminal&quot;&gt;Comic Sans Criminal&lt;/h2&gt;
&lt;p&gt;Je suis un maniaque de la typographie, de la présentation d’information et de la
forme en général. Si vous voulez me mettre hors de moi, montrez-moi simplement
au choix :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;une affiche faite sans ironie où figurent les petites images de la Clipart
Gallery de Microsoft,&lt;/li&gt;
&lt;li&gt;la même chose avec au moins 3 ou 4 polices d’écriture différentes&lt;/li&gt;
&lt;li&gt;un slideshow PowerPoint avec des transitions en étoile, en volet ou que
sais-je encore&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Chez les web-designers, la même chose existe pour la police Comic Sans. L’un
d’entre eux a réalisé le site
&lt;a href=&quot;https://comicsanscriminal.com/&quot;&gt;Comic Sans Criminal&lt;/a&gt;, tout simplement génial.&lt;/p&gt;
&lt;p&gt;Daring Fireball parle aussi cette semaine de
&lt;a href=&quot;https://daringfireball.net/2010/12/title_junk&quot;&gt;la bonne manière de renseigner les balises &amp;lt;title&amp;gt; des sites web&lt;/a&gt;.
Intéressant (et je suis d’accord avec lui, ce site le prouve).&lt;/p&gt;
&lt;p&gt;(via &lt;a href=&quot;https://daringfireball.net&quot;&gt;Daring Fireball&lt;/a&gt;)&lt;/p&gt;
&lt;h2 id=&quot;animation-avec-google-docs&quot;&gt;Animation avec Google Docs&lt;/h2&gt;
&lt;p&gt;Une manière d’être hyper créatif, même avec des outils sans fonctionnalités
hyper évoluées : &lt;a href=&quot;https://youtu.be/bt9F7tKcZcU&quot; title=&quot;une animation de 89 secondes en 450 slides Google Docs&quot;&gt;une animation de 1 minute et 29 secondes faite de 450 slides
Google Docs&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;(via
&lt;a href=&quot;https://flowingdata.com/2010/12/22/epic-animation-in-google-docs/&quot;&gt;flowingdata&lt;/a&gt;)&lt;/p&gt;
&lt;h2 id=&quot;mes-nouveaux-flux-rss&quot;&gt;Mes nouveaux flux RSS&lt;/h2&gt;
&lt;p&gt;Encore une fois, la visite de Daring Fireball m’a fait découvrir un nouveau site
qui va enrichir mon morning coffee : &lt;a href=&quot;https://www.moss.fm/&quot;&gt;Olly Moss&lt;/a&gt;,
responsable de ce
&lt;a href=&quot;https://www.threadless.com/shop/@threadless/design/hell-maybe/home/fine-art-print&quot;&gt;très beau diagramme de Venn&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;set-dicônes-gratuit&quot;&gt;Set d’icônes gratuit&lt;/h2&gt;
&lt;p&gt;Se rendre
&lt;a href=&quot;https://www.smashingmagazine.com/2010/12/free-icon-set-for-web-developers-coded/&quot;&gt;ici&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;(via Webdesigner Depot)&lt;/p&gt;
</content:encoded><category>Typography</category></item></channel></rss>