{"id":23332627,"url":"https://github.com/schapka/opentype-svg-loader","last_synced_at":"2025-10-17T22:53:43.694Z","repository":{"id":57315576,"uuid":"86677605","full_name":"schapka/opentype-svg-loader","owner":"schapka","description":"A loader for webpack that lets you import TrueType and OpenType fonts converted to a SVG string.","archived":false,"fork":false,"pushed_at":"2017-04-10T23:53:20.000Z","size":15102,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T17:14:48.402Z","etag":null,"topics":["loader","opentype","opentype-svg-loader","svg-string","truetype","webpack","webpack-loader"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/schapka.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}},"created_at":"2017-03-30T08:21:54.000Z","updated_at":"2023-03-08T21:35:30.000Z","dependencies_parsed_at":"2022-09-18T20:33:38.453Z","dependency_job_id":null,"html_url":"https://github.com/schapka/opentype-svg-loader","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schapka%2Fopentype-svg-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schapka%2Fopentype-svg-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schapka%2Fopentype-svg-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schapka%2Fopentype-svg-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schapka","download_url":"https://codeload.github.com/schapka/opentype-svg-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248074923,"owners_count":21043490,"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":["loader","opentype","opentype-svg-loader","svg-string","truetype","webpack","webpack-loader"],"created_at":"2024-12-20T23:16:22.967Z","updated_at":"2025-10-17T22:53:38.673Z","avatar_url":"https://github.com/schapka.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/opentype-svg-loader.svg)](https://badge.fury.io/js/opentype-svg-loader)\n[![Build Status](https://travis-ci.org/schapka/opentype-svg-loader.svg?branch=master)](https://travis-ci.org/schapka/opentype-svg-loader)\n\n# OpenType-SVG-Loader\n\nA loader for webpack that lets you import TrueType and OpenType fonts converted to a SVG string.\n\n## Install\n\nUsing `yarn`\n```bash\nyarn add -D opentype-svg-loader\n```\n\nUsing `npm`\n```bash\nnpm i -D opentype-svg-loader\n```\n\n## Usage\n\n`webpack.config.js`\n\n```javascript\nmodule: {\n  rules: [\n    {\n      test: /\\.ot\\.json$/,\n      use: [\n        {\n          loader: 'opentype-svg-loader',\n          options: {\n            fonts: {\n              YellowtailRegular: path.resolve(\n                __dirname,\n                'fonts',\n                'Yellowtail',\n                'Yellowtail-Regular.ttf'\n              )\n            }\n          }\n        }\n      ]\n    }\n  ]\n}\n```\n\n`headline.ot.json`\n\n```json\n{\n  \"text\": \"Hello World!\",\n  \"font\": \"YellowtailRegular\"\n}\n```\n\n`entry.js`\n\n```javascript\nvar headlineSVGString = require('./headline.ot.json');\nvar wrapperEl = document.getElementById('mount');\nwrapperEl.innerHTML = headlineSVGString;\n```\n\n## Examples\n\n* [JSON input file](https://github.com/schapka/opentype-svg-loader/tree/master/examples/json)\n* [Text/Mustache input file](https://github.com/schapka/opentype-svg-loader/tree/master/examples/mustache)\n\n## Input file\n\nThe input file can either be a text file or a `JSON` file.\n\nIn case of a text file its contents will be interpreted as template string (`options.text`).\nIf the input file is a `JSON` file it can contain any of the available options. \n\n## Options\n\nOptions will be merged in following order:\n1. Loader Options\n2. Resource Query\n3. Input file (in case of a `JSON` input file)\n\n### fonts\nType: `Object`\nDefault: `null`\n\nAn object holding a collection of available fonts. Object keys are used as references. Object values represent absolute paths to font files.\n\n```javascript\n{\n  options: {\n    /* ... */\n    fonts: {\n      MyFontName: '/absolute/path/fo/font-file.ttf'\n    }\n    /* ... */\n  }\n}\n```\n\n### data\nType: `Object`\nDefault: `{}`\n\nA data object handed to mustache.\n\n### text\nType: `String | String[]`\nDefault: `''`\n\nA template string that will be processed by mustache. If the input file is not a `JSON` file its contents will be interpreted as the template string.\n\n### font\nType: `String`\nDefault: `null`\n\nA reference to the font that should be used for rendering. Will fallback to the first entry of the font collection (`options.fonts`).\n\n### size\nType: `Number`\nDefault: `72`\n\n### lineHeight\nType: `Number`\nDefault: `1.0`\n\n### letterSpacing\nType: `Number`\nDefault: `0.0`\n\n### textAlign\nType: `String`\nDefault: `'left'`\n\nPossible Options: `'left'` `'center'` `'right'` \n\n### decimalPlaces\nType: `Number`\nDefault: `2`\n\n### kerning\nType: `Boolean`\nDefault: `true`\n\n### attrs\nType: `Object`\nDefault: `{}`\n\nAttributes that should be added to the `\u003csvg\u003e`-element\n\n```json\n{\n  \"attrs\": {\n    \"preserveAspectRatio\": \"xMaxYMax meet\"\n  }\n}\n```\n\n### sharedGlyphStore\nType: `Boolean | String`\nDefault: `true`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschapka%2Fopentype-svg-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschapka%2Fopentype-svg-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschapka%2Fopentype-svg-loader/lists"}