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

Commit e993b8be authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add FontConfig.Font.getPostScriptName API" into sc-dev am: 0566ee96

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14208581

Change-Id: Ie4ce9adc2b28fb1f7841c35219a999cce96e4c1e
parents d954e908 0566ee96
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -14119,6 +14119,7 @@ package android.text {
    method @NonNull public java.io.File getFile();
    method @Nullable public String getFontFamilyName();
    method @NonNull public String getFontVariationSettings();
    method @NonNull public String getPostScriptName();
    method @NonNull public android.graphics.fonts.FontStyle getStyle();
    method public int getTtcIndex();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
+1 −0
Original line number Diff line number Diff line
@@ -2498,6 +2498,7 @@ package android.text {
    method @NonNull public java.io.File getFile();
    method @Nullable public String getFontFamilyName();
    method @NonNull public String getFontVariationSettings();
    method @NonNull public String getPostScriptName();
    method @NonNull public android.graphics.fonts.FontStyle getStyle();
    method public int getTtcIndex();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
+16 −5
Original line number Diff line number Diff line
@@ -194,6 +194,7 @@ public final class FontConfig implements Parcelable {
    public static final class Font implements Parcelable {
        private final @NonNull File mFile;
        private final @Nullable File mOriginalFile;
        private final @NonNull String mPostScriptName;
        private final @NonNull FontStyle mStyle;
        private final @IntRange(from = 0) int mIndex;
        private final @NonNull String mFontVariationSettings;
@@ -204,11 +205,12 @@ public final class FontConfig implements Parcelable {
         *
         * @hide Only system server can create this instance and passed via IPC.
         */
        public Font(@NonNull File file, @Nullable File originalFile, @NonNull FontStyle style,
                @IntRange(from = 0) int index, @NonNull String fontVariationSettings,
                @Nullable String fontFamilyName) {
        public Font(@NonNull File file, @Nullable File originalFile, @NonNull String postScriptName,
                @NonNull FontStyle style, @IntRange(from = 0) int index,
                @NonNull String fontVariationSettings, @Nullable String fontFamilyName) {
            mFile = file;
            mOriginalFile = originalFile;
            mPostScriptName = postScriptName;
            mStyle = style;
            mIndex = index;
            mFontVariationSettings = fontVariationSettings;
@@ -224,6 +226,7 @@ public final class FontConfig implements Parcelable {
        public void writeToParcel(@NonNull Parcel dest, int flags) {
            dest.writeString8(mFile.getAbsolutePath());
            dest.writeString8(mOriginalFile == null ? null : mOriginalFile.getAbsolutePath());
            dest.writeString8(mPostScriptName);
            dest.writeInt(mStyle.getWeight());
            dest.writeInt(mStyle.getSlant());
            dest.writeInt(mIndex);
@@ -238,14 +241,15 @@ public final class FontConfig implements Parcelable {
                File path = new File(source.readString8());
                String originalPathStr = source.readString8();
                File originalPath = originalPathStr == null ? null : new File(originalPathStr);
                String postScriptName = source.readString8();
                int weight = source.readInt();
                int slant = source.readInt();
                int index = source.readInt();
                String varSettings = source.readString8();
                String fallback = source.readString8();

                return new Font(path, originalPath, new FontStyle(weight, slant), index,
                        varSettings, fallback);
                return new Font(path, originalPath, postScriptName, new FontStyle(weight, slant),
                        index, varSettings, fallback);
            }

            @Override
@@ -313,6 +317,13 @@ public final class FontConfig implements Parcelable {
            return mIndex;
        }

        /**
         * Returns the PostScript name of this font.
         */
        public @NonNull String getPostScriptName() {
            return mPostScriptName;
        }

        /**
         * Returns the list of axes associated to this font.
         * @deprecated Use getFontVariationSettings
+32 −12
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ public final class FontListParserTest {
                + "</family>";
        FontConfig.FontFamily expected = new FontConfig.FontFamily(
                Arrays.asList(
                        new FontConfig.Font(new File("test.ttf"), null,
                        new FontConfig.Font(new File("test.ttf"), null, "test",
                                new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
                                0, "", null)),
                "sans-serif", LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT);
@@ -77,10 +77,10 @@ public final class FontListParserTest {
                + "</family>";
        FontConfig.FontFamily expected = new FontConfig.FontFamily(
                Arrays.asList(
                        new FontConfig.Font(new File("test.ttf"), null,
                        new FontConfig.Font(new File("test.ttf"), null, "test",
                                new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
                                0, "", null),
                        new FontConfig.Font(new File("test.ttf"), null,
                        new FontConfig.Font(new File("test.ttf"), null, "test",
                                new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
                                0, "", "serif")),
                null, LocaleList.forLanguageTags("en"), VARIANT_DEFAULT);
@@ -97,7 +97,7 @@ public final class FontListParserTest {
                + "</family>";
        FontConfig.FontFamily expected = new FontConfig.FontFamily(
                Arrays.asList(
                        new FontConfig.Font(new File("test.ttf"), null,
                        new FontConfig.Font(new File("test.ttf"), null, "test",
                                new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
                                0, "", null)),
                null, LocaleList.forLanguageTags("en"), VARIANT_COMPACT);
@@ -114,7 +114,7 @@ public final class FontListParserTest {
                + "</family>";
        FontConfig.FontFamily expected = new FontConfig.FontFamily(
                Arrays.asList(
                        new FontConfig.Font(new File("test.ttf"), null,
                        new FontConfig.Font(new File("test.ttf"), null, "test",
                                new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
                                0, "", null)),
                null, LocaleList.forLanguageTags("en"), VARIANT_ELEGANT);
@@ -133,13 +133,13 @@ public final class FontListParserTest {
                + "</family>";
        FontConfig.FontFamily expected = new FontConfig.FontFamily(
                Arrays.asList(
                        new FontConfig.Font(new File("normal.ttf"), null,
                        new FontConfig.Font(new File("normal.ttf"), null, "test",
                                new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
                                0, "", null),
                        new FontConfig.Font(new File("weight.ttf"), null,
                        new FontConfig.Font(new File("weight.ttf"), null, "test",
                                new FontStyle(100, FONT_SLANT_UPRIGHT),
                                0, "", null),
                        new FontConfig.Font(new File("italic.ttf"), null,
                        new FontConfig.Font(new File("italic.ttf"), null, "test",
                                new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_ITALIC),
                                0, "", null)),
                "sans-serif", LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT);
@@ -162,10 +162,10 @@ public final class FontListParserTest {
                + "</family>";
        FontConfig.FontFamily expected = new FontConfig.FontFamily(
                Arrays.asList(
                        new FontConfig.Font(new File("test-VF.ttf"), null,
                        new FontConfig.Font(new File("test-VF.ttf"), null, "test",
                                new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
                                0, "'wdth' 100.0,'wght' 200.0", null),
                        new FontConfig.Font(new File("test-VF.ttf"), null,
                        new FontConfig.Font(new File("test-VF.ttf"), null, "test",
                                new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
                                0, "'wdth' 400.0,'wght' 700.0", null)),
                "sans-serif", LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT);
@@ -182,10 +182,30 @@ public final class FontListParserTest {
                + "</family>";
        FontConfig.FontFamily expected = new FontConfig.FontFamily(
                Arrays.asList(
                        new FontConfig.Font(new File("test.ttc"), null,
                        new FontConfig.Font(new File("test.ttc"), null, "test",
                                new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
                                0, "", null),
                        new FontConfig.Font(new File("test.ttc"), null,
                        new FontConfig.Font(new File("test.ttc"), null, "test",
                                new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
                                1, "", null)),
                "sans-serif", LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT);
        FontConfig.FontFamily family = readFamily(xml);
        assertThat(family).isEqualTo(expected);
    }

    @Test
    public void psName() throws Exception {
        String xml = "<?xml version='1.0' encoding='UTF-8'?>"
                + "<family name='sans-serif'>"
                + "  <font index='0' postScriptName='foo'>test.ttc</font>"
                + "  <font index='1'>test.ttc</font>"
                + "</family>";
        FontConfig.FontFamily expected = new FontConfig.FontFamily(
                Arrays.asList(
                        new FontConfig.Font(new File("test.ttc"), null, "foo",
                                new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
                                0, "", null),
                        new FontConfig.Font(new File("test.ttc"), null, "test",
                                new FontStyle(FONT_WEIGHT_NORMAL, FONT_SLANT_UPRIGHT),
                                1, "", null)),
                "sans-serif", LocaleList.getEmptyLocaleList(), VARIANT_DEFAULT);
+581 −266

File changed.

Preview size limit exceeded, changes collapsed.

Loading