Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

calc-fontsize

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

calc-fontsize

calculate font-size

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

debug.js

calculate font-size for a given bounding box and optionally a font

Code Example

const FontSize = require('calc-fontsize')

const div = document.createElement('div')
document.body.appendChild(div)
const text = 'find the right size for me'
div.style.fontSize = FontSize(text, {width: 100, height: 100, fontFamily: 'arial'})

div.style.fontFamily = 'arial'
div.style.fontSize = fontSize + 'px'
div.innerText = text

Live Example

https://davidfig.github.io/calc-fontsize/

Installation

npm i calc-fontsize

API Reference

/**
 * @param {string} text
 * @param {object} options
 * @param {number} [width] maximum width for bounding box
 * @param {number} [height] maximum height for bounding box
 * @param {string} [fontFamily]
 * @param {number} [min=10] minimum font size
 * @param {number} [max=1000] maximium font size
 * @param {boolean} [remove=false] remove dummy element instead of hiding it for use on next call
 * @returns {number} fontSize
 */
function FontSize(text, options)

Copyright (c) 2017 YOPEY YOPEY LLC - MIT License

FAQs

Package last updated on 18 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc