wpf: LinearGradientBrush in Multi-language text element bug.

  <Window.Resources>
    <LinearGradientBrush x:Key="brush1" StartPoint="0,0.5" EndPoint="1,0.5">
      <GradientStop Offset="0" Color="Red" />
      <GradientStop Offset="1" Color="blue" />
    </LinearGradientBrush>
  </Window.Resources> 
  <TextBlock Foreground="{StaticResource brush1}" Text="我是abcdefg文本わたしは" /> 

Display result in view ↓ (bad): bad image This is default font (MS YaHei) in zh-cn OS.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 16 (4 by maintainers)

Most upvoted comments

@stevenbrix

  1. A font file contains multiple languages, problems not arise. When multiple font files are referenced at the same textblock run, problems arise.
  2. win10 existing problem. other OS untest.
  • No problem DrawingContext.DrawGeometry with System.Windows.Media.FormattedText

@nsivov the desired result is below ↓(font-family : STSong. Have full character set in one font file.) desired image

Could you bring the Text to geometry and draw the geometry with LinearGradientBrush?

How to bring the Text to geometry see https://stackoverflow.com/q/1036327/6116637