Silverlight 5 RC新特性探索系列:15.Silverlight 5 RC 对OpenType字体属性的支持
2011-11-14 13:04
537 查看
在Silverlight中新增了对OpenType字体属性的支持,它主要通过Typography类的相关属性来控制。下面我们来看看它增加了哪些属性。
注意:必须使用系统的OpenType字体才行,所以FontFamily="Gabriola"。
一、连笔字
在"ft"之间相连起来,如下图绿色框内所示主要通过 Typography.StandardLigatures的True或者False来决定是否连笔:
然后我们看代码如下:
二、分数字
将1/5、4/13等分数按照数学上的分数字来显示,通过设置Typography.Fraction属性为Normal、Slashed、Stacked来控制。
其代码如下:
三、上下标字
比如化学里的三氧化二铁等,通过设置Typography.Variants属性为Subscript、Superscript来实现上下标。如下图:
其具体代码如下:
四、手写字
在生活中我们需要一些比较漂亮的手写字,在Silverlight 5 RC版本中准备了7种样式的手写字,通过设置Typography.StylisticSet*的True、False来实现,其中*号是从1到7的整数 字来代替,8以上的数字设置是无效的。如下图:
其代码如下所示:
如需源码请点击 SL5OpenType.zip 下载,谢谢支持~
注意:必须使用系统的OpenType字体才行,所以FontFamily="Gabriola"。
一、连笔字
在"ft"之间相连起来,如下图绿色框内所示主要通过 Typography.StandardLigatures的True或者False来决定是否连笔:
然后我们看代码如下:
<TextBlock FontFamily="Gabriola" FontSize="100" HorizontalAlignment="Center" Margin="33,304,142,114" Text="NewsftepSet-" Typography.StandardLigatures="False" Width="525" /> <TextBlock FontFamily="Gabriola" FontSize="100" HorizontalAlignment="Center" Margin="33,406,142,12" Text="NewsftepSet-" Typography.StandardLigatures="True" Width="525" />
二、分数字
将1/5、4/13等分数按照数学上的分数字来显示,通过设置Typography.Fraction属性为Normal、Slashed、Stacked来控制。
其代码如下:
<TextBlock Text="5/152 Normal" HorizontalAlignment="Center" FontFamily="Gabriola" FontSize="50" Height="100" Typography.Fraction="Normal" Margin="487,313,12,187" /> <TextBlock Text="5/152 Slashed" HorizontalAlignment="Center" FontFamily="Gabriola" FontSize="50" Height="100" Typography.Fraction="Slashed" Margin="487,373,31,0" VerticalAlignment="Top" /> <TextBlock Text="5/152 Stacked" HorizontalAlignment="Center" FontFamily="Gabriola" FontSize="50" Height="100" Typography.Fraction="Stacked" Margin="487,419,9,81" />
三、上下标字
比如化学里的三氧化二铁等,通过设置Typography.Variants属性为Subscript、Superscript来实现上下标。如下图:
其具体代码如下:
<TextBlock FontFamily="Gabriola" FontSize="50" Height="100" HorizontalAlignment="Center" Margin="487,488,117,12" > <Run Text="Fe" Typography.Variants="Normal" /> <Run Text="2" Typography.Variants="Subscript" /> <Run Text="O" Typography.Variants="Normal" /> <Run Text="3" Typography.Variants="Superscript" /> </TextBlock>
四、手写字
在生活中我们需要一些比较漂亮的手写字,在Silverlight 5 RC版本中准备了7种样式的手写字,通过设置Typography.StylisticSet*的True、False来实现,其中*号是从1到7的整数 字来代替,8以上的数字设置是无效的。如下图:
其代码如下所示:
<TextBlock Text="NewsftepSet-" HorizontalAlignment="Center" FontSize="50" Height="100" FontFamily="Gabriola" Margin="20,12,484,488" /> <TextBlock Text="NewsftepSet1" HorizontalAlignment="Center" FontSize="50" FontFamily="Gabriola" Typography.StylisticSet1="True" Height="100" Margin="245,12,255,488" /> <TextBlock FontFamily="Gabriola" FontSize="50" Height="100" HorizontalAlignment="Center" Margin="471,12,28,488" Text="NewsftepSet2" Typography.StylisticSet2="True" /> <TextBlock FontFamily="Gabriola" FontSize="50" Height="100" HorizontalAlignment="Center" Margin="20,118,478,382" Text="NewsftepSet3" Typography.StylisticSet3="True" /> <TextBlock FontFamily="Gabriola" FontSize="50" Height="100" HorizontalAlignment="Center" Margin="246,118,246,382" Text="NewsftepSet4" Typography.StylisticSet4="True" /> <TextBlock FontFamily="Gabriola" FontSize="50" Height="100" HorizontalAlignment="Center" Margin="471,118,25,382" Text="NewsftepSet5" Typography.StylisticSet5="True" /> <TextBlock FontFamily="Gabriola" FontSize="50" HorizontalAlignment="Center" Width="221" Margin="20,224,459,253" Text="NewsftepSet6" Typography.StylisticSet6="True" /> <TextBlock FontFamily="Gabriola" FontSize="50" HorizontalAlignment="Center" Width="218" Margin="247,224,235,253" Text="NewsftepSet7" Typography.StylisticSet7="True" />
如需源码请点击 SL5OpenType.zip 下载,谢谢支持~
相关文章推荐
- Silverlight 5 RC新特性探索系列:15.Silverlight 5 RC 对OpenType字体属性的支持
- Silverlight 5 RC新特性探索系列:13.Silverlight 5 RC 新增对并行任务库(TPL)的支持
- Silverlight 5 RC新特性探索系列:13.Silverlight 5 RC 新增对并行任务库(TPL)的支持
- Silverlight 5 RC新特性探索系列:11.SaveFileDialog保存文件指定默认名称---OpenFileDialog打开文件指定默认路径
- Silverlight 5 beta新特性探索系列:7.结合上层元素属性绑定和Style Setter上的绑定
- Silverlight 5 beta新特性探索系列:7.结合上层元素属性绑定和Style Setter上的绑定
- Silverlight 5 beta新特性探索系列:6.Silverlight 5新增低延迟声音效果类SoundEffect.支持wav音乐格式【附带源码实例】
- Silverlight 5 RC新特性探索系列:14.Silverlight 5 RC 对字体呈现的改进
- Silverlight 5 RC新特性探索系列:14.Silverlight 5 RC 对字体呈现的改进
- Silverlight 5 beta新特性探索系列:1.安装Silverlight 5 beta环境以及OOB模式下Silverlight 5 多窗口支持
- Silverlight 5 RC新特性探索系列:12.Silverlight 5 RC 窗口模式下访问自定义DLL和WIN32 API
- Silverlight 5 beta新特性探索系列:1.安装Silverlight 5 beta环境以及OOB模式下Silverlight 5 多窗口支持
- Silverlight 5 RC新特性探索系列:12.Silverlight 5 RC 窗口模式下访问自定义DLL和WIN32 API
- Silverlight 5 beta新特性探索系列:3.Silverlight5中的文字增进控制【附带实例源码】
- Silverlight 5 beta新特性探索系列:4.Silverlight 5 beta中鼠标双击/鼠标多重点击的实现
- Silverlight 5 beta新特性探索系列:10.浏览器模式下内嵌HTML+浏览器模式下创建txt文本文件
- Silverlight 5 beta新特性探索系列:10.浏览器模式下内嵌HTML+浏览器模式下创建txt文本文件
- Silverlight 5 beta新特性探索系列:2.在XAML代码中设置断点和Binding绑定调试【附带源码实例】
- Silverlight 5 beta新特性探索系列:2.在XAML代码中设置断点和Binding绑定调试【附带源码实例】
- Silverlight 5 beta新特性探索系列:9.视频快进快退和TextSearch对象对文字项查询