Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Smaller 'steps' #36

Open
adambundy opened this issue Mar 7, 2019 · 1 comment
Open

Feature Request: Smaller 'steps' #36

adambundy opened this issue Mar 7, 2019 · 1 comment

Comments

@adambundy
Copy link

Thanks for this! Great plugin. Would be nice to be able to specify the size of the font-size 'steps', so that, for instance, half-pixel values could result. I've been trying to modify the plugin to do this without much success.

@BenEfrati
Copy link

Thanks for this! Great plugin. Would be nice to be able to specify the size of the font-size 'steps', so that, for instance, half-pixel values could result. I've been trying to modify the plugin to do this without much success.

Try this for better precision ('steps')

// Binary search for highest best fit
    var size = low;
    while (low <= high) {
      mid = (high + low) / 2;
      innerSpan.style.fontSize = mid + 'px';
      if(innerSpan.scrollWidth <= originalWidth && (settings.widthOnly || innerSpan.scrollHeight <= originalHeight)){
        size = mid;
        low = mid + 0.1;
      } else {
        high = mid - 0.1;
      }
      // await injection point
    }

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants