From f0efc091df5310cd7aea700eb8f830cbfb3f5acf Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Thu, 9 Apr 2026 19:58:02 +0000 Subject: [PATCH 1/2] Initial plan From 385a18d7677f41de066469dab9922aa52db6e3d1 Mon Sep 17 00:00:00 2001 From: "anthropic-code-agent[bot]" <242468646+Claude@users.noreply.github.com> Date: Thu, 9 Apr 2026 19:59:37 +0000 Subject: [PATCH 2/2] Add multi-font and bold/italic support to FromStringOriginAndScale Agent-Logs-Url: https://github.com/DynamoDS/DynamoText/sessions/f67d3a54-bb72-4b6b-943d-ae2aa658c38d Co-authored-by: johnpierson <15744724+johnpierson@users.noreply.github.com> --- src/Text.cs | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/Text.cs b/src/Text.cs index 2710fa0..7ed4274 100644 --- a/src/Text.cs +++ b/src/Text.cs @@ -1,5 +1,7 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Windows; using System.Windows.Media; using Autodesk.DesignScript.Geometry; @@ -9,18 +11,29 @@ namespace DynamoText { public static class Text { - public static IEnumerable FromStringOriginAndScale(string text, Point origin, double scale) + public static IEnumerable FromStringOriginAndScale( + string text, + Point origin, + double scale, + string fontFamily = "Arial", + bool bold = false, + bool italic = false) { //http://msdn.microsoft.com/en-us/library/ms745816(v=vs.110).aspx var crvs = new List(); - var font = new System.Windows.Media.FontFamily("Arial"); - var fontStyle = FontStyles.Normal; - var fontWeight = FontWeights.Medium; + // Validate that the font family exists + if (!Fonts.SystemFontFamilies.Any(f => f.Source.Equals(fontFamily, StringComparison.OrdinalIgnoreCase))) + { + throw new ArgumentException( + $"Font family '{fontFamily}' not found. Use GetInstalledFontNames() to get a list of available fonts.", + nameof(fontFamily)); + } - //if (Bold == true) fontWeight = FontWeights.Bold; - //if (Italic == true) fontStyle = FontStyles.Italic; + var font = new System.Windows.Media.FontFamily(fontFamily); + var fontStyle = italic ? FontStyles.Italic : FontStyles.Normal; + var fontWeight = bold ? FontWeights.Bold : FontWeights.Medium; // Create the formatted text based on the properties set. var formattedText = new FormattedText( @@ -73,6 +86,14 @@ public static IEnumerable FromStringOriginAndScale(string text, Point ori return crvs; } + public static IList GetInstalledFontNames() + { + return Fonts.SystemFontFamilies + .Select(f => f.Source) + .OrderBy(name => name, StringComparer.OrdinalIgnoreCase) + .ToList(); + } + private static Line LineBetweenPoints(Point origin, double scale, System.Windows.Point a, System.Windows.Point b) { var pt1 = Point.ByCoordinates((a.X * scale) + origin.X, ((-a.Y + 1) * scale) + origin.Y, origin.Z);