Merge "Reorganize font enumeration API." into oc-dev
am: 2ac9698271
Change-Id: Ie9bdcdb8d5997db421b783475e1058027cc4bb6f
This commit is contained in:
@ -368,7 +368,6 @@ LOCAL_SRC_FILES += \
|
|||||||
core/java/com/android/internal/appwidget/IAppWidgetHost.aidl \
|
core/java/com/android/internal/appwidget/IAppWidgetHost.aidl \
|
||||||
core/java/com/android/internal/backup/IBackupTransport.aidl \
|
core/java/com/android/internal/backup/IBackupTransport.aidl \
|
||||||
core/java/com/android/internal/backup/IObbBackupService.aidl \
|
core/java/com/android/internal/backup/IObbBackupService.aidl \
|
||||||
core/java/com/android/internal/font/IFontManager.aidl \
|
|
||||||
core/java/com/android/internal/inputmethod/IInputContentUriToken.aidl \
|
core/java/com/android/internal/inputmethod/IInputContentUriToken.aidl \
|
||||||
core/java/com/android/internal/policy/IKeyguardDrawnCallback.aidl \
|
core/java/com/android/internal/policy/IKeyguardDrawnCallback.aidl \
|
||||||
core/java/com/android/internal/policy/IKeyguardDismissCallback.aidl \
|
core/java/com/android/internal/policy/IKeyguardDismissCallback.aidl \
|
||||||
|
@ -8889,7 +8889,6 @@ package android.content {
|
|||||||
field public static final java.lang.String DOWNLOAD_SERVICE = "download";
|
field public static final java.lang.String DOWNLOAD_SERVICE = "download";
|
||||||
field public static final java.lang.String DROPBOX_SERVICE = "dropbox";
|
field public static final java.lang.String DROPBOX_SERVICE = "dropbox";
|
||||||
field public static final java.lang.String FINGERPRINT_SERVICE = "fingerprint";
|
field public static final java.lang.String FINGERPRINT_SERVICE = "fingerprint";
|
||||||
field public static final java.lang.String FONT_SERVICE = "font";
|
|
||||||
field public static final java.lang.String HARDWARE_PROPERTIES_SERVICE = "hardware_properties";
|
field public static final java.lang.String HARDWARE_PROPERTIES_SERVICE = "hardware_properties";
|
||||||
field public static final java.lang.String INPUT_METHOD_SERVICE = "input_method";
|
field public static final java.lang.String INPUT_METHOD_SERVICE = "input_method";
|
||||||
field public static final java.lang.String INPUT_SERVICE = "input";
|
field public static final java.lang.String INPUT_SERVICE = "input";
|
||||||
@ -13243,7 +13242,7 @@ package android.graphics {
|
|||||||
method public void setFilterBitmap(boolean);
|
method public void setFilterBitmap(boolean);
|
||||||
method public void setFlags(int);
|
method public void setFlags(int);
|
||||||
method public void setFontFeatureSettings(java.lang.String);
|
method public void setFontFeatureSettings(java.lang.String);
|
||||||
method public boolean setFontVariationSettings(java.lang.String);
|
method public boolean setFontVariationSettings(java.lang.String) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
method public void setHinting(int);
|
method public void setHinting(int);
|
||||||
method public void setLetterSpacing(float);
|
method public void setLetterSpacing(float);
|
||||||
method public void setLinearText(boolean);
|
method public void setLinearText(boolean);
|
||||||
@ -13777,8 +13776,8 @@ package android.graphics {
|
|||||||
method public static android.graphics.Typeface.Builder obtain();
|
method public static android.graphics.Typeface.Builder obtain();
|
||||||
method public void recycle();
|
method public void recycle();
|
||||||
method public void reset();
|
method public void reset();
|
||||||
method public android.graphics.Typeface.Builder setFontVariationSettings(java.lang.String);
|
method public android.graphics.Typeface.Builder setFontVariationSettings(java.lang.String) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
method public android.graphics.Typeface.Builder setFontVariationSettings(android.text.FontConfig.Axis[]);
|
method public android.graphics.Typeface.Builder setFontVariationSettings(android.graphics.fonts.FontVariationAxis[]);
|
||||||
method public android.graphics.Typeface.Builder setItalic(int);
|
method public android.graphics.Typeface.Builder setItalic(int);
|
||||||
method public android.graphics.Typeface.Builder setSourceFromAsset(android.content.res.AssetManager, java.lang.String);
|
method public android.graphics.Typeface.Builder setSourceFromAsset(android.content.res.AssetManager, java.lang.String);
|
||||||
method public android.graphics.Typeface.Builder setSourceFromFile(java.io.File);
|
method public android.graphics.Typeface.Builder setSourceFromFile(java.io.File);
|
||||||
@ -14388,6 +14387,21 @@ package android.graphics.fonts {
|
|||||||
field public static final android.os.Parcelable.Creator<android.graphics.fonts.FontRequest> CREATOR;
|
field public static final android.os.Parcelable.Creator<android.graphics.fonts.FontRequest> CREATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class FontVariationAxis implements android.os.Parcelable {
|
||||||
|
ctor public FontVariationAxis(java.lang.String, float) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
|
method public int describeContents();
|
||||||
|
method public static android.graphics.fonts.FontVariationAxis[] fromFontVariationSettings(java.lang.String) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
|
method public float getStyleValue();
|
||||||
|
method public java.lang.String getTag();
|
||||||
|
method public static java.lang.String toFontVariationSettings(android.graphics.fonts.FontVariationAxis[]);
|
||||||
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
|
field public static final android.os.Parcelable.Creator<android.graphics.fonts.FontVariationAxis> CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FontVariationAxis.InvalidFormatException extends java.lang.Exception {
|
||||||
|
ctor public FontVariationAxis.InvalidFormatException(java.lang.String);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
package android.graphics.pdf {
|
package android.graphics.pdf {
|
||||||
@ -41051,65 +41065,6 @@ package android.text {
|
|||||||
method public android.text.Editable newEditable(java.lang.CharSequence);
|
method public android.text.Editable newEditable(java.lang.CharSequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class FontConfig implements android.os.Parcelable {
|
|
||||||
ctor public FontConfig(android.text.FontConfig.Family[], android.text.FontConfig.Alias[]);
|
|
||||||
method public int describeContents();
|
|
||||||
method public android.text.FontConfig.Alias[] getAliases();
|
|
||||||
method public android.text.FontConfig.Family[] getFamilies();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig> CREATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FontConfig.Alias implements android.os.Parcelable {
|
|
||||||
ctor public FontConfig.Alias(java.lang.String, java.lang.String, int);
|
|
||||||
method public int describeContents();
|
|
||||||
method public java.lang.String getName();
|
|
||||||
method public java.lang.String getToName();
|
|
||||||
method public int getWeight();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig.Alias> CREATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FontConfig.Axis implements android.os.Parcelable {
|
|
||||||
ctor public FontConfig.Axis(int, float);
|
|
||||||
ctor public FontConfig.Axis(java.lang.String, float);
|
|
||||||
method public int describeContents();
|
|
||||||
method public float getStyleValue();
|
|
||||||
method public int getTag();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig.Axis> CREATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FontConfig.Family implements android.os.Parcelable {
|
|
||||||
ctor public FontConfig.Family(java.lang.String, android.text.FontConfig.Font[], java.lang.String, int);
|
|
||||||
method public int describeContents();
|
|
||||||
method public android.text.FontConfig.Font[] getFonts();
|
|
||||||
method public java.lang.String getLanguage();
|
|
||||||
method public java.lang.String getName();
|
|
||||||
method public int getVariant();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig.Family> CREATOR;
|
|
||||||
field public static final int VARIANT_COMPACT = 1; // 0x1
|
|
||||||
field public static final int VARIANT_DEFAULT = 0; // 0x0
|
|
||||||
field public static final int VARIANT_ELEGANT = 2; // 0x2
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FontConfig.Font implements android.os.Parcelable {
|
|
||||||
method public int describeContents();
|
|
||||||
method public android.text.FontConfig.Axis[] getAxes();
|
|
||||||
method public java.lang.String getFontName();
|
|
||||||
method public int getTtcIndex();
|
|
||||||
method public android.net.Uri getUri();
|
|
||||||
method public int getWeight();
|
|
||||||
method public boolean isItalic();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig.Font> CREATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class FontManager {
|
|
||||||
method public android.text.FontConfig getSystemFonts();
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract interface GetChars implements java.lang.CharSequence {
|
public abstract interface GetChars implements java.lang.CharSequence {
|
||||||
method public abstract void getChars(int, int, char[], int);
|
method public abstract void getChars(int, int, char[], int);
|
||||||
}
|
}
|
||||||
@ -51363,7 +51318,7 @@ package android.widget {
|
|||||||
method public void setExtractedText(android.view.inputmethod.ExtractedText);
|
method public void setExtractedText(android.view.inputmethod.ExtractedText);
|
||||||
method public void setFilters(android.text.InputFilter[]);
|
method public void setFilters(android.text.InputFilter[]);
|
||||||
method public void setFontFeatureSettings(java.lang.String);
|
method public void setFontFeatureSettings(java.lang.String);
|
||||||
method public boolean setFontVariationSettings(java.lang.String);
|
method public boolean setFontVariationSettings(java.lang.String) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
method protected boolean setFrame(int, int, int, int);
|
method protected boolean setFrame(int, int, int, int);
|
||||||
method public void setFreezesText(boolean);
|
method public void setFreezesText(boolean);
|
||||||
method public void setGravity(int);
|
method public void setGravity(int);
|
||||||
|
@ -9386,7 +9386,6 @@ package android.content {
|
|||||||
field public static final java.lang.String DOWNLOAD_SERVICE = "download";
|
field public static final java.lang.String DOWNLOAD_SERVICE = "download";
|
||||||
field public static final java.lang.String DROPBOX_SERVICE = "dropbox";
|
field public static final java.lang.String DROPBOX_SERVICE = "dropbox";
|
||||||
field public static final java.lang.String FINGERPRINT_SERVICE = "fingerprint";
|
field public static final java.lang.String FINGERPRINT_SERVICE = "fingerprint";
|
||||||
field public static final java.lang.String FONT_SERVICE = "font";
|
|
||||||
field public static final java.lang.String HARDWARE_PROPERTIES_SERVICE = "hardware_properties";
|
field public static final java.lang.String HARDWARE_PROPERTIES_SERVICE = "hardware_properties";
|
||||||
field public static final java.lang.String HDMI_CONTROL_SERVICE = "hdmi_control";
|
field public static final java.lang.String HDMI_CONTROL_SERVICE = "hdmi_control";
|
||||||
field public static final java.lang.String INPUT_METHOD_SERVICE = "input_method";
|
field public static final java.lang.String INPUT_METHOD_SERVICE = "input_method";
|
||||||
@ -13975,7 +13974,7 @@ package android.graphics {
|
|||||||
method public void setFilterBitmap(boolean);
|
method public void setFilterBitmap(boolean);
|
||||||
method public void setFlags(int);
|
method public void setFlags(int);
|
||||||
method public void setFontFeatureSettings(java.lang.String);
|
method public void setFontFeatureSettings(java.lang.String);
|
||||||
method public boolean setFontVariationSettings(java.lang.String);
|
method public boolean setFontVariationSettings(java.lang.String) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
method public void setHinting(int);
|
method public void setHinting(int);
|
||||||
method public void setLetterSpacing(float);
|
method public void setLetterSpacing(float);
|
||||||
method public void setLinearText(boolean);
|
method public void setLinearText(boolean);
|
||||||
@ -14509,8 +14508,8 @@ package android.graphics {
|
|||||||
method public static android.graphics.Typeface.Builder obtain();
|
method public static android.graphics.Typeface.Builder obtain();
|
||||||
method public void recycle();
|
method public void recycle();
|
||||||
method public void reset();
|
method public void reset();
|
||||||
method public android.graphics.Typeface.Builder setFontVariationSettings(java.lang.String);
|
method public android.graphics.Typeface.Builder setFontVariationSettings(java.lang.String) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
method public android.graphics.Typeface.Builder setFontVariationSettings(android.text.FontConfig.Axis[]);
|
method public android.graphics.Typeface.Builder setFontVariationSettings(android.graphics.fonts.FontVariationAxis[]);
|
||||||
method public android.graphics.Typeface.Builder setItalic(int);
|
method public android.graphics.Typeface.Builder setItalic(int);
|
||||||
method public android.graphics.Typeface.Builder setSourceFromAsset(android.content.res.AssetManager, java.lang.String);
|
method public android.graphics.Typeface.Builder setSourceFromAsset(android.content.res.AssetManager, java.lang.String);
|
||||||
method public android.graphics.Typeface.Builder setSourceFromFile(java.io.File);
|
method public android.graphics.Typeface.Builder setSourceFromFile(java.io.File);
|
||||||
@ -15120,6 +15119,21 @@ package android.graphics.fonts {
|
|||||||
field public static final android.os.Parcelable.Creator<android.graphics.fonts.FontRequest> CREATOR;
|
field public static final android.os.Parcelable.Creator<android.graphics.fonts.FontRequest> CREATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class FontVariationAxis implements android.os.Parcelable {
|
||||||
|
ctor public FontVariationAxis(java.lang.String, float) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
|
method public int describeContents();
|
||||||
|
method public static android.graphics.fonts.FontVariationAxis[] fromFontVariationSettings(java.lang.String) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
|
method public float getStyleValue();
|
||||||
|
method public java.lang.String getTag();
|
||||||
|
method public static java.lang.String toFontVariationSettings(android.graphics.fonts.FontVariationAxis[]);
|
||||||
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
|
field public static final android.os.Parcelable.Creator<android.graphics.fonts.FontVariationAxis> CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FontVariationAxis.InvalidFormatException extends java.lang.Exception {
|
||||||
|
ctor public FontVariationAxis.InvalidFormatException(java.lang.String);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
package android.graphics.pdf {
|
package android.graphics.pdf {
|
||||||
@ -44510,65 +44524,6 @@ package android.text {
|
|||||||
method public android.text.Editable newEditable(java.lang.CharSequence);
|
method public android.text.Editable newEditable(java.lang.CharSequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class FontConfig implements android.os.Parcelable {
|
|
||||||
ctor public FontConfig(android.text.FontConfig.Family[], android.text.FontConfig.Alias[]);
|
|
||||||
method public int describeContents();
|
|
||||||
method public android.text.FontConfig.Alias[] getAliases();
|
|
||||||
method public android.text.FontConfig.Family[] getFamilies();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig> CREATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FontConfig.Alias implements android.os.Parcelable {
|
|
||||||
ctor public FontConfig.Alias(java.lang.String, java.lang.String, int);
|
|
||||||
method public int describeContents();
|
|
||||||
method public java.lang.String getName();
|
|
||||||
method public java.lang.String getToName();
|
|
||||||
method public int getWeight();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig.Alias> CREATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FontConfig.Axis implements android.os.Parcelable {
|
|
||||||
ctor public FontConfig.Axis(int, float);
|
|
||||||
ctor public FontConfig.Axis(java.lang.String, float);
|
|
||||||
method public int describeContents();
|
|
||||||
method public float getStyleValue();
|
|
||||||
method public int getTag();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig.Axis> CREATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FontConfig.Family implements android.os.Parcelable {
|
|
||||||
ctor public FontConfig.Family(java.lang.String, android.text.FontConfig.Font[], java.lang.String, int);
|
|
||||||
method public int describeContents();
|
|
||||||
method public android.text.FontConfig.Font[] getFonts();
|
|
||||||
method public java.lang.String getLanguage();
|
|
||||||
method public java.lang.String getName();
|
|
||||||
method public int getVariant();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig.Family> CREATOR;
|
|
||||||
field public static final int VARIANT_COMPACT = 1; // 0x1
|
|
||||||
field public static final int VARIANT_DEFAULT = 0; // 0x0
|
|
||||||
field public static final int VARIANT_ELEGANT = 2; // 0x2
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FontConfig.Font implements android.os.Parcelable {
|
|
||||||
method public int describeContents();
|
|
||||||
method public android.text.FontConfig.Axis[] getAxes();
|
|
||||||
method public java.lang.String getFontName();
|
|
||||||
method public int getTtcIndex();
|
|
||||||
method public android.net.Uri getUri();
|
|
||||||
method public int getWeight();
|
|
||||||
method public boolean isItalic();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig.Font> CREATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class FontManager {
|
|
||||||
method public android.text.FontConfig getSystemFonts();
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract interface GetChars implements java.lang.CharSequence {
|
public abstract interface GetChars implements java.lang.CharSequence {
|
||||||
method public abstract void getChars(int, int, char[], int);
|
method public abstract void getChars(int, int, char[], int);
|
||||||
}
|
}
|
||||||
@ -55190,7 +55145,7 @@ package android.widget {
|
|||||||
method public void setExtractedText(android.view.inputmethod.ExtractedText);
|
method public void setExtractedText(android.view.inputmethod.ExtractedText);
|
||||||
method public void setFilters(android.text.InputFilter[]);
|
method public void setFilters(android.text.InputFilter[]);
|
||||||
method public void setFontFeatureSettings(java.lang.String);
|
method public void setFontFeatureSettings(java.lang.String);
|
||||||
method public boolean setFontVariationSettings(java.lang.String);
|
method public boolean setFontVariationSettings(java.lang.String) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
method protected boolean setFrame(int, int, int, int);
|
method protected boolean setFrame(int, int, int, int);
|
||||||
method public void setFreezesText(boolean);
|
method public void setFreezesText(boolean);
|
||||||
method public void setGravity(int);
|
method public void setGravity(int);
|
||||||
|
@ -8921,7 +8921,6 @@ package android.content {
|
|||||||
field public static final java.lang.String DOWNLOAD_SERVICE = "download";
|
field public static final java.lang.String DOWNLOAD_SERVICE = "download";
|
||||||
field public static final java.lang.String DROPBOX_SERVICE = "dropbox";
|
field public static final java.lang.String DROPBOX_SERVICE = "dropbox";
|
||||||
field public static final java.lang.String FINGERPRINT_SERVICE = "fingerprint";
|
field public static final java.lang.String FINGERPRINT_SERVICE = "fingerprint";
|
||||||
field public static final java.lang.String FONT_SERVICE = "font";
|
|
||||||
field public static final java.lang.String HARDWARE_PROPERTIES_SERVICE = "hardware_properties";
|
field public static final java.lang.String HARDWARE_PROPERTIES_SERVICE = "hardware_properties";
|
||||||
field public static final java.lang.String INPUT_METHOD_SERVICE = "input_method";
|
field public static final java.lang.String INPUT_METHOD_SERVICE = "input_method";
|
||||||
field public static final java.lang.String INPUT_SERVICE = "input";
|
field public static final java.lang.String INPUT_SERVICE = "input";
|
||||||
@ -13293,7 +13292,7 @@ package android.graphics {
|
|||||||
method public void setFilterBitmap(boolean);
|
method public void setFilterBitmap(boolean);
|
||||||
method public void setFlags(int);
|
method public void setFlags(int);
|
||||||
method public void setFontFeatureSettings(java.lang.String);
|
method public void setFontFeatureSettings(java.lang.String);
|
||||||
method public boolean setFontVariationSettings(java.lang.String);
|
method public boolean setFontVariationSettings(java.lang.String) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
method public void setHinting(int);
|
method public void setHinting(int);
|
||||||
method public void setLetterSpacing(float);
|
method public void setLetterSpacing(float);
|
||||||
method public void setLinearText(boolean);
|
method public void setLinearText(boolean);
|
||||||
@ -13827,8 +13826,8 @@ package android.graphics {
|
|||||||
method public static android.graphics.Typeface.Builder obtain();
|
method public static android.graphics.Typeface.Builder obtain();
|
||||||
method public void recycle();
|
method public void recycle();
|
||||||
method public void reset();
|
method public void reset();
|
||||||
method public android.graphics.Typeface.Builder setFontVariationSettings(java.lang.String);
|
method public android.graphics.Typeface.Builder setFontVariationSettings(java.lang.String) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
method public android.graphics.Typeface.Builder setFontVariationSettings(android.text.FontConfig.Axis[]);
|
method public android.graphics.Typeface.Builder setFontVariationSettings(android.graphics.fonts.FontVariationAxis[]);
|
||||||
method public android.graphics.Typeface.Builder setItalic(int);
|
method public android.graphics.Typeface.Builder setItalic(int);
|
||||||
method public android.graphics.Typeface.Builder setSourceFromAsset(android.content.res.AssetManager, java.lang.String);
|
method public android.graphics.Typeface.Builder setSourceFromAsset(android.content.res.AssetManager, java.lang.String);
|
||||||
method public android.graphics.Typeface.Builder setSourceFromFile(java.io.File);
|
method public android.graphics.Typeface.Builder setSourceFromFile(java.io.File);
|
||||||
@ -14439,6 +14438,21 @@ package android.graphics.fonts {
|
|||||||
field public static final android.os.Parcelable.Creator<android.graphics.fonts.FontRequest> CREATOR;
|
field public static final android.os.Parcelable.Creator<android.graphics.fonts.FontRequest> CREATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class FontVariationAxis implements android.os.Parcelable {
|
||||||
|
ctor public FontVariationAxis(java.lang.String, float) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
|
method public int describeContents();
|
||||||
|
method public static android.graphics.fonts.FontVariationAxis[] fromFontVariationSettings(java.lang.String) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
|
method public float getStyleValue();
|
||||||
|
method public java.lang.String getTag();
|
||||||
|
method public static java.lang.String toFontVariationSettings(android.graphics.fonts.FontVariationAxis[]);
|
||||||
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
|
field public static final android.os.Parcelable.Creator<android.graphics.fonts.FontVariationAxis> CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FontVariationAxis.InvalidFormatException extends java.lang.Exception {
|
||||||
|
ctor public FontVariationAxis.InvalidFormatException(java.lang.String);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
package android.graphics.pdf {
|
package android.graphics.pdf {
|
||||||
@ -41259,65 +41273,6 @@ package android.text {
|
|||||||
method public android.text.Editable newEditable(java.lang.CharSequence);
|
method public android.text.Editable newEditable(java.lang.CharSequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class FontConfig implements android.os.Parcelable {
|
|
||||||
ctor public FontConfig(android.text.FontConfig.Family[], android.text.FontConfig.Alias[]);
|
|
||||||
method public int describeContents();
|
|
||||||
method public android.text.FontConfig.Alias[] getAliases();
|
|
||||||
method public android.text.FontConfig.Family[] getFamilies();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig> CREATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FontConfig.Alias implements android.os.Parcelable {
|
|
||||||
ctor public FontConfig.Alias(java.lang.String, java.lang.String, int);
|
|
||||||
method public int describeContents();
|
|
||||||
method public java.lang.String getName();
|
|
||||||
method public java.lang.String getToName();
|
|
||||||
method public int getWeight();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig.Alias> CREATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FontConfig.Axis implements android.os.Parcelable {
|
|
||||||
ctor public FontConfig.Axis(int, float);
|
|
||||||
ctor public FontConfig.Axis(java.lang.String, float);
|
|
||||||
method public int describeContents();
|
|
||||||
method public float getStyleValue();
|
|
||||||
method public int getTag();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig.Axis> CREATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FontConfig.Family implements android.os.Parcelable {
|
|
||||||
ctor public FontConfig.Family(java.lang.String, android.text.FontConfig.Font[], java.lang.String, int);
|
|
||||||
method public int describeContents();
|
|
||||||
method public android.text.FontConfig.Font[] getFonts();
|
|
||||||
method public java.lang.String getLanguage();
|
|
||||||
method public java.lang.String getName();
|
|
||||||
method public int getVariant();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig.Family> CREATOR;
|
|
||||||
field public static final int VARIANT_COMPACT = 1; // 0x1
|
|
||||||
field public static final int VARIANT_DEFAULT = 0; // 0x0
|
|
||||||
field public static final int VARIANT_ELEGANT = 2; // 0x2
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class FontConfig.Font implements android.os.Parcelable {
|
|
||||||
method public int describeContents();
|
|
||||||
method public android.text.FontConfig.Axis[] getAxes();
|
|
||||||
method public java.lang.String getFontName();
|
|
||||||
method public int getTtcIndex();
|
|
||||||
method public android.net.Uri getUri();
|
|
||||||
method public int getWeight();
|
|
||||||
method public boolean isItalic();
|
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
|
||||||
field public static final android.os.Parcelable.Creator<android.text.FontConfig.Font> CREATOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class FontManager {
|
|
||||||
method public android.text.FontConfig getSystemFonts();
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract interface GetChars implements java.lang.CharSequence {
|
public abstract interface GetChars implements java.lang.CharSequence {
|
||||||
method public abstract void getChars(int, int, char[], int);
|
method public abstract void getChars(int, int, char[], int);
|
||||||
}
|
}
|
||||||
@ -51754,7 +51709,7 @@ package android.widget {
|
|||||||
method public void setExtractedText(android.view.inputmethod.ExtractedText);
|
method public void setExtractedText(android.view.inputmethod.ExtractedText);
|
||||||
method public void setFilters(android.text.InputFilter[]);
|
method public void setFilters(android.text.InputFilter[]);
|
||||||
method public void setFontFeatureSettings(java.lang.String);
|
method public void setFontFeatureSettings(java.lang.String);
|
||||||
method public boolean setFontVariationSettings(java.lang.String);
|
method public boolean setFontVariationSettings(java.lang.String) throws android.graphics.fonts.FontVariationAxis.InvalidFormatException;
|
||||||
method protected boolean setFrame(int, int, int, int);
|
method protected boolean setFrame(int, int, int, int);
|
||||||
method public void setFreezesText(boolean);
|
method public void setFreezesText(boolean);
|
||||||
method public void setGravity(int);
|
method public void setGravity(int);
|
||||||
|
@ -4061,7 +4061,6 @@ android.text.FontConfig$Family
|
|||||||
android.text.FontConfig$Family$1
|
android.text.FontConfig$Family$1
|
||||||
android.text.FontConfig$Font
|
android.text.FontConfig$Font
|
||||||
android.text.FontConfig$Font$1
|
android.text.FontConfig$Font$1
|
||||||
android.text.FontManager
|
|
||||||
android.text.GetChars
|
android.text.GetChars
|
||||||
android.text.GraphicsOperations
|
android.text.GraphicsOperations
|
||||||
android.text.Html
|
android.text.Html
|
||||||
@ -5501,8 +5500,6 @@ com.android.internal.content.PackageHelper
|
|||||||
com.android.internal.content.PackageMonitor
|
com.android.internal.content.PackageMonitor
|
||||||
com.android.internal.content.ReferrerIntent
|
com.android.internal.content.ReferrerIntent
|
||||||
com.android.internal.content.ReferrerIntent$1
|
com.android.internal.content.ReferrerIntent$1
|
||||||
com.android.internal.font.IFontManager
|
|
||||||
com.android.internal.font.IFontManager$Stub
|
|
||||||
com.android.internal.graphics.drawable.AnimationScaleListDrawable
|
com.android.internal.graphics.drawable.AnimationScaleListDrawable
|
||||||
com.android.internal.graphics.drawable.AnimationScaleListDrawable$AnimationScaleListState
|
com.android.internal.graphics.drawable.AnimationScaleListDrawable$AnimationScaleListState
|
||||||
com.android.internal.hardware.AmbientDisplayConfiguration
|
com.android.internal.hardware.AmbientDisplayConfiguration
|
||||||
|
@ -127,7 +127,6 @@ import android.telecom.TelecomManager;
|
|||||||
import android.telephony.CarrierConfigManager;
|
import android.telephony.CarrierConfigManager;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.FontManager;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -143,7 +142,6 @@ import com.android.internal.app.IAppOpsService;
|
|||||||
import com.android.internal.app.IBatteryStats;
|
import com.android.internal.app.IBatteryStats;
|
||||||
import com.android.internal.app.ISoundTriggerService;
|
import com.android.internal.app.ISoundTriggerService;
|
||||||
import com.android.internal.appwidget.IAppWidgetService;
|
import com.android.internal.appwidget.IAppWidgetService;
|
||||||
import com.android.internal.font.IFontManager;
|
|
||||||
import com.android.internal.os.IDropBoxManagerService;
|
import com.android.internal.os.IDropBoxManagerService;
|
||||||
import com.android.internal.policy.PhoneLayoutInflater;
|
import com.android.internal.policy.PhoneLayoutInflater;
|
||||||
|
|
||||||
@ -831,14 +829,6 @@ final class SystemServiceRegistry {
|
|||||||
return new IncidentManager(ctx);
|
return new IncidentManager(ctx);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
registerService(Context.FONT_SERVICE, FontManager.class,
|
|
||||||
new CachedServiceFetcher<FontManager>() {
|
|
||||||
@Override
|
|
||||||
public FontManager createService(ContextImpl ctx)
|
|
||||||
throws ServiceNotFoundException {
|
|
||||||
IBinder b = ServiceManager.getServiceOrThrow(Context.FONT_SERVICE);
|
|
||||||
return new FontManager(IFontManager.Stub.asInterface(b));
|
|
||||||
}});
|
|
||||||
registerService(Context.AUTOFILL_MANAGER_SERVICE, AutofillManager.class,
|
registerService(Context.AUTOFILL_MANAGER_SERVICE, AutofillManager.class,
|
||||||
new CachedServiceFetcher<AutofillManager>() {
|
new CachedServiceFetcher<AutofillManager>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -3869,11 +3869,6 @@ public abstract class Context {
|
|||||||
*/
|
*/
|
||||||
public static final String DEVICE_IDENTIFIERS_SERVICE = "device_identifiers";
|
public static final String DEVICE_IDENTIFIERS_SERVICE = "device_identifiers";
|
||||||
|
|
||||||
/**
|
|
||||||
* Service that provides System font data.
|
|
||||||
*/
|
|
||||||
public static final String FONT_SERVICE = "font";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to report a system health "incident"
|
* Service to report a system health "incident"
|
||||||
* @hide
|
* @hide
|
||||||
|
@ -21,7 +21,7 @@ import static java.lang.annotation.RetentionPolicy.SOURCE;
|
|||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.graphics.FontListParser;
|
import android.graphics.fonts.FontVariationAxis;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
@ -31,6 +31,7 @@ import java.lang.annotation.Retention;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Font configuration descriptions for System fonts.
|
* Font configuration descriptions for System fonts.
|
||||||
|
* @hide
|
||||||
*/
|
*/
|
||||||
public final class FontConfig implements Parcelable {
|
public final class FontConfig implements Parcelable {
|
||||||
private final @NonNull Family[] mFamilies;
|
private final @NonNull Family[] mFamilies;
|
||||||
@ -83,79 +84,13 @@ public final class FontConfig implements Parcelable {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Class that holds information about a Font axis.
|
|
||||||
*/
|
|
||||||
public static final class Axis implements Parcelable {
|
|
||||||
private final int mTag;
|
|
||||||
private final float mStyleValue;
|
|
||||||
|
|
||||||
public Axis(int tag, float styleValue) {
|
|
||||||
mTag = tag;
|
|
||||||
mStyleValue = styleValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Axis(@NonNull String tagString, float styleValue) {
|
|
||||||
if (!FontListParser.isValidTag(tagString)) {
|
|
||||||
throw new IllegalArgumentException("Invalid tag pattern: " + tagString);
|
|
||||||
}
|
|
||||||
mTag = FontListParser.makeTag(tagString);
|
|
||||||
mStyleValue = styleValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the variable font axis tag associated to this axis.
|
|
||||||
*/
|
|
||||||
public int getTag() {
|
|
||||||
return mTag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the style value associated to the given axis for this font.
|
|
||||||
*/
|
|
||||||
public float getStyleValue() {
|
|
||||||
return mStyleValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public Axis(Parcel in) {
|
|
||||||
mTag = in.readInt();
|
|
||||||
mStyleValue = in.readFloat();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel out, int flag) {
|
|
||||||
out.writeInt(mTag);
|
|
||||||
out.writeFloat(mStyleValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<Axis> CREATOR = new Creator<Axis>() {
|
|
||||||
@Override
|
|
||||||
public Axis createFromParcel(Parcel in) {
|
|
||||||
return new Axis(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Axis[] newArray(int size) {
|
|
||||||
return new Axis[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that holds information about a Font.
|
* Class that holds information about a Font.
|
||||||
*/
|
*/
|
||||||
public static final class Font implements Parcelable {
|
public static final class Font implements Parcelable {
|
||||||
private final @NonNull String mFontName;
|
private final @NonNull String mFontName;
|
||||||
private final int mTtcIndex;
|
private final int mTtcIndex;
|
||||||
private final @NonNull Axis[] mAxes;
|
private final @NonNull FontVariationAxis[] mAxes;
|
||||||
private final int mWeight;
|
private final int mWeight;
|
||||||
private final boolean mIsItalic;
|
private final boolean mIsItalic;
|
||||||
private Uri mUri;
|
private Uri mUri;
|
||||||
@ -163,8 +98,8 @@ public final class FontConfig implements Parcelable {
|
|||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public Font(@NonNull String fontName, int ttcIndex, @NonNull Axis[] axes, int weight,
|
public Font(@NonNull String fontName, int ttcIndex, @NonNull FontVariationAxis[] axes,
|
||||||
boolean isItalic) {
|
int weight, boolean isItalic) {
|
||||||
mFontName = fontName;
|
mFontName = fontName;
|
||||||
mTtcIndex = ttcIndex;
|
mTtcIndex = ttcIndex;
|
||||||
mAxes = axes;
|
mAxes = axes;
|
||||||
@ -189,7 +124,7 @@ public final class FontConfig implements Parcelable {
|
|||||||
/**
|
/**
|
||||||
* Returns the list of axes associated to this font.
|
* Returns the list of axes associated to this font.
|
||||||
*/
|
*/
|
||||||
public @NonNull Axis[] getAxes() {
|
public @NonNull FontVariationAxis[] getAxes() {
|
||||||
return mAxes;
|
return mAxes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +165,7 @@ public final class FontConfig implements Parcelable {
|
|||||||
public Font(Parcel in) {
|
public Font(Parcel in) {
|
||||||
mFontName = in.readString();
|
mFontName = in.readString();
|
||||||
mTtcIndex = in.readInt();
|
mTtcIndex = in.readInt();
|
||||||
mAxes = in.createTypedArray(Axis.CREATOR);
|
mAxes = in.createTypedArray(FontVariationAxis.CREATOR);
|
||||||
mWeight = in.readInt();
|
mWeight = in.readInt();
|
||||||
mIsItalic = in.readInt() == 1;
|
mIsItalic = in.readInt() == 1;
|
||||||
mUri = in.readTypedObject(Uri.CREATOR);
|
mUri = in.readTypedObject(Uri.CREATOR);
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package android.text;
|
|
||||||
|
|
||||||
import android.os.RemoteException;
|
|
||||||
|
|
||||||
import com.android.internal.font.IFontManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interact with the Font service.
|
|
||||||
*/
|
|
||||||
public final class FontManager {
|
|
||||||
private static final String TAG = "FontManager";
|
|
||||||
|
|
||||||
private final IFontManager mService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public FontManager(IFontManager service) {
|
|
||||||
mService = service;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the system fonts data. This loads the fonts.xml data if needed and loads all system
|
|
||||||
* fonts in to memory, providing file descriptors for them.
|
|
||||||
*/
|
|
||||||
public FontConfig getSystemFonts() {
|
|
||||||
try {
|
|
||||||
return mService.getSystemFonts();
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
throw e.rethrowFromSystemServer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +1,11 @@
|
|||||||
/*
|
/**
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
* Copyright (c) 2017, The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@ -14,14 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.internal.font;
|
package android.text;
|
||||||
|
|
||||||
import android.text.FontConfig;
|
parcelable FontVariationAxis;
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface to the font manager.
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
interface IFontManager {
|
|
||||||
FontConfig getSystemFonts();
|
|
||||||
}
|
|
@ -56,6 +56,7 @@ import android.graphics.Rect;
|
|||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.graphics.fonts.FontVariationAxis;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.LocaleList;
|
import android.os.LocaleList;
|
||||||
@ -3808,10 +3809,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
* TextView. This function also returns true for empty settings string. Otherwise
|
* TextView. This function also returns true for empty settings string. Otherwise
|
||||||
* returns false.
|
* returns false.
|
||||||
*
|
*
|
||||||
|
* @throws FontVariationAxis.InvalidFormatException
|
||||||
|
* If given string is not a valid font variation settings format.
|
||||||
|
*
|
||||||
* @see #getFontVariationSettings()
|
* @see #getFontVariationSettings()
|
||||||
* @see Paint#getFontVariationSettings() Paint.getFontVariationSettings()
|
* @see Paint#getFontVariationSettings() Paint.getFontVariationSettings()
|
||||||
*/
|
*/
|
||||||
public boolean setFontVariationSettings(@Nullable String fontVariationSettings) {
|
public boolean setFontVariationSettings(@Nullable String fontVariationSettings)
|
||||||
|
throws FontVariationAxis.InvalidFormatException {
|
||||||
final String existingSettings = mTextPaint.getFontVariationSettings();
|
final String existingSettings = mTextPaint.getFontVariationSettings();
|
||||||
if (fontVariationSettings == existingSettings
|
if (fontVariationSettings == existingSettings
|
||||||
|| (fontVariationSettings != null
|
|| (fontVariationSettings != null
|
||||||
|
@ -55,7 +55,7 @@ void init_FontUtils(JNIEnv* env) {
|
|||||||
gListClassInfo.mGet = GetMethodIDOrDie(env, listClass, "get", "(I)Ljava/lang/Object;");
|
gListClassInfo.mGet = GetMethodIDOrDie(env, listClass, "get", "(I)Ljava/lang/Object;");
|
||||||
gListClassInfo.mSize = GetMethodIDOrDie(env, listClass, "size", "()I");
|
gListClassInfo.mSize = GetMethodIDOrDie(env, listClass, "size", "()I");
|
||||||
|
|
||||||
jclass axisClass = FindClassOrDie(env, "android/text/FontConfig$Axis");
|
jclass axisClass = FindClassOrDie(env, "android/graphics/fonts/FontVariationAxis");
|
||||||
gAxisClassInfo.mTag = GetFieldIDOrDie(env, axisClass, "mTag", "I");
|
gAxisClassInfo.mTag = GetFieldIDOrDie(env, axisClass, "mTag", "I");
|
||||||
gAxisClassInfo.mStyleValue = GetFieldIDOrDie(env, axisClass, "mStyleValue", "F");
|
gAxisClassInfo.mStyleValue = GetFieldIDOrDie(env, axisClass, "mStyleValue", "F");
|
||||||
}
|
}
|
||||||
|
@ -1,126 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package android.graphics;
|
|
||||||
|
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
|
||||||
import android.text.FontConfig;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class VariationParserTest extends TestCase {
|
|
||||||
|
|
||||||
@SmallTest
|
|
||||||
public void testParseFontVariationSetting() {
|
|
||||||
int tag = FontListParser.makeTag("wdth");
|
|
||||||
List<FontConfig.Axis> axes = FontListParser.parseFontVariationSettings("'wdth' 1");
|
|
||||||
assertEquals(tag, axes.get(0).getTag());
|
|
||||||
assertEquals(1.0f, axes.get(0).getStyleValue());
|
|
||||||
|
|
||||||
axes = FontListParser.parseFontVariationSettings("\"wdth\" 100");
|
|
||||||
assertEquals(tag, axes.get(0).getTag());
|
|
||||||
assertEquals(100.0f, axes.get(0).getStyleValue());
|
|
||||||
|
|
||||||
axes = FontListParser.parseFontVariationSettings(" 'wdth' 100");
|
|
||||||
assertEquals(tag, axes.get(0).getTag());
|
|
||||||
assertEquals(100.0f, axes.get(0).getStyleValue());
|
|
||||||
|
|
||||||
axes = FontListParser.parseFontVariationSettings("\t'wdth' 0.5");
|
|
||||||
assertEquals(tag, axes.get(0).getTag());
|
|
||||||
assertEquals(0.5f, axes.get(0).getStyleValue());
|
|
||||||
|
|
||||||
tag = FontListParser.makeTag("AX ");
|
|
||||||
axes = FontListParser.parseFontVariationSettings("'AX ' 1");
|
|
||||||
assertEquals(tag, axes.get(0).getTag());
|
|
||||||
assertEquals(1.0f, axes.get(0).getStyleValue());
|
|
||||||
|
|
||||||
axes = FontListParser.parseFontVariationSettings("'AX '\t1");
|
|
||||||
assertEquals(tag, axes.get(0).getTag());
|
|
||||||
assertEquals(1.0f, axes.get(0).getStyleValue());
|
|
||||||
|
|
||||||
axes = FontListParser.parseFontVariationSettings("'AX '\n1");
|
|
||||||
assertEquals(tag, axes.get(0).getTag());
|
|
||||||
assertEquals(1.0f, axes.get(0).getStyleValue());
|
|
||||||
|
|
||||||
axes = FontListParser.parseFontVariationSettings("'AX '\r1");
|
|
||||||
assertEquals(tag, axes.get(0).getTag());
|
|
||||||
assertEquals(1.0f, axes.get(0).getStyleValue());
|
|
||||||
|
|
||||||
axes = FontListParser.parseFontVariationSettings("'AX '\r\t\n 1");
|
|
||||||
assertEquals(tag, axes.get(0).getTag());
|
|
||||||
assertEquals(1.0f, axes.get(0).getStyleValue());
|
|
||||||
|
|
||||||
// Test for invalid input
|
|
||||||
axes = FontListParser.parseFontVariationSettings("");
|
|
||||||
assertEquals(0, axes.size());
|
|
||||||
axes = FontListParser.parseFontVariationSettings("invalid_form");
|
|
||||||
assertEquals(0, axes.size());
|
|
||||||
|
|
||||||
// Test with invalid tag
|
|
||||||
axes = FontListParser.parseFontVariationSettings("'' 1");
|
|
||||||
assertEquals(0, axes.size());
|
|
||||||
axes = FontListParser.parseFontVariationSettings("'invalid' 1");
|
|
||||||
assertEquals(0, axes.size());
|
|
||||||
|
|
||||||
// Test with invalid styleValue
|
|
||||||
axes = FontListParser.parseFontVariationSettings("'wdth' ");
|
|
||||||
assertEquals(0, axes.size());
|
|
||||||
axes = FontListParser.parseFontVariationSettings("'wdth' x");
|
|
||||||
assertEquals(0, axes.size());
|
|
||||||
axes = FontListParser.parseFontVariationSettings("'wdth' \t");
|
|
||||||
assertEquals(0, axes.size());
|
|
||||||
axes = FontListParser.parseFontVariationSettings("'wdth' \n\r");
|
|
||||||
assertEquals(0, axes.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SmallTest
|
|
||||||
public void testParseFontVariationStyleSettings() {
|
|
||||||
List<FontConfig.Axis> axes =
|
|
||||||
FontListParser.parseFontVariationSettings("'wdth' 10,'AX '\r1");
|
|
||||||
int tag1 = FontListParser.makeTag("wdth");
|
|
||||||
int tag2 = FontListParser.makeTag("AX ");
|
|
||||||
assertEquals(tag1, axes.get(0).getTag());
|
|
||||||
assertEquals(10.0f, axes.get(0).getStyleValue());
|
|
||||||
assertEquals(tag2, axes.get(1).getTag());
|
|
||||||
assertEquals(1.0f, axes.get(1).getStyleValue());
|
|
||||||
|
|
||||||
// Test only spacers are allowed before tag
|
|
||||||
axes = FontListParser.parseFontVariationSettings(" 'wdth' 10,ab'wdth' 1");
|
|
||||||
tag1 = FontListParser.makeTag("wdth");
|
|
||||||
assertEquals(tag1, axes.get(0).getTag());
|
|
||||||
assertEquals(10.0f, axes.get(0).getStyleValue());
|
|
||||||
assertEquals(1, axes.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SmallTest
|
|
||||||
public void testInvalidTagCharacters() {
|
|
||||||
List<FontConfig.Axis> axes =
|
|
||||||
FontListParser.parseFontVariationSettings("'\u0000\u0000\u0000\u0000' 10");
|
|
||||||
assertEquals(0, axes.size());
|
|
||||||
axes = FontListParser.parseFontVariationSettings("'\u3042\u3044\u3046\u3048' 10");
|
|
||||||
assertEquals(0, axes.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SmallTest
|
|
||||||
public void testMakeTag() {
|
|
||||||
assertEquals(0x77647468, FontListParser.makeTag("wdth"));
|
|
||||||
assertEquals(0x41582020, FontListParser.makeTag("AX "));
|
|
||||||
assertEquals(0x20202020, FontListParser.makeTag(" "));
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.text;
|
||||||
|
|
||||||
|
import android.graphics.fonts.FontVariationAxis;
|
||||||
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
public class VariationParserTest extends TestCase {
|
||||||
|
private static final String[] INVALID_STYLE_VALUES = {
|
||||||
|
"", "x", "\t", "\n"
|
||||||
|
};
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
|
public void testFromFontVariationSetting_InvalidStyleValue() {
|
||||||
|
// Test with invalid styleValue
|
||||||
|
for (String invalidStyle : INVALID_STYLE_VALUES) {
|
||||||
|
try {
|
||||||
|
FontVariationAxis.fromFontVariationSettings("'wdth' " + invalidStyle);
|
||||||
|
fail();
|
||||||
|
} catch (FontVariationAxis.InvalidFormatException e) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String invalidStyle : INVALID_STYLE_VALUES) {
|
||||||
|
try {
|
||||||
|
FontVariationAxis.fromFontVariationSettings("'wght' 1, 'wdth' " + invalidStyle);
|
||||||
|
fail();
|
||||||
|
} catch (FontVariationAxis.InvalidFormatException e) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
|
public void testOpenTypeTagValue() throws FontVariationAxis.InvalidFormatException {
|
||||||
|
assertEquals(0x77647468, (new FontVariationAxis("wdth", 0).getOpenTypeTagValue()));
|
||||||
|
assertEquals(0x41582020, (new FontVariationAxis("AX ", 0).getOpenTypeTagValue()));
|
||||||
|
assertEquals(0x20202020, (new FontVariationAxis(" ", 0).getOpenTypeTagValue()));
|
||||||
|
}
|
||||||
|
}
|
@ -3,15 +3,10 @@
|
|||||||
WARNING: Parsing of this file by third-party apps is not supported. The
|
WARNING: Parsing of this file by third-party apps is not supported. The
|
||||||
file, and the font files it refers to, will be renamed and/or moved out
|
file, and the font files it refers to, will be renamed and/or moved out
|
||||||
from their respective location in the next Android release, and/or the
|
from their respective location in the next Android release, and/or the
|
||||||
format or syntax of the file may change significantly. You must not
|
format or syntax of the file may change significantly. If you parse this
|
||||||
parse this file for information about system fonts. Instead, you must
|
file for information about system fonts, do it at your own risk. Your
|
||||||
call android.text.FontManager#getSystemFonts(). For example, it can be
|
application will almost certainly break with the next major Android
|
||||||
called as context.getSystemService(FontManager.class).getSystemFonts().
|
release.
|
||||||
Note that the returned FontConfig includes data on all the defined font
|
|
||||||
families and all the details about weight, style, etc. It also provides
|
|
||||||
an open file descriptor to each font file. Note that callers of the API
|
|
||||||
should ensure they close the given file descriptors once they are done
|
|
||||||
using them.
|
|
||||||
|
|
||||||
In this file, all fonts without names are added to the default list.
|
In this file, all fonts without names are added to the default list.
|
||||||
Fonts are chosen based on a match: full BCP-47 language tag including
|
Fonts are chosen based on a match: full BCP-47 language tag including
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package android.graphics;
|
package android.graphics;
|
||||||
|
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
|
import android.graphics.fonts.FontVariationAxis;
|
||||||
import android.text.FontConfig;
|
import android.text.FontConfig;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import dalvik.annotation.optimization.CriticalNative;
|
import dalvik.annotation.optimization.CriticalNative;
|
||||||
@ -81,7 +82,7 @@ public class FontFamily {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addFont(String path, int ttcIndex, FontConfig.Axis[] axes, int weight,
|
public boolean addFont(String path, int ttcIndex, FontVariationAxis[] axes, int weight,
|
||||||
int italic) {
|
int italic) {
|
||||||
if (mBuilderPtr == 0) {
|
if (mBuilderPtr == 0) {
|
||||||
throw new IllegalStateException("Unable to call addFont after freezing.");
|
throw new IllegalStateException("Unable to call addFont after freezing.");
|
||||||
@ -91,8 +92,8 @@ public class FontFamily {
|
|||||||
long fontSize = fileChannel.size();
|
long fontSize = fileChannel.size();
|
||||||
ByteBuffer fontBuffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fontSize);
|
ByteBuffer fontBuffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fontSize);
|
||||||
if (axes != null) {
|
if (axes != null) {
|
||||||
for (FontConfig.Axis axis : axes) {
|
for (FontVariationAxis axis : axes) {
|
||||||
nAddAxisValue(mBuilderPtr, axis.getTag(), axis.getStyleValue());
|
nAddAxisValue(mBuilderPtr, axis.getOpenTypeTagValue(), axis.getStyleValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nAddFont(mBuilderPtr, fontBuffer, ttcIndex, weight, italic);
|
return nAddFont(mBuilderPtr, fontBuffer, ttcIndex, weight, italic);
|
||||||
@ -102,14 +103,14 @@ public class FontFamily {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addFontFromBuffer(ByteBuffer font, int ttcIndex, FontConfig.Axis[] axes,
|
public boolean addFontFromBuffer(ByteBuffer font, int ttcIndex, FontVariationAxis[] axes,
|
||||||
int weight, int italic) {
|
int weight, int italic) {
|
||||||
if (mBuilderPtr == 0) {
|
if (mBuilderPtr == 0) {
|
||||||
throw new IllegalStateException("Unable to call addFontWeightStyle after freezing.");
|
throw new IllegalStateException("Unable to call addFontWeightStyle after freezing.");
|
||||||
}
|
}
|
||||||
if (axes != null) {
|
if (axes != null) {
|
||||||
for (FontConfig.Axis axis : axes) {
|
for (FontVariationAxis axis : axes) {
|
||||||
nAddAxisValue(mBuilderPtr, axis.getTag(), axis.getStyleValue());
|
nAddAxisValue(mBuilderPtr, axis.getOpenTypeTagValue(), axis.getStyleValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nAddFontWeightStyle(mBuilderPtr, font, ttcIndex, weight, italic);
|
return nAddFontWeightStyle(mBuilderPtr, font, ttcIndex, weight, italic);
|
||||||
@ -129,13 +130,13 @@ public class FontFamily {
|
|||||||
*/
|
*/
|
||||||
public boolean addFontFromAssetManager(AssetManager mgr, String path, int cookie,
|
public boolean addFontFromAssetManager(AssetManager mgr, String path, int cookie,
|
||||||
boolean isAsset, int ttcIndex, int weight, int isItalic,
|
boolean isAsset, int ttcIndex, int weight, int isItalic,
|
||||||
FontConfig.Axis[] axes) {
|
FontVariationAxis[] axes) {
|
||||||
if (mBuilderPtr == 0) {
|
if (mBuilderPtr == 0) {
|
||||||
throw new IllegalStateException("Unable to call addFontFromAsset after freezing.");
|
throw new IllegalStateException("Unable to call addFontFromAsset after freezing.");
|
||||||
}
|
}
|
||||||
if (axes != null) {
|
if (axes != null) {
|
||||||
for (FontConfig.Axis axis : axes) {
|
for (FontVariationAxis axis : axes) {
|
||||||
nAddAxisValue(mBuilderPtr, axis.getTag(), axis.getStyleValue());
|
nAddAxisValue(mBuilderPtr, axis.getOpenTypeTagValue(), axis.getStyleValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nAddFontFromAssetManager(mBuilderPtr, mgr, path, cookie, isAsset, ttcIndex, weight,
|
return nAddFontFromAssetManager(mBuilderPtr, mgr, path, cookie, isAsset, ttcIndex, weight,
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package android.graphics;
|
package android.graphics;
|
||||||
|
|
||||||
import android.text.FontConfig;
|
import android.text.FontConfig;
|
||||||
|
import android.graphics.fonts.FontVariationAxis;
|
||||||
import android.util.Xml;
|
import android.util.Xml;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
@ -50,72 +51,6 @@ public class FontListParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that a well-formed variation contains a four-character tag and a float as styleValue,
|
|
||||||
// with spacers in between. The tag is enclosd either by double quotes or single quotes.
|
|
||||||
@VisibleForTesting
|
|
||||||
public static ArrayList<FontConfig.Axis> parseFontVariationSettings(@Nullable String settings) {
|
|
||||||
ArrayList<FontConfig.Axis> axisList = new ArrayList<>();
|
|
||||||
if (settings == null) {
|
|
||||||
return axisList;
|
|
||||||
}
|
|
||||||
String[] settingList = settings.split(",");
|
|
||||||
settingLoop:
|
|
||||||
for (String setting : settingList) {
|
|
||||||
int pos = 0;
|
|
||||||
while (pos < setting.length()) {
|
|
||||||
char c = setting.charAt(pos);
|
|
||||||
if (c == '\'' || c == '"') {
|
|
||||||
break;
|
|
||||||
} else if (!isSpacer(c)) {
|
|
||||||
continue settingLoop; // Only spacers are allowed before tag appeared.
|
|
||||||
}
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
if (pos + 7 > setting.length()) {
|
|
||||||
continue; // 7 is the minimum length of tag-style value pair text.
|
|
||||||
}
|
|
||||||
if (setting.charAt(pos) != setting.charAt(pos + 5)) {
|
|
||||||
continue; // Tag should be wrapped with double or single quote.
|
|
||||||
}
|
|
||||||
String tagString = setting.substring(pos + 1, pos + 5);
|
|
||||||
if (!TAG_PATTERN.matcher(tagString).matches()) {
|
|
||||||
continue; // Skip incorrect format tag.
|
|
||||||
}
|
|
||||||
pos += 6;
|
|
||||||
while (pos < setting.length()) {
|
|
||||||
if (!isSpacer(setting.charAt(pos++))) {
|
|
||||||
break; // Skip spacers between the tag and the styleValue.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Skip invalid styleValue
|
|
||||||
float styleValue;
|
|
||||||
String valueString = setting.substring(pos - 1);
|
|
||||||
if (!STYLE_VALUE_PATTERN.matcher(valueString).matches()) {
|
|
||||||
continue; // Skip incorrect format styleValue.
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
styleValue = Float.parseFloat(valueString);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
continue; // ignoreing invalid number format
|
|
||||||
}
|
|
||||||
int tag = makeTag(tagString);
|
|
||||||
axisList.add(new FontConfig.Axis(tag, styleValue));
|
|
||||||
}
|
|
||||||
return axisList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int makeTag(String tagString) {
|
|
||||||
char c1 = tagString.charAt(0);
|
|
||||||
char c2 = tagString.charAt(1);
|
|
||||||
char c3 = tagString.charAt(2);
|
|
||||||
char c4 = tagString.charAt(3);
|
|
||||||
return (c1 << 24) | (c2 << 16) | (c3 << 8) | c4;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isSpacer(char c) {
|
|
||||||
return c == ' ' || c == '\r' || c == '\t' || c == '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
private static FontConfig readFamilies(XmlPullParser parser)
|
private static FontConfig readFamilies(XmlPullParser parser)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
List<FontConfig.Family> families = new ArrayList<>();
|
List<FontConfig.Family> families = new ArrayList<>();
|
||||||
@ -172,7 +107,7 @@ public class FontListParser {
|
|||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
String indexStr = parser.getAttributeValue(null, "index");
|
String indexStr = parser.getAttributeValue(null, "index");
|
||||||
int index = indexStr == null ? 0 : Integer.parseInt(indexStr);
|
int index = indexStr == null ? 0 : Integer.parseInt(indexStr);
|
||||||
List<FontConfig.Axis> axes = new ArrayList<FontConfig.Axis>();
|
List<FontVariationAxis> axes = new ArrayList<FontVariationAxis>();
|
||||||
String weightStr = parser.getAttributeValue(null, "weight");
|
String weightStr = parser.getAttributeValue(null, "weight");
|
||||||
int weight = weightStr == null ? 400 : Integer.parseInt(weightStr);
|
int weight = weightStr == null ? 400 : Integer.parseInt(weightStr);
|
||||||
boolean isItalic = "italic".equals(parser.getAttributeValue(null, "style"));
|
boolean isItalic = "italic".equals(parser.getAttributeValue(null, "style"));
|
||||||
@ -191,47 +126,20 @@ public class FontListParser {
|
|||||||
}
|
}
|
||||||
String sanitizedName = FILENAME_WHITESPACE_PATTERN.matcher(filename).replaceAll("");
|
String sanitizedName = FILENAME_WHITESPACE_PATTERN.matcher(filename).replaceAll("");
|
||||||
return new FontConfig.Font(sanitizedName, index,
|
return new FontConfig.Font(sanitizedName, index,
|
||||||
axes.toArray(new FontConfig.Axis[axes.size()]), weight, isItalic);
|
axes.toArray(new FontVariationAxis[axes.size()]), weight, isItalic);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The 'tag' attribute value is read as four character values between U+0020 and U+007E
|
private static FontVariationAxis readAxis(XmlPullParser parser)
|
||||||
* inclusive.
|
|
||||||
*/
|
|
||||||
private static final Pattern TAG_PATTERN = Pattern.compile("[\\x20-\\x7E]{4}");
|
|
||||||
|
|
||||||
public static boolean isValidTag(String tagString) {
|
|
||||||
if (tagString == null || tagString.length() != 4) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return TAG_PATTERN.matcher(tagString).matches();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The 'styleValue' attribute has an optional leading '-', followed by '<digits>',
|
|
||||||
* '<digits>.<digits>', or '.<digits>' where '<digits>' is one or more of [0-9].
|
|
||||||
*/
|
|
||||||
private static final Pattern STYLE_VALUE_PATTERN =
|
|
||||||
Pattern.compile("-?(([0-9]+(\\.[0-9]+)?)|(\\.[0-9]+))");
|
|
||||||
|
|
||||||
private static FontConfig.Axis readAxis(XmlPullParser parser)
|
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
int tag = 0;
|
|
||||||
String tagStr = parser.getAttributeValue(null, "tag");
|
String tagStr = parser.getAttributeValue(null, "tag");
|
||||||
if (isValidTag(tagStr)) {
|
|
||||||
tag = makeTag(tagStr);
|
|
||||||
} else {
|
|
||||||
throw new XmlPullParserException("Invalid tag attribute value.", parser, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
float styleValue = 0;
|
|
||||||
String styleValueStr = parser.getAttributeValue(null, "stylevalue");
|
String styleValueStr = parser.getAttributeValue(null, "stylevalue");
|
||||||
if (styleValueStr != null && STYLE_VALUE_PATTERN.matcher(styleValueStr).matches()) {
|
|
||||||
styleValue = Float.parseFloat(styleValueStr);
|
|
||||||
} else {
|
|
||||||
throw new XmlPullParserException("Invalid styleValue attribute value.", parser, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
skip(parser); // axis tag is empty, ignore any contents and consume end tag
|
skip(parser); // axis tag is empty, ignore any contents and consume end tag
|
||||||
return new FontConfig.Axis(tag, styleValue);
|
try {
|
||||||
|
return new FontVariationAxis(tagStr, Float.parseFloat(styleValueStr));
|
||||||
|
} catch (FontVariationAxis.InvalidFormatException e) {
|
||||||
|
// Treat as system failure since system preinstalled font setting has invalid format.
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FontConfig.Alias readAlias(XmlPullParser parser)
|
private static FontConfig.Alias readAlias(XmlPullParser parser)
|
||||||
|
@ -20,6 +20,7 @@ import android.annotation.ColorInt;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Size;
|
import android.annotation.Size;
|
||||||
import android.graphics.FontListParser;
|
import android.graphics.FontListParser;
|
||||||
|
import android.graphics.fonts.FontVariationAxis;
|
||||||
import android.os.LocaleList;
|
import android.os.LocaleList;
|
||||||
import android.text.FontConfig;
|
import android.text.FontConfig;
|
||||||
import android.text.GraphicsOperations;
|
import android.text.GraphicsOperations;
|
||||||
@ -1551,8 +1552,11 @@ public class Paint {
|
|||||||
* @return true if the given settings is effective to at least one font file underlying this
|
* @return true if the given settings is effective to at least one font file underlying this
|
||||||
* typeface. This function also returns true for empty settings string. Otherwise
|
* typeface. This function also returns true for empty settings string. Otherwise
|
||||||
* returns false
|
* returns false
|
||||||
|
* @throws FontVariationAxis.InvalidFormatException
|
||||||
|
* If given string is not a valid font variation settings format.
|
||||||
*/
|
*/
|
||||||
public boolean setFontVariationSettings(String settings) {
|
public boolean setFontVariationSettings(String settings)
|
||||||
|
throws FontVariationAxis.InvalidFormatException {
|
||||||
settings = TextUtils.nullIfEmpty(settings);
|
settings = TextUtils.nullIfEmpty(settings);
|
||||||
if (settings == mFontVariationSettings
|
if (settings == mFontVariationSettings
|
||||||
|| (settings != null && settings.equals(mFontVariationSettings))) {
|
|| (settings != null && settings.equals(mFontVariationSettings))) {
|
||||||
@ -1566,11 +1570,10 @@ public class Paint {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ArrayList<FontConfig.Axis> axes = FontListParser.parseFontVariationSettings(settings);
|
FontVariationAxis[] axes = FontVariationAxis.fromFontVariationSettings(settings);
|
||||||
final ArrayList<FontConfig.Axis> filteredAxes = new ArrayList<FontConfig.Axis>();
|
final ArrayList<FontVariationAxis> filteredAxes = new ArrayList<FontVariationAxis>();
|
||||||
for (int i = 0; i < axes.size(); ++i) {
|
for (final FontVariationAxis axis : axes) {
|
||||||
final FontConfig.Axis axis = axes.get(i);
|
if (mTypeface.isSupportedAxes(axis.getOpenTypeTagValue())) {
|
||||||
if (mTypeface.isSupportedAxes(axis.getTag())) {
|
|
||||||
filteredAxes.add(axis);
|
filteredAxes.add(axis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import android.content.res.AssetManager;
|
|||||||
import android.graphics.FontListParser;
|
import android.graphics.FontListParser;
|
||||||
import android.graphics.fonts.FontRequest;
|
import android.graphics.fonts.FontRequest;
|
||||||
import android.graphics.fonts.FontResult;
|
import android.graphics.fonts.FontResult;
|
||||||
|
import android.graphics.fonts.FontVariationAxis;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
@ -358,11 +359,15 @@ public class Typeface {
|
|||||||
FileChannel.MapMode.READ_ONLY, 0, fontSize);
|
FileChannel.MapMode.READ_ONLY, 0, fontSize);
|
||||||
int style = result.getStyle();
|
int style = result.getStyle();
|
||||||
int weight = (style & BOLD) != 0 ? 700 : 400;
|
int weight = (style & BOLD) != 0 ? 700 : 400;
|
||||||
final ArrayList<FontConfig.Axis> axes = FontListParser.parseFontVariationSettings(
|
FontVariationAxis[] axes = null;
|
||||||
result.getFontVariationSettings());
|
try {
|
||||||
if (!fontFamily.addFontFromBuffer(fontBuffer, result.getTtcIndex(),
|
axes = FontVariationAxis.fromFontVariationSettings(
|
||||||
axes.toArray(new FontConfig.Axis[axes.size()]), weight,
|
result.getFontVariationSettings());
|
||||||
(style & ITALIC) == 0 ? Builder.NORMAL : Builder.ITALIC)) {
|
} catch (FontVariationAxis.InvalidFormatException e) {
|
||||||
|
// TODO: Nice to pass FontVariationAxis[] directly instead of string.
|
||||||
|
}
|
||||||
|
if (!fontFamily.addFontFromBuffer(fontBuffer, result.getTtcIndex(), axes, weight,
|
||||||
|
(style & ITALIC) == 0 ? Builder.NORMAL : Builder.ITALIC)) {
|
||||||
Log.e(TAG, "Error creating font " + request.getQuery());
|
Log.e(TAG, "Error creating font " + request.getQuery());
|
||||||
callback.onTypefaceRequestFailed(
|
callback.onTypefaceRequestFailed(
|
||||||
FontRequestCallback.FAIL_REASON_FONT_LOAD_ERROR);
|
FontRequestCallback.FAIL_REASON_FONT_LOAD_ERROR);
|
||||||
@ -514,7 +519,7 @@ public class Typeface {
|
|||||||
public static final int ITALIC = 1;
|
public static final int ITALIC = 1;
|
||||||
|
|
||||||
private int mTtcIndex;
|
private int mTtcIndex;
|
||||||
private FontConfig.Axis[] mAxes;
|
private FontVariationAxis[] mAxes;
|
||||||
|
|
||||||
private AssetManager mAssetManager;
|
private AssetManager mAssetManager;
|
||||||
private String mPath;
|
private String mPath;
|
||||||
@ -682,15 +687,16 @@ public class Typeface {
|
|||||||
* Sets a font variation settings.
|
* Sets a font variation settings.
|
||||||
*
|
*
|
||||||
* @param variationSettings See {@link android.widget.TextView#setFontVariationSettings}.
|
* @param variationSettings See {@link android.widget.TextView#setFontVariationSettings}.
|
||||||
|
* @throws FontVariationAxis.InvalidFormatException If given string is not a valid font
|
||||||
|
* variation settings format.
|
||||||
*/
|
*/
|
||||||
public Builder setFontVariationSettings(@Nullable String variationSettings) {
|
public Builder setFontVariationSettings(@Nullable String variationSettings)
|
||||||
|
throws FontVariationAxis.InvalidFormatException {
|
||||||
checkNotRecycled();
|
checkNotRecycled();
|
||||||
if (mAxes != null) {
|
if (mAxes != null) {
|
||||||
throw new IllegalStateException("Font variation settings are already set.");
|
throw new IllegalStateException("Font variation settings are already set.");
|
||||||
}
|
}
|
||||||
final List<FontConfig.Axis> axesList = FontListParser.parseFontVariationSettings(
|
mAxes = FontVariationAxis.fromFontVariationSettings(variationSettings);
|
||||||
variationSettings);
|
|
||||||
mAxes = axesList.toArray(new FontConfig.Axis[axesList.size()]);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,7 +705,7 @@ public class Typeface {
|
|||||||
*
|
*
|
||||||
* @param axes An array of font variation axis tag-value pairs.
|
* @param axes An array of font variation axis tag-value pairs.
|
||||||
*/
|
*/
|
||||||
public Builder setFontVariationSettings(@Nullable FontConfig.Axis[] axes) {
|
public Builder setFontVariationSettings(@Nullable FontVariationAxis[] axes) {
|
||||||
checkNotRecycled();
|
checkNotRecycled();
|
||||||
if (mAxes != null) {
|
if (mAxes != null) {
|
||||||
throw new IllegalStateException("Font variation settings are already set.");
|
throw new IllegalStateException("Font variation settings are already set.");
|
||||||
@ -718,7 +724,7 @@ public class Typeface {
|
|||||||
* @return Unique id for a given AssetManager and asset path.
|
* @return Unique id for a given AssetManager and asset path.
|
||||||
*/
|
*/
|
||||||
private static String createAssetUid(final AssetManager mgr, String path, int ttcIndex,
|
private static String createAssetUid(final AssetManager mgr, String path, int ttcIndex,
|
||||||
@Nullable FontConfig.Axis[] axes) {
|
@Nullable FontVariationAxis[] axes) {
|
||||||
final SparseArray<String> pkgs = mgr.getAssignedPackageIdentifiers();
|
final SparseArray<String> pkgs = mgr.getAssignedPackageIdentifiers();
|
||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
final int size = pkgs.size();
|
final int size = pkgs.size();
|
||||||
@ -731,8 +737,8 @@ public class Typeface {
|
|||||||
builder.append(Integer.toString(ttcIndex));
|
builder.append(Integer.toString(ttcIndex));
|
||||||
builder.append("-");
|
builder.append("-");
|
||||||
if (axes != null) {
|
if (axes != null) {
|
||||||
for (FontConfig.Axis axis : axes) {
|
for (FontVariationAxis axis : axes) {
|
||||||
builder.append(Integer.toHexString(axis.getTag()));
|
builder.append(axis.getTag());
|
||||||
builder.append("-");
|
builder.append("-");
|
||||||
builder.append(Float.toString(axis.getStyleValue()));
|
builder.append(Float.toString(axis.getStyleValue()));
|
||||||
}
|
}
|
||||||
@ -865,7 +871,7 @@ public class Typeface {
|
|||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public static Typeface createFromTypefaceWithVariation(Typeface family,
|
public static Typeface createFromTypefaceWithVariation(Typeface family,
|
||||||
List<FontConfig.Axis> axes) {
|
List<FontVariationAxis> axes) {
|
||||||
final long ni = family == null ? 0 : family.native_instance;
|
final long ni = family == null ? 0 : family.native_instance;
|
||||||
return new Typeface(nativeCreateFromTypefaceWithVariation(ni, axes));
|
return new Typeface(nativeCreateFromTypefaceWithVariation(ni, axes));
|
||||||
}
|
}
|
||||||
@ -1162,9 +1168,9 @@ public class Typeface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static native long nativeCreateFromTypeface(long native_instance, int style);
|
private static native long nativeCreateFromTypeface(long native_instance, int style);
|
||||||
// TODO: clean up: change List<FontConfig.Axis> to FontConfig.Axis[]
|
// TODO: clean up: change List<FontVariationAxis> to FontVariationAxis[]
|
||||||
private static native long nativeCreateFromTypefaceWithVariation(
|
private static native long nativeCreateFromTypefaceWithVariation(
|
||||||
long native_instance, List<FontConfig.Axis> axes);
|
long native_instance, List<FontVariationAxis> axes);
|
||||||
private static native long nativeCreateWeightAlias(long native_instance, int weight);
|
private static native long nativeCreateWeightAlias(long native_instance, int weight);
|
||||||
private static native void nativeUnref(long native_instance);
|
private static native void nativeUnref(long native_instance);
|
||||||
private static native int nativeGetStyle(long native_instance);
|
private static native int nativeGetStyle(long native_instance);
|
||||||
|
230
graphics/java/android/graphics/fonts/FontVariationAxis.java
Normal file
230
graphics/java/android/graphics/fonts/FontVariationAxis.java
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.graphics.fonts;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class that holds information about single font variation axis.
|
||||||
|
*/
|
||||||
|
public final class FontVariationAxis implements Parcelable {
|
||||||
|
private final int mTag;
|
||||||
|
private final String mTagString;
|
||||||
|
private final float mStyleValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct FontVariationAxis.
|
||||||
|
*
|
||||||
|
* The axis tag must contain four ASCII characters. Tag string that are longer or shorter than
|
||||||
|
* four characters, or contains characters outside of U+0020..U+007E are invalid.
|
||||||
|
*
|
||||||
|
* @throws {@link InvalidFormatException} If given tag string is invalid.
|
||||||
|
*/
|
||||||
|
public FontVariationAxis(@NonNull String tagString, float styleValue)
|
||||||
|
throws InvalidFormatException {
|
||||||
|
if (!isValidTag(tagString)) {
|
||||||
|
throw new InvalidFormatException("Invalid tag pattern: " + tagString);
|
||||||
|
}
|
||||||
|
mTag = makeTag(tagString);
|
||||||
|
mTagString = tagString;
|
||||||
|
mStyleValue = styleValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the OpenType style tag value.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public int getOpenTypeTagValue() {
|
||||||
|
return mTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the variable font axis tag associated to this axis.
|
||||||
|
*/
|
||||||
|
public String getTag() {
|
||||||
|
return mTagString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the style value associated to the given axis for this font.
|
||||||
|
*/
|
||||||
|
public float getStyleValue() {
|
||||||
|
return mStyleValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public FontVariationAxis(Parcel in) {
|
||||||
|
mTag = in.readInt();
|
||||||
|
mTagString = in.readString();
|
||||||
|
mStyleValue = in.readFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel out, int flag) {
|
||||||
|
out.writeInt(mTag);
|
||||||
|
out.writeString(mTagString);
|
||||||
|
out.writeFloat(mStyleValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<FontVariationAxis> CREATOR = new Creator<FontVariationAxis>() {
|
||||||
|
@Override
|
||||||
|
public FontVariationAxis createFromParcel(Parcel in) {
|
||||||
|
return new FontVariationAxis(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FontVariationAxis[] newArray(int size) {
|
||||||
|
return new FontVariationAxis[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a valid font variation setting string for this object.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public @NonNull String toString() {
|
||||||
|
return "'" + mTagString + "' " + Float.toString(mStyleValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'tag' attribute value is read as four character values between U+0020 and U+007E
|
||||||
|
* inclusive.
|
||||||
|
*/
|
||||||
|
private static final Pattern TAG_PATTERN = Pattern.compile("[\u0020-\u007E]{4}");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if 'tagString' is valid for font variation axis tag.
|
||||||
|
*/
|
||||||
|
private static boolean isValidTag(String tagString) {
|
||||||
|
return tagString != null && TAG_PATTERN.matcher(tagString).matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The 'styleValue' attribute has an optional leading '-', followed by '<digits>',
|
||||||
|
* '<digits>.<digits>', or '.<digits>' where '<digits>' is one or more of [0-9].
|
||||||
|
*/
|
||||||
|
private static final Pattern STYLE_VALUE_PATTERN =
|
||||||
|
Pattern.compile("-?(([0-9]+(\\.[0-9]+)?)|(\\.[0-9]+))");
|
||||||
|
|
||||||
|
private static boolean isValidValueFormat(String valueString) {
|
||||||
|
return valueString != null && STYLE_VALUE_PATTERN.matcher(valueString).matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
public static int makeTag(String tagString) {
|
||||||
|
final char c1 = tagString.charAt(0);
|
||||||
|
final char c2 = tagString.charAt(1);
|
||||||
|
final char c3 = tagString.charAt(2);
|
||||||
|
final char c4 = tagString.charAt(3);
|
||||||
|
return (c1 << 24) | (c2 << 16) | (c3 << 8) | c4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception indicates that the format of font variation settings is invalid.
|
||||||
|
*/
|
||||||
|
public static class InvalidFormatException extends Exception {
|
||||||
|
public InvalidFormatException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct FontVariationAxis array from font variation settings.
|
||||||
|
*
|
||||||
|
* The settings string is constructed from multiple pairs of axis tag and style values. The axis
|
||||||
|
* tag must contain four ASCII characters and must be wrapped with single quotes (U+0027) or
|
||||||
|
* double quotes (U+0022). Axis strings that are longer or shorter than four characters, or
|
||||||
|
* contain characters outside of U+0020..U+007E are invalid. If a specified axis name is not
|
||||||
|
* defined in the font, the settings will be ignored.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* FontVariationAxis.fromFontVariationSettings("'wdth' 1.0");
|
||||||
|
* FontVariationAxis.fromFontVariationSettings("'AX ' 1.0, 'FB ' 2.0");
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param settings font variation settings.
|
||||||
|
* @return FontVariationAxis[] the array of parsed font variation axis. {@code null} if settings
|
||||||
|
* has no font variation settings.
|
||||||
|
* @throws InvalidFormatException If given string is not a valid font variation settings format.
|
||||||
|
*/
|
||||||
|
public static @Nullable FontVariationAxis[] fromFontVariationSettings(@Nullable String settings)
|
||||||
|
throws InvalidFormatException {
|
||||||
|
if (settings == null || settings.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final ArrayList<FontVariationAxis> axisList = new ArrayList<>();
|
||||||
|
final int length = settings.length();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
final char c = settings.charAt(i);
|
||||||
|
if (Character.isWhitespace(c)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!(c == '\'' || c == '"') || length < i + 6 || settings.charAt(i + 5) != c) {
|
||||||
|
throw new InvalidFormatException(
|
||||||
|
"Tag should be wrapped with double or single quote: " + settings);
|
||||||
|
}
|
||||||
|
final String tagString = settings.substring(i + 1, i + 5);
|
||||||
|
|
||||||
|
i += 6; // Move to end of tag.
|
||||||
|
int endOfValueString = settings.indexOf(',', i);
|
||||||
|
if (endOfValueString == -1) {
|
||||||
|
endOfValueString = length;
|
||||||
|
}
|
||||||
|
final float value;
|
||||||
|
try {
|
||||||
|
// Float.parseFloat ignores leading/trailing whitespaces.
|
||||||
|
value = Float.parseFloat(settings.substring(i, endOfValueString));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new InvalidFormatException("Failed to parse float string: " + e.getMessage());
|
||||||
|
}
|
||||||
|
axisList.add(new FontVariationAxis(tagString, value));
|
||||||
|
i = endOfValueString;
|
||||||
|
}
|
||||||
|
if (axisList.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return axisList.toArray(new FontVariationAxis[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stringify the array of FontVariationAxis.
|
||||||
|
*
|
||||||
|
* @param axes an array of FontVariationAxis.
|
||||||
|
* @return String a valid font variation settings string.
|
||||||
|
*/
|
||||||
|
public static @NonNull String toFontVariationSettings(@Nullable FontVariationAxis[] axes) {
|
||||||
|
if (axes == null || axes.length == 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return TextUtils.join(",", axes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1817,7 +1817,6 @@ android.text.FontConfig$Family
|
|||||||
android.text.FontConfig$Family$1
|
android.text.FontConfig$Family$1
|
||||||
android.text.FontConfig$Font
|
android.text.FontConfig$Font
|
||||||
android.text.FontConfig$Font$1
|
android.text.FontConfig$Font$1
|
||||||
android.text.FontManager
|
|
||||||
android.text.GetChars
|
android.text.GetChars
|
||||||
android.text.GraphicsOperations
|
android.text.GraphicsOperations
|
||||||
android.text.Html
|
android.text.Html
|
||||||
|
@ -1,100 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2017 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.server;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.FontListParser;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.ParcelFileDescriptor;
|
|
||||||
import android.text.FontConfig;
|
|
||||||
import android.util.Slog;
|
|
||||||
|
|
||||||
import com.android.internal.annotations.GuardedBy;
|
|
||||||
import com.android.internal.font.IFontManager;
|
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class FontManagerService extends IFontManager.Stub {
|
|
||||||
private static final String TAG = "FontManagerService";
|
|
||||||
private static final String FONTS_CONFIG = "/system/etc/fonts.xml";
|
|
||||||
private static final String SYSTEM_FONT_DIR = "/system/fonts/";
|
|
||||||
|
|
||||||
@GuardedBy("mLock")
|
|
||||||
private FontConfig mConfig;
|
|
||||||
private final Object mLock = new Object();
|
|
||||||
|
|
||||||
public static final class Lifecycle extends SystemService {
|
|
||||||
private final FontManagerService mService;
|
|
||||||
|
|
||||||
public Lifecycle(Context context) {
|
|
||||||
super(context);
|
|
||||||
mService = new FontManagerService();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
try {
|
|
||||||
publishBinderService(Context.FONT_SERVICE, mService);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
// Starting this service is not critical to the running of this device and should
|
|
||||||
// therefore not crash the device. If it fails, log the error and continue.
|
|
||||||
Slog.e(TAG, "Could not start the FontManagerService.", t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FontConfig getSystemFonts() {
|
|
||||||
synchronized (mLock) {
|
|
||||||
if (mConfig != null) {
|
|
||||||
return mConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
mConfig = loadFromSystem();
|
|
||||||
if (mConfig == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (FontConfig.Family family : mConfig.getFamilies()) {
|
|
||||||
for (FontConfig.Font font : family.getFonts()) {
|
|
||||||
File fontFile = new File(SYSTEM_FONT_DIR, font.getFontName());
|
|
||||||
font.setUri(Uri.fromFile(fontFile));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return mConfig;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private FontConfig loadFromSystem() {
|
|
||||||
File configFilename = new File(FONTS_CONFIG);
|
|
||||||
try {
|
|
||||||
FileInputStream fontsIn = new FileInputStream(configFilename);
|
|
||||||
return FontListParser.parse(fontsIn);
|
|
||||||
} catch (IOException | XmlPullParserException e) {
|
|
||||||
Slog.e(TAG, "Error opening " + configFilename, e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FontManagerService() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1027,12 +1027,6 @@ public final class SystemServer {
|
|||||||
Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
|
Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!disableNonCoreServices) {
|
|
||||||
traceBeginAndSlog("StartFontServiceManager");
|
|
||||||
mSystemServiceManager.startService(FontManagerService.Lifecycle.class);
|
|
||||||
traceEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!disableNonCoreServices && !disableTextServices) {
|
if (!disableNonCoreServices && !disableTextServices) {
|
||||||
traceBeginAndSlog("StartTextServicesManager");
|
traceBeginAndSlog("StartTextServicesManager");
|
||||||
mSystemServiceManager.startService(TextServicesManagerService.Lifecycle.class);
|
mSystemServiceManager.startService(TextServicesManagerService.Lifecycle.class);
|
||||||
|
@ -2481,7 +2481,6 @@ Landroid/text/FontConfig$Family;
|
|||||||
Landroid/text/FontConfig$Family$1;
|
Landroid/text/FontConfig$Family$1;
|
||||||
Landroid/text/FontConfig$Font;
|
Landroid/text/FontConfig$Font;
|
||||||
Landroid/text/FontConfig$Font$1;
|
Landroid/text/FontConfig$Font$1;
|
||||||
Landroid/text/FontManager;
|
|
||||||
Landroid/text/format/DateFormat;
|
Landroid/text/format/DateFormat;
|
||||||
Landroid/text/format/Time;
|
Landroid/text/format/Time;
|
||||||
Landroid/text/format/Time$TimeCalculator;
|
Landroid/text/format/Time$TimeCalculator;
|
||||||
@ -3132,8 +3131,6 @@ Lcom/android/internal/content/PackageHelper;
|
|||||||
Lcom/android/internal/content/PackageMonitor;
|
Lcom/android/internal/content/PackageMonitor;
|
||||||
Lcom/android/internal/content/ReferrerIntent;
|
Lcom/android/internal/content/ReferrerIntent;
|
||||||
Lcom/android/internal/content/ReferrerIntent$1;
|
Lcom/android/internal/content/ReferrerIntent$1;
|
||||||
Lcom/android/internal/font/IFontManager;
|
|
||||||
Lcom/android/internal/font/IFontManager$Stub;
|
|
||||||
Lcom/android/internal/graphics/drawable/AnimationScaleListDrawable;
|
Lcom/android/internal/graphics/drawable/AnimationScaleListDrawable;
|
||||||
Lcom/android/internal/graphics/drawable/AnimationScaleListDrawable$AnimationScaleListState;
|
Lcom/android/internal/graphics/drawable/AnimationScaleListDrawable$AnimationScaleListState;
|
||||||
Lcom/android/internal/hardware/AmbientDisplayConfiguration;
|
Lcom/android/internal/hardware/AmbientDisplayConfiguration;
|
||||||
@ -4377,8 +4374,6 @@ Lcom/android/server/firewall/StringFilter$7;
|
|||||||
Lcom/android/server/firewall/StringFilter$8;
|
Lcom/android/server/firewall/StringFilter$8;
|
||||||
Lcom/android/server/firewall/StringFilter$9;
|
Lcom/android/server/firewall/StringFilter$9;
|
||||||
Lcom/android/server/firewall/StringFilter$ValueProvider;
|
Lcom/android/server/firewall/StringFilter$ValueProvider;
|
||||||
Lcom/android/server/FontManagerService;
|
|
||||||
Lcom/android/server/FontManagerService$Lifecycle;
|
|
||||||
Lcom/android/server/GestureLauncherService;
|
Lcom/android/server/GestureLauncherService;
|
||||||
Lcom/android/server/GestureLauncherService$1;
|
Lcom/android/server/GestureLauncherService$1;
|
||||||
Lcom/android/server/GestureLauncherService$2;
|
Lcom/android/server/GestureLauncherService$2;
|
||||||
|
@ -26,6 +26,7 @@ import android.annotation.NonNull;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.content.res.BridgeAssetManager;
|
import android.content.res.BridgeAssetManager;
|
||||||
|
import android.graphics.fonts.FontVariationAxis;
|
||||||
import android.text.FontConfig;
|
import android.text.FontConfig;
|
||||||
|
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
@ -250,7 +251,7 @@ public class FontFamily_Delegate {
|
|||||||
// ---- delegate methods ----
|
// ---- delegate methods ----
|
||||||
@LayoutlibDelegate
|
@LayoutlibDelegate
|
||||||
/*package*/ static boolean addFont(FontFamily thisFontFamily, String path, int ttcIndex,
|
/*package*/ static boolean addFont(FontFamily thisFontFamily, String path, int ttcIndex,
|
||||||
FontConfig.Axis[] axes, int weight, int italic) {
|
FontVariationAxis[] axes, int weight, int italic) {
|
||||||
if (thisFontFamily.mBuilderPtr == 0) {
|
if (thisFontFamily.mBuilderPtr == 0) {
|
||||||
assert false : "Unable to call addFont after freezing.";
|
assert false : "Unable to call addFont after freezing.";
|
||||||
return false;
|
return false;
|
||||||
|
@ -23,6 +23,7 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
|
|||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.graphics.FontFamily_Delegate.FontVariant;
|
import android.graphics.FontFamily_Delegate.FontVariant;
|
||||||
|
import android.graphics.fonts.FontVariationAxis;
|
||||||
import android.text.FontConfig;
|
import android.text.FontConfig;
|
||||||
|
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
@ -163,7 +164,7 @@ public final class Typeface_Delegate {
|
|||||||
|
|
||||||
@LayoutlibDelegate
|
@LayoutlibDelegate
|
||||||
/*package*/ static synchronized long nativeCreateFromTypefaceWithVariation(long native_instance,
|
/*package*/ static synchronized long nativeCreateFromTypefaceWithVariation(long native_instance,
|
||||||
List<FontConfig.Axis> axes) {
|
List<FontVariationAxis> axes) {
|
||||||
long newInstance = nativeCreateFromTypeface(native_instance, 0);
|
long newInstance = nativeCreateFromTypeface(native_instance, 0);
|
||||||
|
|
||||||
if (newInstance != 0) {
|
if (newInstance != 0) {
|
||||||
|
Reference in New Issue
Block a user