{"id":15019906,"url":"https://github.com/fazouane-marouane/fancy-textfill","last_synced_at":"2025-05-02T12:31:08.633Z","repository":{"id":17369958,"uuid":"78674070","full_name":"fazouane-marouane/fancy-textfill","owner":"fazouane-marouane","description":"Fast implementation for resizing text to fill its container.","archived":false,"fork":false,"pushed_at":"2024-12-14T23:13:45.000Z","size":1618,"stargazers_count":20,"open_issues_count":4,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T01:48:36.251Z","etag":null,"topics":["bigtext","fill","font-size","hacktoberfest","javascript","javascript-library","jquery","jquery-plugin","jquery-textfill","textfill"],"latest_commit_sha":null,"homepage":"https://fazouane-marouane.github.io/fancy-textfill/","language":"TypeScript","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/fazouane-marouane.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-11T19:54:02.000Z","updated_at":"2024-07-16T15:48:22.000Z","dependencies_parsed_at":"2024-06-21T16:34:16.137Z","dependency_job_id":"4038af0e-9129-4beb-8677-a1aa1f4c4f1e","html_url":"https://github.com/fazouane-marouane/fancy-textfill","commit_stats":{"total_commits":51,"total_committers":3,"mean_commits":17.0,"dds":"0.039215686274509776","last_synced_commit":"fa2595d7daacb093db4b8a91e5c55430febd4552"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fazouane-marouane%2Ffancy-textfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fazouane-marouane%2Ffancy-textfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fazouane-marouane%2Ffancy-textfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fazouane-marouane%2Ffancy-textfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fazouane-marouane","download_url":"https://codeload.github.com/fazouane-marouane/fancy-textfill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252038114,"owners_count":21684626,"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":["bigtext","fill","font-size","hacktoberfest","javascript","javascript-library","jquery","jquery-plugin","jquery-textfill","textfill"],"created_at":"2024-09-24T19:54:18.221Z","updated_at":"2025-05-02T12:31:07.856Z","avatar_url":"https://github.com/fazouane-marouane.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fancy-textfill\n[![npm](https://img.shields.io/npm/v/fancy-textfill.svg)](https://www.npmjs.com/package/fancy-textfill)\n[![license](https://img.shields.io/github/license/fazouane-marouane/fancy-textfill.svg)](https://github.com/fazouane-marouane/fancy-textfill/blob/master/LICENSE)\n\nFast implementation for resizing text to fill its container.\nIt computes the optimal font-size needed to match a text to specific width and height.\nIt's also available as a jquery plugin.\n\nIt's really fast. See for yourself. :metal: [Demo](https://fazouane-marouane.github.io/fancy-textfill/)\n\n## Install\n\n```bash\nnpm install --save fancy-textfill\n# or you can use yarn (yarn add fancy-textfill)\n```\n\n## Example\n\n```html\n\u003c!-- In case you're using it as a jquery plugin --\u003e\n\u003cscript src=\"jquery.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://unpkg.com/fancy-textfill/dist/fancy-text-fill.jQuery.js\"\u003e\u003c/script\u003e\n\u003c!-- Or you can use it without jquery, by using https://unpkg.com/fancy-textfill/dist/fancy-text-fill.js --\u003e\n\u003c!-- Example setup --\u003e\n\u003cstyle\u003e\n  .container {\n    width: 200px;\n    height: 50px;\n  }\n  .myText {\n    display: block;\n  }\n\u003c/style\u003e\n\u003cdiv class=\"container\"\u003e\n  \u003cspan class=\"myText\"\u003eHello darkness, my old friend.\u003c/span\u003e\n\u003c/div\u003e\n\u003cdiv class=\"container\"\u003e\n  \u003cspan class=\"myText\"\u003eI've come to talk with you again.\u003c/span\u003e\n\u003c/div\u003e\n```\n\nYou can either use it on bare dom elements or on jquery objects.\n\n```js\n// Without jquery\ndocument.getElementsByClassName('myText')\n  .forEach(function (el) {\n    fancyTextFill.fillParentContainer(el, {\n      minFontSize: 6,\n      maxFontSize: 26\n    });\n  });\n// With jquery\n$('.myText').fancyTextFill({\n  minFontSize: 6,\n  maxFontSize: 26\n});\n```\n\nYou can also use it as a module. You can import it like so:\n\n```js\n// Without jquery\nimport { fillParentContainer } from 'fancy-textfill';\n// Or const { fillParentContainer } = require('fancy-textfill');\nfillParentContainer(el, {\n  minFontSize: 6,\n  maxFontSize: 26\n});\n```\n\n```js\n// as a jquery plugin\nimport 'fancy-textfill/es2015/jquery.plugin';\n// Or require('fancy-textfill/es2015/jquery.plugin');\n$('.myText').fancyTextFill({\n minFontSize: 6,\n maxFontSize: 26\n});\n```\n\n## Options\n\n| Name        | Description | Default value |\n|-------------|-------------|---------------|\n| minFontSize | Minimal font size (in pixels). The text will shrink up to this value. | 4 |\n| maxFontSize | Maximum font size (in pixels). The text will stretch up to this value. If it is `null` or a negative number (`maxFontSize \u003c= 0`), the text will stretch to as big as the container can accommodate. | 40 |\n| maxWidth    | Explicit width to resize. Defaults to the container's width. | `null` |\n| maxHeight   | Explicit height to resize. Defaults to the container's height. | `null` |\n| multiline   | Will only resize to the width restraint when set to `false` | true |\n| explicitLineHeight | When set to `false`, `line-height`s are assumed to be relative to the current `font-size`| `false`|\n\n## How does it compare to...\n\n1. [jquery-textfill](https://github.com/jquery-textfill/jquery-textfill)\n\n\u003e **Performance!** fancy-TextFill implements the same features while being way faster than the original jquery plugin.\n\n2. [BigText](https://github.com/zachleat/BigText)\n\n\u003e BigText doesn't support multiple lines.\n\n## Unit tests\n\n```bash\n# Run chrome driver\nchromedriver --port=4444 --url-base=wd/hub\n# In another console\nnpm run build:dev\nnpm run test\n```\n\n## License\n\nThis code is licensed under the _MIT License_. See file LICENSE for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffazouane-marouane%2Ffancy-textfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffazouane-marouane%2Ffancy-textfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffazouane-marouane%2Ffancy-textfill/lists"}