Fonts DirectWrite连字替换功能
我正在尝试使用DirectWrite为给定字符串获取适当的标志符号。我正在尝试启用OpenType特性进行测试,在本例中是字体连字替换。我使用的字体包含OpenType“liga”标记,并且有一个单独的ll字形 这是我的密码:Fonts DirectWrite连字替换功能,fonts,directwrite,ligature,Fonts,Directwrite,Ligature,我正在尝试使用DirectWrite为给定字符串获取适当的标志符号。我正在尝试启用OpenType特性进行测试,在本例中是字体连字替换。我使用的字体包含OpenType“liga”标记,并且有一个单独的ll字形 这是我的密码: text = 'Hello' analyze = IDWriteTextAnalyzer() self.font.write_factory.CreateTextAnalyzer(byref(analyze))
text = 'Hello'
analyze = IDWriteTextAnalyzer()
self.font.write_factory.CreateTextAnalyzer(byref(analyze))
tags = [DWRITE_FONT_FEATURE_TAG_STANDARD_LIGATURES]
num_feature = len(tags)
if num_feature:
typo_features = DWRITE_TYPOGRAPHIC_FEATURES()
typo_features.featureCount = num_feature
typo_features.features = (DWRITE_FONT_FEATURE * num_feature)()
for i in range(num_feature):
typo_features.features[i] = DWRITE_FONT_FEATURE(tags[i], 1)
feature_range = (UINT32 * num_feature)(len(text))
else:
typo_features = None
feature_range = None
max_count = int(3 * len(text) / 2 + 16)
length = len(text)
clusters = (UINT16 * length)()
text_props = (DWRITE_SHAPING_TEXT_PROPERTIES * length)()
indices = (UINT16 * max_count)()
glyph_props = (DWRITE_SHAPING_GLYPH_PROPERTIES * max_count)()
actual_count = UINT32()
analyze.GetGlyphs(text,
len(text),
self.font.font_face,
False, # sideways
False, # righttoleft
script, # scriptAnalysis
None, # localName
None, # numberSub
typo_features, # typo features
feature_range, # feature range
1, # count
max_count,
clusters, # cluster map
text_props, # text props
indices, # glyph indices
glyph_props, #glyph pops
byref(actual_count)#glyph count
)
但是,在检查返回值时,它总共有5个标志符号,并且在标志符号索引中没有显示连字标记,只有原来的两个l:[43、72、79、79、82、0、0、0、0、0、0、0、0、0、0、0、0、0、0、0、0、0、0、0、0、0、0]
我不确定我是否理解正确。我认为它会用字符串中的两个l替换ll标志符号,这是错误的吗?或者有没有另一个过程让这个标记成为真正的系带?任何输入都是有帮助的,因为我是新手。谢谢有很多东西需要检查:
- 字体如何定义“liga”,需要哪个脚本/语言对,使用什么样的查找李>
- 尝试使用相同字体的IDirectWriteTextLayout使用简单的测试程序,以查看默认情况下是否获得此连字。如果您这样做,则表示“liga”在默认情况下处于启用状态,您不需要将其指定为用户功能李>
- 首先检查您在更传统的环境中测试代码,如C/C++
SetScriptAnalysis
中的某个地方出现了一个bug,不知怎的,它从DirectWrite中被回调了两次。第一个调用获取正确的脚本id(49),但第二个调用正在用错误的脚本id(1)覆盖正确的脚本id。我不确定是什么触发了这种情况,但我想可能是某个地方的错误实现。@Charlie:旁白:你用什么语言写的?(我只尝试用C++调用DWrite)缺少“;”,并且使用“:”用于<代码>…………/>代码就像Python,但我不知道如何使用Python调用dWrand。