[HarfBuzz] Simplifying the hb-shape.cc example

Kenichi Ishibashi bashi at chromium.org
Fri Jan 6 01:46:34 PST 2012


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).

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).

Thanks,

On Fri, Jan 6, 2012 at 5:09 PM, Nicolas Rougier <Nicolas.Rougier at inria.fr>wrote:

>
> Thanks, this was certainly an error but it did not fix the problem.
>
> Nicolas
>
>
> On Jan 6, 2012, at 9:00 , Kenichi Ishibashi wrote:
>
> You may want to define "HAVE_OT" if you use your custom makefile (see
> configure.ac).
>
> On Fri, Jan 6, 2012 at 4:40 PM, Nicolas Rougier <Nicolas.Rougier at inria.fr>wrote:
>
>>
>> Thanks for the quick answer. I will try to investigate a bit further to
>> see if there are any errors.
>> If anyone on the list can test the code and report results, that might be
>> helpful as well.
>>
>> I'm attaching the Makefile I used to compile (removed all glib stuff,
>> maybe this where the error is):
>>
>> Nicolas
>>
>> Makefile
>> ======
>>
>> PLATFORM                = $(shell uname)
>> CC                              = g++
>> CFLAGS                  = -Wall `freetype-config --cflags`
>> LIBS                    = `freetype-config --libs`
>>
>> SOURCES = main.cc \
>>        hb-blob.cc hb-buffer.cc hb-common.cc hb-fallback-shape.cc
>> hb-font.cc  \
>>    hb-ft.cc hb-ot-layout.cc hb-ot-map.cc hb-ot-shape-complex-arabic.cc   \
>>    hb-ot-shape-complex-indic.cc  hb-ot-shape-complex-misc.cc hb-shape.cc \
>>    hb-ot-shape-normalize.cc hb-ot-shape.cc hb-ot-tag.cc hb-unicode.cc
>>
>> HEADERS = \
>>    hb-buffer-private.hh hb-fallback-shape-private.hh hb-font-private.hh
>>    \
>>    hb-ot-shape-complex-arabic-table.hh hb-ot-shape-complex-indic-table.hh
>>    \
>>    hb-ot-shape-complex-private.hh hb-mutex-private.hh
>> hb-object-private.hh   \
>>    hb-open-file-private.hh hb-open-type-private.hh hb-ot-head-table.hh
>>     \
>>    hb-ot-hhea-table.hh hb-ot-hmtx-table.hh hb-ot-layout-common-private.hh
>>    \
>>    hb-ot-layout-gpos-table.hh hb-ot-layout-gsub-table.hh hb-unicode.h
>>    \
>>        hb-ot-layout-gsubgpos-private.hh hb-ot-layout-private.hh
>> hb-shape.h       \
>>        hb-ot-map-private.hh hb-ot-maxp-table.hh hb-ot-name-table.hh
>> hb-blob.h    \
>>    hb-private.hh hb-unicode-private.hh hb.h hb-buffer.h hb-version.h
>> hb-ot.h \
>>    hb-common.h hb-font.h hb-ft.h hb-ot-layout.h hb-ot-shape.h hb-ot-tag.h
>>
>> OBJECTS :=  $(SOURCES:.cc=.o)
>>
>> all: main
>>
>> main: $(OBJECTS)
>>        $(CC) $(OBJECTS) $(LIBS) -o $@
>>
>> %.o : %.cc
>>        @echo "$@..."
>>        @$(CC) -c $(CFLAGS) $< -o $@
>>
>> clean:
>>        @-rm -f glut-main
>>        @-rm -f $(OBJECTS)
>>
>> distclean: clean
>>        @-rm -f *~
>>
>>
>>
>> On Jan 5, 2012, at 23:07 , Behdad Esfahbod wrote:
>>
>> > On 01/05/2012 04:44 PM, Nicolas Rougier wrote:
>> >>
>> >> Hi,
>> >>
>> >> 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):
>> >>
>> >> $ hb-shape DejaVuSans.ttf "fi"
>> >> <fi=0+1290>
>> >>
>> >> $ main DejaVuSans.ttf "fi"
>> >> <f=0+721|i=2+569>
>> >>
>> >>
>> >> Did I do something wrong ?
>> >
>> > The code looks fine.  I'm out of ideas.  Can you recompile harfbuzz
>> with glib
>> > and test the same code?
>> >
>> > behdad
>> >
>> >>
>> >> Nicolas
>> >>
>> >>
>> >> main.cc
>> >> ======
>> >>
>> >> #include <stdio.h>
>> >> #include <ft2build.h>
>> >> #include FT_FREETYPE_H
>> >> #include "hb-ft.h"
>> >>
>> >> int main( int argc, char **argv )
>> >> {
>> >>    const char *text = "fi";
>> >>    char glyph_name[30];
>> >>    size_t i;
>> >>
>> >>    FT_Library library;
>> >>    FT_Face face;
>> >>    FT_Init_FreeType( &library );
>> >>    FT_New_Face( library, "./DejaVuSans.ttf", 0, &face );
>> >>    FT_Set_Char_Size( face, (int)(32*64), 0, 72, 72 );
>> >>
>> >>    hb_font_t * font = hb_ft_font_create( face, 0 );
>> >>    hb_ft_font_set_funcs( font );
>> >>
>> >>    hb_buffer_t * buffer = hb_buffer_create( );
>> >>    hb_buffer_set_direction( buffer, HB_DIRECTION_LTR );
>> >>    hb_buffer_add_utf8( buffer, text, strlen(text), 0, strlen(text) );
>> >>    hb_shape( font, buffer, NULL, 0 );
>> >>    unsigned int num_glyphs = hb_buffer_get_length (buffer);
>> >>    hb_glyph_info_t* glyphs = hb_buffer_get_glyph_infos( buffer, 0 );
>> >>    hb_glyph_position_t *pos = hb_buffer_get_glyph_positions( buffer, 0
>> );
>> >>    hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, NULL);
>> >>
>> >>    for( i=0; i<num_glyphs; ++i )
>> >>    {
>> >>        if( i ) printf( "|" );
>> >>        else    printf( "<" );
>> >>        if (!FT_Get_Glyph_Name( face, glyphs[i].codepoint, glyph_name,
>> sizeof (glyph_name) ))
>> >>            printf( "%s", glyph_name );
>> >>        else
>> >>            printf( "%u", info->codepoint );
>> >>        printf( "=%u", info->cluster );
>> >>        if (pos->x_offset || pos->y_offset) {
>> >>            printf("@");
>> >>            if (pos->x_offset) printf ("%d", pos->x_offset);
>> >>            if (pos->y_offset) printf (",%d", pos->y_offset);
>> >>        }
>> >>        if (pos->x_advance || pos->y_advance) {
>> >>            printf ("+");
>> >>            if (pos->x_advance) printf ("%d", pos->x_advance);
>> >>            if (pos->y_advance) printf (",%d", pos->y_advance);
>> >>        }
>> >>        ++pos; ++info;
>> >>    }
>> >>    printf( ">\n" );
>> >>
>> >>    hb_font_destroy(font);
>> >>    FT_Done_Face( face );
>> >>    FT_Done_FreeType( library );
>> >> }
>> >>
>> >>
>> >> _______________________________________________
>> >> HarfBuzz mailing list
>> >> HarfBuzz at lists.freedesktop.org
>> >> http://lists.freedesktop.org/mailman/listinfo/harfbuzz
>> >>
>>
>> _______________________________________________
>> HarfBuzz mailing list
>> HarfBuzz at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/harfbuzz
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20120106/cfc6cc95/attachment.html>


More information about the HarfBuzz mailing list