获取希伯来语文本的字体轮廓
getting font outline for hebrew text
我编辑了一个代码,我发现它可以获取文本的所有轮廓数据,因此我可以在其他程序中将其手动绘制为线条。
我的代码在英语中运行良好,但是当我尝试发送希伯来语文本时,轮廓变成乱码。
代码的主要步骤是:
字体 -> GlyphTypeface -> GlyphRun
主要代码是
Private m_gtf As System.Windows.Media.GlyphTypeface
Private m_glypText As GlyphRun
Private m_textFont As System.Drawing.Font
textFont = New Font("Aharoni", 12, FontStyle.Regular, GraphicsUnit.World, 177, False)
m_typeface = New Typeface(New System.Windows.Media.FontFamily(m_textFont.Name), m_fontStyle, _
m_fontWeight, New System.Windows.FontStretch())
m_typeface.TryGetGlyphTypeface(m_gtf)
'then use m_gtf to crate the m_glyphIndices and advanceWidths vectors
m_glypText = New GlyphRun(m_gtf, bidiLevel, False, m_height, m_glyphIndices, origin, advanceWidths, _
Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
我认为我的问题出在 "m_typeface = New Typeface(…"
在此命令中无法发送字体 gdiCharSet 值。
有没有办法直接从 m_textFont 获取字体?
或者还有其他方法吗?
佐哈尔
找到问题了。
我正在使用:
Dim glyphIndex As UShort = m_gtf.CharacterToGlyphMap(Asc(m_textString(n)))
但我不得不使用 AscW 来获取正确的 ascii 码:
Dim glyphIndex As UShort = m_gtf.CharacterToGlyphMap(AscW(m_textString(n)))
现在可以了!
佐哈
我编辑了一个代码,我发现它可以获取文本的所有轮廓数据,因此我可以在其他程序中将其手动绘制为线条。 我的代码在英语中运行良好,但是当我尝试发送希伯来语文本时,轮廓变成乱码。
代码的主要步骤是: 字体 -> GlyphTypeface -> GlyphRun
主要代码是
Private m_gtf As System.Windows.Media.GlyphTypeface
Private m_glypText As GlyphRun
Private m_textFont As System.Drawing.Font
textFont = New Font("Aharoni", 12, FontStyle.Regular, GraphicsUnit.World, 177, False)
m_typeface = New Typeface(New System.Windows.Media.FontFamily(m_textFont.Name), m_fontStyle, _
m_fontWeight, New System.Windows.FontStretch())
m_typeface.TryGetGlyphTypeface(m_gtf)
'then use m_gtf to crate the m_glyphIndices and advanceWidths vectors
m_glypText = New GlyphRun(m_gtf, bidiLevel, False, m_height, m_glyphIndices, origin, advanceWidths, _
Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
我认为我的问题出在 "m_typeface = New Typeface(…" 在此命令中无法发送字体 gdiCharSet 值。
有没有办法直接从 m_textFont 获取字体? 或者还有其他方法吗?
佐哈尔
找到问题了。
我正在使用:
Dim glyphIndex As UShort = m_gtf.CharacterToGlyphMap(Asc(m_textString(n)))
但我不得不使用 AscW 来获取正确的 ascii 码:
Dim glyphIndex As UShort = m_gtf.CharacterToGlyphMap(AscW(m_textString(n)))
现在可以了! 佐哈