GlyphType字面行换行 [英] GlyphTypeface and line spasing

查看:128
本文介绍了GlyphType字面行换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



示例代码:

Hi,

Sample code:

Typeface

 

字体= .GetBestTypeface("Arial",fontStyle,fontWeight,System.Windows. 字体拉伸 .Normal);
GlyphTypeface glyphTypeface;
typeface.TryGetGlyphTypeface( 输出

typeface = FontExtractor.GetBestTypeface("Arial", fontStyle, fontWeight, System.Windows.FontStretches.Normal);
GlyphTypeface glyphTypeface;
typeface.TryGetGlyphTypeface(out glyphTypeface);

double

 

baseline1 = typeface.FontFamily.Baseline;
double double lineSpacing 1 =字体. FontFamily. LineSpacing ;
double lineSpacing 2 = glyphTypeface.

baseline1 = typeface.FontFamily.Baseline;
double baseline2 = glyphTypeface.Baseline;
double lineSpacing1 = typeface.FontFamily.LineSpacing;
double lineSpacing2 = glyphTypeface.Height;


The values of baseline1 and baseline2 are different, line spacing too. Why?
I'm trying compare WPF output with Word and for different fonts different spacing values are optimal. How can I determine true baseline and line spacing values for given font?

推荐答案

glyphTypeface.Baseline可以使您上升,glyphTypeface.Height可以使您上升+下降.

The glyphTypeface.Baseline gives you ascent, glyphTypeface.Height gives you ascent + descent.

现在,fontFamily.Baseline为您提供上升++外部引导/2,而fontFamily.LineSpacing为您提供上升+下降+外部引导.那可能就是您想要的值.

Now, fontFamily.Baseline gives you ascent + external leading / 2, and fontFamily.LineSpacing gives you ascent + descent + external leading. That is probably the value you are looking for.

还请注意,FontFamily搜索整个字体系列并返回第一个匹配字体的度量.这可能是与glyphTypeface变量不同的字体.

Also note that the FontFamily searches the whole font family and returns metrics of the first matching font face. This might be a different typeface than you have in the glyphTypeface variable.

Jan


这篇关于GlyphType字面行换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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