Skip to content
Snippets Groups Projects
  • Paul Melnikow's avatar
    51897b3c
    Precompute text width using a lookup table (#2311) · 51897b3c
    Paul Melnikow authored
    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
    51897b3c
    History
    Precompute text width using a lookup table (#2311)
    Paul Melnikow authored
    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