我剛發現你的問題後,我做了一些研究。
GlyphRun使用公共構造函數來創建創建了TextFormattingMode = Ideal
所有WPF對象contols其rendring使用方法/構造接受TextFormattingMode作爲參數。
您可以通過反射調用GlyphRun.TryCreate()
靜態方法:
internal static GlyphRun TryCreate(
GlyphTypeface glyphTypeface,
int bidiLevel,
bool isSideways,
double renderingEmSize,
IList<ushort> glyphIndices,
Point baselineOrigin,
IList<double> advanceWidths,
IList<Point> glyphOffsets,
IList<char> characters,
string deviceFontName,
IList<ushort> clusterMap,
IList<bool> caretStops,
XmlLanguage language,
TextFormattingMode textLayout
)
,但你需要得到advanceWidths
與TextFormattingMode = Ideal
問題。爲此,您需要通過反射訪問GlyphTypeface
課程提供的內部方法。
GlyphTypeface.AdvanceWidths
屬性,返回字典,這些寬度,當你訪問字典的指數與textFormattingMode = TextFormattingMode.Ideal
您可以下載的.Net源代碼,並檢查自己內部調用到
internal double GetAdvanceWidth(ushort glyph, TextFormattingMode textFormattingMode, bool isSideways)
。
至於你的第二個問題,我認爲你使用字符而不是unicode代碼點來獲得標誌符號索引。