Commit c600bdf7 authored by Natalie Chouinard's avatar Natalie Chouinard Committed by Commit Bot

[GoogleSans] Disable besteffort matching

By default, GMS Core will use best effort matching to provide a font
within the same family if the exact match is not available. For this use
case, providing a font match for the renderer, only exact matches are
valid results, so the query now includes besteffort=false.

Bug: 1111148
Change-Id: I9bad598b7c4d9d64ebf3ce9297015e335185b928
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419592
Commit-Queue: Natalie Chouinard <chouinard@chromium.org>
Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Reviewed-by: default avatarBrandon Wylie <wylieb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809518}
parent de408620
......@@ -36,6 +36,7 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executor;
......@@ -249,11 +250,23 @@ public class AndroidFontLookupImpl implements AndroidFontLookup {
*/
private static Map<String, String> createFullFontNameToQueryMap() {
Map<String, String> map = new HashMap<>();
map.put("google sans regular", "name=Google Sans&weight=400");
map.put("google sans medium", "name=Google Sans&weight=500");
map.put("google sans regular", createFontQuery("Google Sans", 400));
map.put("google sans medium", createFontQuery("Google Sans", 500));
return map;
}
/**
* Construct a GMS Core Downloadable fonts query for a font with exact match parameters.
* (More info: https://developers.google.com/fonts/docs/android#query_format)
*
* @param name Font family name (from fonts.google.com).
* @param weight Font weight.
* @return Query for Google Fonts provider.
*/
private static String createFontQuery(String name, int weight) {
return String.format(Locale.US, "name=%s&weight=%d&besteffort=false", name, weight);
}
private static void logFetchFontResult(@FetchFontResult int result) {
RecordHistogram.recordEnumeratedHistogram(
FETCH_FONT_HISTOGRAM, result, FetchFontResult.COUNT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment