我正在做一些自定義的控制和我有一些文本通過雕文被抽運行WPF字形運行正確渲染度的符號
我的問題是℃,沒有被正確我的字形渲染(無論字體家庭),看起來像這樣:
所以我對字形運行代碼(簡體)是:
var typeface = new Typeface(this.FontFamily, this.FontStyle, this.FontWeight, this.FontStretch);
...
GlyphRun glyphRun = CreateGlyphRun(typeface, "°C", 10, new Point(0,0));
dc.DrawGlyphRun(brush, glyphRun);
凡
internal static GlyphRun CreateGlyphRun(Typeface typeface, string text, double size, Point origin)
{
if (text.Length == 0)
return null;
GlyphTypeface glyphTypeface;
typeface.TryGetGlyphTypeface(out glyphTypeface)
var glyphIndexes = new ushort[text.Length];
var advanceWidths = new double[text.Length];
for (int n = 0; n < text.Length; n++)
{
var glyphIndex = (ushort)(text[n] - 29);
glyphIndexes[n] = glyphIndex;
advanceWidths[n] = glyphTypeface.AdvanceWidths[glyphIndex] * size;
}
var glyphRun = new GlyphRun(glyphTypeface, 0, false, size, glyphIndexes, origin, advanceWidths, null, null,
null,
null, null, null);
return glyphRun;
}
我假定它是某種本地化問題。任何幫助,將不勝感激。
這種問題通常是由於因爲一個特定的字體系列沒有特定的字符......你能確認你使用過的字體*是否有這個字符?如果不是,那麼您應該可以爲該字符使用不同的字體系列。 – Sheridan
它的確如我使用Segoe UI一樣。如果我在Segoe UI中使用文本塊,則會顯示符號。它只有當我使用字形運行中的字體時,符號不能正確顯示。 –