Reduce line spacing in TextBlock / FlowDocument

Some fonts have a large number of spaces above and below characters. Is there a way to fix this and tighten the space between the lines of the paragraph enclosed in Word in WPF (in TextBlock or FlowDocument)? Kind of like a negative margin between the lines?

Paragraph and TextBlock have the LineHeight property, but it only seems that you are increasing the interval - if you set it to a smaller value than the default, it is simply ignored.

+41
fonts wpf textwrapping
Aug 10 '09 at 12:08
source share
3 answers

Set LineHeight as before, but change LineStackingStrategy to BlockLineHeight

+81
Sep 17 '09 at 20:14
source share

To illustrate @Joel's answer (which is still very useful after 5 years: P)

  <StackPanel VerticalAlignment="Center"> <Button Width="137" Height="47.96"> <TextBlock Text="This is a very long text that gets cut because it is so long" TextWrapping="Wrap"/> </Button> <Button Width="137" Height="47.96"> <TextBlock Text="This is a very long text that doesn't cut thanks to @Joel" TextWrapping="Wrap" LineStackingStrategy="BlockLineHeight" LineHeight="13"/> </Button> </StackPanel> 
+3
Aug 08 '14 at 15:09
source share

See question .

There are several ways to correct the height. The one that worked for me is this , which sets the margin to 0.

0
Aug 10 '09 at 12:24
source share



All Articles