Skip to content

Commit 2b9e558

Browse files
patgoleyalmedina-ms
authored andcommitted
add ability to inject custom typefaces into TextRendererUtil.java (#3137)
1 parent bd8615d commit 2b9e558

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

source/android/adaptivecards/src/main/java/io/adaptivecards/renderer/readonly/TextRendererUtil.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import android.graphics.Typeface;
66
import android.view.Gravity;
77

8+
import java.util.HashMap;
9+
import java.util.Map;
10+
811
import io.adaptivecards.objectmodel.ContainerStyle;
912
import io.adaptivecards.objectmodel.FontType;
1013
import io.adaptivecards.objectmodel.ForegroundColor;
@@ -15,6 +18,12 @@
1518

1619
public class TextRendererUtil
1720
{
21+
private static Map<String, Typeface> customTypefaces = new HashMap<>();
22+
23+
public static void registerCustomTypeface(String name, Typeface typeface) {
24+
25+
customTypefaces.put(name, typeface);
26+
}
1827

1928
static int getTextAlignment(HorizontalAlignment textAlignment)
2029
{
@@ -53,8 +62,12 @@ static Typeface getTextFormat(HostConfig hostConfig, FontType type)
5362
{
5463
typeface = Typeface.MONOSPACE;
5564
}
65+
else if (customTypefaces.containsKey(fontFamily)) {
66+
typeface = customTypefaces.get(fontFamily);
67+
}
5668
else
5769
{
70+
5871
typeface = Typeface.create(fontFamily, Typeface.NORMAL);
5972
}
6073

0 commit comments

Comments
 (0)