Skip to content

Commit d5a9da9

Browse files
committed
[lib] Added from static method in font variations table
1 parent ff9603f commit d5a9da9

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tehreer-android/src/main/java/com/mta/tehreer/internal/sfnt/tables/fvar/FontVariationsTable.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@
1717
package com.mta.tehreer.internal.sfnt.tables.fvar;
1818

1919
import androidx.annotation.NonNull;
20+
import androidx.annotation.Nullable;
2021

22+
import com.mta.tehreer.graphics.Typeface;
23+
import com.mta.tehreer.internal.sfnt.DataTable;
2124
import com.mta.tehreer.internal.sfnt.SfntTable;
25+
import com.mta.tehreer.sfnt.SfntTag;
26+
27+
import static com.mta.tehreer.internal.util.Preconditions.checkNotNull;
2228

2329
public final class FontVariationsTable {
2430
private static final int MAJOR_VERSION = 0;
@@ -31,7 +37,18 @@ public final class FontVariationsTable {
3137

3238
private final @NonNull SfntTable data;
3339

34-
public FontVariationsTable(@NonNull SfntTable data) {
40+
public static @Nullable FontVariationsTable from(@NonNull Typeface typeface) {
41+
checkNotNull(typeface);
42+
43+
final byte[] fvarData = typeface.getTableData(SfntTag.make("fvar"));
44+
if (fvarData != null) {
45+
return new FontVariationsTable(new DataTable(fvarData));
46+
}
47+
48+
return null;
49+
}
50+
51+
FontVariationsTable(@NonNull SfntTable data) {
3552
this.data = data;
3653
}
3754

0 commit comments

Comments
 (0)