- let fcMatchOut = execSync(
- `fc-match "${style.name}":${TextWeight[style.textWeight]}:`+
- `${TextStyle[style.textStyle]}`);
-
- let fontFileName : string = fcMatchOut.toString().match(/^[^:]+/g)[0];
-
- if (fontFileName.match(/[.]ttc$/g)){
- console.log("WARNING: the program doesn't support .ttc font format!\n"+
- "Font file name: "+
- fontFileName);
- return "";
- }
-
- let fcListOut = execSync(
- `fc-list | grep ${fontFileName}`);
- let fontPath : string = fcListOut.toString().match(/^[^:]+/g)[0];
- return fontPath;
+ let fcMatchCommand = `fc-match "${style.family}":${TextWeight[style.textWeight]}:`+
+ `${TextStyle[style.textStyle]}` +` postscriptname file`;
+
+ let fcMatchOut = execSync(fcMatchCommand);
+ let matched = fcMatchOut
+ .toString()
+ .match(/\:file=(.+):postscriptname=(.+)\n/);
+
+ let fontPath : string = matched[1];
+ let psName : string = matched[2];
+
+ return {path: fontPath, psName : psName};
+
+