[HarfBuzz] get/set_user_data()

Konstantin Ritt ritt.ks at gmail.com
Mon May 19 19:21:07 PDT 2014


2014-05-20 4:10 GMT+03:00 Behdad Esfahbod <behdad at behdad.org>:

> On 14-05-19 04:39 PM, Konstantin Ritt wrote:
> > I only use get/set_user_data() in a single place, where it is impossible
> to
> > pass some modifiers anyhow else:
>
> It's NOT impossible.  There are at least two different ways to do that:
>
>
> > {code}
> > static hb_user_data_key_t _useDesignMetricsKey;
> > void hb_qt_font_set_use_design_metrics(hb_font_t *font, uint value) {
> > hb_font_set_user_data(font, &_useDesignMetricsKey, (void
> *)quintptr(value),
> > NULL, true); }
> > uint hb_qt_font_get_use_design_metrics(hb_font_t *font) { return
> > quintptr(hb_font_get_user_data(font, &_useDesignMetricsKey)); }
> > static hb_position_t _hb_qt_font_get_glyph_h_advance(hb_font_t *font,
> void
> > *font_data, hb_codepoint_t glyph, void * /*user_data*/)
> > {
> >     QFontEngine *fe = (QFontEngine *)font_data;
>
> font_data is a closure for *all* data you would need in your callbacks.
>  The
> fact that you are passing QFontEngine as font_data, and that it doesn't
> include the piece of data you need, is your fault.  You can allocate a
> small
> piece of memory to contain both the QFontEngine AND the use_design_metrics
> bit.
>
> The alternative is to use different font_funcs implementations for the
> use_design_metrics and the !use_design_metrics cases.
>
> Does that make sense?
>
>
Not really. The use_design_metrics flag implies just the metrics behavior
and the intention was to make it a modifier.
Passing it at hb_font construction/initialization time would require
instantiating yet another hb_font for the same engine but different
use_design_metrics bit, which also affects the shape plan cache.
Like I said before, it would be better to have a real API to control the
metrics behavior. But well, you continue ignoring that thread :P

Regards,
Konstantin



> behdad
>
>
> >     ...
> >     fe->recalcAdvances(&g,
> > QFontEngine::ShaperFlags(hb_qt_font_get_use_design_metrics(font)));
> > {/code}
> >
> > However, I find the get/set_user_data() API somewhat inconvenient
> (mostly due
> > to key restrictions) and would love a proper solution for the issue
> solved
> > here with a useDesignMetrics flag (the issue was described in another
> thread).
> > Except of that, I don't think this API is really that useful.
> >
> > Regards,
> > Konstantin
> >
> >
> > 2014-05-20 1:10 GMT+03:00 Behdad Esfahbod <behdad at behdad.org
> > <mailto:behdad at behdad.org>>:
> >
> >     So, are people actually using the get/set_user_data() methods on HB
> objects?
> >     I'm thinking about removing them at least for hb_blob_t, as part of
> >     streamlining blobs and making them more lightweight.  But if no one
> uses the
> >     get/set_user_data(), I may as well just remove them all.
> >
> >     Initially I added these because (based on cairo experience) I was
> under the
> >     impression that they are extremely useful for language bindings.
>  However,
> >     they are only if one is willing to write manual bindings, which is
> something I
> >     prefer to avoid.
> >
> >     So, if no existing user of HarfBuzz uses them, I think it's a good
> indication
> >     that they were overkill design artifacts and I'll remove before 1.0.
> >
> >     Thanks,
> >     --
> >     behdad
> >     http://behdad.org/
> >     _______________________________________________
> >     HarfBuzz mailing list
> >     HarfBuzz at lists.freedesktop.org <mailto:
> HarfBuzz at lists.freedesktop.org>
> >     http://lists.freedesktop.org/mailman/listinfo/harfbuzz
> >
> >
>
> --
> behdad
> http://behdad.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20140520/d1c00b37/attachment.html>


More information about the HarfBuzz mailing list