• WPF在资源内嵌入字体


     图片
    比如需要有这种电子表的字体风格--这种样式叫 :longzhoufeng 字体 在微软的字体有 Quartz MS.TTF或者Quartz Regular.TTF字体。下面以Quartz Regular.TTF为例
    找到 Quartz Regular.TTF字体文件,把它添加到WPF工程的Resources内,并设置成Resource类型。
    写一个FontStyle.xaml 的 字体资源 

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                    
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="Quartz Regular">
      <Setter Property="TextElement.FontFamily" Value="/Resources/#Quartz Regular"/>
    </Style></ResourceDictionary>


    字体使用中将字体作为字体样式来引用

    <Window.Resources>       
      <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
          <ResourceDictionary Source="Resources/FontStyle.xaml"/>
        </ResourceDictionary.MergedDictionaries>
      </ResourceDictionary>
    </Window.Resources> <Grid Background="#2a3747">
      <Label Content="5201314" HorizontalAlignment="Left" FontSize="34"
          VerticalContentAlignment="Center" Height="60" Margin="101,77,0,0" VerticalAlignment="Top"
          Width="286" Foreground="GreenYellow" Style="{DynamicResource 'Quartz Regular'}" />
      <Label Content="lovessea@sina.com" HorizontalAlignment="right" Foreground="White" Height="29" Margin="379,291,0,0"
          VerticalAlignment="Top" Width="128"/>
    </Grid>

    http://www.th7.cn/Program/WPF/201506/489768.shtml

  • 相关阅读:
    Redhat MysqlReport安装配置详解
    asp.net中服务器端控件和客户端控件的交互问题
    关于弹出对话框返回值的分析
    关于父子窗口的参数传递(引用的高手的)
    呵呵!刚刚申请!
    Loadrunner教程
    性能测试常见用语
    如何删除电脑垃圾文件
    内连接和外连接
    酒桌上的规矩
  • 原文地址:https://www.cnblogs.com/tianciliangen/p/5909749.html
Copyright © 2020-2023  润新知