{"id":23749307,"url":"https://github.com/frzi/swift-variablefonts","last_synced_at":"2025-07-04T00:36:36.991Z","repository":{"id":210277174,"uuid":"724594366","full_name":"frzi/swift-variablefonts","owner":"frzi","description":"Extends UIFont/NSFont (and SwiftUI Font) for easier variable font support","archived":false,"fork":false,"pushed_at":"2024-10-13T11:32:23.000Z","size":19,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-23T00:50:22.622Z","etag":null,"topics":["fonts","swift","swiftui","variable"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/frzi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-11-28T12:00:43.000Z","updated_at":"2024-10-15T18:52:35.000Z","dependencies_parsed_at":"2023-12-14T16:32:26.532Z","dependency_job_id":null,"html_url":"https://github.com/frzi/swift-variablefonts","commit_stats":null,"previous_names":["frzi/swift-variablefonts"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frzi%2Fswift-variablefonts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frzi%2Fswift-variablefonts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frzi%2Fswift-variablefonts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frzi%2Fswift-variablefonts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frzi","download_url":"https://codeload.github.com/frzi/swift-variablefonts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231893423,"owners_count":18442004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fonts","swift","swiftui","variable"],"created_at":"2024-12-31T15:16:29.811Z","updated_at":"2024-12-31T15:16:30.313Z","avatar_url":"https://github.com/frzi.png","language":"Swift","readme":"# Variable Fonts\n\n\u003e Easier use of variable fonts with AppKit, UIKit and SwiftUI. For iOS, macOS, tvOS, watchOS and visionOS\n\n![SwiftUI](https://img.shields.io/github/v/release/frzi/swift-variablefonts?style=for-the-badge)\n[![SwiftUI](https://img.shields.io/badge/SwiftUI-blue.svg?style=for-the-badge\u0026logo=swift\u0026logoColor=black)](https://developer.apple.com/xcode/swiftui)\n[![Swift](https://img.shields.io/badge/Swift-5.9-orange.svg?style=for-the-badge\u0026logo=swift)](https://swift.org)\n[![Xcode](https://img.shields.io/badge/Xcode-15-blue.svg?style=for-the-badge\u0026logo=Xcode\u0026logoColor=white)](https://developer.apple.com/xcode)\n[![MIT](https://img.shields.io/badge/license-MIT-black.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)\n\nExtends AppKit's `NSFont`, UIKit's `UIFont` and SwiftUI's `Font` with variable font features. Couldn't be easier!\n\n## How-to-use\n### Initializing font with axes.\n```swift\nlet font = NSFont(name: \"Amstelvar\", size: 20, axes: [\n\t.weight: 650,\n\t.opticalSize: 144,\n\t\"GRAD\": 500,\n])\n```\n\n### New font with a single axis applied\n```swift\nlet scienceGothic = UIFont(name: \"ScienceGothic\", size: 20)!\nlet slanted = scienceGothic.withAxis(.slant, value: -10)\n```\n\n### Get all available axes of a font\n```swift\nlet tiltWarp = NSFont(name: \"TiltWarp-Regular\", size: 100)!\nlet axes = tiltWarp.allAxes()\nprint(axes)\n/*\n[VariableFonts.FontAxis(\n\tid: 1481789268,\n\tname: \"XROT\",\n\tdescription: \"Rotation in X\",\n\tminimumValue: -45.0,\n\tmaximumValue: 45.0,\n\tdefaultValue: 0.0),\netc...]\n*/\n```\n\n### SwiftUI\n```swift\nText(\"Hello world\")\n\t.font(.custom(name: \"Fraunces\", size: 40, axes: [\n\t\t.weight: 900,\n\t\t\"SOFT\": 100,\n\t\t\"WONK\": 1,\n\t]))\n```\n\n### Example: maxed out font\n```swift\nlet nunito = UIFont(name: \"NunitoSans\", size: 20)!\nlet axes = nunito.allAxes()\n\n// Creates a UIFont with all axes set to their maximum value.\nlet megaNunito = nunito.withAxes(\n\tDictionary(uniqueKeysWithValues: axes.map { axis in\n\t\treturn (axis.id, axis.maximumValue)\n\t})\n)\n```\n\n## Axis names\nThe dictionary you supply to configure the axes use [`FontAxis.Name`](Sources/VariableFonts/FontAxis.swift#L38) as keys. This type comes with a set of well known axis names. I.e. `.weight` (`wght`), `.width` (`wdth`), etc. This type is `ExpressibleByStringLiteral`. String literals can be used for custom axis names.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrzi%2Fswift-variablefonts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrzi%2Fswift-variablefonts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrzi%2Fswift-variablefonts/lists"}