为什么FontStretch不会在WPF的工作? [英] Why FontStretch does not work in WPF?

查看:1217
本文介绍了为什么FontStretch不会在WPF的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置的 FontStretch 属性在WPF一个TextBlock,但似乎这是行不通的。我试图扩大,浓缩等,但文本外观不会改变。

I am trying setting FontStretch property on a TextBlock in WPF but it seems that it does not work. I tried Expanded, Condensed, etc. but the text appearance does not change.

我的工作在Windows XP上使用框架4.0,并测试了用宋体和宋体。

I am working on Windows XP with Framework 4.0 and tested both with Verdana and Arial.

是否在Windows 7或只与某些特定的字体只能在工作吗?

Does it work only on Windows 7 or only with some specific fonts?

修改:如果它不与所有字体的工作,有没有对支持此功能的字体列表?或者是有可能修改字体像宋体/宋体来支持它?

EDIT: If it does not work with all fonts, is there a list of fonts that support this feature? Or is it possible to modify a font like Verdana/Arial to support it?

推荐答案

要获得类似的效果在不支持它的字体FontStretch,你可以使用一个LayoutTransform的文本块:

To get a similar effect to FontStretch in a font that doesn't support it, you can use a LayoutTransform on the TextBlock:

<Application.Resources>
  <ScaleTransform x:Key="FontStretchCondensed" ScaleX="0.8" />
  <ScaleTransform x:Key="FontStretchExpanded" ScaleX="1.2" />
</Application.Resources>

...

<TextBlock Text="This is my text"
           LayoutTransform="{StaticResource FontStretchCondensed}" />

在一种风格,如果你想拥有的TextBlocks的所有文字出现凝结这也可以设置:

This can also be set in a style if you want to have all text in TextBlocks appear condensed:

<Style TargetType="TextBlock">
  <Style.Setters>
    <Setter Property="LayoutTransform" Value="{StaticResource FontStretchCondensed}" />
  </Style.Setters>
</Style>

这篇关于为什么FontStretch不会在WPF的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆