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

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

Merge "Update layoutlib following Changes I7cf390d9 and I65e220ac"

parents cafcbf4c fa23e5fc
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -411,6 +411,14 @@ public class FontFamily_Delegate {
        sManager.removeJavaReferenceFor(builderPtr);
    }

    /**
     * @see FontFamily#allowUnsupportedFont
     */
    @LayoutlibDelegate
    /*package*/ static void nAllowUnsupportedFont(long builderPtr) {
        // Do nothing here as this is used for Minikin fonts
    }

    // ---- private helper methods ----

    private void init() {
+42 −9
Original line number Diff line number Diff line
@@ -90,9 +90,12 @@ public final class Typeface_Delegate {
        assert variant != FontVariant.NONE;

        // Calculate the required weight based on style and weight of this typeface.
        int weight = mWeight + ((mStyle & Font.BOLD) == 0 ? 0 : FontFamily_Delegate.BOLD_FONT_WEIGHT_DELTA);
        if (weight > 900) {
            weight = 900;
        int weight = mWeight + 50 +
                ((mStyle & Font.BOLD) == 0 ? 0 : FontFamily_Delegate.BOLD_FONT_WEIGHT_DELTA);
        if (weight > 1000) {
            weight = 1000;
        } else if (weight < 100) {
            weight = 100;
        }
        final boolean isItalic = (mStyle & Font.ITALIC) != 0;
        List<Font> fonts = new ArrayList<Font>(mFontFamilies.length);
@@ -162,6 +165,22 @@ public final class Typeface_Delegate {
                delegate.mWeight));
    }

    @LayoutlibDelegate
    /*package*/ static long nativeCreateFromTypefaceWithExactStyle(long native_instance,
            int weight, boolean italic) {
        Typeface_Delegate delegate = sManager.getDelegate(native_instance);
        if (delegate == null) {
            delegate = sManager.getDelegate(sDefaultTypeface);
        }
        if (delegate == null) {
            return 0;
        }

        int style = weight >= 600 ? (italic ? Typeface.BOLD_ITALIC : Typeface.BOLD) :
                (italic ? Typeface.ITALIC : Typeface.NORMAL);
        return sManager.addNewDelegate(new Typeface_Delegate(delegate.mFontFamilies, style, weight));
    }

    @LayoutlibDelegate
    /*package*/ static synchronized long nativeCreateFromTypefaceWithVariation(long native_instance,
            List<FontVariationAxis> axes) {
@@ -195,12 +214,21 @@ public final class Typeface_Delegate {
    }

    @LayoutlibDelegate
    /*package*/ static synchronized long nativeCreateFromArray(long[] familyArray) {
    /*package*/ static synchronized long nativeCreateFromArray(long[] familyArray, int weight,
            int italic) {
        FontFamily_Delegate[] fontFamilies = new FontFamily_Delegate[familyArray.length];
        for (int i = 0; i < familyArray.length; i++) {
            fontFamilies[i] = FontFamily_Delegate.getDelegate(familyArray[i]);
        }
        Typeface_Delegate delegate = new Typeface_Delegate(fontFamilies, Typeface.NORMAL);
        if (weight == Typeface.RESOLVE_BY_FONT_TABLE) {
            weight = 400;
        }
        if (italic == Typeface.RESOLVE_BY_FONT_TABLE) {
            italic = 0;
        }
        int style = weight >= 600 ? (italic == 1 ? Typeface.BOLD_ITALIC : Typeface.BOLD) :
                (italic == 1 ? Typeface.ITALIC : Typeface.NORMAL);
        Typeface_Delegate delegate = new Typeface_Delegate(fontFamilies, style, weight);
        return sManager.addNewDelegate(delegate);
    }

@@ -224,6 +252,15 @@ public final class Typeface_Delegate {
        sDefaultTypeface = native_instance;
    }

    @LayoutlibDelegate
    /*package*/ static int nativeGetBaseWeight(long native_instance) {
        Typeface_Delegate delegate = sManager.getDelegate(native_instance);
        if (delegate == null) {
            return 0;
        }
        return delegate.mWeight;
    }

    @LayoutlibDelegate
    /*package*/ static File getSystemFontConfigLocation() {
        return new File(getFontLocation());
@@ -244,10 +281,6 @@ public final class Typeface_Delegate {

    // ---- Private delegate/helper methods ----

    private Typeface_Delegate(@NonNull FontFamily_Delegate[] fontFamilies, int style) {
        this(fontFamilies, style, FontFamily_Delegate.DEFAULT_FONT_WEIGHT);
    }

    public Typeface_Delegate(@NonNull FontFamily_Delegate[] fontFamilies, int style, int weight) {
        mFontFamilies = fontFamilies;
        mStyle = style;