On Sat, Jun 30, 2018 at 1:55 AM, Werner LEMBERG <[email protected]> wrote:

>
> > I haven't got time to fully review the API. But just taking a look
> > now, in the example in freetype.h:
> >
> >      if ( palette && layer_glyph_index )
> >      {
> >        do
> >        {
> >          FT_Color  layer_color = palette[layer_color_index];
> >
> >
> >          // Load and render glyph `layer_glyph_index', then
> >          // blend resulting pixmap with previously created pixmaps.
> >
> >        } while ( ( layer_glyph_index =
> >                      FT_Get_Color_Glyph_Layer( face,
> >                                                glyph_index,
> >                                                &layer_color_index,
> >                                                &iterator ) ) != 0 );
> >      }
> >
> > First, I think the use of a FT_LayerIterator type is unnecessary. A
> > single index could have done.
>
> Using a single index would be slower, since I had to derive the number
> of glyph layers from `glyph_index' each time I call
> `FT_Get_Color_Glyph_Layer'.  Theoretically, I could implement a cache
> just for this purpose, but somehow it doesn't feel right to extend
> `FT_Face_Internal' for this.
>

Not a huge deal. Whatever you are happy with.


> > Second, the use of 0 return value to signify end of iteration is
> > problematic given that 0 is a valid glyph index that can appear in
> > the layers itself.
>
> OK, will change.
>
> > Third, "palette[layer_color_index]" is recipe for invalid memory
> > access.
>
> Is it?  The code checks that `layer_color_index' is not out of bound.
> Do you have a better idea?
>

What does the code do if the font has bad index then?  Maybe treating those
as foreground works.


> > Let alone that it does not handle the foreground color magic number
> > 0xFFFF.
>
> What I could do is to make the magic number 0xFFFF completely
> disappear by giving it index `num_palette_entries' while increasing
> the size of `palette' (and `num_palette_entries') by one element...
>

I'd say stay close to the spec.  Just document returning 0xFFFF.


> > 1. I'm not sure the modifiable palettes are a good idea.
>
> Yeah.  Maybe my memory tricks me, but I somehow remember that this was
> asked for...
>
> > 2. Default foreground color of black makes more sense to me.  Who
> > reads white?
>
> Please read again.  It is white only if the palette is intended for a
> dark background.
>

My bad.


> > 3. "palette_types" would have been better called "palette_flags",
> > given that that's what is in the spec.
>
> Makes sense.  I'll change that.


Ok, bigger problem.  I'm getting crashes rendering anything using hb-view:

 Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007ffff726a1ca in FT_Get_Color_Glyph_Layer (face=0x555555787320,
base_glyph=265, acolor_index=0x7fffffffa30c, iterator=0x7fffffffa310)
    at
/home/behdad/SSD/src/savannah/freetype/freetype2/src/base/ftobjs.c:5496
#2  0x00007ffff726922d in FT_Render_Glyph_Internal (library=0x555555786260,
slot=0x5555557890c0, render_mode=FT_RENDER_MODE_NORMAL) at
/home/behdad/SSD/src/savannah/freetype/freetype2/src/base/ftobjs.c:4526
#3  0x00007ffff7269457 in FT_Render_Glyph (slot=0x5555557890c0,
render_mode=FT_RENDER_MODE_NORMAL) at
/home/behdad/SSD/src/savannah/freetype/freetype2/src/base/ftobjs.c:4746
#4  0x00007ffff75b5078 in _render_glyph_outline (face=0x555555787320,
surface=0x7fffffffa408, font_options=0x55555578c120) at cairo-ft-font.c:1514
#5  _cairo_ft_scaled_glyph_init (abstract_font=0x55555578bf30,
scaled_glyph=0x55555578c440, info=<optimized out>) at cairo-ft-font.c:2608
#6  0x00007ffff7563210 in _cairo_scaled_glyph_lookup
(scaled_font=0x55555578bf30, index=<optimized out>, index@entry=265,
info=info@entry=CAIRO_SCALED_GLYPH_INFO_SURFACE,
    scaled_glyph_ret=scaled_glyph_ret@entry=0x7fffffffa658) at
cairo-scaled-font.c:3039
#7  0x00007ffff752bd10 in composite_glyphs (_dst=0x55555578b670,
op=CAIRO_OPERATOR_DEST_OUT, _src=0x55555578eb90, src_x=0, src_y=0, dst_x=0,
dst_y=0, info=0x7fffffffaf70) at cairo-image-compositor.c:889
#8  0x00007ffff75789ff in clip_and_composite
(compositor=compositor@entry=0x7ffff78135e0
<compositor>, extents=extents@entry=0x7fffffffaff0,
draw_func=draw_func@entry=0x7ffff75772f0 <composite_glyphs>,
    mask_func=mask_func@entry=0x0,
draw_closure=draw_closure@entry=0x7fffffffaf70,
need_clip=4) at cairo-traps-compositor.c:1049
#9  0x00007ffff7578bee in _cairo_traps_compositor_glyphs
(_compositor=0x7ffff78135e0 <compositor>, extents=0x7fffffffaff0,
scaled_font=0x55555578bf30, glyphs=0x7fffffffb720, num_glyphs=<optimized
out>,
    overlap=1) at cairo-traps-compositor.c:2331
#10 0x00007ffff7521267 in _cairo_compositor_glyphs
(compositor=0x7ffff78135e0 <compositor>, surface=0x55555578b670,
op=<optimized out>, source=<optimized out>, glyphs=0x7fffffffb720,
num_glyphs=4,
    scaled_font=0x55555578bf30, clip=0x0) at cairo-compositor.c:250
#11 0x00007ffff7532ef7 in _cairo_image_surface_glyphs
(abstract_surface=<optimized out>, op=<optimized out>, source=<optimized
out>, glyphs=<optimized out>, num_glyphs=<optimized out>,
    scaled_font=<optimized out>, clip=0x0) at cairo-image-surface.c:1007
#12 0x00007ffff75726d9 in _cairo_surface_show_text_glyphs
(surface=0x55555578b670, op=op@entry=CAIRO_OPERATOR_CLEAR,
source=source@entry=0x7ffff75d8100 <_cairo_pattern_clear>,
    utf8=0x5555557861a0 "द्यु", utf8_len=<optimized out>,
glyphs=0x7fffffffb720, num_glyphs=<optimized out>, clusters=0x7fffffffbf20,
num_clusters=<optimized out>, cluster_flags=(unknown: 0),
    scaled_font=0x55555578bf30, clip=0x0) at cairo-surface.c:2891
#13 0x00007ffff752a95a in _cairo_gstate_show_text_glyphs
(gstate=0x55555578b8a0, glyphs=<optimized out>, num_glyphs=<optimized out>,
info=0x7fffffffc770) at cairo-gstate.c:2077
#14 0x00007ffff757eb06 in cairo_show_text_glyphs (cr=cr@entry=0x55555578b870,
utf8=0x5555557861a0 "द्यु", utf8_len=12, glyphs=0x555555786110,
num_glyphs=4, clusters=0x5555557861c0, num_clusters=1,
    cluster_flags=(unknown: 0)) at cairo.c:3735
#15 0x000055555555e257 in view_cairo_t::render (this=0x7fffffffcae8,
font_opts=<optimized out>) at ../../util/view-cairo.cc:125
#16 0x00005555555592cc in finish (buffer=<optimized out>,
font_opts=0x7fffffffc9d8, this=0x7fffffffcae8) at
../../util/view-cairo.hh:76
#17 finish (font_opts=0x7fffffffc9d8, this=0x7fffffffca80) at
../../util/shape-consumer.hh:82
#18 main_font_text_t<shape_consumer_t<view_cairo_t>, 256, 8>::main
(this=<optimized out>, argc=<optimized out>, argv=<optimized out>) at
../../util/main-font-text.hh:83
#19 0x0000555555559787 in main (argc=3, argv=0x7fffffffcc88) at
../../util/hb-view.cc:39



-- 
behdad
http://behdad.org/
_______________________________________________
Freetype-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype-devel

Reply via email to