Beispiel #1
0
void ass_shaper_font_data_free(ASS_ShaperFontData *priv)
{
#ifdef CONFIG_HARFBUZZ
    int i;
    for (i = 0; i < ASS_FONT_MAX_FACES; i++)
        if (priv->fonts[i]) {
            free(priv->metrics_data[i]);
            hb_font_destroy(priv->fonts[i]);
            hb_font_funcs_destroy(priv->font_funcs[i]);
        }
    free(priv);
#endif
}
Beispiel #2
0
static hb_font_funcs_t *
icu_le_hb_get_font_funcs (void)
{
  static hb_font_funcs_t *ffuncs = NULL;

retry:
  if (!ffuncs) {
    /* Only pseudo-thread-safe... */
    hb_font_funcs_t *f = hb_font_funcs_create ();
    hb_font_funcs_set_glyph_func (f, icu_le_hb_font_get_glyph, NULL, NULL);
    hb_font_funcs_set_glyph_h_advance_func (f, icu_le_hb_font_get_glyph_h_advance, NULL, NULL);
    hb_font_funcs_set_glyph_contour_point_func (f, icu_le_hb_font_get_glyph_contour_point, NULL, NULL);

    if (!ffuncs)
      ffuncs = f;
    else {
      hb_font_funcs_destroy (f);
      goto retry;
    }
  }

  return ffuncs;
}
Beispiel #3
0
void
hb_font_destroy(hb_font_t *font)
{
  if (!font)
    return;
  if (hb_atomic_int32_get(&font->ref_cnt) == REF_CNT_INVALID_VAL)
    return;
  hb_atomic_int32_add(&font->ref_cnt, -1);
  if (hb_atomic_int32_get(&font->ref_cnt) > 0)
    return;
  hb_atomic_int32_set(&font->ref_cnt, REF_CNT_INVALID_VAL);

#ifdef HAVE_GRAPHITE2
  if (font->shaper_data.graphite2
      && font->shaper_data.graphite2 != HB_SHAPER_DATA_INVALID
      && font->shaper_data.graphite2 != HB_SHAPER_DATA_SUCCEEDED)
    hb_graphite2_shaper_font_data_destroy(font->shaper_data.graphite2);
#endif
#ifdef HAVE_OT
  if (font->shaper_data.ot
      && font->shaper_data.ot != HB_SHAPER_DATA_INVALID
      && font->shaper_data.ot != HB_SHAPER_DATA_SUCCEEDED)
    hb_ot_shaper_font_data_destroy(font->shaper_data.ot);
#endif
  if (font->shaper_data.fallback
      && font->shaper_data.fallback != HB_SHAPER_DATA_INVALID
      && font->shaper_data.fallback != HB_SHAPER_DATA_SUCCEEDED)
    hb_fallback_shaper_font_data_destroy(font->shaper_data.fallback);

  if (font->destroy)
    font->destroy(font->user_data);

  hb_font_destroy(font->parent);
  hb_face_destroy(font->face);
  hb_font_funcs_destroy(font->klass);
  free(font);
}