Skip to content

Commit e3b4562

Browse files
Merged PR 51399: Fix for Inter
Some elements with Inter font come with Null instead of actual FontPostScriptName. In thoses cases we do fallback to Inter-Regular
1 parent 1396472 commit e3b4562

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Editor/FigmaParser.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ public UssStyle(string name, Func<string, string, (bool valid, string path)> get
686686
}
687687
else if (type == Style.StyleType.TEXT && node is TextNode text)
688688
{
689-
AddTextStyle(text.style.fontSize, text.style.fontPostScriptName, text.style.textAlignHorizontal, text.style.textAlignVertical);
689+
AddTextStyle(text.style.fontSize, text.style.fontFamily, text.style.fontPostScriptName, text.style.textAlignHorizontal, text.style.textAlignVertical);
690690
}
691691
else if (type == Style.StyleType.EFFECT && node is BlendMixin blend)
692692
{
@@ -880,7 +880,7 @@ void AddTextNode(TextNode node)
880880
AddDefaultShapeNode(node);
881881

882882
FixWhiteSpace();
883-
AddTextStyle(node.style.fontSize, node.style.fontPostScriptName, node.style.textAlignHorizontal, node.style.textAlignVertical);
883+
AddTextStyle(node.style.fontSize, node.style.fontFamily, node.style.fontPostScriptName, node.style.textAlignHorizontal, node.style.textAlignVertical);
884884
}
885885
void AddComponentSetNode(ComponentSetNode node)
886886
{
@@ -1467,7 +1467,7 @@ void AddStrokeFillStyle(IEnumerable<Paint> strokes)
14671467
}
14681468
}
14691469
}
1470-
void AddTextStyle(number? fontSize, string fontPostScriptName, TextAlignHorizontal? textAlignHorizontal, TextAlignVertical? textAlignVertical)
1470+
void AddTextStyle(number? fontSize, string fontFamily, string fontPostScriptName, TextAlignHorizontal? textAlignHorizontal, TextAlignVertical? textAlignVertical)
14711471
{
14721472
void AddUnityFont()
14731473
{
@@ -1514,6 +1514,10 @@ void AddTextAlign()
15141514
}
15151515

15161516
if (fontSize.HasValue) this.fontSize = fontSize;
1517+
if (fontPostScriptName.NullOrEmpty() && fontFamily == "Inter")
1518+
{
1519+
Debug.LogWarning($"FontPostScriptName is null for {fontFamily}. Fallback to {fontPostScriptName = "Inter-Regular"}");
1520+
}
15171521
if (fontPostScriptName.NotNullOrEmpty()) AddUnityFont();
15181522
if (textAlignVertical.HasValue && textAlignHorizontal.HasValue) AddTextAlign();
15191523
}

0 commit comments

Comments
 (0)