freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft] FT_Done_Face Should Not Return An Error


From: Lawrence D'Oliveiro
Subject: Re: [ft] FT_Done_Face Should Not Return An Error
Date: Sun, 6 May 2018 10:15:44 +1200

On Sat, 05 May 2018 20:10:43 +0200 (CEST), Werner LEMBERG wrote:

> I agree with Gregor: A library should not call `exit' by itself.

What else is it supposed to do? Lots of code is already ignoring the
result from FT_Done_Face.

Exhibit A: HarfBuzz
<https://github.com/harfbuzz/harfbuzz/blob/master/src/hb-ft.cc>:

    static void
    _hb_ft_face_destroy (FT_Face ft_face)
    {
      FT_Done_Face (ft_face);
    }

Exhibit B: Fontconfig
<https://github.com/behdad/fontconfig/blob/master/src/fcdir.c>, which
also ignoring the result from FC_Done_FreeType:

    static FcBool
    FcFileScanFontConfig (FcFontSet             *set,
                  FcBlanks              *blanks,
                  const FcChar8 *file,
                  FcConfig              *config)
    {
        ...
        FT_Done_Face (face);
        ...

        FT_Done_FreeType (ftLibrary);

        return ret;
    }

Another pair of examples from Fontconfig
<https://github.com/behdad/fontconfig/blob/master/src/fcfreetype.c>:

    FcPattern *
    FcFreeTypeQuery(const FcChar8       *file,
            int         id,
            FcBlanks    *blanks,
            int         *count)
    {
        ...

        FT_Done_Face (face);
    bail:
        FT_Done_FreeType (ftLibrary);
        return pat;
    }

Exhibit C: libraqm
<https://github.com/HOST-Oman/libraqm/blob/master/src/raqm.c> (one of
3 instances):

    static void
    _raqm_free_text_info (raqm_t *rq)
    {
      if (!rq->text_info)
        return;

      for (size_t i = 0; i < rq->text_len; i++)
      {
        if (rq->text_info[i].ftface)
          FT_Done_Face (rq->text_info[i].ftface);
      }

      free (rq->text_info);
      rq->text_info = NULL;
    }

Is all this code wrong?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]