Skip to content

Throw a more informative exception when FontFamily is missing from the Style specified in a TextBlock #74

@vchelaru

Description

@vchelaru

To reproduce:

  1. Create a Topten.RichTextKit.Style instance where the FontFamily is not specified
  2. Use this style to render text, using text similar to textBlock.AddText("Hello", styleWithNoFontFamilySet);
  3. Run the application to get an exception

Observe - Exception provides confusing information which does not lead the user to solve the problem.

System.InvalidOperationException: 'Exception in BuildFontRuns() with original length of 1 now 1, style run count 1, font run count 0, 

Expected - Exception should perform a null check and provide information to the user such as

System.InvalidOperationException: 'Style used to draw text includes a null FontFamily value. FontFamily must be set to a non-null, valid font'

Additional information:
This issue was referenced in conversation in another topic:
#43 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions