-
- Downloads
Precompute text width using a lookup table (#2311)
This simplifies and further optimizes text-width computation by computing the entire width table in advance, and serializing it in the style of QuickTextMeasurer (#1390). This entirely removes the need for PDFKit at runtime. This has the advantage of fixing #1305 – more generally: producing the same result everywhere – without having to deploy a copy of Verdana. The lifting is delegated to these three libraries, which are housed in a monorepo: https://github.com/metabolize/anafanafo I'd be happy to move it into the badges org if folks want to collaborate on maintaining them. QuickTextMeasurer took kerning pairs into account, whereas this implementation does not. I was thinking kerning would be a necessary refinement, though this seems to work well enough. I dropped in a binary-search package to traverse the data structure, in part to conserve space. This causes a moderate performance regression, though there is ample room for improving on that: https://github.com/badges/shields/pull/2311#issuecomment-439182704
Showing
- .circleci/images/prepare-container.sh 0 additions, 1 deletion.circleci/images/prepare-container.sh
- Dockerfile 0 additions, 1 deletionDockerfile
- __snapshots__/make-badge.spec.js 1 addition, 1 deletion__snapshots__/make-badge.spec.js
- gh-badges/README.md 1 addition, 26 deletionsgh-badges/README.md
- gh-badges/lib/badge-cli.js 2 additions, 9 deletionsgh-badges/lib/badge-cli.js
- gh-badges/lib/defaults.js 0 additions, 10 deletionsgh-badges/lib/defaults.js
- gh-badges/lib/index.js 8 additions, 7 deletionsgh-badges/lib/index.js
- gh-badges/lib/make-badge-test-helpers.js 0 additions, 25 deletionsgh-badges/lib/make-badge-test-helpers.js
- gh-badges/lib/make-badge.js 19 additions, 34 deletionsgh-badges/lib/make-badge.js
- gh-badges/lib/make-badge.spec.js 1 addition, 13 deletionsgh-badges/lib/make-badge.spec.js
- gh-badges/lib/svg-to-img.spec.js 1 addition, 3 deletionsgh-badges/lib/svg-to-img.spec.js
- gh-badges/lib/text-measurer.js 0 additions, 94 deletionsgh-badges/lib/text-measurer.js
- gh-badges/lib/text-measurer.spec.js 0 additions, 153 deletionsgh-badges/lib/text-measurer.spec.js
- gh-badges/package.json 1 addition, 0 deletionsgh-badges/package.json
- lib/request-handler.js 2 additions, 5 deletionslib/request-handler.js
- lib/request-handler.spec.js 1 addition, 4 deletionslib/request-handler.spec.js
- lib/server-config.js 0 additions, 9 deletionslib/server-config.js
- package-lock.json 75 additions, 85 deletionspackage-lock.json
- package.json 0 additions, 1 deletionpackage.json
- server.js 2 additions, 13 deletionsserver.js
Loading
Please register or sign in to comment