summaryrefslogtreecommitdiff
path: root/graphics/java/android
diff options
context:
space:
mode:
author Seigo Nonaka <nona@google.com> 2018-09-11 05:02:46 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-09-11 05:02:46 +0000
commitf18fadb7c06949d15cd6a8a90c1a590219ede554 (patch)
tree683567734aaf582abca0e10effe58f57442f6888 /graphics/java/android
parent3005995a341586da69ab0e45dd0bdddd79565581 (diff)
parenta8fab8acdb4e96d791b4763a1ed97c3202f31a36 (diff)
Merge "Move maximum weight constant from Typeface to Font and make it public"
Diffstat (limited to 'graphics/java/android')
-rw-r--r--graphics/java/android/graphics/Typeface.java8
-rw-r--r--graphics/java/android/graphics/fonts/Font.java16
2 files changed, 15 insertions, 9 deletions
diff --git a/graphics/java/android/graphics/Typeface.java b/graphics/java/android/graphics/Typeface.java
index 4388411c6a99..5aa09cef0c4e 100644
--- a/graphics/java/android/graphics/Typeface.java
+++ b/graphics/java/android/graphics/Typeface.java
@@ -148,13 +148,7 @@ public class Typeface {
@UnsupportedAppUsage
private @Style int mStyle = 0;
- /**
- * A maximum value for the weight value.
- * @hide
- */
- public static final int MAX_WEIGHT = 1000;
-
- private @IntRange(from = 0, to = MAX_WEIGHT) int mWeight = 0;
+ private @IntRange(from = 0, to = android.graphics.fonts.Font.FONT_WEIGHT_MAX) int mWeight = 0;
// Value for weight and italic. Indicates the value is resolved by font metadata.
// Must be the same as the C++ constant in core/jni/android/graphics/FontFamily.cpp
diff --git a/graphics/java/android/graphics/fonts/Font.java b/graphics/java/android/graphics/fonts/Font.java
index a99d297cbd92..8aa48456ebff 100644
--- a/graphics/java/android/graphics/fonts/Font.java
+++ b/graphics/java/android/graphics/fonts/Font.java
@@ -51,6 +51,11 @@ public final class Font {
private static final int STYLE_NORMAL = 0;
/**
+ * A minimum weight value for the font
+ */
+ public static final int FONT_WEIGHT_MIN = 1;
+
+ /**
* A font weight value for the thin weight
*/
public static final int FONT_WEIGHT_THIN = 100;
@@ -96,6 +101,11 @@ public final class Font {
public static final int FONT_WEIGHT_BLACK = 900;
/**
+ * A maximum weight value for the font
+ */
+ public static final int FONT_WEIGHT_MAX = 1000;
+
+ /**
* A builder class for creating new Font.
*/
public static class Builder {
@@ -322,8 +332,9 @@ public final class Font {
* @param weight a weight value
* @return this builder
*/
- public @NonNull Builder setWeight(@IntRange(from = 1, to = 1000) int weight) {
- Preconditions.checkArgument(1 <= weight && weight <= 1000);
+ public @NonNull Builder setWeight(
+ @IntRange(from = FONT_WEIGHT_MIN, to = FONT_WEIGHT_MAX) int weight) {
+ Preconditions.checkArgument(FONT_WEIGHT_MIN <= weight && weight <= FONT_WEIGHT_MAX);
mWeight = weight;
return this;
}
@@ -403,6 +414,7 @@ public final class Font {
mItalic = STYLE_NORMAL;
}
}
+ mWeight = Math.max(FONT_WEIGHT_MIN, Math.min(FONT_WEIGHT_MAX, mWeight));
final boolean italic = (mItalic == STYLE_ITALIC);
final long builderPtr = nInitBuilder();
if (mAxes != null) {