Latest 0.4.0
License MIT
Platforms osx 10.9, ios 8.0, watchos 2.0, tvos 9.0

A framework for macOS, iOS, tvOS, and watchOS to create monospaced variants of fonts.

Carthage compatible



To use Monospacer with CocoaPods, add a dependency to your Podfile:

target 'MyAwesomeApp' do
  pod 'Monospacer'

Then run pod install and use the generated .xcworkspace to open your project.


To use Monospacer with Carthage, add a dependency to your Cartfile:

github "SlaunchaMan/Monospacer"

Run carthage update to build the framework. Then follow the rest of the steps in Carthage’s README to add the framework to your project, configure a Run Script build phase, etc.


To integrate Monospacer manually into your project, drag Monospacer.xcodeproj into your Xcode project, then use the correct Monospacer.framework for your platform.

Using Monospacer


To use Monospacer, use the extension on UIFont (NSFont for macOS):

let newFont = try? myFont.withMonospaceDigits()

You can also use this on a font descriptor to add the monospaced digits attribute (useful if you need to perform other modifications to the descriptor before using it to create a font):

let newFontDescriptor = myFontDescrpitor.withMonospaceDigits


Monospacer also works with Objective-C:

UIFont *newFont = [myFont fontWithMonospaceDigitsError:NULL];

UIFontDescriptor *newFontDescriptor = myFontDescriptor.descriptorForMonospaceDigits;

Error Handling

Not all fonts support monospaced digits. In the case where a font doesn’t support this feature, Monospacer throws a MonospacerError.fontUnsupported error. On macOS, if font creations fails, Monospacer throws a MonospacerError.fontCreationFailed error. You can handle these in Swift or Objective-C:

// Swift
do {
    let font = try someFont.withMonospaceDigits()
catch MonospacerError.fontUnsupported {
    NSLog("Whoops! This font isn't supported!")
catch MonospacerError.fontCreationFailed {
    NSLog("Uh-oh. Creating this font failed.")
catch {
    fatalError("Unexpected error: (error.localizedDescription)")
// Objective-C
NSError *error = nil;
UIFont *font = [font fontWithMonospaceDigitsError:&error];

if (font == nil) {
    if (error.domain == MonospacerErrorDomain &&
        error.code == MonospacerErrorFontUnsupported) {
        NSLog(@"Whoops! This font isn't supported!");

If you don’t care about the errors, you can safely ignore them:

let newFont = try? font.withMonospaceDigits()

myLabel.font = newFont ?? font

Latest podspec

    "name": "Monospacer",
    "version": "0.4.0",
    "summary": "A small framework to generate monospaced fonts.",
    "description": "A framework for macOS, iOS, tvOS, and watchOS to create monospaced variants ofnfonts.",
    "license": "MIT",
    "authors": {
        "Jeff Kelley": "[email protected]"
    "social_media_url": "",
    "homepage": "",
    "module_name": "Monospacer",
    "swift_version": "4.0",
    "platforms": {
        "osx": "10.9",
        "ios": "8.0",
        "watchos": "2.0",
        "tvos": "9.0"
    "source": {
        "git": "",
        "tag": "0.4.0"
    "source_files": "Code/*.swift",
    "osx": {
        "frameworks": "AppKit"
    "ios": {
        "frameworks": "UIKit"
    "watchos": {
        "frameworks": "UIKit"
    "tvos": {
        "frameworks": "UIKit"

Pin It on Pinterest

Share This