npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bigtext

v1.0.1

Published

Calculates the font-size and word-spacing needed to match a line of text to a specific width. (jQuery plugin)

Downloads

1,729

Readme

BigText

Build Status

BigText Makes Text Big

Download bigtext.js

Or use bower: bower install bigtext

Run the Tests

Requirements

  1. jQuery
  2. A block level parent element. BigText will force all children to be block level as well.

Learn More

BigText works best on browsers that support subpixel font scaling. In order to best serve sizes to all browsers, BigText will adjust word-spacing as well as font-size.

Examples

Simple Example

<div id="bigtext">
    <span>BIGTEXT</span>
    <span>Makes Text Big</span>
</div>
<script>
$('#bigtext').bigtext();
</script>

Better, Progressive Enhancement-Based Example

Use display: inline children (like a span) so the text will flow correctly if BigText doesn’t run.

<div id="bigtext">
    <span>BIGTEXT</span>
    <span>Makes Text Big</span>
</div>
<script>
// Only BigText on “new-ish” browsers
if( 'querySelectorAll' in document ) {
    $('#bigtext').bigtext();    
}
</script>

Using a List (ordered/unordered)

<ol id="bigtext">
    <li>BIGTEXT</li>
    <li>Makes Text Big</li>
</ol>
<script>
$('#bigtext').bigtext();
</script>

Restrict to a subset of children

Opt-in children with JS

<div id="bigtext">
    <p>BIGTEXT</p>
    <p>Makes Text Big</p>
</div>
<script>
$('#bigtext').bigtext({
    childSelector: '> p'
});
</script>

Opt-out lines using markup

<ol id="bigtext">
    <li>BIGTEXT</li>
    <li class="bigtext-exempt">Makes Text Big</li>
</ol>
<script>
$('#bigtext').bigtext();
</script>

Mix and Match Fonts

<ol id="bigtext">
    <li>
        <span style="font-family: sans-serif">BIG</span>
        <span style="font-family: serif">TEXT</span>
    </li>
    <li>Makes Text Big</li>
</ol>
<script>
$('#bigtext').bigtext();
</script>

Works also with letter-spacing, word-spacing, and text-transform.

Using with Custom Font-Face

Warning: a known issue exists with the Google/TypeKit font loader in WebKit.

<div id="bigtext">
    <span>BIGTEXT</span>
    <span>Makes Text Big</span>
</div>
<script src="//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"></script>
<script>
$(function() {
    WebFont.load({
        custom: {
            families: ['LeagueGothicRegular'], // font-family name
            urls : ['css/fonts/league-gothic/stylesheet.css'] // URL to css
        },
        active: function() {
            $('#bigtext').bigtext();
        }
    });
});
</script>

Change the default max font size

<div id="bigtext">
    <span>BIG</span><!-- the shorter the line, the larger the size required --> 
</div>
<script>
$('#bigtext').bigtext({
    maxfontsize: 60 // default is 528 (in px)
});
</script>

Adding a default min font size

<div id="bigtext">
    <span>This is a super long line that will probably be resized to epically small proportions. We need a minimum font size!</span>
</div>
<script>
$('#bigtext').bigtext({
    minfontsize: 16 // default is null
});
</script>

Is your text static and unchanging?

See Paravel's FitText plugin. Curious how the two plugins compare? I've written a full comparison between FitText and BigText.

Extra Features

Re-BigText on Resize (Responsive BigText)

As of 0.1.8, BigText implements its own debounced resize event.

Debug Mode

BigText uses an off-canvas detached node to improve performance when sizing. Setting DEBUG_MODE to true will leave this detached node on the canvas for visual inspection for problem resolution.

BigText.DEBUG_MODE = true;

Common Problems

Lines Wrapping Pre-BigText

The starting font-size must be small enough to guarantee that each individual line is not wrapping pre-BigText. If the line is too long, BigText will not size it correctly.

Releases

  • v0.1.0 Initial release
  • v0.1.1 Added line exempt feature.
  • v0.1.2 Responsive BigText resizes with media queries and resize events (optionally debounced).
  • v0.1.3
  • v0.1.4 on 2013-08-24 Numerous bug fixes, improved accuracy, adds debug mode.
  • v0.1.5 on 2013-10-14 BigText uses all children by default (#40)
  • v0.1.6 Various bug fixes.

Using the repo

Run these commands:

  • npm install
  • bower install
  • grunt

Configuring Grunt

Rather than one giant Gruntfile.js, this project is using a modular Grunt setup. Each individual grunt configuration option key has its own file located in grunt/config-lib/ (readonly upstream configs, do not modify these directly) or grunt/config/ (project specific configs). You may use the same key in both directories, the objects are smartly combined using Lo-Dash merge.

For concatenation in the previous Gruntfile setup, you’d add another key to the giant object passed into grunt.initConfig like this: grunt.initConfig({ concat: { /* YOUR CONFIG */ } });. In the new configuration, you’ll create a grunt/config/concat.js with module.exports = { /* YOUR CONFIG */ };.

License

MIT License