Skip to content
This repository was archived by the owner on Feb 17, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions dist/bigtext.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! BigText - v0.1.8 - 2015-02-28
/*! BigText - v0.1.8 - 2015-04-25
* https://github.com/zachleat/bigtext
* Copyright (c) 2015 Zach Leatherman (@zachleat)
* MIT License */
Expand Down Expand Up @@ -136,7 +136,9 @@

function testLineDimensions($line, maxWidth, property, size, interval, units, previousWidth)
{
var width;
var width,
return_size;

previousWidth = typeof previousWidth === 'number' ? previousWidth : 0;
$line.css(property, size + units);

Expand All @@ -147,9 +149,13 @@
$line.css(property, '');

if(width === maxWidth) {
return_size = parseFloat((parseFloat(size) - 0.1).toFixed(3));
if(BigText.supports.wholeNumberFontSizeOnly) {
return_size = Math.round(return_size);
}
return {
match: 'exact',
size: parseFloat((parseFloat(size) - 0.1).toFixed(3))
size: return_size
};
}

Expand All @@ -159,9 +165,14 @@
var under = maxWidth - previousWidth,
over = width - maxWidth;

return_size = parseFloat((parseFloat(size) - (property === 'word-spacing' && previousWidth && ( over < under ) ? 0 : interval)).toFixed(3));
if(BigText.supports.wholeNumberFontSizeOnly) {
return_size = Math.round(return_size);
}

return {
match: 'estimate',
size: parseFloat((parseFloat(size) - (property === 'word-spacing' && previousWidth && ( over < under ) ? 0 : interval)).toFixed(3))
size: return_size
};
}

Expand Down Expand Up @@ -258,7 +269,7 @@
// must re-use font-size, even though it was removed above.
$line.css('font-size', fontSizes[lineNumber] + 'px');

for(var m=1, n=3; m<n; m+=interval) {
for(var m=1, n=20; m<n; m+=interval) {
maxWordSpacing = testLineDimensions($line, maxWidth, 'word-spacing', m, interval, 'px', maxWordSpacing);
if(typeof maxWordSpacing !== 'number') {
wordSpacing = maxWordSpacing.size;
Expand Down
19 changes: 15 additions & 4 deletions src/bigtext.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@

function testLineDimensions($line, maxWidth, property, size, interval, units, previousWidth)
{
var width;
var width,
return_size;

previousWidth = typeof previousWidth === 'number' ? previousWidth : 0;
$line.css(property, size + units);

Expand All @@ -142,9 +144,13 @@
$line.css(property, '');

if(width === maxWidth) {
return_size = parseFloat((parseFloat(size) - 0.1).toFixed(3));
if(BigText.supports.wholeNumberFontSizeOnly) {
return_size = Math.round(return_size);
}
return {
match: 'exact',
size: parseFloat((parseFloat(size) - 0.1).toFixed(3))
size: return_size
};
}

Expand All @@ -154,9 +160,14 @@
var under = maxWidth - previousWidth,
over = width - maxWidth;

return_size = parseFloat((parseFloat(size) - (property === 'word-spacing' && previousWidth && ( over < under ) ? 0 : interval)).toFixed(3));
if(BigText.supports.wholeNumberFontSizeOnly) {
return_size = Math.round(return_size);
}

return {
match: 'estimate',
size: parseFloat((parseFloat(size) - (property === 'word-spacing' && previousWidth && ( over < under ) ? 0 : interval)).toFixed(3))
size: return_size
};
}

Expand Down Expand Up @@ -253,7 +264,7 @@
// must re-use font-size, even though it was removed above.
$line.css('font-size', fontSizes[lineNumber] + 'px');

for(var m=1, n=3; m<n; m+=interval) {
for(var m=1, n=20; m<n; m+=interval) {
maxWordSpacing = testLineDimensions($line, maxWidth, 'word-spacing', m, interval, 'px', maxWordSpacing);
if(typeof maxWordSpacing !== 'number') {
wordSpacing = maxWordSpacing.size;
Expand Down