Skip to content

Cherry-pick multi-font and bold/italic support from Support-multiple-fonts-and-modernize #12

@johnpierson

Description

@johnpierson

Background

The Support-multiple-fonts-and-modernize branch contains both infrastructure/migration work and new user-facing features. This issue tracks cherry-picking the features only — no project format, build, or CI changes.

Reference branch: Support-multiple-fonts-and-modernize

This issue is assigned to an AI coding agent. Every step below is meant to be executed directly — no design decisions left open.


Files to touch

File Action
Text.cs Add parameters to FromStringOriginAndScale, add GetInstalledFontNames()

No other files. Do not touch .csproj, packages.config, CI, or any build infrastructure.


Checklist

1. Extend FromStringOriginAndScale with font, bold, and italic parameters

Current signature:

public static IEnumerable<Curve> FromStringOriginAndScale(string text, Point origin, double scale)

New signature:

public static IEnumerable<Curve> FromStringOriginAndScale(
    string text,
    Point origin,
    double scale,
    string fontFamily = "Arial",
    bool bold = false,
    bool italic = false)

Implementation requirements:

  • Validate that fontFamily exists in Fonts.SystemFontFamilies. If not found, throw ArgumentException with a message that references GetInstalledFontNames() so the user knows how to discover valid values.
  • Apply font weight: bold ? FontWeights.Bold : FontWeights.Medium
  • Apply font style: italic ? FontStyles.Italic : FontStyles.Normal
  • Default behavior (fontFamily = "Arial", bold = false, italic = false) must be identical to the current method — this is a non-breaking change.

2. Add GetInstalledFontNames() utility method

public static IList<string> GetInstalledFontNames()
  • Query Fonts.SystemFontFamilies, extract the .Source property from each family.
  • Return as an alphabetically sorted IList<string> (case-insensitive sort).
  • No parameters. Windows-only (same as the rest of the library).

3. Add required using statements if missing

  • using System; (for ArgumentException)
  • using System.Linq; (for LINQ queries on SystemFontFamilies)

Definition of done

  • FromStringOriginAndScale accepts fontFamily, bold, and italic — all optional with defaults
  • Calling FromStringOriginAndScale with no new arguments produces identical output to current behavior
  • Passing an uninstalled font name throws ArgumentException with message referencing GetInstalledFontNames()
  • GetInstalledFontNames() returns a non-empty, alphabetically sorted list on Windows
  • No .csproj, CI, NuGet, or build file changes in this PR

Notes

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions