@@ -684,14 +684,14 @@ export class Font {
684
684
let axs ;
685
685
if ( ( this . data ?. fvar ?. length ?? 0 ) > 0 ) {
686
686
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 ] ) => {
688
688
if ( ! renderer ) return defaultVal ;
689
689
if ( tag === 'wght' ) {
690
690
return renderer . states . fontWeight ;
691
691
} else if ( tag === 'wdth' ) {
692
692
// TODO: map from keywords (normal, ultra-condensed, etc) to values
693
693
// return renderer.states.fontStretch
694
- return defaultVal ;
694
+ return 100 ;
695
695
} else if ( renderer . textCanvas ( ) . style . fontVariationSettings ) {
696
696
const match = new RegExp ( `\\b${ tag } \s+(\d+)` )
697
697
. exec ( renderer . textCanvas ( ) . style . fontVariationSettings ) ;
@@ -971,6 +971,18 @@ function createFontFace(name, path, descriptors, rawFont) {
971
971
fontArg = path ;
972
972
}
973
973
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
+
974
986
// create/return the FontFace object
975
987
let face = new FontFace ( name , fontArg , descriptors ) ;
976
988
if ( face . status === 'error' ) {
0 commit comments