Skip to content

Commit 9503663

Browse files
committed
Round texture size to pow2
1 parent 7288c0c commit 9503663

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let kerning = require('detect-kerning')
1616
let extend = require('object-assign')
1717
let metrics = require('font-measure')
1818
let flatten = require('flatten-vertex-data')
19-
19+
let { nextPow2 } = require('bit-twiddle')
2020

2121
let shaderCache = new WeakMap
2222

@@ -596,9 +596,9 @@ class GlText {
596596
let cols = Math.min(maxCols, atlas.chars.length)
597597
let rows = Math.ceil(atlas.chars.length / cols)
598598

599-
let atlasWidth = cols * step
599+
let atlasWidth = nextPow2( cols * step )
600600
// let atlasHeight = Math.min(rows * step + step * .5, GlText.maxAtlasSize);
601-
let atlasHeight = rows * step;
601+
let atlasHeight = nextPow2( rows * step );
602602

603603
atlas.width = atlasWidth
604604
atlas.height = atlasHeight;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
},
3030
"homepage": "https://github.com/a-vis/gl-text#readme",
3131
"dependencies": {
32+
"bit-twiddle": "^1.0.2",
3233
"color-normalize": "^1.1.0",
3334
"css-font": "^1.2.0",
3435
"detect-kerning": "^2.1.2",

0 commit comments

Comments
 (0)