Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF C#4.0 font
I have found that at least one ttf font vanishes in WPF (4.0) when its text size is 100 or higher. Is this a known bug?
 
E.g.
This can be seen:
<TextBlock x:Name="tb" FontFamily="Roboto" FontSize="99" Text="abcdef" HorizontalAlignment="Left" VerticalAlignment="Top" />
This can't:
<TextBlock x:Name="tb" FontFamily="Roboto" FontSize="100" Text="abcdef" HorizontalAlignment="Left" VerticalAlignment="Top" />
 
This also applies when the text is enlarged through render transforms:
 
This can be seen:
<Grid Height="200">
  <TextBlock x:Name="tb" FontFamily="Roboto" FontSize="50" Text="abcdef" />
  <Grid.RenderTransform>
  <ScaleTransform ScaleX="1.9999" />
  </Grid.RenderTransform>
  </Grid>
But this can't:
<Grid>
  <TextBlock x:Name="tb" FontFamily="Roboto" FontSize="50" Text="abcdef" />
  <Grid.RenderTransform>
  <ScaleTransform ScaleX="2" />
  </Grid.RenderTransform>
  </Grid>
 
The textblock:
1)Still arranges fine, and has appropriate actualheight and actualwidth values.
2)Has normal opacity and visibility values
3)If it has a background, the background appears fine/right size etc.
 
Also worth noting:
1)This font is by google and seems to work just fine otherwise. I've even opened it in a font editor and it seems normal
2)This is a TTF font
3)The font works fine in MS word etc at all font sizes BUT
4)If you publish an Ms Word file with this font at a large size to XPS, the font is invisible in the XPS doc (selectable, but not visible. As though it's opacity is 0)
4)This applies to content controls and textboxes too
 
The reason I don't just 'pick another font' is because my program uses a LOT of fonts like this. I can't manually check each one!
 
Has anyone seen this before? Any ideas?
 
The font can be downloaded from here[^]
Posted 16-Aug-12 16:37pm
Lee Reid1.6K
Edited 16-Aug-12 16:51pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I have read the documentation from Microsoft and it does not say anything about FontSize limit. Pasted the liks below as references:
 
http://msdn.microsoft.com/en-us/library/office/aa200988%28v=office.10%29.aspx[^]
http://msdn.microsoft.com/en-us/library/cc189010%28v=vs.95%29.aspx[^]
 
My advice to you is to head over to the Microsoft WPF Forum and ask this question were Microsoft employees ansers. I dont think this is a common problem for programmers, but you never know:
http://social.msdn.microsoft.com/forums/en/wpf/threads/[^]
  Permalink  
Comments
Lee Reid at 16-Aug-12 22:58pm
   
Thanks :)
I've copied this question across to here: http://social.msdn.microsoft.com/Forums/en/wpf/thread/50e6086f-e767-4e07-bcc2-9e53ed78d05d
 
I'll update codeproject if I hear back from microsoft
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I eventually solved this issue by specifying the textformattingmode to be display.
 
<textblock fontfamily="Roboto" fontsize="110" text="abcdef" textoptions.textformattingmode="Display" />
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 304
1 Maciej Los 285
2 Sergey Alexandrovich Kryukov 230
3 Shweta N Mishra 186
4 Aajmot Sk 153
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,760


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 19 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100