Ver código fonte

normalize font-stretch when computing font keys

Gildas 7 anos atrás
pai
commit
ea09c279af
1 arquivos alterados com 16 adições e 1 exclusões
  1. 16 1
      lib/single-file/css-fonts-minifier.js

+ 16 - 1
lib/single-file/css-fonts-minifier.js

@@ -41,6 +41,17 @@ this.fontsMinifier = this.fontsMinifier || (() => {
 		normal: 400,
 		bold: 700
 	};
+	const FONT_STRETCHES = {
+		"ultra-condensed": "50%",
+		"extra-condensed": "62.5%",
+		"condensed": "75%",
+		"semi-condensed": "87.5%",
+		"normal": "100%",
+		"semi-expanded": "112.5%",
+		"expanded": "125%",
+		"extra-expanded": "150%",
+		"ultra-expanded": "200%"
+	};
 
 	return {
 		process: (doc, secondPass) => {
@@ -289,7 +300,7 @@ this.fontsMinifier = this.fontsMinifier || (() => {
 			getFontWeight(style.getPropertyValue("font-weight")),
 			style.getPropertyValue("font-style"),
 			style.getPropertyValue("unicode-range"),
-			style.getPropertyValue("font-stretch"),
+			getFontStretch(style.getPropertyValue("font-stretch")),
 			style.getPropertyValue("font-variant"),
 			style.getPropertyValue("font-feature-settings"),
 			style.getPropertyValue("font-variation-settings")
@@ -310,4 +321,8 @@ this.fontsMinifier = this.fontsMinifier || (() => {
 		return FONT_WEIGHTS[weight] || weight;
 	}
 
+	function getFontStretch(stretch) {
+		return FONT_STRETCHES[stretch] || stretch;
+	}
+
 })();