Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-5326

TTFSubsetter incorrectly calculating 'searchRange'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.24
    • 2.0.25, 3.0.0 PDFBox
    • FontBox
    • None

    Description

      The log2 method in TTFSubsetter is incorrectly calling round instead of floor on the log2 result.

      If 

      Math.log(num) / Math.log(2)

      results in a whole number, the searchRange is correct but decimal results could get rounded up or down. 

      The spec calls for a floor of the result.
      https://docs.microsoft.com/en-us/typography/opentype/spec/cmap#:~:text=uint16-,searchRange,-Maximum%20power%20of

      Attached two svgs with embedded subset fonts. Firefox gives the best console error output.

      Attachments

        1. working.svg
          13 kB
          Brian Blocher
        2. notworking.svg
          11 kB
          Brian Blocher

        Activity

          People

            tilman Tilman Hausherr
            bblocher@frontporch.com Brian Blocher
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: