freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [autofit] Don't depend on 'hb-ft'.


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] [autofit] Don't depend on 'hb-ft'.
Date: Fri, 06 Jan 2023 11:58:47 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

  • ebe7e912
    by Matthias Clasen at 2023-01-06T12:54:17+01:00
    [autofit] Don't depend on 'hb-ft'.
    
    The circular dependency is still there, but at least we no longer depend on
    the HarfBuzz API that is only present if HarfBuzz has been built with
    FreeType support, making the bootstrapping a bit easier.
    
    * src/autofit/ft-hb.c, src/autofit/ft-hb.h: New files, providing
    `_hb_ft_font_create`, which is more or less a verbatim copy of the
    corresponding HarfBuzz code from file `hb-ft.cc`.
    
    * src/autofit/afglobal.c (af_face_globals_new): Use it.
    * src/autofit/afshaper.h: Don't include `hb-ft.h` but `ft-hb.h`.
    * src/autofit/autofit.c: Include `ft-hb.c`.
    
    * LICENSE.TXT: Updated.
    

6 changed files:

Changes:

  • LICENSE.TXT
    ... ... @@ -35,6 +35,10 @@ in earlier FreeType versions.
    35 35
     The gzip  module uses the  zlib license (see  `src/gzip/zlib.h`) which
    
    36 36
     too is compatible to the above two licenses.
    
    37 37
     
    
    38
    +The files `src/autofit/ft-hb.c` and `src/autofit/ft-hb.h` contain code
    
    39
    +taken almost  verbatim from the  HarfBuzz file `hb-ft.cc`,  which uses
    
    40
    +the 'Old MIT' license, compatible to the above two licenses.
    
    41
    +
    
    38 42
     The  MD5 checksum  support  (only used  for  debugging in  development
    
    39 43
     builds) is in the public domain.
    
    40 44
     
    

  • src/autofit/afglobal.c
    ... ... @@ -356,7 +356,7 @@
    356 356
         globals->scale_down_factor         = 0;
    
    357 357
     
    
    358 358
     #ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    
    359
    -    globals->hb_font = hb_ft_font_create( face, NULL );
    
    359
    +    globals->hb_font = _hb_ft_font_create( face, NULL );
    
    360 360
         globals->hb_buf  = hb_buffer_create();
    
    361 361
     #endif
    
    362 362
     
    

  • src/autofit/afshaper.h
    ... ... @@ -27,7 +27,7 @@
    27 27
     
    
    28 28
     #include <hb.h>
    
    29 29
     #include <hb-ot.h>
    
    30
    -#include <hb-ft.h>
    
    30
    +#include "ft-hb.h"
    
    31 31
     
    
    32 32
     #endif
    
    33 33
     
    

  • src/autofit/autofit.c
    ... ... @@ -18,6 +18,7 @@
    18 18
     
    
    19 19
     #define FT_MAKE_OPTION_SINGLE_OBJECT
    
    20 20
     
    
    21
    +#include "ft-hb.c"
    
    21 22
     #include "afblue.c"
    
    22 23
     #include "afcjk.c"
    
    23 24
     #include "afdummy.c"
    

  • src/autofit/ft-hb.c
    1
    +/*
    
    2
    + * Copyright © 2009, 2023  Red Hat, Inc.
    
    3
    + * Copyright © 2015  Google, Inc.
    
    4
    + *
    
    5
    + * Permission is hereby granted, without written agreement and without
    
    6
    + * license or royalty fees, to use, copy, modify, and distribute this
    
    7
    + * software and its documentation for any purpose, provided that the
    
    8
    + * above copyright notice and the following two paragraphs appear in
    
    9
    + * all copies of this software.
    
    10
    + *
    
    11
    + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
    
    12
    + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
    
    13
    + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
    
    14
    + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
    
    15
    + * DAMAGE.
    
    16
    + *
    
    17
    + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
    
    18
    + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    
    19
    + * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
    
    20
    + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
    
    21
    + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
    
    22
    + *
    
    23
    + * Red Hat Author(s): Behdad Esfahbod, Matthias Clasen
    
    24
    + * Google Author(s): Behdad Esfahbod
    
    25
    + */
    
    26
    +
    
    27
    +#include <freetype/freetype.h>
    
    28
    +#include <freetype/tttables.h>
    
    29
    +
    
    30
    +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
    
    31
    +
    
    32
    +#include "ft-hb.h"
    
    33
    +
    
    34
    +/* The following three functions are a more or less verbatim
    
    35
    + * copy of corresponding HarfBuzz code from hb-ft.cc
    
    36
    + */
    
    37
    +
    
    38
    +static hb_blob_t *
    
    39
    +_hb_ft_reference_table (hb_face_t *face, hb_tag_t tag, void *user_data)
    
    40
    +{
    
    41
    +  FT_Face ft_face = (FT_Face) user_data;
    
    42
    +  FT_Byte *buffer;
    
    43
    +  FT_ULong  length = 0;
    
    44
    +  FT_Error error;
    
    45
    +
    
    46
    +  /* Note: FreeType like HarfBuzz uses the NONE tag for fetching the entire blob */
    
    47
    +
    
    48
    +  error = FT_Load_Sfnt_Table (ft_face, tag, 0, NULL, &length);
    
    49
    +  if (error)
    
    50
    +    return NULL;
    
    51
    +
    
    52
    +  buffer = (FT_Byte *) malloc (length);
    
    53
    +  if (!buffer)
    
    54
    +    return NULL;
    
    55
    +
    
    56
    +  error = FT_Load_Sfnt_Table (ft_face, tag, 0, buffer, &length);
    
    57
    +  if (error)
    
    58
    +  {
    
    59
    +    free (buffer);
    
    60
    +    return NULL;
    
    61
    +  }
    
    62
    +
    
    63
    +  return hb_blob_create ((const char *) buffer, length,
    
    64
    +                         HB_MEMORY_MODE_WRITABLE,
    
    65
    +                         buffer, free);
    
    66
    +}
    
    67
    +
    
    68
    +static hb_face_t *
    
    69
    +_hb_ft_face_create (FT_Face           ft_face,
    
    70
    +                    hb_destroy_func_t destroy)
    
    71
    +{
    
    72
    +  hb_face_t *face;
    
    73
    +
    
    74
    +  if (!ft_face->stream->read) {
    
    75
    +    hb_blob_t *blob;
    
    76
    +
    
    77
    +    blob = hb_blob_create ((const char *) ft_face->stream->base,
    
    78
    +                           (unsigned int) ft_face->stream->size,
    
    79
    +                           HB_MEMORY_MODE_READONLY,
    
    80
    +                           ft_face, destroy);
    
    81
    +    face = hb_face_create (blob, ft_face->face_index);
    
    82
    +    hb_blob_destroy (blob);
    
    83
    +  } else {
    
    84
    +    face = hb_face_create_for_tables (_hb_ft_reference_table, ft_face, destroy);
    
    85
    +  }
    
    86
    +
    
    87
    +  hb_face_set_index (face, ft_face->face_index);
    
    88
    +  hb_face_set_upem (face, ft_face->units_per_EM);
    
    89
    +
    
    90
    +  return face;
    
    91
    +}
    
    92
    +
    
    93
    +hb_font_t *
    
    94
    +_hb_ft_font_create (FT_Face           ft_face,
    
    95
    +                    hb_destroy_func_t destroy)
    
    96
    +{
    
    97
    +  hb_font_t *font;
    
    98
    +  hb_face_t *face;
    
    99
    +
    
    100
    +  face = _hb_ft_face_create (ft_face, destroy);
    
    101
    +  font = hb_font_create (face);
    
    102
    +  hb_face_destroy (face);
    
    103
    +  return font;
    
    104
    +}
    
    105
    +
    
    106
    +#endif

  • src/autofit/ft-hb.h
    1
    +/*
    
    2
    + * Copyright © 2009, 2023  Red Hat, Inc.
    
    3
    + * Copyright © 2015  Google, Inc.
    
    4
    + *
    
    5
    + * Permission is hereby granted, without written agreement and without
    
    6
    + * license or royalty fees, to use, copy, modify, and distribute this
    
    7
    + * software and its documentation for any purpose, provided that the
    
    8
    + * above copyright notice and the following two paragraphs appear in
    
    9
    + * all copies of this software.
    
    10
    + *
    
    11
    + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
    
    12
    + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
    
    13
    + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
    
    14
    + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
    
    15
    + * DAMAGE.
    
    16
    + *
    
    17
    + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
    
    18
    + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    
    19
    + * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
    
    20
    + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
    
    21
    + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
    
    22
    + *
    
    23
    + * Red Hat Author(s): Behdad Esfahbod, Matthias Clasen
    
    24
    + * Google Author(s): Behdad Esfahbod
    
    25
    + */
    
    26
    +
    
    27
    +#ifndef FT_HB_H
    
    28
    +#define FT_HB_H
    
    29
    +
    
    30
    +#include <hb.h>
    
    31
    +
    
    32
    +hb_font_t * _hb_ft_font_create (FT_Face           ft_face,
    
    33
    +                                hb_destroy_func_t destroy);
    
    34
    +
    
    35
    +#endif


  • reply via email to

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