@@ -376,41 +376,41 @@ export class MinecraftFont {
376376 const { lines, backgroundWidth } = await computeTextWrapping ( words , maxLineWidth )
377377 const width = backgroundWidth + 1
378378 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+ }
414414
415415 const backgroundGeo = new THREE . PlaneBufferGeometry ( width , height )
416416 const backgroundMesh = new THREE . Mesh (
@@ -438,7 +438,6 @@ export class MinecraftFont {
438438 default :
439439 cursor . x = - width / 2 + 1
440440 }
441- // center the line
442441 for ( const word of line . words ) {
443442 for ( const span of word . styles ) {
444443 const text = word . text . slice ( span . start , span . end )
@@ -458,7 +457,7 @@ export class MinecraftFont {
458457 }
459458
460459 let charGeo : THREE . BufferGeometry | undefined
461- if ( geos . length > 1 ) {
460+ if ( geos . length > 0 ) {
462461 charGeo = mergeGeometries ( geos ) !
463462 const charMesh = new THREE . Mesh (
464463 charGeo ,
0 commit comments