#268 – Default FontFamily and FontSize

In WPF, the default font family for text displayed on controls (like Label and Button) is Segoe UI, with a default size of 12.0 device-independent units.

Because a device-independent unit is 1/96 inch, a FontSize value of 12 represents characters whose capitals are 1/8″ high.  This is also equivalent to a size of 9 points.

Windows also uses 9 point Segoe UI as its default system font (in Windows 7).

Most books use a font that is 11 or 12 pts (14-16 WPF units).  Paperbacks often have slightly smaller type, e.g. 10 pt (13-1/3 WPF Units).

Web sites will also typically use fonts for body text that results in text that ranges from 10-12 points.

Microsoft Word uses 11 pt as its default font size.




#266 – Specifying Values for FontSize

When specifying character size using the FontSize property, you can express the font size in one of several different units.

  • WPF device independent units (the default) – 1/96 in = 1 pixel at 96 dpi
  • Points – Traditional metric for font size, 1/72 in
  • Inches
  • Centimeters

In all cases, the text will render at the requested size, regardless of the display device.

Here’s an example of several different font size values.

<Paragraph FontSize="8 pt">8 pt - Sphinx of black quartz</Paragraph>
<Paragraph FontSize="10 pt">10 pt - Sphinx of black quartz</Paragraph>
<Paragraph FontSize="12 pt">12 pt - Sphinx of black quartz</Paragraph>
<Paragraph FontSize="13">13 units - Sphinx of black quartz</Paragraph>
<Paragraph FontSize="16">16 units - Sphinx of black quartz</Paragraph>
<Paragraph FontSize="0.2 in">0.2 in - Sphinx of black quartz</Paragraph>
<Paragraph FontSize="0.5 cm">0.5 cm - Sphinx of black quartz</Paragraph>
<Paragraph FontSize="32">32 units - Sphinx of black quartz</Paragraph>

#263 – Specifying Font Properties

In WPF, you specify the font for text elements by specifying values for one or more font-related properties.

There are five main properties for specifying font characteristics, found in the Control class.

  • FontFamily – The typeface, e.g. Arial
  • FontSize – The size of the text, in device independent units, points, inches, or centimeters
  • FontStretch – Optionally stretch/compress the font
  • FontStyle – Set font as italic (e.g. Italic, Oblique)
  • FontWeight – Set font as bold or light (e.g. Bold, Light, Extra-Bold, etc)

Below is a simple example.

	<TextBlock FontFamily="Cambria" FontSize="14 pt" FontStyle="Normal" FontWeight="Normal"
		HorizontalAlignment="Center" VerticalAlignment="Center" Width="300" Height="100" TextWrapping="Wrap">
		A man who carries a cat by the tail learns something he can learn in no other way.