{"id":16681476,"url":"https://github.com/hlorenzi/font-js","last_synced_at":"2025-04-09T23:05:08.003Z","repository":{"id":57116151,"uuid":"154144195","full_name":"hlorenzi/font-js","owner":"hlorenzi","description":"🔠 Visually inspect .otf/.ttf/.otc/.ttc glyphs online, and extract glyph images and metadata through the command line! -- https://hlorenzi.github.io/font-js/","archived":false,"fork":false,"pushed_at":"2021-04-03T19:20:31.000Z","size":51,"stargazers_count":23,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-02T15:03:18.170Z","etag":null,"topics":["command-line","command-line-tool","commandline","file","file-format","font","font-collection","font-face","glyph","glyphs","inspect","inspector","opentype","otc","otf","truetype","ttc","ttf","web","webapp"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/hlorenzi.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}},"created_at":"2018-10-22T12:57:37.000Z","updated_at":"2024-12-20T22:20:46.000Z","dependencies_parsed_at":"2022-08-22T13:20:34.435Z","dependency_job_id":null,"html_url":"https://github.com/hlorenzi/font-js","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/hlorenzi%2Ffont-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlorenzi%2Ffont-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlorenzi%2Ffont-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlorenzi%2Ffont-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hlorenzi","download_url":"https://codeload.github.com/hlorenzi/font-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239073969,"owners_count":19577123,"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":["command-line","command-line-tool","commandline","file","file-format","font","font-collection","font-face","glyph","glyphs","inspect","inspector","opentype","otc","otf","truetype","ttc","ttf","web","webapp"],"created_at":"2024-10-12T14:04:20.369Z","updated_at":"2025-02-16T00:32:15.661Z","avatar_url":"https://github.com/hlorenzi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# font\n\n[📱 Try a glyph viewer right now in your browser!](https://hlorenzi.github.io/font-js)\n\nUtilities and a CLI for extracting glyphs and metadata from font files.\n\nCurrently allows loading TrueType or OpenType fonts or font collections,\nand extracting metadata and glyph geometry.  \n\nThe command-line interface allows for extracting black-and-white,\ngrayscale, and signed distance field PNG renderings, and JSON metadata.\n\nRun the command-line interface without arguments to check all the\navailable options.\n\nRun via npx: `npx @hlorenzi/font`\n\nInstall with: `npm install @hlorenzi/font`\n\n## Command-line Examples\n\n```shell\n# Extracts all glyphs from \"arial.ttf\" into PNG and JSON files.\nnpx @hlorenzi/font arial.ttf -o \"output/unicode_[unicode]\"\n\n# Set glyph range.\nnpx @hlorenzi/font arial.ttf -o \"output/unicode_[unicode]\" --glyphs=\"u+30..u+39\"\n\n# Set output mode.\nnpx @hlorenzi/font arial.ttf -o \"output/unicode_[unicode]\" --img-mode=\"png-sdf\"\n```\n\n## Package Example\n\n```js\nimport { FontCollection, GlyphRenderer } from \"@hlorenzi/font\"\nimport fs from \"fs\"\n\n// Load font file.\nconst fontBuffer = fs.readFileSync(\"arial.ttf\")\n\n// Load font collection and get first font.\nconst fontCollection = FontCollection.fromBytes(fontBuffer)\nconst font = fontCollection.fonts[0]\n\n// Find glyph for Unicode character \"a\" and get its geometry,\n// simplifying each bézier curve into 100 line segments.\nconst glyphIndex = font.getGlyphIndexForUnicode(\"a\".charCodeAt(0))\nconst glyphGeometry = font.getGlyphGeometry(glyphIndex, 100)\n\n// Render into a black-and-white buffer with scale factor 1 EM = 30 pixels,\n// then crop empty borders and print to the console.\nconst glyphImage = GlyphRenderer.render(glyphGeometry, 30).cropped()\nconsole.log(glyphImage.printToString())\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhlorenzi%2Ffont-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhlorenzi%2Ffont-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhlorenzi%2Ffont-js/lists"}