<font size=2 face="Arial">Dear Konstantin,</font>
<br>
<br><font size=2 face="Arial"> I got
it!</font>
<br>
<br><font size=2 face="Arial"> Thank
you for your help.</font>
<br>
<br><font size=2 face="Arial">Best regards,</font>
<br>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">发件人:
</font><font size=1 face="sans-serif">Konstantin
Ritt <ritt.ks@gmail.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">收件人:
</font><font size=1 face="sans-serif">ff.feng@sunmedia.com.cn</font>
<br><font size=1 color=#5f5f5f face="sans-serif">抄送:
</font><font size=1 face="sans-serif">Harfbuzz <harfbuzz@lists.freedesktop.org></font>
<br><font size=1 color=#5f5f5f face="sans-serif">日期:
</font><font size=1 face="sans-serif">2014/10/30
21:01</font>
<br><font size=1 color=#5f5f5f face="sans-serif">主题:
</font><font size=1 face="sans-serif">Re: [HarfBuzz]
How many unicode make up a glyph?</font>
<br>
<hr noshade>
<br>
<br>
<br><font size=3>Hi,</font>
<br><font size=3> </font>
<br><font size=3>if I understood you correctly, you're talking about
the Unicode code point to glyph mapping (aka logical to visual cluster
mapping). If so, it would look like</font>
<br><font size=3>{code}</font>
<br><font size=3>const uint16_t *string = ..; // UTF-16 string<br>
int str_len = ..; // length of `string` buffer</font>
<br><font size=3> </font>
<br><font size=3>hb_buffer_add_utf16(buffer, string, str_len, 0, str_len);</font>
<br><font size=3>..</font>
<br><font size=3>hb_shape_full(..);</font>
<br><font size=3> </font>
<br><font size=3>const uint num_glyphs = hb_buffer_get_length(buffer);</font>
<br><font size=3>ensureSpace(num_glyphs); // ensure we have enough space
for shaped glyphs and metrics (here we reallocate the `glyphs`, `advances`, and
`offsets` buffers, if needed)</font>
<br><font size=3>ushort *log_clusters = ..;</font>
<br><font size=3>uint *glyphs = ..;</font>
<br><font size=3>float *advances = ..;</font>
<br><font size=3>float *offsets_x = ..;</font>
<br><font size=3>float *offsets_y = ..;</font>
<br><font size=3> </font>
<br><font size=3>// fetch the shaped glyphs and metrics<br>
b_glyph_info_t *infos = hb_buffer_get_glyph_infos(buffer, 0);<br>
hb_glyph_position_t *positions = hb_buffer_get_glyph_positions(buffer,
0);<br>
uint str_pos = 0;<br>
uint last_cluster = ~0u;<br>
uint last_glyph_pos = 0;<br>
for (uint i = 0; i < num_glyphs; ++i) {<br>
glyphs[i] = infos[i].codepoint;</font>
<br><font size=3> advances[i] = positions[i].x_advance;<br>
offsets_x[i] = positions[i].x_offset;<br>
offsets_y[i] = positions[i].y_offset;</font>
<br><font size=3> </font>
<br><font size=3> uint cluster = infos[i].cluster;<br>
if (last_cluster != cluster) {<br>
// fix up clusters so that the
cluster indices will be monotonic<br>
// and thus we never return
out-of-order indices<br>
while (last_cluster++ < cluster
&& str_pos < str_len)<br>
log_clusters[str_pos++]
= last_glyph_pos;</font>
<br><font size=3> // [last_glyph_pos..i)
forms a single glyph cluster; if you have glyph attributes, here you could
remember the cluster start for iterating over the glyph clusters later,
e.g. attribs[i].clusterStart = true;<br>
last_glyph_pos = i;<br>
last_cluster = cluster;<br>
}<br>
}<br>
while (str_pos < str_len)<br>
log_clusters[str_pos++] = last_glyph_pos;</font>
<br><font size=3>{code}</font>
<br><font size=3> </font>
<br>
<br><font size=3>Regards,<br>
Konstantin</font>
<br>
<br><font size=3>2014-10-30 6:50 GMT+04:00 <</font><a href=mailto:ff.feng@sunmedia.com.cn target=_blank><font size=3 color=blue><u>ff.feng@sunmedia.com.cn</u></font></a><font size=3>>:</font>
<br><font size=3 face="sans-serif">Hi !</font><font size=3> <br>
</font><font size=3 face="sans-serif"><br>
I'm developing a font engine with harfbuzz & freetype for Cambodia.
<br>
I can get the correct glyph index array and position array by harfbuzz.
<br>
That's sweet.</font><font size=3> <br>
</font><font size=3 face="sans-serif"><br>
Now I got a problem : I'm wondering how many unicode(UTF16) form a glyph?</font><font size=3>
</font><font size=3 face="sans-serif"><br>
(If I specify a item in the glyph index array from hb_buffer_get_glyph_infos)</font><font size=3>
<br>
</font><font size=3 face="sans-serif"><br>
thanks a lot & sorry for my poor English.</font><font size=3> <br>
<br>
</font><font size=3 face="sans-serif"><br>
Best regards,</font><font size=3> </font>
<br><font size=1 face="Arial">**********************************************************************</font>
<p><font size=1 face="Arial">The preceding e-mail message (including any
attachments) may contain confidential information intended for a specific
individual and purpose.If you are not an intended recipient of this message,
please notify the sender by replying to this message and then delete it
from your system.Use,dissemination, distribution, or reproduction of this
message by unintended recipients is not authorized and may be unlawful.
</font>
<p><font size=1 face="Arial">**********************************************************************</font>
<p><font size=1 face="Arial"> </font>
<br><font size=3><br>
_______________________________________________<br>
HarfBuzz mailing list</font><font size=3 color=blue><u><br>
</u></font><a href=mailto:HarfBuzz@lists.freedesktop.org><font size=3 color=blue><u>HarfBuzz@lists.freedesktop.org</u></font></a><font size=3 color=blue><u><br>
</u></font><a href=http://lists.freedesktop.org/mailman/listinfo/harfbuzz target=_blank><font size=3 color=blue><u>http://lists.freedesktop.org/mailman/listinfo/harfbuzz</u></font></a><font size=3><br>
</font>
<br>
<br>