Skip to content

Commit 656f726

Browse files
Merged PR 53325: Fix #147705 (italic fonts)
Fix #147705 (italic fonts)
1 parent 56dd26f commit 656f726

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Editor/FigmaParser.cs

Lines changed: 6 additions & 5 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.fontFamily, 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, text.style.italic is not null && text.style.italic.Value);
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.fontFamily, 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, node.style.italic is not null && node.style.italic.Value);
884884
}
885885
void AddComponentSetNode(ComponentSetNode node)
886886
{
@@ -1475,18 +1475,19 @@ void AddStrokeFillStyle(IEnumerable<Paint> strokes)
14751475
}
14761476
}
14771477
}
1478-
void AddTextStyle(number? fontSize, string fontFamily, string fontPostScriptName, TextAlignHorizontal? textAlignHorizontal, TextAlignVertical? textAlignVertical)
1478+
void AddTextStyle(number? fontSize, string fontFamily, string fontPostScriptName, TextAlignHorizontal? textAlignHorizontal, TextAlignVertical? textAlignVertical, bool italic)
14791479
{
14801480
void AddUnityFont()
14811481
{
1482-
(bool valid, string url) = getAssetPath(fontPostScriptName, "ttf");
1482+
string postfix = italic && !fontPostScriptName.Contains("Italic") ? "Italic" : string.Empty;
1483+
(bool valid, string url) = getAssetPath($"{fontPostScriptName}{postfix}", "ttf");
14831484
if (valid)
14841485
{
14851486
unityFont = $"url('{url}')";
14861487
}
14871488
else
14881489
{
1489-
(valid, url) = getAssetPath(fontPostScriptName, "otf");
1490+
(valid, url) = getAssetPath($"{fontPostScriptName}{postfix}", "otf");
14901491
if (valid)
14911492
{
14921493
unityFont = $"url('{url}')";

0 commit comments

Comments
 (0)