<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    I've been where you are! I have a set of hb unicode functions I
    wrote up because I did not want to depend on glib or icu either for
    my test program. It is a handful of simple functions and a rather
    large file of data, and might not work for you, but if you want I am
    happy to send them to you (about 210k uncompressed). I also wrote a
    small (rather ugly) program that parses the unicode data files to
    generate the tables it uses.<br>
    <br>
    Also, it is possible to get simple strings of right-to-left to work,
    if you use the functions to determine the primary script and
    direction of the run. No mixed rtl/ltr, but at least arabic/hebrew
    would work (It does for me at least). Others could probably help you
    tweak it to be more complete. (get_script and get_bidi are calls
    from my unicode functions above).<br>
    <br>
    <br>
        run_script = HB_SCRIPT_UNKNOWN;<br>
        run_direction = HB_DIRECTION_UNKNOWN;<br>
    <br>
    Roughly for each character:<br>
    <br>
                if (run_script == HB_SCRIPT_UNKNOWN)<br>
                {<br>
                    script = get_script(character);<br>
                    if ((script != HB_SCRIPT_COMMON) && (script
    != HB_SCRIPT_INHERITED) && (script != HB_SCRIPT_UNKNOWN))
    run_script = script;<br>
                }<br>
    <br>
                if (run_direction == HB_DIRECTION_UNKNOWN)<br>
                {<br>
                    direction = get_bidi(character);<br>
                    if (direction == UNICODE_BIDI_STRONG_LTR)
    run_direction = HB_DIRECTION_LTR;<br>
                    else if (direction == UNICODE_BIDI_STRONG_RTL)
    run_direction = HB_DIRECTION_RTL;<br>
                }<br>
    <br>
    and then<br>
    <br>
        if (run_direction != HB_DIRECTION_UNKNOWN)
    hb_buffer_set_direction (buffer, run_direction);<br>
        if (run_script != HB_SCRIPT_UNKNOWN) hb_buffer_set_script
    (buffer, run_script);<br>
    <br>
    <br>
    Deron<br>
    <br>
    <br>
    <br>
    On 1/6/12 3:33 AM, Nicolas Rougier wrote:
    <blockquote cite="mid:761B87C9-D5EE-419E-AB1D-CD6185E2CE67@inria.fr"
      type="cite">
      <div><br>
      </div>
      <div><br>
      </div>
      <div>Thanks for the explanation but now I'm a bit lost...</div>
      <div>I thought that harfbuzz could work alone for shaping but from
        what you suggest (I need to try), I would need either glib or
        ICU, is that right ? But if I have to depend on ICU, I could as
        well use it directly for shaping and layout, no ?</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div>Nicolas </div>
      <div><br>
      </div>
      <br>
      <div>
        <div>On Jan 6, 2012, at 10:46 , Kenichi Ishibashi wrote:</div>
        <br class="Apple-interchange-newline">
        <blockquote type="cite">I took a look at your code and noticed
          that you don't call hb_buffer_set_unicode_funcs(). Since both
          HAVE_GLIB and HAVE_ICU are not defined, _hb_unicode_funcs_nil
          is used as default. It won't work for many cases(including
          ligatures). You need to implement your custom
          hb_unicode_funcs_t or use existing
          functions(hb_{glib,icu}_unicode_funcs).
          <div>
            <br>
          </div>
          <div>I think using ICU is a handy way if you can depend on
            ICU. hb-icu.cc contains two 'gint' variables, but you can
            just remove 'g' from them (Someone already sent a patch,
            IIRC).</div>
          <div><br>
          </div>
          <div>Thanks,</div>
          <div><br>
            <div class="gmail_quote">On Fri, Jan 6, 2012 at 5:09 PM,
              Nicolas Rougier <span dir="ltr"><<a
                  moz-do-not-send="true"
                  href="mailto:Nicolas.Rougier@inria.fr">Nicolas.Rougier@inria.fr</a>></span>
              wrote:<br>
              <blockquote class="gmail_quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div style="word-wrap:break-word">
                  <div><br>
                  </div>
                  <div>Thanks, this was certainly an error but it did
                    not fix the problem.</div>
                  <span class="HOEnZb"><font color="#888888">
                      <div><br>
                      </div>
                      <div>Nicolas</div>
                    </font></span>
                  <div>
                    <div class="h5">
                      <div><br>
                      </div>
                      <br>
                      <div>
                        <div>On Jan 6, 2012, at 9:00 , Kenichi Ishibashi
                          wrote:</div>
                        <br>
                        <blockquote type="cite">You may want to define
                          "HAVE_OT" if you use your custom makefile (see
                          <a moz-do-not-send="true"
                            href="http://configure.ac/" target="_blank">configure.ac</a>).<br>
                          <br>
                          <div class="gmail_quote">On Fri, Jan 6, 2012
                            at 4:40 PM, Nicolas Rougier <span dir="ltr"><<a
                                moz-do-not-send="true"
                                href="mailto:Nicolas.Rougier@inria.fr"
                                target="_blank">Nicolas.Rougier@inria.fr</a>></span>
                            wrote:<br>
                            <blockquote class="gmail_quote"
                              style="margin:0 0 0 .8ex;border-left:1px
                              #ccc solid;padding-left:1ex"><br>
                              Thanks for the quick answer. I will try to
                              investigate a bit further to see if there
                              are any errors.<br>
                              If anyone on the list can test the code
                              and report results, that might be helpful
                              as well.<br>
                              <br>
                              I'm attaching the Makefile I used to
                              compile (removed all glib stuff, maybe
                              this where the error is):<br>
                              <br>
                              Nicolas<br>
                              <br>
                              Makefile<br>
                              ======<br>
                              <br>
                              PLATFORM                = $(shell uname)<br>
                              CC                              = g++<br>
                              CFLAGS                  = -Wall
                              `freetype-config --cflags`<br>
                              LIBS                    = `freetype-config
                              --libs`<br>
                              <br>
                              SOURCES = main.cc \<br>
                                     hb-blob.cc hb-buffer.cc
                              hb-common.cc hb-fallback-shape.cc
                              hb-font.cc  \<br>
                                 hb-ft.cc hb-ot-layout.cc hb-ot-map.cc
                              hb-ot-shape-complex-arabic.cc   \<br>
                                 hb-ot-shape-complex-indic.cc
                               hb-ot-shape-complex-misc.cc hb-shape.cc \<br>
                                 hb-ot-shape-normalize.cc hb-ot-shape.cc
                              hb-ot-tag.cc hb-unicode.cc<br>
                              <br>
                              HEADERS = \<br>
                                 hb-buffer-private.hh
                              hb-fallback-shape-private.hh
                              hb-font-private.hh      \<br>
                                 hb-ot-shape-complex-arabic-table.hh
                              hb-ot-shape-complex-indic-table.hh    \<br>
                                 hb-ot-shape-complex-private.hh
                              hb-mutex-private.hh hb-object-private.hh  
                              \<br>
                                 hb-open-file-private.hh
                              hb-open-type-private.hh
                              hb-ot-head-table.hh       \<br>
                                 hb-ot-hhea-table.hh hb-ot-hmtx-table.hh
                              hb-ot-layout-common-private.hh    \<br>
                                 hb-ot-layout-gpos-table.hh
                              hb-ot-layout-gsub-table.hh hb-unicode.h  
                                   \<br>
                                     hb-ot-layout-gsubgpos-private.hh
                              hb-ot-layout-private.hh hb-shape.h       \<br>
                                     hb-ot-map-private.hh
                              hb-ot-maxp-table.hh hb-ot-name-table.hh
                              hb-blob.h    \<br>
                                 hb-private.hh hb-unicode-private.hh
                              hb.h hb-buffer.h hb-version.h hb-ot.h \<br>
                                 hb-common.h hb-font.h hb-ft.h
                              hb-ot-layout.h hb-ot-shape.h hb-ot-tag.h<br>
                              <br>
                              OBJECTS :=  $(SOURCES:.cc=.o)<br>
                              <br>
                              all: main<br>
                              <br>
                              main: $(OBJECTS)<br>
                                     $(CC) $(OBJECTS) $(LIBS) -o $@<br>
                              <br>
                              %.o : %.cc<br>
                                     @echo <a class="moz-txt-link-rfc2396E" href="mailto:$@...">"$@..."</a><br>
                                     @$(CC) -c $(CFLAGS) $< -o $@<br>
                              <br>
                              clean:<br>
                                     @-rm -f glut-main<br>
                                     @-rm -f $(OBJECTS)<br>
                              <br>
                              distclean: clean<br>
                                     @-rm -f *~<br>
                              <div>
                                <div><br>
                                  <br>
                                  <br>
                                  On Jan 5, 2012, at 23:07 , Behdad
                                  Esfahbod wrote:<br>
                                  <br>
                                  > On 01/05/2012 04:44 PM, Nicolas
                                  Rougier wrote:<br>
                                  >><br>
                                  >> Hi,<br>
                                  >><br>
                                  >> I've been trying to simplify
                                  the hb-shape.c example from the util
                                  directory in order to remove any glib
                                  dependencies and come up with source
                                  below ( ~50 lines) but it does not
                                  seem to work (no ligature for fi):<br>
                                  >><br>
                                  >> $ hb-shape DejaVuSans.ttf
                                  "fi"<br>
                                  >> <fi=0+1290><br>
                                  >><br>
                                  >> $ main DejaVuSans.ttf "fi"<br>
                                  >> <f=0+721|i=2+569><br>
                                  >><br>
                                  >><br>
                                  >> Did I do something wrong ?<br>
                                  ><br>
                                  > The code looks fine.  I'm out of
                                  ideas.  Can you recompile harfbuzz
                                  with glib<br>
                                  > and test the same code?<br>
                                  ><br>
                                  > behdad<br>
                                  ><br>
                                  >><br>
                                  >> Nicolas<br>
                                  >><br>
                                  >><br>
                                  >> main.cc<br>
                                  >> ======<br>
                                  >><br>
                                  >> #include <stdio.h><br>
                                  >> #include <ft2build.h><br>
                                  >> #include FT_FREETYPE_H<br>
                                  >> #include "hb-ft.h"<br>
                                  >><br>
                                  >> int main( int argc, char
                                  **argv )<br>
                                  >> {<br>
                                  >>    const char *text = "fi";<br>
                                  >>    char glyph_name[30];<br>
                                  >>    size_t i;<br>
                                  >><br>
                                  >>    FT_Library library;<br>
                                  >>    FT_Face face;<br>
                                  >>    FT_Init_FreeType(
                                  &library );<br>
                                  >>    FT_New_Face( library,
                                  "./DejaVuSans.ttf", 0, &face );<br>
                                  >>    FT_Set_Char_Size( face,
                                  (int)(32*64), 0, 72, 72 );<br>
                                  >><br>
                                  >>    hb_font_t * font =
                                  hb_ft_font_create( face, 0 );<br>
                                  >>    hb_ft_font_set_funcs( font
                                  );<br>
                                  >><br>
                                  >>    hb_buffer_t * buffer =
                                  hb_buffer_create( );<br>
                                  >>    hb_buffer_set_direction(
                                  buffer, HB_DIRECTION_LTR );<br>
                                  >>    hb_buffer_add_utf8(
                                  buffer, text, strlen(text), 0,
                                  strlen(text) );<br>
                                  >>    hb_shape( font, buffer,
                                  NULL, 0 );<br>
                                  >>    unsigned int num_glyphs =
                                  hb_buffer_get_length (buffer);<br>
                                  >>    hb_glyph_info_t* glyphs =
                                  hb_buffer_get_glyph_infos( buffer, 0
                                  );<br>
                                  >>    hb_glyph_position_t *pos =
                                  hb_buffer_get_glyph_positions( buffer,
                                  0 );<br>
                                  >>    hb_glyph_info_t *info =
                                  hb_buffer_get_glyph_infos (buffer,
                                  NULL);<br>
                                  >><br>
                                  >>    for( i=0; i<num_glyphs;
                                  ++i )<br>
                                  >>    {<br>
                                  >>        if( i ) printf( "|" );<br>
                                  >>        else    printf( "<"
                                  );<br>
                                  >>        if
                                  (!FT_Get_Glyph_Name( face,
                                  glyphs[i].codepoint, glyph_name,
                                  sizeof (glyph_name) ))<br>
                                  >>            printf( "%s",
                                  glyph_name );<br>
                                  >>        else<br>
                                  >>            printf( "%u",
                                  info->codepoint );<br>
                                  >>        printf( "=%u",
                                  info->cluster );<br>
                                  >>        if (pos->x_offset
                                  || pos->y_offset) {<br>
                                  >>            printf("@");<br>
                                  >>            if
                                  (pos->x_offset) printf ("%d",
                                  pos->x_offset);<br>
                                  >>            if
                                  (pos->y_offset) printf (",%d",
                                  pos->y_offset);<br>
                                  >>        }<br>
                                  >>        if (pos->x_advance
                                  || pos->y_advance) {<br>
                                  >>            printf ("+");<br>
                                  >>            if
                                  (pos->x_advance) printf ("%d",
                                  pos->x_advance);<br>
                                  >>            if
                                  (pos->y_advance) printf (",%d",
                                  pos->y_advance);<br>
                                  >>        }<br>
                                  >>        ++pos; ++info;<br>
                                  >>    }<br>
                                  >>    printf( ">\n" );<br>
                                  >><br>
                                  >>    hb_font_destroy(font);<br>
                                  >>    FT_Done_Face( face );<br>
                                  >>    FT_Done_FreeType( library
                                  );<br>
                                  >> }<br>
                                  >><br>
                                </div>
                              </div>
                            </blockquote>
                          </div>
                        </blockquote>
                      </div>
                    </div>
                  </div>
                </div>
              </blockquote>
            </div>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Happy Trails,
Deron Kazmaier   <a class="moz-txt-link-abbreviated" href="mailto:deron@dogstarkennel.com">deron@dogstarkennel.com</a>
KD0AYO  Western South Dakota
Dog Star Kennel <a class="moz-txt-link-freetext" href="http://www.dogstarkennel.com">http://www.dogstarkennel.com</a>
--- Racing AKC Sepp-Star Seppala Siberian Husky Sled Dogs
</pre>
  </body>
</html>