Took me about 3 hours to finally figure this out - after much detective work, but now it is pixel perfect !
Appears that WPF on XP and WPF on Windows 7 not only have different default font faces as well as a default font sizes.
- I had a problem where fonts were rendering differentl on XP from how they were on Windows 7. It was quite critical since the final output was the printer and they needed to be identical. It appeared initially that the problem was a difference in line spacing.
- Yes - I had the same exact font installed on XP as I was using on Windows 7
- Yes - I tried a very generic font (Arial) and still had the same problems.
- Yes - Same DPI on both machines.
- Yes - Same result whether in a VM (XP Mode) or on a real XP machine.
Eventually I discovered that the fonts where I was specifying an explicit size looked identical on XP, and only the ones where I didn't specify an explicit size were they different.
So here's how I fixed it in my MainWindow.xaml
- with a ContentControl
to set a default size:
<Grid x:Name="LayoutRoot" Background="#FFDEDEDE" UseLayoutRounding="True">
<ContentControl FontFamily="Segoe UI" FontSize="12">
... window contents ...
</ContentControl>
</Grid>
Note: If you're using Blend you may need to enter FontSize="12"
by hand. If you select it from the properties designer it will delete it because it thinks 12 is already the default!
Like I said my destination was the printer - so i had to do the same for the control being printed.
Now if anyone knows where else I can set this default font size please let me know - but now I have pixel perfect rendering on XP and Windows 7, and they differ only by the cleartype anti-aliasing differences.
Note: UseLayoutRounding
is not part of my solution - but I always use it on my root control also.