@@ -684,14 +684,14 @@ export class Font {
684684 let axs ;
685685 if ( ( this . data ?. fvar ?. length ?? 0 ) > 0 ) {
686686 const fontAxes = this . data . fvar [ 0 ] ;
687- axs = fontAxes . map ( ( [ tag , minVal , maxVal , defaultVal , flags , name ] ) => {
687+ axs = fontAxes . map ( ( [ tag , minVal , defaultVal , maxVal , flags , name ] ) => {
688688 if ( ! renderer ) return defaultVal ;
689689 if ( tag === 'wght' ) {
690690 return renderer . states . fontWeight ;
691691 } else if ( tag === 'wdth' ) {
692692 // TODO: map from keywords (normal, ultra-condensed, etc) to values
693693 // return renderer.states.fontStretch
694- return defaultVal ;
694+ return 100 ;
695695 } else if ( renderer . textCanvas ( ) . style . fontVariationSettings ) {
696696 const match = new RegExp ( `\\b${ tag } \s+(\d+)` )
697697 . exec ( renderer . textCanvas ( ) . style . fontVariationSettings ) ;
@@ -971,6 +971,18 @@ function createFontFace(name, path, descriptors, rawFont) {
971971 fontArg = path ;
972972 }
973973
974+ if ( ( rawFont ?. fvar ?. length ?? 0 ) > 0 ) {
975+ descriptors = descriptors || { } ;
976+ for ( const [ tag , minVal , defaultVal , maxVal , flags , name ] of rawFont . fvar [ 0 ] ) {
977+ if ( tag === 'wght' ) {
978+ descriptors . weight = `${ minVal } ${ maxVal } ` ;
979+ } else if ( tag === 'wdth' ) {
980+ descriptors . stretch = `${ minVal } % ${ maxVal } %` ;
981+ }
982+ // TODO add other descriptors
983+ }
984+ }
985+
974986 // create/return the FontFace object
975987 let face = new FontFace ( name , fontArg , descriptors ) ;
976988 if ( face . status === 'error' ) {
0 commit comments