Proper MIME type for OTF fonts

There are a number of font formats that one can set MIME types for, on both Apache and IIS servers. I’ve traditionally had luck with the following: svg as “image/svg+xml” (W3C: August 2011) ttf as “application/x-font-ttf” (IANA: March 2013) or “application/x-font-truetype” otf as “application/x-font-opentype” (IANA: March 2013) woff as “application/font-woff” (IANA: January 2013) woff2 as … Read more

How to add multiple font files for the same font?

The solution seems to be to add multiple @font-face rules, for example: @font-face { font-family: “DejaVu Sans”; src: url(“fonts/DejaVuSans.ttf”); } @font-face { font-family: “DejaVu Sans”; src: url(“fonts/DejaVuSans-Bold.ttf”); font-weight: bold; } @font-face { font-family: “DejaVu Sans”; src: url(“fonts/DejaVuSans-Oblique.ttf”); font-style: italic, oblique; } @font-face { font-family: “DejaVu Sans”; src: url(“fonts/DejaVuSans-BoldOblique.ttf”); font-weight: bold; font-style: italic, oblique; } By … Read more

How do I make an attributed string using Swift?

This answer has been updated for Swift 4.2. Quick Reference The general form for making and setting an attributed string is like this. You can find other common options below. // create attributed string let myString = “Swift Attributed String” let myAttribute = [ NSAttributedString.Key.foregroundColor: UIColor.blue ] let myAttrString = NSAttributedString(string: myString, attributes: myAttribute) // … Read more