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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegate.java

Issue 1135583003: Fix the issue that certain system captioning fonts are not honored by chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test on Kitkat Created 5 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegate.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegate.java b/content/public/android/java/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegate.java
index 30a89358b508b989558bcd1e3f8b66fb58a53f34..1e9bca8c3f06f94c73774f657af538bf6e8bc0a6 100644
--- a/content/public/android/java/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegate.java
+++ b/content/public/android/java/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegate.java
@@ -197,10 +197,20 @@ public class CaptioningChangeDelegate {
* Describes a font available for Closed Captioning
*/
public static enum ClosedCaptionFont {
+ // The list of fonts are obtained from apps/Settings/res/values/arrays.xml
+ // in Android settings app.
+ // Fonts in Lollipop and above
DEFAULT (""),
- MONOSPACE ("monospace"),
SANS_SERIF ("sans-serif"),
- SERIF ("serif");
+ SANS_SERIF_CONDENSED ("sans-serif-condensed"),
+ SANS_SERIF_MONOSPACE ("sans-serif-monospace"),
+ SERIF ("serif"),
+ SERIF_MONOSPACE ("serif-monospace"),
+ CASUAL ("casual"),
+ CURSIVE ("cursive"),
+ SANS_SERIF_SMALLCAPS ("sans-serif-smallcaps"),
+ // Fronts in Kitkat
+ MONOSPACE("monospace");
private final String mFontFamily;
@@ -215,19 +225,26 @@ public class CaptioningChangeDelegate {
* @return a string representation of the typeface
*/
public static ClosedCaptionFont fromSystemFont(Typeface typeFace) {
- if (typeFace == null || typeFace.equals(Typeface.DEFAULT)) {
- return DEFAULT;
- } else if (typeFace.equals(Typeface.MONOSPACE)) {
- return MONOSPACE;
- } else if (typeFace.equals(Typeface.SANS_SERIF)) {
- return SANS_SERIF;
- } else if (typeFace.equals(Typeface.SERIF)) {
- return SERIF;
- } else {
- // This includes Typeface.DEFAULT_BOLD since font-weight
- // is not yet supported as a WebKit setting for a VTTCue.
- return DEFAULT;
+ if (typeFace == null) return DEFAULT;
+ for (ClosedCaptionFont font : ClosedCaptionFont.values()) {
+ if (belongsToFontFamily(typeFace, font)) {
+ return font;
+ }
}
+ // This includes Typeface.DEFAULT_BOLD since font-weight
+ // is not yet supported as a WebKit setting for a VTTCue.
+ return DEFAULT;
+ }
+
+ /**
+ * Check if the a Typeface belongs to the given font family.
+ *
+ * @param typeFace a Typeface object
+ * @param font Font family to be matched
+ * @return true if the Typeface belongs to the font family, or false otherwise.
+ */
+ private static boolean belongsToFontFamily(Typeface typeFace, ClosedCaptionFont font) {
+ return Typeface.create(font.getFontFamily(), typeFace.getStyle()).equals(typeFace);
}
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698