@@ -376,41 +376,41 @@ export class MinecraftFont {
376
376
const { lines, backgroundWidth } = await computeTextWrapping ( words , maxLineWidth )
377
377
const width = backgroundWidth + 1
378
378
const height = lines . length * 10 + 1
379
- // // Debug output
380
- // const wordWidths = words.map(word => this.getWordWidth(word))
381
- // for (const word of words) {
382
- // console.log(
383
- // `${words.indexOf(word)} '${word.text.toString()}' width: ${
384
- // wordWidths[words.indexOf(word)]
385
- // }`
386
- // )
387
- // for (const span of word.styles) {
388
- // console.log(
389
- // `'${word.text.slice(span.start, span.end).toString()}' ${span.start}-${
390
- // span.end
391
- // } = `,
392
- // span.style
393
- // )
394
- // }
395
- // }
396
- // console.log('Lines:', lines, 'CanvasWidth:', canvasWidth )
397
- // for (const line of lines) {
398
- // console.log('Line', lines.indexOf(line), line.width)
399
- // for (const word of line.words) {
400
- // console.log(
401
- // 'Word',
402
- // line.words.indexOf(word),
403
- // `'${word.text.toString()}'`,
404
- // word.styles.map(span => span.style),
405
- // word.styles.map(
406
- // span =>
407
- // `${span.start}-${span.end} '${word.text
408
- // .slice(span.start, span.end)
409
- // .toString() }'`
410
- // )
411
- // )
412
- // }
413
- // }
379
+ // Debug output
380
+ const wordWidths = words . map ( word => this . getWordWidth ( word ) )
381
+ for ( const word of words ) {
382
+ console . log (
383
+ `${ words . indexOf ( word ) } '${ word . text . toString ( ) } ' width: ${
384
+ wordWidths [ words . indexOf ( word ) ]
385
+ } `
386
+ )
387
+ for ( const span of word . styles ) {
388
+ console . log (
389
+ `'${ word . text . slice ( span . start , span . end ) . toString ( ) } ' ${ span . start } -${
390
+ span . end
391
+ } = `,
392
+ span . style
393
+ )
394
+ }
395
+ }
396
+ console . log ( 'Lines:' , lines , 'CanvasWidth:' , maxLineWidth )
397
+ for ( const line of lines ) {
398
+ console . log ( 'Line' , lines . indexOf ( line ) , line . width )
399
+ for ( const word of line . words ) {
400
+ console . log (
401
+ 'Word' ,
402
+ line . words . indexOf ( word ) ,
403
+ `'${ word . text . toString ( ) } '` ,
404
+ word . styles . map ( span => span . style ) ,
405
+ word . styles . map (
406
+ span =>
407
+ `${ span . start } -${ span . end } '${ word . text
408
+ . slice ( span . start , span . end )
409
+ . toString ( ) } '`
410
+ )
411
+ )
412
+ }
413
+ }
414
414
415
415
const backgroundGeo = new THREE . PlaneBufferGeometry ( width , height )
416
416
const backgroundMesh = new THREE . Mesh (
@@ -438,7 +438,6 @@ export class MinecraftFont {
438
438
default :
439
439
cursor . x = - width / 2 + 1
440
440
}
441
- // center the line
442
441
for ( const word of line . words ) {
443
442
for ( const span of word . styles ) {
444
443
const text = word . text . slice ( span . start , span . end )
@@ -458,7 +457,7 @@ export class MinecraftFont {
458
457
}
459
458
460
459
let charGeo : THREE . BufferGeometry | undefined
461
- if ( geos . length > 1 ) {
460
+ if ( geos . length > 0 ) {
462
461
charGeo = mergeGeometries ( geos ) !
463
462
const charMesh = new THREE . Mesh (
464
463
charGeo ,
0 commit comments