[OTVar] fit-to-width JavaScript library

Laurence Penney
Posts: 50
I recently polished my fit-to-width code and added it as a new fit-to-width GitHub repository. The published code is a development of the method I first presented in this Skia demo from November 2016, and is available under the Apache open source license.
From the README:
Comments welcome, particularly from people using it.
From the README:
fit-to-width.js is a tiny JavaScript library for fitting text into text containers in a typographically sensitive way, using standard CSS. Its user-facing function, ftw_fit(), takes a set of elements, and automatically adjusts a variable font’s width axis, as well as adjustments of letter-spacing and word-spacing, attempting to fill each element with the text that it contains. By default, it adjusts the width axis via CSS "font-variation-settings", then resorts to a horizontal scale using CSS "transform". In general, a sequence of operations can be specified, each performed to the best of its ability before proceeding to the next operation if an optimal result has not yet been reached. For efficiency it uses a binary search algorithm to converge quickly on a good result. Typically it performs only 8 or so tests to arrive at an ideal solution for the width axis setting, even though there are thousands of possible values.
Comments welcome, particularly from people using it.
Tagged:
2
Categories
- All Categories
- 44 Introductions
- 3.8K Typeface Design
- 817 Font Technology
- 1.1K Technique and Theory
- 635 Type Business
- 451 Type Design Critiques
- 549 Type Design Software
- 30 Punchcutting
- 139 Lettering and Calligraphy
- 86 Technique and Theory
- 53 Lettering Critiques
- 500 Typography
- 309 History of Typography
- 117 Education
- 74 Resources
- 520 Announcements
- 84 Events
- 107 Job Postings
- 160 Type Releases
- 168 Miscellaneous News
- 271 About TypeDrawers
- 53 TypeDrawers Announcements
- 117 Suggestions and Bug Reports