Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a174935 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Deprecate graphics/FontFamily."

parents 4cf96309 28eb14a8
Loading
Loading
Loading
Loading
+32 −7
Original line number Diff line number Diff line
@@ -36,7 +36,10 @@ import java.nio.channels.FileChannel;
 * A family of typefaces with different styles.
 *
 * @hide
 *
 * @deprecated Use {@link android.graphics.fonts.FontFamily} instead.
 */
@Deprecated
public class FontFamily {

    private static String TAG = "FontFamily";
@@ -51,20 +54,28 @@ public class FontFamily {

    /**
     * @hide
     *
     * This cannot be deleted because it's in use by AndroidX.
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(trackingBug = 123768928)
    public long mNativePtr;

    // Points native font family builder. Must be zero after freezing this family.
    private long mBuilderPtr;

    @UnsupportedAppUsage
    /**
     * This cannot be deleted because it's in use by AndroidX.
     */
    @UnsupportedAppUsage(trackingBug = 123768928)
    public FontFamily() {
        mBuilderPtr = nInitBuilder(null, 0);
        mNativeBuilderCleaner = sBuilderRegistry.registerNativeAllocation(this, mBuilderPtr);
    }

    @UnsupportedAppUsage
    /**
     * This cannot be deleted because it's in use by AndroidX.
     */
    @UnsupportedAppUsage(trackingBug = 123768928)
    public FontFamily(@Nullable String[] langs, int variant) {
        final String langsString;
        if (langs == null || langs.length == 0) {
@@ -83,8 +94,10 @@ public class FontFamily {
     *
     * @return boolean returns false if some error happens in native code, e.g. broken font file is
     *                 passed, etc.
     *
     * This cannot be deleted because it's in use by AndroidX.
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(trackingBug = 123768928)
    public boolean freeze() {
        if (mBuilderPtr == 0) {
            throw new IllegalStateException("This FontFamily is already frozen");
@@ -98,7 +111,10 @@ public class FontFamily {
        return mNativePtr != 0;
    }

    @UnsupportedAppUsage
    /**
     * This cannot be deleted because it's in use by AndroidX.
     */
    @UnsupportedAppUsage(trackingBug = 123768928)
    public void abortCreation() {
        if (mBuilderPtr == 0) {
            throw new IllegalStateException("This FontFamily is already frozen or abandoned");
@@ -107,6 +123,10 @@ public class FontFamily {
        mBuilderPtr = 0;
    }

    /**
     * This cannot be deleted because it's in use by AndroidX.
     */
    @UnsupportedAppUsage(trackingBug = 123768928)
    public boolean addFont(String path, int ttcIndex, FontVariationAxis[] axes, int weight,
            int italic) {
        if (mBuilderPtr == 0) {
@@ -128,7 +148,10 @@ public class FontFamily {
        }
    }

    @UnsupportedAppUsage
    /**
     * This cannot be deleted because it's in use by AndroidX.
     */
    @UnsupportedAppUsage(trackingBug = 123768928)
    public boolean addFontFromBuffer(ByteBuffer font, int ttcIndex, FontVariationAxis[] axes,
            int weight, int italic) {
        if (mBuilderPtr == 0) {
@@ -153,8 +176,10 @@ public class FontFamily {
     * @param isItalic Whether this font is italic. If the weight is set to 0, this will be resolved
     *            using the OS/2 table in the font.
     * @return
     *
     * This cannot be deleted because it's in use by AndroidX.
     */
    @UnsupportedAppUsage
    @UnsupportedAppUsage(trackingBug = 123768928)
    public boolean addFontFromAssetManager(AssetManager mgr, String path, int cookie,
            boolean isAsset, int ttcIndex, int weight, int isItalic,
            FontVariationAxis[] axes) {
+10 −0
Original line number Diff line number Diff line
@@ -125,7 +125,11 @@ public class Typeface {
    static final Map<String, Typeface> sSystemFontMap;

    // We cannot support sSystemFallbackMap since we will migrate to public FontFamily API.
    /**
     * @deprecated Use {@link android.graphics.fonts.FontFamily} instead.
     */
    @UnsupportedAppUsage
    @Deprecated
    static final Map<String, android.graphics.FontFamily[]> sSystemFallbackMap =
            Collections.emptyMap();

@@ -1019,8 +1023,11 @@ public class Typeface {

    /**
     * This method is used by supportlib-v27.
     *
     * @deprecated Use {@link android.graphics.fonts.FontFamily} instead.
     */
    @UnsupportedAppUsage(trackingBug = 123768395)
    @Deprecated
    private static Typeface createFromFamiliesWithDefault(
            android.graphics.FontFamily[] families, int weight, int italic) {
        return createFromFamiliesWithDefault(families, DEFAULT_FAMILY, weight, italic);
@@ -1038,8 +1045,11 @@ public class Typeface {
     *               the first family's font is used. If the first family has multiple fonts, the
     *               closest to the regular weight and upright font is used.
     * @param families array of font families
     *
     * @deprecated Use {@link android.graphics.fonts.FontFamily} instead.
     */
    @UnsupportedAppUsage
    @Deprecated
    private static Typeface createFromFamiliesWithDefault(android.graphics.FontFamily[] families,
                String fallbackName, int weight, int italic) {
        android.graphics.fonts.FontFamily[] fallback = SystemFonts.getSystemFallback(fallbackName);