Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Unified Diff: LayoutTests/fast/css/font-face-unicode-range-load.html

Issue 23446007: Use unicode-range to prevent unnecessary @font-face donwnloads (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase and add toSegmentedFontData() Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/css/font-face-unicode-range-load-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/css/font-face-unicode-range-load.html
diff --git a/LayoutTests/fast/css/font-face-unicode-range-load.html b/LayoutTests/fast/css/font-face-unicode-range-load.html
new file mode 100644
index 0000000000000000000000000000000000000000..5c2a5450b14f8fdb5a794036d61b35b987249b21
--- /dev/null
+++ b/LayoutTests/fast/css/font-face-unicode-range-load.html
@@ -0,0 +1,67 @@
+<html>
+<head>
+<script src="../js/resources/js-test-pre.js"></script>
+<script>
+description('Tests that unicode-range descriptor is used to selectively download fonts that are used in document.');
+
+window.jsTestIsAsync = true;
+
+var latin1Loaded = false;
+var cyrillicLoaded = false;
+var arabicLoaded = false;
+
+function runTests() {
+ document.fonts.addEventListener('load', onload);
+ document.fonts.notifyWhenFontsReady(verify);
+}
+
+function onload(e) {
+ var range = e.fontfaces[0].unicodeRange;
+ if (range == 'U+0-FF')
+ latin1Loaded = true;
+ if (range == 'U+400-4FF')
+ cyrillicLoaded = true;
+ if (range == 'U+600-6FF')
+ arabicLoaded = true;
+}
+
+function verify() {
+ shouldBeTrue('latin1Loaded'); // Latin-1 font is loaded for basic font metrics.
+ shouldBeTrue('cyrillicLoaded');
+ shouldBeFalse('arabicLoaded');
+ finishJSTest();
+}
+
+if (document.fonts)
+ runTests();
+else {
+ testFailed('document.fonts does not exist');
+ finishJSTest();
+}
+</script>
+<style>
+@font-face {
+ font-family: TestFont;
+ src: url('../../resources/Ahem.ttf');
+ unicode-range: U+00-0FF; /* Latin-1 */
+}
+@font-face {
+ font-family: TestFont;
+ src: url('../../resources/Ahem.otf');
+ unicode-range: U+0400-04FF; /* Cyrillic */
+}
+@font-face {
+ font-family: TestFont;
+ src: url('../../resources/Ahem.woff');
+ unicode-range: U+0600-06FF; /* Arabic */
+}
+#test {
+ font-family: TestFont;
+}
+</style>
+</head>
+<body>
+ <p id="test">&#x41F;&#x440;&#x43E;&#x432;&#x435;&#x440;&#x43A;&#x430;</p>
+ <script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/css/font-face-unicode-range-load-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698