微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Silverlight 5 RC新特性探索系列:15.Silverlight 5 RC 对OpenType字体属性的支持

        在Silverlight中新增了对OpenType字体属性支持,它主要通过Typography类的相关属性来控制。下面我们来看看它增加了哪些属性

注意:必须使用系统的OpenType字体才行,所以FontFamily="Gabriola"。

一、连笔字

        在"ft"之间相连起来,如下图绿色框内所示主要通过 Typography.Standardligatures的True或者False来决定是否连笔:

        然后我们看代码如下:

 
 
  1. <TextBlock FontFamily="Gabriola" FontSize="100" HorizontalAlignment="Center"  
  2.            Margin="33,304,142,114" Text="NewsftepSet-"  
  3.            Typography.Standardligatures="False" Width="525" /> 
  4. <TextBlock FontFamily="Gabriola" FontSize="100" HorizontalAlignment="Center" 
  5.            Margin="33,406,12" Text="NewsftepSet-" 
  6.            Typography.Standardligatures="True" Width="525" /> 

二、分数字

        将1/5、4/13等分数按照数学上的分数字来显示,通过设置Typography.Fraction属性normal、Slashed、Stacked来控制。

        其代码如下:

 
 
  1. <TextBlock Text="5/152 normal"  HorizontalAlignment="Center"   
  2.            FontFamily="Gabriola" FontSize="50"   Height="100"   
  3.            Typography.Fraction="normal" Margin="487,313,12,187" /> 
  4. <TextBlock Text="5/152 Slashed" HorizontalAlignment="Center"   
  5.            FontFamily="Gabriola" FontSize="50"   Height="100"   
  6.            Typography.Fraction="Slashed" Margin="487,373,31,0" VerticalAlignment="Top" /> 
  7. <TextBlock Text="5/152 Stacked"  HorizontalAlignment="Center"  
  8.            FontFamily="Gabriola" FontSize="50"   Height="100"    
  9.            Typography.Fraction="Stacked" Margin="487,419,9,81" /> 

三、上下标字

      比如化学里的三氧化二铁等,通过设置Typography.Variants属性为Subscript、Superscript来实现上下标。如下图:

 

      其具体代码如下:

 
 
  1. <TextBlock    FontFamily="Gabriola" FontSize="50"   Height="100" 
  2.               HorizontalAlignment="Center"     Margin="487,488,117,12" > 
  3.     <Run Text="Fe" Typography.Variants="normal" />  
  4.     <Run Text="2" Typography.Variants="Subscript" />   
  5.     <Run Text="O" Typography.Variants="normal" /> 
  6.     <Run Text="3" Typography.Variants="Superscript" /> 
  7. </TextBlock> 

四、手写字

      在生活中我们需要一些比较漂亮的手写字,在Silverlight 5 RC版本中准备了7种样式的手写字,通过设置Typography.StylisticSet*的True、False来实现,其中*号是从1到7的整数 字来代替,8以上的数字设置是无效的。如下图:

        其代码如下所示:

 
 
  1. <TextBlock Text="NewsftepSet-" HorizontalAlignment="Center" FontSize="50"       
  2.  
  3.                   Height="100" FontFamily="Gabriola" Margin="20,484,488" />  
  4.        <TextBlock Text="NewsftepSet1" HorizontalAlignment="Center" FontSize="50" FontFamily="Gabriola"  
  5.                   Typography.StylisticSet1="True" Height="100" Margin="245,255,488" />  
  6.        <TextBlock FontFamily="Gabriola" FontSize="50" Height="100" HorizontalAlignment="Center"  
  7.                   Margin="471,28,488" Text="NewsftepSet2" Typography.StylisticSet2="True" />  
  8.        <TextBlock FontFamily="Gabriola" FontSize="50" Height="100" HorizontalAlignment="Center"  
  9.                   Margin="20,118,478,382" Text="NewsftepSet3" Typography.StylisticSet3="True" />  
  10.        <TextBlock FontFamily="Gabriola" FontSize="50" Height="100" HorizontalAlignment="Center"  
  11.                   Margin="246,246,382" Text="NewsftepSet4" Typography.StylisticSet4="True" />  
  12.        <TextBlock FontFamily="Gabriola" FontSize="50" Height="100" HorizontalAlignment="Center"  
  13.                   Margin="471,25,382" Text="NewsftepSet5" Typography.StylisticSet5="True" />  
  14.        <TextBlock FontFamily="Gabriola" FontSize="50" HorizontalAlignment="Center" Width="221"  
  15.                   Margin="20,224,459,253" Text="NewsftepSet6" Typography.StylisticSet6="True" />  
  16.        <TextBlock FontFamily="Gabriola" FontSize="50" HorizontalAlignment="Center" Width="218"  
  17.                   Margin="247,235,253" Text="NewsftepSet7" Typography.StylisticSet7="True"  />  

        如需源码请点击 SL5OpenType.zip 下载,谢谢支持~

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐