WPF/XAML: Typography.Capitals seems to have no effect
Asked Answered
W

2

7

All of these bits of text look the same, but I am trying to get them to look different. I want small caps text. What am I missing here to get the small caps typography effect to work?

To reproduce this, open Visual Studio 2008, Do File|New Project, create a new Windows|WPF application, paste the mark-up below into Window1.xaml, then run it.

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <FlowDocumentReader>
        <FlowDocument>
            <Paragraph>
                <Run>Some text</Run> <LineBreak />
                <Run Typography.Capitals="SmallCaps">Some text</Run> <LineBreak />
                <Run Typography.Capitals="AllSmallCaps">Some text</Run> <LineBreak />
                <Run Typography.Capitals="PetiteCaps">Some text</Run> <LineBreak />
                <Run Typography.Capitals="AllPetiteCaps">Some text</Run> <LineBreak />
            </Paragraph>
        </FlowDocument>
        </FlowDocumentReader>
    </Grid>
</Window>   

Based on the first answer, it seems that if you specify a particular font, you can get somewhere. Change the FlowDocument start tag to:

   <FlowDocument FontFamily="Palatino Linotype">

.. and you get SmallCaps and AllSmallCaps, but not PetiteCaps or AllPetiteCaps. So it depends on the font. But this gives rise to other questions:

  • Why doesn't the default font (which looks a lot like Times New Roman) support these?
  • Do other widely used fonts (e.g. the local Courier New equivalent) support these?
  • Is there a list of which fonts support what?
  • What percentage of fonts will support this - most, some, or few?
  • Can you determine in code what the font supports - if this is the case, I could fake the AllSmallCaps - e.g. by converting the text to all capitals and scaling by 80%. But not SmallCaps.
Wormwood answered 11/3, 2009 at 21:27 Comment(1)
Good question. That's pretty much the most basic example from the help and it doesn't work.Goodfellowship
P
9

This only works with specific OpenType fonts - the example in Help uses Pescadero which is in the Open Type Sample. Even then, only SmallCaps and AllSmallCaps are supported.

Persia answered 12/3, 2009 at 14:31 Comment(0)
R
4

I noticed that default font with a "bold" fontweight does render the SmallCaps properly:

<StackPanel>
    <TextBlock Typography.Capitals="SmallCaps" FontFamily="Pescadero" Padding="2">2pm</TextBlock>
    <TextBlock Typography.Capitals="SmallCaps" FontWeight="Bold" Padding="2">2pm</TextBlock>
</StackPanel>
Rickettsia answered 16/5, 2012 at 3:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.