Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10723,6 +10723,7 @@ package android.content.res { method public android.graphics.drawable.Drawable getDrawable(int, android.content.res.Resources.Theme) throws android.content.res.Resources.NotFoundException; method public deprecated android.graphics.drawable.Drawable getDrawableForDensity(int, int) throws android.content.res.Resources.NotFoundException; method public android.graphics.drawable.Drawable getDrawableForDensity(int, int, android.content.res.Resources.Theme); method public android.graphics.Typeface getFont(int) throws android.content.res.Resources.NotFoundException; method public float getFraction(int, int, int); method public int getIdentifier(java.lang.String, java.lang.String, java.lang.String); method public int[] getIntArray(int) throws android.content.res.Resources.NotFoundException; api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -11245,6 +11245,7 @@ package android.content.res { method public android.graphics.drawable.Drawable getDrawable(int, android.content.res.Resources.Theme) throws android.content.res.Resources.NotFoundException; method public deprecated android.graphics.drawable.Drawable getDrawableForDensity(int, int) throws android.content.res.Resources.NotFoundException; method public android.graphics.drawable.Drawable getDrawableForDensity(int, int, android.content.res.Resources.Theme); method public android.graphics.Typeface getFont(int) throws android.content.res.Resources.NotFoundException; method public float getFraction(int, int, int); method public int getIdentifier(java.lang.String, java.lang.String, java.lang.String); method public int[] getIntArray(int) throws android.content.res.Resources.NotFoundException; api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10755,6 +10755,7 @@ package android.content.res { method public android.graphics.drawable.Drawable getDrawable(int, android.content.res.Resources.Theme) throws android.content.res.Resources.NotFoundException; method public deprecated android.graphics.drawable.Drawable getDrawableForDensity(int, int) throws android.content.res.Resources.NotFoundException; method public android.graphics.drawable.Drawable getDrawableForDensity(int, int, android.content.res.Resources.Theme); method public android.graphics.Typeface getFont(int) throws android.content.res.Resources.NotFoundException; method public float getFraction(int, int, int); method public int getIdentifier(java.lang.String, java.lang.String, java.lang.String); method public int[] getIntArray(int) throws android.content.res.Resources.NotFoundException; core/java/android/content/res/Resources.java +30 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.annotation.StyleableRes; import android.annotation.XmlRes; import android.content.pm.ActivityInfo; import android.graphics.Movie; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable.ConstantState; import android.graphics.drawable.DrawableInflater; Loading Loading @@ -336,6 +337,34 @@ public class Resources { + Integer.toHexString(id)); } /** * Return the Typeface value associated with a particular resource ID. * {@more} * * @param id The desired resource identifier, as generated by the aapt * tool. This integer encodes the package, type, and resource * entry. The value 0 is an invalid identifier. * * @throws NotFoundException Throws NotFoundException if the given ID does not exist. * * @return Typeface The Typeface data associated with the resource. */ @NonNull public Typeface getFont(@StringRes int id) throws NotFoundException { final TypedValue value = obtainTempTypedValue(); try { final ResourcesImpl impl = mResourcesImpl; impl.getValue(id, value, true); Typeface typeface = impl.loadFont(value, id); if (typeface != null) { return typeface; } } finally { releaseTempTypedValue(value); } throw new NotFoundException("Font resource ID #0x" + Integer.toHexString(id)); } /** * Returns the character sequence necessary for grammatically correct pluralization * of the given resource ID for the given quantity. Loading core/java/android/content/res/ResourcesImpl.java +32 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.annotation.StyleableRes; import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo.Config; import android.content.res.Resources.NotFoundException; import android.graphics.Typeface; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.icu.text.PluralRules; Loading @@ -47,6 +48,7 @@ import android.util.Xml; import android.view.Display; import android.view.DisplayAdjustments; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.Locale; Loading Loading @@ -739,6 +741,36 @@ public class ResourcesImpl { return dr; } /** * Loads a font from XML or resources stream. */ @Nullable public Typeface loadFont(TypedValue value, int id) { if (value.string == null) { throw new NotFoundException("Resource \"" + getResourceName(id) + "\" (" + Integer.toHexString(id) + ") is not a Font: " + value); } final String file = value.string.toString(); if (DEBUG_LOAD) { Log.v(TAG, "Loading font for cookie " + value.assetCookie + ": " + file); } Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, file); try { if (file.endsWith(".xml")) { // TODO handle xml type font definitions } else { return Typeface.createFromResources( mAssets, value.string.toString(), value.assetCookie); } } finally { Trace.traceEnd(Trace.TRACE_TAG_RESOURCES); } return null; } /** * Given the value and id, we can get the XML filename as in value.data, based on that, we * first try to load CSL from the cache. If not found, try to get from the constant state. Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10723,6 +10723,7 @@ package android.content.res { method public android.graphics.drawable.Drawable getDrawable(int, android.content.res.Resources.Theme) throws android.content.res.Resources.NotFoundException; method public deprecated android.graphics.drawable.Drawable getDrawableForDensity(int, int) throws android.content.res.Resources.NotFoundException; method public android.graphics.drawable.Drawable getDrawableForDensity(int, int, android.content.res.Resources.Theme); method public android.graphics.Typeface getFont(int) throws android.content.res.Resources.NotFoundException; method public float getFraction(int, int, int); method public int getIdentifier(java.lang.String, java.lang.String, java.lang.String); method public int[] getIntArray(int) throws android.content.res.Resources.NotFoundException;
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -11245,6 +11245,7 @@ package android.content.res { method public android.graphics.drawable.Drawable getDrawable(int, android.content.res.Resources.Theme) throws android.content.res.Resources.NotFoundException; method public deprecated android.graphics.drawable.Drawable getDrawableForDensity(int, int) throws android.content.res.Resources.NotFoundException; method public android.graphics.drawable.Drawable getDrawableForDensity(int, int, android.content.res.Resources.Theme); method public android.graphics.Typeface getFont(int) throws android.content.res.Resources.NotFoundException; method public float getFraction(int, int, int); method public int getIdentifier(java.lang.String, java.lang.String, java.lang.String); method public int[] getIntArray(int) throws android.content.res.Resources.NotFoundException;
api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10755,6 +10755,7 @@ package android.content.res { method public android.graphics.drawable.Drawable getDrawable(int, android.content.res.Resources.Theme) throws android.content.res.Resources.NotFoundException; method public deprecated android.graphics.drawable.Drawable getDrawableForDensity(int, int) throws android.content.res.Resources.NotFoundException; method public android.graphics.drawable.Drawable getDrawableForDensity(int, int, android.content.res.Resources.Theme); method public android.graphics.Typeface getFont(int) throws android.content.res.Resources.NotFoundException; method public float getFraction(int, int, int); method public int getIdentifier(java.lang.String, java.lang.String, java.lang.String); method public int[] getIntArray(int) throws android.content.res.Resources.NotFoundException;
core/java/android/content/res/Resources.java +30 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.annotation.StyleableRes; import android.annotation.XmlRes; import android.content.pm.ActivityInfo; import android.graphics.Movie; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable.ConstantState; import android.graphics.drawable.DrawableInflater; Loading Loading @@ -336,6 +337,34 @@ public class Resources { + Integer.toHexString(id)); } /** * Return the Typeface value associated with a particular resource ID. * {@more} * * @param id The desired resource identifier, as generated by the aapt * tool. This integer encodes the package, type, and resource * entry. The value 0 is an invalid identifier. * * @throws NotFoundException Throws NotFoundException if the given ID does not exist. * * @return Typeface The Typeface data associated with the resource. */ @NonNull public Typeface getFont(@StringRes int id) throws NotFoundException { final TypedValue value = obtainTempTypedValue(); try { final ResourcesImpl impl = mResourcesImpl; impl.getValue(id, value, true); Typeface typeface = impl.loadFont(value, id); if (typeface != null) { return typeface; } } finally { releaseTempTypedValue(value); } throw new NotFoundException("Font resource ID #0x" + Integer.toHexString(id)); } /** * Returns the character sequence necessary for grammatically correct pluralization * of the given resource ID for the given quantity. Loading
core/java/android/content/res/ResourcesImpl.java +32 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.annotation.StyleableRes; import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo.Config; import android.content.res.Resources.NotFoundException; import android.graphics.Typeface; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.icu.text.PluralRules; Loading @@ -47,6 +48,7 @@ import android.util.Xml; import android.view.Display; import android.view.DisplayAdjustments; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.Locale; Loading Loading @@ -739,6 +741,36 @@ public class ResourcesImpl { return dr; } /** * Loads a font from XML or resources stream. */ @Nullable public Typeface loadFont(TypedValue value, int id) { if (value.string == null) { throw new NotFoundException("Resource \"" + getResourceName(id) + "\" (" + Integer.toHexString(id) + ") is not a Font: " + value); } final String file = value.string.toString(); if (DEBUG_LOAD) { Log.v(TAG, "Loading font for cookie " + value.assetCookie + ": " + file); } Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, file); try { if (file.endsWith(".xml")) { // TODO handle xml type font definitions } else { return Typeface.createFromResources( mAssets, value.string.toString(), value.assetCookie); } } finally { Trace.traceEnd(Trace.TRACE_TAG_RESOURCES); } return null; } /** * Given the value and id, we can get the XML filename as in value.data, based on that, we * first try to load CSL from the cache. If not found, try to get from the constant state. Loading