Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In PrimitivePropertyBuilder.Src -> try to narrow down the PropertyValue list to a single value. This allow to link directly a google font css #423

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,23 @@ public static class Right extends LengthLikeWithAuto {
}

public static class Src extends GenericURIWithNone {

public List buildDeclarations(
CSSName cssName, List values, int origin, boolean important, boolean inheritAllowed) {

// currently Src accept only one values, thus making skip the whole property like:
// "src: local('PT Sans'), local('PTSans-Regular'), url(https://fonts.gstatic.com/s/ptsans/v11/jizaRExUiTo99u79D0KEwA.ttf) format('truetype');"
// ideally, we want to isolate the url
// removing all unknown values and fetching the first one is a decent heuristic (with a fallback to the first value)
if (values.size() > 1) {
values = Collections.singletonList(values.stream().filter(o -> o instanceof PropertyValue)
.filter(o -> ((PropertyValue) o).getPrimitiveType() != CSSPrimitiveValue.CSS_UNKNOWN)
.findFirst().orElse(values.get(0)));
}

return super.buildDeclarations(cssName, values, origin, important, inheritAllowed);
}

}

public static class TabSize extends PlainInteger {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html>
<head>
<style>
@import url('https://fonts.googleapis.com/css?family=PT+Sans&amp;display=swap&amp;subset=cyrillic,cyrillic-ext,latin-ext');
body {
font-family: 'PT Sans', sans-serif;
}
</style>
</head>
<body>
ABCČĆDĐEFGHIJKLMNOPQRSŠTUVWXYZŽabcčćdđefghijklmnopqrsštuvwxyzž
АБВГҐДЂЕЁЄЖЗЅИІЇЙЈКЛЉМНЊОПРСТЋ
УЎФХЦЧЏШЩЪЫЬЭЮЯабвгґдђеёєжзѕиіїйјклљмнњопрстћуўфхцчџшщъыьэюя
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,12 @@ public void testIssue420JustifyTextWhiteSpacePre() throws IOException {
assertTrue(vt.runTest("issue-420-justify-text-white-space-pre"));
}


@Test
public void testBetterGoogleFontsSupport() throws IOException {
assertTrue(vt.runTest("better-google-font-support"));
}

// TODO:
// + Elements that appear just on generated overflow pages.
// + content property (page counters, etc)
Expand Down