[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] master ebe7e9128: [autofit] Don't depend on 'hb-ft'.
From: |
Werner Lemberg |
Subject: |
[freetype2] master ebe7e9128: [autofit] Don't depend on 'hb-ft'. |
Date: |
Fri, 6 Jan 2023 06:58:56 -0500 (EST) |
branch: master
commit ebe7e9128cdf81cb0a0d27fe293ecff96f6c98a8
Author: Matthias Clasen <mclasen@redhat.com>
Commit: Werner Lemberg <wl@gnu.org>
[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.
---
LICENSE.TXT | 4 ++
src/autofit/afglobal.c | 2 +-
src/autofit/afshaper.h | 2 +-
src/autofit/autofit.c | 1 +
src/autofit/ft-hb.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++
src/autofit/ft-hb.h | 35 ++++++++++++++++
6 files changed, 148 insertions(+), 2 deletions(-)
diff --git a/LICENSE.TXT b/LICENSE.TXT
index ca0bff819..8b9ce9e2e 100644
--- a/LICENSE.TXT
+++ b/LICENSE.TXT
@@ -35,6 +35,10 @@ in earlier FreeType versions.
The gzip module uses the zlib license (see `src/gzip/zlib.h`) which
too is compatible to the above two licenses.
+The files `src/autofit/ft-hb.c` and `src/autofit/ft-hb.h` contain code
+taken almost verbatim from the HarfBuzz file `hb-ft.cc`, which uses
+the 'Old MIT' license, compatible to the above two licenses.
+
The MD5 checksum support (only used for debugging in development
builds) is in the public domain.
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index 8ae8592cb..3ff08e3d1 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -356,7 +356,7 @@
globals->scale_down_factor = 0;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
- globals->hb_font = hb_ft_font_create( face, NULL );
+ globals->hb_font = _hb_ft_font_create( face, NULL );
globals->hb_buf = hb_buffer_create();
#endif
diff --git a/src/autofit/afshaper.h b/src/autofit/afshaper.h
index 558f03bde..110469c3d 100644
--- a/src/autofit/afshaper.h
+++ b/src/autofit/afshaper.h
@@ -27,7 +27,7 @@
#include <hb.h>
#include <hb-ot.h>
-#include <hb-ft.h>
+#include "ft-hb.h"
#endif
diff --git a/src/autofit/autofit.c b/src/autofit/autofit.c
index 3d78a9b33..af6c594d9 100644
--- a/src/autofit/autofit.c
+++ b/src/autofit/autofit.c
@@ -18,6 +18,7 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
+#include "ft-hb.c"
#include "afblue.c"
#include "afcjk.c"
#include "afdummy.c"
diff --git a/src/autofit/ft-hb.c b/src/autofit/ft-hb.c
new file mode 100644
index 000000000..b06121ff4
--- /dev/null
+++ b/src/autofit/ft-hb.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright © 2009, 2023 Red Hat, Inc.
+ * Copyright © 2015 Google, Inc.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Red Hat Author(s): Behdad Esfahbod, Matthias Clasen
+ * Google Author(s): Behdad Esfahbod
+ */
+
+#include <freetype/freetype.h>
+#include <freetype/tttables.h>
+
+#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
+
+#include "ft-hb.h"
+
+/* The following three functions are a more or less verbatim
+ * copy of corresponding HarfBuzz code from hb-ft.cc
+ */
+
+static hb_blob_t *
+_hb_ft_reference_table (hb_face_t *face, hb_tag_t tag, void *user_data)
+{
+ FT_Face ft_face = (FT_Face) user_data;
+ FT_Byte *buffer;
+ FT_ULong length = 0;
+ FT_Error error;
+
+ /* Note: FreeType like HarfBuzz uses the NONE tag for fetching the entire
blob */
+
+ error = FT_Load_Sfnt_Table (ft_face, tag, 0, NULL, &length);
+ if (error)
+ return NULL;
+
+ buffer = (FT_Byte *) malloc (length);
+ if (!buffer)
+ return NULL;
+
+ error = FT_Load_Sfnt_Table (ft_face, tag, 0, buffer, &length);
+ if (error)
+ {
+ free (buffer);
+ return NULL;
+ }
+
+ return hb_blob_create ((const char *) buffer, length,
+ HB_MEMORY_MODE_WRITABLE,
+ buffer, free);
+}
+
+static hb_face_t *
+_hb_ft_face_create (FT_Face ft_face,
+ hb_destroy_func_t destroy)
+{
+ hb_face_t *face;
+
+ if (!ft_face->stream->read) {
+ hb_blob_t *blob;
+
+ blob = hb_blob_create ((const char *) ft_face->stream->base,
+ (unsigned int) ft_face->stream->size,
+ HB_MEMORY_MODE_READONLY,
+ ft_face, destroy);
+ face = hb_face_create (blob, ft_face->face_index);
+ hb_blob_destroy (blob);
+ } else {
+ face = hb_face_create_for_tables (_hb_ft_reference_table, ft_face,
destroy);
+ }
+
+ hb_face_set_index (face, ft_face->face_index);
+ hb_face_set_upem (face, ft_face->units_per_EM);
+
+ return face;
+}
+
+hb_font_t *
+_hb_ft_font_create (FT_Face ft_face,
+ hb_destroy_func_t destroy)
+{
+ hb_font_t *font;
+ hb_face_t *face;
+
+ face = _hb_ft_face_create (ft_face, destroy);
+ font = hb_font_create (face);
+ hb_face_destroy (face);
+ return font;
+}
+
+#endif
diff --git a/src/autofit/ft-hb.h b/src/autofit/ft-hb.h
new file mode 100644
index 000000000..db0b35e9c
--- /dev/null
+++ b/src/autofit/ft-hb.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright © 2009, 2023 Red Hat, Inc.
+ * Copyright © 2015 Google, Inc.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Red Hat Author(s): Behdad Esfahbod, Matthias Clasen
+ * Google Author(s): Behdad Esfahbod
+ */
+
+#ifndef FT_HB_H
+#define FT_HB_H
+
+#include <hb.h>
+
+hb_font_t * _hb_ft_font_create (FT_Face ft_face,
+ hb_destroy_func_t destroy);
+
+#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] master ebe7e9128: [autofit] Don't depend on 'hb-ft'.,
Werner Lemberg <=