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

问题描述



示例代码:

字体

Hi,

Sample code:

Typeface

 

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

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

double

 

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


baseline1的值和baseline2不同,行间距也不同.为什么?
我正在尝试将WPF输出与Word进行比较,对于不同的字体,不同的间距值是最佳的.如何确定给定字体的 true 基线和行间距值?

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?

推荐答案

现在,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字面行换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 09:36