Skip to content

Commit 34de9db

Browse files
committed
Fix font face format to be more cross browser compatible
1 parent f9f20b6 commit 34de9db

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4201,13 +4201,13 @@ mod tests {
42014201
minify_test("@font-face {src: local(\"Foo Bar\");}", "@font-face{src:local(Foo Bar)}");
42024202
minify_test("@font-face {src: local(Test);}", "@font-face{src:local(Test)}");
42034203
minify_test("@font-face {src: local(Foo Bar);}", "@font-face{src:local(Foo Bar)}");
4204-
minify_test("@font-face {src: url(\"test.woff\") format(woff);}", "@font-face{src:url(test.woff)format(woff)}");
4205-
minify_test("@font-face {src: url(\"test.woff\") format(woff), url(test.ttf) format(truetype);}", "@font-face{src:url(test.woff)format(woff),url(test.ttf)format(truetype)}");
4206-
minify_test("@font-face {src: url(\"test.woff\") format(woff supports features(opentype));}", "@font-face{src:url(test.woff)format(woff supports features(opentype))}");
4207-
minify_test("@font-face {src: url(\"test.woff\") format(woff supports color(COLRv1));}", "@font-face{src:url(test.woff)format(woff supports color(colrv1))}");
4208-
minify_test("@font-face {src: url(\"test.woff\") format(woff supports variations);}", "@font-face{src:url(test.woff)format(woff supports variations)}");
4209-
minify_test("@font-face {src: url(\"test.woff\") format(woff supports palettes);}", "@font-face{src:url(test.woff)format(woff supports palettes)}");
4210-
minify_test("@font-face {src: url(\"test.woff\") format(woff supports features(opentype) color(sbix));}", "@font-face{src:url(test.woff)format(woff supports features(opentype) color(sbix))}");
4204+
minify_test("@font-face {src: url(\"test.woff\") format(woff);}", "@font-face{src:url(test.woff)format(\"woff\")}");
4205+
minify_test("@font-face {src: url(\"test.woff\") format(woff), url(test.ttf) format(truetype);}", "@font-face{src:url(test.woff)format(\"woff\"),url(test.ttf)format(\"truetype\")}");
4206+
minify_test("@font-face {src: url(\"test.woff\") format(woff supports features(opentype));}", "@font-face{src:url(test.woff)format(\"woff\" supports features(opentype))}");
4207+
minify_test("@font-face {src: url(\"test.woff\") format(woff supports color(COLRv1));}", "@font-face{src:url(test.woff)format(\"woff\" supports color(colrv1))}");
4208+
minify_test("@font-face {src: url(\"test.woff\") format(woff supports variations);}", "@font-face{src:url(test.woff)format(\"woff\" supports variations)}");
4209+
minify_test("@font-face {src: url(\"test.woff\") format(woff supports palettes);}", "@font-face{src:url(test.woff)format(\"woff\" supports palettes)}");
4210+
minify_test("@font-face {src: url(\"test.woff\") format(woff supports features(opentype) color(sbix));}", "@font-face{src:url(test.woff)format(\"woff\" supports features(opentype) color(sbix))}");
42114211
}
42124212

42134213
#[test]

src/rules/font_face.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,11 @@ impl ToCss for FontFormat {
169169
EmbeddedOpenType => "embedded-opentype",
170170
Collection => "collection",
171171
SVG => "svg",
172-
String(s) => return serialize_string(&s, dest)
172+
String(s) => &s
173173
};
174-
dest.write_str(s)
174+
// Browser support for keywords rather than strings is very limited.
175+
// https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/src
176+
serialize_string(&s, dest)
175177
}
176178
}
177179

0 commit comments

Comments
 (0)