Просмотр исходного кода

TTFLoader: Fix when TTF has different unicode assign to same glyph index (#31386)

* TTFLoader - Fix when TTF has different unicode assign to same glyph index

* Update TTFLoader.js

Clean up.

* Change to isArray

---------

Co-authored-by: Michael Herzog <michael.herzog@human-interactive.org>
Aless Li 6 месяцев назад
Родитель
Сommit
b9ce407722
1 измененных файлов с 13 добавлено и 1 удалено
  1. 13 1
      examples/jsm/loaders/TTFLoader.js

+ 13 - 1
examples/jsm/loaders/TTFLoader.js

@@ -152,7 +152,19 @@ class TTFLoader extends Loader {
 
 					} );
 
-					glyphs[ String.fromCodePoint( glyph.unicode ) ] = token;
+					if ( Array.isArray( glyph.unicodes ) && glyph.unicodes.length > 0 ) {
+						
+						glyph.unicodes.forEach( function ( unicode ) {
+							
+							glyphs[ String.fromCodePoint( unicode ) ] = token;
+							
+						} );
+						
+					} else {
+
+						glyphs[ String.fromCodePoint( glyph.unicode ) ] = token;
+
+					}
 
 				}
 

粤ICP备19079148号