{"id":18936404,"url":"https://github.com/vaporexampleslab/mcxfontmetrics","last_synced_at":"2026-03-21T03:30:15.739Z","repository":{"id":133119464,"uuid":"194487712","full_name":"VaporExamplesLab/MCxFontMetrics","owner":"VaporExamplesLab","description":null,"archived":false,"fork":false,"pushed_at":"2022-01-05T21:01:54.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-31T21:26:27.704Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VaporExamplesLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-30T07:25:05.000Z","updated_at":"2022-01-05T21:01:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"93469617-57f4-4592-b0e7-fe8293a739fd","html_url":"https://github.com/VaporExamplesLab/MCxFontMetrics","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaporExamplesLab%2FMCxFontMetrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaporExamplesLab%2FMCxFontMetrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaporExamplesLab%2FMCxFontMetrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaporExamplesLab%2FMCxFontMetrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VaporExamplesLab","download_url":"https://codeload.github.com/VaporExamplesLab/MCxFontMetrics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239937702,"owners_count":19721482,"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":[],"created_at":"2024-11-08T12:07:19.311Z","updated_at":"2026-03-21T03:30:15.663Z","avatar_url":"https://github.com/VaporExamplesLab.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MCxFontMetrics\n\n\u003ca id=\"toc\"\u003e\u003c/a\u003e\n[Original Setup](#linkOriginalProjectSetup) • \n[Resources](#linkResources) \n\n**Options:**\n\n```sh\nmcxfontmetrics --font-name=DejaVuSansMono\n\n# DejaVuSansMono\n```\n\nGenerate an Xcode project.\n\n``` sh\nswift package update\nswift package generate-xcodeproj --xcconfig-overrides Package.xcconfig\n```\n\n\n## Original Project Setup \u003ca id=\"linkOriginalProjectSetup\"\u003e\u003c/a\u003e[▴](#toc)\n\nSummary of original steps used to create the MCxFontMetrics example template.\n\n``` sh\nmkdir MCxFontMetrics\ncd MCxFontMetrics\nswift package init --type executable\n\n# review \u0026 update .gitignore, as needed\nnano .gitignore\n```\n\n**Framework \u0026 Executable Modules**\n\nCreate two modules: one framework `MCxFontMetrics` and one executable `MCxFontMetricsCore`. Each top level folder under `Sources` defines a module.\n\nThe executable module only contains the `main.swift` file. The core framework contains all of the tool’s actual functionality.  The separation of the core framework provides for *easier testing*; and, the *core framework can be used as a dependency in other executables*.\n\n``` sh\n// create core framework module\nmkdir Sources/MCxFontMetricsCore\n```\n\nUpdate `Package.swift` to define two targets — one for the `MCxFontMetrics` executable module and one for the `MCxFontMetricsCore` framework.\n\n``` sh\n# edit Package.swift\nnano Package.swift\n```\n\n_Package.swift_\n\n``` swift\nimport PackageDescription\n\nlet package = Package(\n    name: \"MCxFontMetrics\",\n    // ...\n    targets: [\n        .target(\n            name: \"MCxFontMetrics\",\n            dependencies: [\"MCxFontMetricsCore\"]),\n        .target(\n            name: \"MCxFontMetricsCore\",\n            dependencies: []),\n        // Test MCxFontMetricsCore directly instead of MCxFontMetrics main.swift\n        .testTarget(\n            name: \"MCxFontMetricsTests\",\n            dependencies: [\"MCxFontMetricsCore\"]),\n        // ...\n    ]\n)\n```\n\n**Define Programmatic Entry Point**\n\nCreate a new MCxFontMetrics.swift core framework class.\n\n``` sh\n# nano Sources/MCxFontMetricsCore/MCxFontMetrics.swift\ntouch Sources/MCxFontMetricsCore/MCxFontMetrics.swift\nedit Sources/MCxFontMetricsCore/MCxFontMetrics.swift \n```\n\n``` swift\nimport Foundation\n\npublic final class MCxFontMetrics {\n    private let arguments: [String]\n\n    public init(arguments: [String] = CommandLine.arguments) { \n        self.arguments = arguments\n    }\n\n    public func run() throws {\n        print(\"Hello world\")\n    }\n}\n```\n\nUpdate Sources/MCxFontMetrics/main.swift to call the `run()` method which is in the core framework MCxFontMetrics class.\n\n``` sh\n# nano Sources/MCxFontMetrics/main.swift\nedit Sources/MCxFontMetrics/main.swift\n```\n\n\n``` swift\nimport MCxFontMetricsCore\n\nlet tool = MCxFontMetrics()\n\ndo {\n    try tool.run()\n} catch {\n    print(\"Whoops! An error occurred: \\(error)\")\n}\n```\n\n**Xcode**\n\n``` sh\n# edit Package.xcconfig \nnano Package.xcconfig\n```\n\n``` ini\n/// macOS Deployment Target\nMACOSX_DEPLOYMENT_TARGET=10.13\n\n// Swift Language Version\n// \nSWIFT_VERSION = 4.2\n```\n\nGenerate an Xcode project.\n\n``` sh\nswift package update\nswift package generate-xcodeproj --xcconfig-overrides Package.xcconfig\n```\n\n**Run**\n\n``` sh\nswift build\n.build/debug/MCxFontMetrics\n# Hello World\n```\n\n**Test**\n\nThe `MCxFontMetricsCore` framework can be tested directly. Or, a `Process` can be run to test the `MCxFontMetrics` executable.\n\n_Command Line Tests_\n\n\n``` sh\n## runs 'All tests'\n## path .build/architecture/debug/MCxFontMetrics\nswift test\n```\n\n_Xcode Testing_\n\nRuns 'Selected Tests'. Execution path: .../DerivedData/MCxFontMetrics-id/Build/Products/Debug/MCxFontMetrics\n\n**Installation**\n\nTo run the CLI tool from anywhere, move the executable command to some path which is present on the `$PATH` environment variable. For example, move the the compiled binary to `/usr/local/bin` or `/opt/local/bin`.\n\n\u003e Note: On macOS, `brew doctor` may complain about file in `/usr/local/bin` which are not managed by Homebrew. \n\n``` sh\nswift build --configuration release\n```\n\n_macOS_\n\n``` sh\n# Linking ./.build/x86_64-apple-macosx10.10/release/MCxFontMetrics\ncd .build/x86_64-apple-macosx10.10/release\n\nsudo mkdir -p /opt/local/bin\n// -f force overwrite of existing file\ncp -f MCxFontMetrics /opt/local/bin/MCxFontMetrics\n```\n\n_Ubuntu_\n\n``` sh\n# Linking ./.build/x86_64-apple-macosx10.10/release/MCxFontMetrics\n\ncd .build/release\n#cp -f MCxFontMetrics /usr/local/bin/MCxFontMetrics\ncp -f MCxFontMetrics /opt/local/bin/MCxFontMetrics\n```\n\n## Resources \u003ca id=\"linkResources\"\u003e\u003c/a\u003e[▴](#toc)\n\n* [AppleOS: CoreText](https://developer.apple.com/documentation/coretext)\n* [R: systemfonts](https://github.com/r-lib/systemfonts) … native system font handling\n* Linux: FontConfig \n* Freetype\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaporexampleslab%2Fmcxfontmetrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaporexampleslab%2Fmcxfontmetrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaporexampleslab%2Fmcxfontmetrics/lists"}