Superscript or subscript in TextBlock

此生再无相见时 提交于 2019-12-08 02:46:53

问题


<TextBlock Foreground="Black" FontSize="50" FontFamily="Segoe UI">
    <Run>Normal Text</Run>
    <Run Typography.Variants="Superscript" Text="Superscript123"/>
    <Run Typography.Variants="Subscript" Text="Subscript123"/>
</TextBlock>

Below is my screen shot. It seems that certain characters are not allowed in super/sub script.

Actually I want to put a ® symbol what I'm getting is

and what I want is

P.S. I found this answer https://stackoverflow.com/a/3435675/468724 but there is no such property as BaselineAlignment


回答1:


Either use Segoe WP font

Or can do like this

<StackPanel Orientation="Horizontal">
    <TextBlock FontFamily="Segoe UI" FontSize="16" Text"Normal Text"/>
    <TextBlock FontFamily="Segoe UI" FontSize="9" Text="&#174;"/>
</StackPanel>

I used 60% lesser font for trademark symbol




回答2:


This looks nice for a subscsript Run in a TextBlock on my screen, using VS2015:

<Style TargetType="{x:Type Run}" x:Key="Sub">
    <Setter Property="FontSize" Value="10"/>        
    <Setter Property="BaselineAlignment" Value="TextBottom"/>
</Style>

It's just a bit lower than Typography.Variants = Subscript, which seems to use just a smaller font



来源:https://stackoverflow.com/questions/14950827/superscript-or-subscript-in-textblock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!