admin管理员组文章数量:1312774
I want to shape a string of text with harfbuzz where some portions of the string (a word) is BOLD, whereas the rest remain REGULAR. The text buffer is entirely a single script, language and direction.
I'm uncertain how to use the API to specify which portions of the text is REGULAR, and which is BOLD.
The following documentation describes the basic overview of shaping text, which I'm following, and here it mentions:
The safest approach is to add all of the text available (even if your text contains a mix of scripts, directions, languages and fonts), then use item_offset and item_length to indicate which characters you want shaped (which must all have the same script, direction, language and font), so that HarfBuzz has access to any context.
Given the above I've so far assumed that for the given sample string: A test sentence
with uniform formatting I would simply:
- Add the entire string of text in one go using
hb_buffer_add_utf8
(and specify the entire length of the buffer) - Set thte language, script and direction
- Call
hb_shape
with a single font (REGULAR.ttf etc)
However, how do I shape the string if I want the word test
to be BOLD, but the rest REGULAR?
Do I:
- call
hb_buffer_add_utf8
three times? - the first to shape offsets 0 to 1 (inclusive) to shape
A
- then a second call to shape offsets 2 to 5, for
test
- then lastly another call to shape
sentence
The issue I'm having is that hb_shape doesn't accept offsets like hb_buffer_add_utf8
, and takes a single font
.
Does this imply that I call hb_shape
three times as well? where in the second call I just pass it the BOLD font?
本文标签: fontsharfbuzz shaping text with different formattingStack Overflow
版权声明:本文标题:fonts - harfbuzz shaping text with different formatting - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741887730a2403121.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论