<div dir="ltr"><br><div class="gmail_quote">2014/1/6 Khaled Hosny <span dir="ltr"><<a href="mailto:khaledhosny@eglug.org" target="_blank">khaledhosny@eglug.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Another thing that I’d like to see sorted before the API is finalised,<br>
is reverse mapping of output glyphs to input characters with proper<br>
handling of combing marks. I feel we should keep the current cluster<br>
stuff since it might have its uses (I’m not sure though) and introduce a<br>
separate way for that mapping. Either way, I think a more indicative<br>
name would be better (it took me sometime to understand what those<br>
clusters are for and they mislead me quit a bit when I tried to use<br>
HarfBuzz for the first time).<br>
<br>
Regards,<br>
Khaled<br>
</blockquote></div><div><br></div><div>Oh, I thought I'm the only one who felt into that trouble :)</div><div><br></div><div>Here is a result of my tries and fails:</div><div><span style="color:#c0c0c0">[code]<br></span></div>

<div>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">        </span>ushort<span style="color:#c0c0c0"> </span><span style="color:#000000">*</span>log_clusters<span style="color:#c0c0c0"> </span><span style="color:#000000">=</span><span style="color:#c0c0c0"> </span>...<span style="color:#000000">;<br>

</span><span style="color:#c0c0c0">        </span><span style="color:#808000">const</span><span style="color:#c0c0c0"> </span>uint<span style="color:#c0c0c0"> </span>num_glyphs<span style="color:#c0c0c0"> </span><span style="color:#000000">=</span><span style="color:#c0c0c0"> </span>hb_buffer_get_length<span style="color:#000000">(</span>buffer<span style="color:#000000">);<br>

</span><span style="color:#c0c0c0">        </span>hb_glyph_info_t<span style="color:#c0c0c0"> </span><span style="color:#000000">*</span>infos<span style="color:#c0c0c0"> </span><span style="color:#000000">=</span><span style="color:#c0c0c0"> </span>hb_buffer_get_glyph_infos<span style="color:#000000">(</span>buffer<span style="color:#000000">,</span><span style="color:#c0c0c0"> </span><span style="color:#000080">0</span><span style="color:#000000">);</span></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">        </span><span style="color:#808000">for</span><span style="color:#c0c0c0"> </span><span style="color:#000000">(</span>uint<span style="color:#c0c0c0"> </span>i<span style="color:#c0c0c0"> </span><span style="color:#000000">=</span><span style="color:#c0c0c0"> </span><span style="color:#000080">0</span><span style="color:#000000">;</span><span style="color:#c0c0c0"> </span>i<span style="color:#c0c0c0"> </span><span style="color:#000000"><</span><span style="color:#c0c0c0"> </span>num_glyphs<span style="color:#000000">;</span><span style="color:#c0c0c0"> </span><span style="color:#000000">++</span>i<span style="color:#000000">)</span><span style="color:#c0c0c0"> </span><span style="color:#000000">{</span></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">            </span>log_clusters<span style="color:#000000">[</span>i<span style="color:#000000">]</span><span style="color:#c0c0c0"> </span><span style="color:#000000">=</span><span style="color:#c0c0c0"> </span>infos<span style="color:#000000">[</span>i<span style="color:#000000">].</span>cluster<span style="color:#000000">;<br>

            // ... </span>glyphs<span style="color:#000000">[</span>i<span style="color:#000000">]</span><span style="color:#c0c0c0"> </span><span style="color:#000000">=</span><span style="color:#c0c0c0"> </span>infos<span style="color:#000000">[</span>i<span style="color:#000000">].</span>codepoint; and so on<br>

<span style="color:#c0c0c0">        </span><span style="color:#000000">}</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">        </span><span style="color:#008000">//</span><span style="color:#c0c0c0"> </span><span style="color:#008000">adjust</span><span style="color:#c0c0c0"> </span><span style="color:#008000">clusters</span></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">        </span>uint<span style="color:#c0c0c0"> </span>glyph_pos<span style="color:#c0c0c0"> </span><span style="color:#000000">=</span><span style="color:#c0c0c0"> </span><span style="color:#000080">0</span><span style="color:#000000">;</span></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">        </span><span style="color:#808000">for</span><span style="color:#c0c0c0"> </span><span style="color:#000000">(</span>uint<span style="color:#c0c0c0"> </span>i<span style="color:#c0c0c0"> </span><span style="color:#000000">=</span><span style="color:#c0c0c0"> </span><span style="color:#000080">0</span><span style="color:#000000">;</span><span style="color:#c0c0c0"> </span>i<span style="color:#c0c0c0"> </span><span style="color:#000000"><</span> num_characters;<span style="color:#c0c0c0"> </span><span style="color:#000000">++</span>i<span style="color:#000000">)</span><span style="color:#c0c0c0"> </span><span style="color:#000000">{</span></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">            </span><span style="color:#808000">if</span><span style="color:#c0c0c0"> </span><span style="color:#000000">(i</span><span style="color:#c0c0c0"> </span><span style="color:#000000">!=</span><span style="color:#c0c0c0"> </span>infos<span style="color:#000000">[</span>glyph_pos<span style="color:#000000">].</span>cluster<span style="color:#000000">)</span><span style="color:#c0c0c0"> </span><span style="color:#000000">{</span></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">                </span><span style="color:#808000">for</span><span style="color:#c0c0c0"> </span><span style="color:#000000">(</span>uint<span style="color:#c0c0c0"> </span>j<span style="color:#c0c0c0"> </span><span style="color:#000000">=</span><span style="color:#c0c0c0"> </span>glyph_pos<span style="color:#c0c0c0"> </span><span style="color:#000000">+</span><span style="color:#c0c0c0"> </span><span style="color:#000080">1</span><span style="color:#000000">;</span><span style="color:#c0c0c0"> </span>j<span style="color:#c0c0c0"> </span><span style="color:#000000"><</span><span style="color:#c0c0c0"> </span>num_glyphs<span style="color:#000000">;</span><span style="color:#c0c0c0"> </span><span style="color:#000000">++</span>j<span style="color:#000000">)</span><span style="color:#c0c0c0"> </span><span style="color:#000000">{</span></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">                    </span><span style="color:#808000">if</span><span style="color:#c0c0c0"> </span><span style="color:#000000">(</span>i<span style="color:#c0c0c0"> </span><span style="color:#000000"><=</span><span style="color:#c0c0c0"> </span>infos<span style="color:#000000">[</span>j<span style="color:#000000">].</span>cluster<span style="color:#000000">)</span><span style="color:#c0c0c0"> </span><span style="color:#000000">{</span></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">                        </span><span style="color:#808000">if</span><span style="color:#c0c0c0"> </span><span style="color:#000000">(</span>i<span style="color:#c0c0c0"> </span><span style="color:#000000">==</span><span style="color:#c0c0c0"> </span>infos<span style="color:#000000">[</span>j<span style="color:#000000">].</span>cluster<span style="color:#000000">)</span></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">                            </span>glyph_pos<span style="color:#c0c0c0"> </span><span style="color:#000000">=</span><span style="color:#c0c0c0"> </span>j<span style="color:#000000">;</span></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">                        </span><span style="color:#808000">break</span><span style="color:#000000">;</span></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">                    </span><span style="color:#000000">}</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">                </span><span style="color:#000000">}</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">            </span><span style="color:#000000">}</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">            </span>log_clusters<span style="color:#000000">[</span>i<span style="color:#000000">]</span><span style="color:#c0c0c0"> </span><span style="color:#000000">=</span><span style="color:#c0c0c0"> </span>glyph_pos<span style="color:#000000">;</span></pre>


<pre style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:#c0c0c0">        </span><span style="color:#000000">}</span></pre></div><div>
<span style="color:#c0c0c0">[/code]</span>
<br><div class="gmail_extra"><br clear="all"><div>You could agree that the latter part is not obvious.</div><div>And except of bringing some inconvenience to the user, lack of reverse mapping API also hits the performance a bit since we can not avoid this loop with "if (num_glyphs != num_characters)".</div>

<div><br></div><div>Regards,<br>Konstantin</div></div><br></div></div>