diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2009-11-03 15:12:25 -0500 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2009-11-03 20:28:51 -0500 |
commit | 1a9072ec14c2d57a53c90746e182884453e08957 (patch) | |
tree | 4d9d768bd62392093018837994be2657979fa60c /pango | |
parent | 8e9d153733cac83bfc8ce0c068d2af455d0e9a76 (diff) | |
download | pango-1a9072ec14c2d57a53c90746e182884453e08957.tar.gz |
Use external harfbuzz shared library from harfbuzz-ng
Diffstat (limited to 'pango')
39 files changed, 18 insertions, 9350 deletions
diff --git a/pango/Makefile.am b/pango/Makefile.am index ef0245c0..e1285b5d 100644 --- a/pango/Makefile.am +++ b/pango/Makefile.am @@ -4,18 +4,10 @@ # which are more like other make's VPATH. GPATH = $(srcdir) -if HAVE_FREETYPE -OPENTYPE_SUBDIR=opentype -endif - EXTRA_DIST = BUILT_GIRSOURCES = -FRIBIDI_SUBDIR=mini-fribidi - -SUBDIRS = $(OPENTYPE_SUBDIR) $(FRIBIDI_SUBDIR) - -DIST_SUBDIRS = mini-fribidi opentype +SUBDIRS = mini-fribidi INCLUDES = \ -DG_LOG_DOMAIN=\"Pango\" \ @@ -28,6 +20,7 @@ INCLUDES = \ $(GLIB_CFLAGS) \ $(XFT_CFLAGS) \ $(CAIRO_CFLAGS) \ + $(HARFBUZZ_CFLAGS) \ $(FREETYPE_CFLAGS) \ $(X_CFLAGS) @@ -242,14 +235,13 @@ pangoft2_public_sources = \ libpangoft2_1_0_la_LDFLAGS = $(LIBRARY_LIBTOOL_OPTIONS) libpangoft2_1_0_la_LIBADD = \ - opentype/libharfbuzz.la \ libpango-$(PANGO_API_VERSION).la \ $(INCLUDED_FC_MODULES) \ $(GLIB_LIBS) \ + $(HARFBUZZ_LIBS) \ $(FREETYPE_LIBS) \ $(libm) libpangoft2_1_0_la_DEPENDENCIES = \ - opentype/libharfbuzz.la \ libpango-$(PANGO_API_VERSION).la \ $(INCLUDED_FC_MODULES) libpangoft2_1_0_la_SOURCES = \ diff --git a/pango/opentype/COPYING b/pango/opentype/COPYING deleted file mode 100644 index d5075a3c..00000000 --- a/pango/opentype/COPYING +++ /dev/null @@ -1,17 +0,0 @@ -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. diff --git a/pango/opentype/Makefile.am b/pango/opentype/Makefile.am deleted file mode 100644 index ebec8ce6..00000000 --- a/pango/opentype/Makefile.am +++ /dev/null @@ -1,58 +0,0 @@ -# Process this file with automake to produce Makefile.in - -NULL = - -# The following warning options are useful for debugging: -Wpadded -Wcast-align -#AM_CXXFLAGS = - -noinst_LTLIBRARIES = libharfbuzz.la - -HBSOURCES = \ - hb-blob.c \ - hb-buffer.c \ - hb-buffer-private.h \ - hb-font.cc \ - hb-font-private.h \ - hb-glib.h \ - hb-glib.c \ - hb-private.h \ - hb-shape.h \ - hb-shape.c \ - hb-unicode.c \ - hb-unicode.h \ - hb-unicode-private.h \ - hb-open-file-private.hh \ - hb-open-type-private.hh \ - hb-ot-layout.cc \ - hb-ot-layout-common-private.hh \ - hb-ot-layout-gdef-private.hh \ - hb-ot-layout-gpos-private.hh \ - hb-ot-layout-gsubgpos-private.hh \ - hb-ot-layout-gsub-private.hh \ - hb-ot-layout-private.h \ - hb-object-private.h \ - $(NULL) - -HBHEADERS = \ - hb.h \ - hb-blob.h \ - hb-buffer.h \ - hb-common.h \ - hb-font.h \ - hb-ot.h \ - hb-ot-layout.h \ - $(NULL) - -libharfbuzz_la_SOURCES = $(HBSOURCES) $(HBHEADERS) -libharfbuzz_la_CPPFLAGS = -DHAVE_GLIB $(GLIB_CFLAGS) -libharfbuzz_la_LIBADD = $(GLIB_LIBS) - -noinst_PROGRAMS = main - -main_SOURCES = main.cc -main_CPPFLAGS = -DHAVE_GLIB $(GLIB_CFLAGS) -main_LDADD = libharfbuzz.la $(GLIB_LIBS) - -EXTRA_DIST = README COPYING - --include $(top_srcdir)/git.mk diff --git a/pango/opentype/README b/pango/opentype/README deleted file mode 100644 index 42d01046..00000000 --- a/pango/opentype/README +++ /dev/null @@ -1,9 +0,0 @@ -This is HarfBuzz, an OpenType Layout engine. - -Bug reports on these files should be sent to the HarfBuzz mailing list as -listed on http://freedesktop.org/wiki/Software/harfbuzz - -For license information, see the file COPYING. - -Behdad Esfahbod -May 24, 2009 diff --git a/pango/opentype/TODO b/pango/opentype/TODO deleted file mode 100644 index 8524279f..00000000 --- a/pango/opentype/TODO +++ /dev/null @@ -1,6 +0,0 @@ -- HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH vs LookupType::... mess -- Rename LookupFlag::MarkAttachmentType to LookupFlag:IgnoreSpecialMarks -- cmap14 support in get_glyph callback -- size_t? -- Figure out compiler selection (add test for link to libstdc++) -- Rename MEMORY_MODE to ACCESS_MODE diff --git a/pango/opentype/hb-blob.c b/pango/opentype/hb-blob.c deleted file mode 100644 index 107cd432..00000000 --- a/pango/opentype/hb-blob.c +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#include "hb-private.h" - -#include "hb-blob.h" - -#ifdef HAVE_SYS_MMAN_H -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif /* HAVE_UNISTD_H */ -#include <sys/mman.h> -#endif /* HAVE_SYS_MMAN_H */ - -#ifndef HB_DEBUG_BLOB -#define HB_DEBUG_BLOB HB_DEBUG -#endif - -struct _hb_blob_t { - hb_reference_count_t ref_count; - - unsigned int length; - - hb_mutex_t lock; - /* the rest are protected by lock */ - - unsigned int lock_count; - hb_memory_mode_t mode; - - const char *data; - - hb_destroy_func_t destroy; - void *user_data; -}; -static hb_blob_t _hb_blob_nil = { - HB_REFERENCE_COUNT_INVALID, /* ref_count */ - - 0, /* length */ - - HB_MUTEX_INIT, /* lock */ - - 0, /* lock_count */ - HB_MEMORY_MODE_READONLY, /* mode */ - - NULL, /* data */ - - NULL, /* destroy */ - NULL /* user_data */ -}; - -static void -_hb_blob_destroy_user_data (hb_blob_t *blob) -{ - if (blob->destroy) { - blob->destroy (blob->user_data); - blob->destroy = NULL; - blob->user_data = NULL; - } -} - -static void -_hb_blob_unlock_and_destroy (hb_blob_t *blob) -{ - hb_blob_unlock (blob); - hb_blob_destroy (blob); -} - -hb_blob_t * -hb_blob_create (const char *data, - unsigned int length, - hb_memory_mode_t mode, - hb_destroy_func_t destroy, - void *user_data) -{ - hb_blob_t *blob; - - if (!length || !HB_OBJECT_DO_CREATE (hb_blob_t, blob)) { - if (destroy) - destroy (user_data); - return &_hb_blob_nil; - } - - hb_mutex_init (blob->lock); - blob->lock_count = 0; - - blob->data = data; - blob->length = length; - blob->mode = mode; - - blob->destroy = destroy; - blob->user_data = user_data; - - if (blob->mode == HB_MEMORY_MODE_DUPLICATE) { - blob->mode = HB_MEMORY_MODE_READONLY; - if (!hb_blob_try_writable (blob)) { - hb_blob_destroy (blob); - return &_hb_blob_nil; - } - } - - return blob; -} - -hb_blob_t * -hb_blob_create_sub_blob (hb_blob_t *parent, - unsigned int offset, - unsigned int length) -{ - hb_blob_t *blob; - const char *pdata; - - if (!length || offset >= parent->length || !HB_OBJECT_DO_CREATE (hb_blob_t, blob)) - return &_hb_blob_nil; - - pdata = hb_blob_lock (parent); - - blob->data = pdata + offset; - blob->length = MIN (length, parent->length - offset); - - hb_mutex_lock (parent->lock); - blob->mode = parent->mode; - hb_mutex_unlock (parent->lock); - - blob->destroy = (hb_destroy_func_t) _hb_blob_unlock_and_destroy; - blob->user_data = hb_blob_reference (parent); - - return blob; -} - -hb_blob_t * -hb_blob_create_empty (void) -{ - return &_hb_blob_nil; -} - -hb_blob_t * -hb_blob_reference (hb_blob_t *blob) -{ - HB_OBJECT_DO_REFERENCE (blob); -} - -unsigned int -hb_blob_get_reference_count (hb_blob_t *blob) -{ - HB_OBJECT_DO_GET_REFERENCE_COUNT (blob); -} - -void -hb_blob_destroy (hb_blob_t *blob) -{ - HB_OBJECT_DO_DESTROY (blob); - - _hb_blob_destroy_user_data (blob); - - free (blob); -} - -unsigned int -hb_blob_get_length (hb_blob_t *blob) -{ - return blob->length; -} - -const char * -hb_blob_lock (hb_blob_t *blob) -{ - if (HB_OBJECT_IS_INERT (blob)) - return NULL; - - hb_mutex_lock (blob->lock); - - blob->lock_count++; -#if HB_DEBUG_BLOB - fprintf (stderr, "%p %s (%d) -> %p\n", blob, __FUNCTION__, - blob->lock_count, blob->data); -#endif - - hb_mutex_unlock (blob->lock); - - return blob->data; -} - -void -hb_blob_unlock (hb_blob_t *blob) -{ - if (HB_OBJECT_IS_INERT (blob)) - return; - - hb_mutex_lock (blob->lock); - - assert (blob->lock_count > 0); - blob->lock_count--; -#if HB_DEBUG_BLOB - fprintf (stderr, "%p %s (%d) -> %p\n", blob, __FUNCTION__, - hb_atomic_int_get (blob->lock_count), blob->data); -#endif - - hb_mutex_unlock (blob->lock); -} - -hb_bool_t -hb_blob_is_writable (hb_blob_t *blob) -{ - hb_memory_mode_t mode; - - if (HB_OBJECT_IS_INERT (blob)) - return FALSE; - - hb_mutex_lock (blob->lock); - - mode = blob->mode; - - hb_mutex_unlock (blob->lock); - - return mode == HB_MEMORY_MODE_WRITABLE; -} - - -static hb_bool_t -_try_make_writable_inplace_unix_locked (hb_blob_t *blob) -{ -#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MPROTECT) - unsigned int pagesize = -1, mask, length; - const char *addr; - -#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE) - pagesize = (unsigned int) sysconf (_SC_PAGE_SIZE); -#elif defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE) - pagesize = (unsigned int) sysconf (_SC_PAGESIZE); -#elif defined(HAVE_GETPAGESIZE) - pagesize = (unsigned int) getpagesize (); -#endif - - if ((unsigned int) -1 == pagesize) { -#if HB_DEBUG_BLOB - fprintf (stderr, "%p %s: failed to get pagesize: %s\n", blob, __FUNCTION__, strerror (errno)); -#endif - return FALSE; - } -#if HB_DEBUG_BLOB - fprintf (stderr, "%p %s: pagesize is %u\n", blob, __FUNCTION__, pagesize); -#endif - - mask = ~(pagesize-1); - addr = (const char *) (((size_t) blob->data) & mask); - length = (const char *) (((size_t) blob->data + blob->length + pagesize-1) & mask) - addr; -#if HB_DEBUG_BLOB - fprintf (stderr, "%p %s: calling mprotect on [%p..%p] (%d bytes)\n", - blob, __FUNCTION__, - addr, addr+length, length); -#endif - if (-1 == mprotect ((void *) addr, length, PROT_READ | PROT_WRITE)) { -#if HB_DEBUG_BLOB - fprintf (stderr, "%p %s: %s\n", blob, __FUNCTION__, strerror (errno)); -#endif - return FALSE; - } - -#if HB_DEBUG_BLOB - fprintf (stderr, "%p %s: successfully made [%p..%p] (%d bytes) writable\n", - blob, __FUNCTION__, - addr, addr+length, length); -#endif - return TRUE; -#else - return FALSE; -#endif -} - -static void -_try_writable_inplace_locked (hb_blob_t *blob) -{ -#if HB_DEBUG_BLOB - fprintf (stderr, "%p %s: making writable\n", blob, __FUNCTION__); -#endif - - if (_try_make_writable_inplace_unix_locked (blob)) { -#if HB_DEBUG_BLOB - fprintf (stderr, "%p %s: making writable -> succeeded\n", blob, __FUNCTION__); -#endif - blob->mode = HB_MEMORY_MODE_WRITABLE; - } else { -#if HB_DEBUG_BLOB - fprintf (stderr, "%p %s: making writable -> FAILED\n", blob, __FUNCTION__); -#endif - /* Failed to make writable inplace, mark that */ - blob->mode = HB_MEMORY_MODE_READONLY; - } -} - -hb_bool_t -hb_blob_try_writable_inplace (hb_blob_t *blob) -{ - hb_memory_mode_t mode; - - if (HB_OBJECT_IS_INERT (blob)) - return FALSE; - - hb_mutex_lock (blob->lock); - - if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE) - _try_writable_inplace_locked (blob); - - mode = blob->mode; - - hb_mutex_unlock (blob->lock); - - return mode == HB_MEMORY_MODE_WRITABLE; -} - -hb_bool_t -hb_blob_try_writable (hb_blob_t *blob) -{ - hb_memory_mode_t mode; - - if (HB_OBJECT_IS_INERT (blob)) - return FALSE; - - hb_mutex_lock (blob->lock); - - if (blob->mode == HB_MEMORY_MODE_READONLY) - { - char *new_data; - -#if HB_DEBUG_BLOB - fprintf (stderr, "%p %s (%d) -> %p\n", blob, __FUNCTION__, - blob->lock_count, blob->data); -#endif - - if (blob->lock_count) - goto done; - - new_data = malloc (blob->length); - if (new_data) { -#if HB_DEBUG_BLOB - fprintf (stderr, "%p %s: dupped successfully -> %p\n", blob, __FUNCTION__, blob->data); -#endif - memcpy (new_data, blob->data, blob->length); - blob->data = new_data; - blob->mode = HB_MEMORY_MODE_WRITABLE; - _hb_blob_destroy_user_data (blob); - } - } - else if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE) - _try_writable_inplace_locked (blob); - -done: - mode = blob->mode; - - hb_mutex_unlock (blob->lock); - - return mode == HB_MEMORY_MODE_WRITABLE; -} diff --git a/pango/opentype/hb-blob.h b/pango/opentype/hb-blob.h deleted file mode 100644 index 131a282b..00000000 --- a/pango/opentype/hb-blob.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_BLOB_H -#define HB_BLOB_H - -#include "hb-common.h" - -HB_BEGIN_DECLS - -typedef enum { - HB_MEMORY_MODE_DUPLICATE, - HB_MEMORY_MODE_READONLY, - HB_MEMORY_MODE_WRITABLE, - HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE -} hb_memory_mode_t; - -typedef struct _hb_blob_t hb_blob_t; - -hb_blob_t * -hb_blob_create (const char *data, - unsigned int length, - hb_memory_mode_t mode, - hb_destroy_func_t destroy, - void *user_data); - -hb_blob_t * -hb_blob_create_sub_blob (hb_blob_t *parent, - unsigned int offset, - unsigned int length); - -hb_blob_t * -hb_blob_create_empty (void); - -hb_blob_t * -hb_blob_reference (hb_blob_t *blob); - -unsigned int -hb_blob_get_reference_count (hb_blob_t *blob); - -void -hb_blob_destroy (hb_blob_t *blob); - -unsigned int -hb_blob_get_length (hb_blob_t *blob); - -const char * -hb_blob_lock (hb_blob_t *blob); - -void -hb_blob_unlock (hb_blob_t *blob); - -hb_bool_t -hb_blob_is_writable (hb_blob_t *blob); - -hb_bool_t -hb_blob_try_writable_inplace (hb_blob_t *blob); - -hb_bool_t -hb_blob_try_writable (hb_blob_t *blob); - -HB_END_DECLS - -#endif /* HB_BLOB_H */ diff --git a/pango/opentype/hb-buffer-private.h b/pango/opentype/hb-buffer-private.h deleted file mode 100644 index 45cdc4de..00000000 --- a/pango/opentype/hb-buffer-private.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 1998-2004 David Turner and Werner Lemberg - * Copyright (C) 2004,2007,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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): Owen Taylor, Behdad Esfahbod - */ - -#ifndef HB_BUFFER_PRIVATE_H -#define HB_BUFFER_PRIVATE_H - -#include "hb-private.h" -#include "hb-buffer.h" - -HB_BEGIN_DECLS - -#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF - - -typedef struct _hb_internal_glyph_info_t { - hb_codepoint_t codepoint; - hb_mask_t mask; - uint32_t cluster; - uint16_t component; - uint16_t lig_id; - uint32_t gproperty; -} hb_internal_glyph_info_t; - -typedef struct _hb_internal_glyph_position_t { - hb_position_t x_pos; - hb_position_t y_pos; - hb_position_t x_advance; - hb_position_t y_advance; - uint32_t new_advance :1; /* if set, the advance width values are - absolute, i.e., they won't be - added to the original glyph's value - but rather replace them */ - uint32_t back : 15; /* number of glyphs to go back - for drawing current glyph */ - int32_t cursive_chain : 16; /* character to which this connects, - may be positive or negative; used - only internally */ -} hb_internal_glyph_position_t; - -ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_internal_glyph_info_t)); -ASSERT_STATIC (sizeof (hb_glyph_position_t) == sizeof (hb_internal_glyph_position_t)); -ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t)); - - -struct _hb_buffer_t { - hb_reference_count_t ref_count; - - unsigned int allocated; - - hb_bool_t have_output; /* weather we have an output buffer going on */ - unsigned int in_length; - unsigned int out_length; - unsigned int in_pos; - unsigned int out_pos; /* out_length and out_pos are actually always the same */ - - hb_internal_glyph_info_t *in_string; - hb_internal_glyph_info_t *out_string; - hb_internal_glyph_position_t *positions; - - hb_direction_t direction; - unsigned int max_lig_id; -}; - - -HB_INTERNAL void -_hb_buffer_swap (hb_buffer_t *buffer); - -HB_INTERNAL void -_hb_buffer_clear_output (hb_buffer_t *buffer); - -HB_INTERNAL void -_hb_buffer_add_output_glyphs (hb_buffer_t *buffer, - unsigned int num_in, - unsigned int num_out, - const uint16_t *glyph_data_be, - unsigned short component, - unsigned short ligID); - -HB_INTERNAL void -_hb_buffer_add_output_glyph (hb_buffer_t *buffer, - hb_codepoint_t glyph_index, - unsigned short component, - unsigned short ligID); - -HB_INTERNAL void -_hb_buffer_next_glyph (hb_buffer_t *buffer); - -HB_INTERNAL void -_hb_buffer_replace_glyph (hb_buffer_t *buffer, - hb_codepoint_t glyph_index); - -HB_INTERNAL unsigned short -_hb_buffer_allocate_lig_id (hb_buffer_t *buffer); - - -/* convenience macros */ -#define IN_GLYPH(pos) (buffer->in_string[(pos)].codepoint) -#define IN_INFO(pos) (&buffer->in_string[(pos)]) -#define IN_CURGLYPH() (buffer->in_string[buffer->in_pos].codepoint) -#define IN_CURINFO() (&buffer->in_string[buffer->in_pos]) -#define IN_MASK(pos) (buffer->in_string[(pos)].mask) -#define IN_LIGID(pos) (buffer->in_string[(pos)].lig_id) -#define IN_COMPONENT(pos) (buffer->in_string[(pos)].component) -#define POSITION(pos) (&buffer->positions[(pos)]) -#define CURPOSITION() (&buffer->positions[buffer->in_pos]) -#define OUT_GLYPH(pos) (buffer->out_string[(pos)].codepoint) -#define OUT_INFO(pos) (&buffer->out_string[(pos)]) - -HB_END_DECLS - -#endif /* HB_BUFFER_PRIVATE_H */ diff --git a/pango/opentype/hb-buffer.c b/pango/opentype/hb-buffer.c deleted file mode 100644 index 93b51e5c..00000000 --- a/pango/opentype/hb-buffer.c +++ /dev/null @@ -1,516 +0,0 @@ -/* - * Copyright (C) 1998-2004 David Turner and Werner Lemberg - * Copyright (C) 2004,2007 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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): Owen Taylor, Behdad Esfahbod - */ - -#include "hb-buffer-private.h" - -#include <string.h> - - -static hb_buffer_t _hb_buffer_nil = { - HB_REFERENCE_COUNT_INVALID /* ref_count */ -}; - -/* Here is how the buffer works internally: - * - * There are two string pointers: in_string and out_string. They - * always have same allocated size, but different length and positions. - * - * As an optimization, both in_string and out_string may point to the - * same piece of memory, which is owned by in_string. This remains the - * case as long as out_length doesn't exceed in_length at any time. - * In that case, swap() is no-op and the glyph operations operate mostly - * in-place. - * - * As soon as out_string gets longer than in_string, out_string is moved over - * to an alternate buffer (which we reuse the positions buffer for!), and its - * current contents (out_length entries) are copied to the alt buffer. - * This should all remain transparent to the user. swap() then switches - * in_string and out_string. - */ - -/* XXX err handling */ - -/* Internal API */ - -static void -hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size) -{ - hb_buffer_ensure (buffer, size); - if (buffer->out_string == buffer->in_string) - { - assert (buffer->have_output); - if (!buffer->positions) - buffer->positions = calloc (buffer->allocated, sizeof (buffer->positions[0])); - - buffer->out_string = (hb_internal_glyph_info_t *) buffer->positions; - memcpy (buffer->out_string, buffer->in_string, buffer->out_length * sizeof (buffer->out_string[0])); - } -} - -/* Public API */ - -hb_buffer_t * -hb_buffer_create (unsigned int pre_alloc_size) -{ - hb_buffer_t *buffer; - - if (!HB_OBJECT_DO_CREATE (hb_buffer_t, buffer)) - return &_hb_buffer_nil; - - if (pre_alloc_size) - hb_buffer_ensure(buffer, pre_alloc_size); - - return buffer; -} - -hb_buffer_t * -hb_buffer_reference (hb_buffer_t *buffer) -{ - HB_OBJECT_DO_REFERENCE (buffer); -} - -unsigned int -hb_buffer_get_reference_count (hb_buffer_t *buffer) -{ - HB_OBJECT_DO_GET_REFERENCE_COUNT (buffer); -} - -void -hb_buffer_destroy (hb_buffer_t *buffer) -{ - HB_OBJECT_DO_DESTROY (buffer); - - free (buffer->in_string); - free (buffer->positions); - - free (buffer); -} - -void -hb_buffer_clear (hb_buffer_t *buffer) -{ - buffer->have_output = FALSE; - buffer->in_length = 0; - buffer->out_length = 0; - buffer->in_pos = 0; - buffer->out_pos = 0; - buffer->out_string = buffer->in_string; - buffer->max_lig_id = 0; -} - -void -hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size) -{ - unsigned int new_allocated = buffer->allocated; - - if (size > new_allocated) - { - while (size > new_allocated) - new_allocated += (new_allocated >> 1) + 8; - - if (buffer->positions) - buffer->positions = realloc (buffer->positions, new_allocated * sizeof (buffer->positions[0])); - - if (buffer->out_string != buffer->in_string) - { - buffer->in_string = realloc (buffer->in_string, new_allocated * sizeof (buffer->in_string[0])); - buffer->out_string = (hb_internal_glyph_info_t *) buffer->positions; - } - else - { - buffer->in_string = realloc (buffer->in_string, new_allocated * sizeof (buffer->in_string[0])); - buffer->out_string = buffer->in_string; - } - - buffer->allocated = new_allocated; - } -} - -void -hb_buffer_add_glyph (hb_buffer_t *buffer, - hb_codepoint_t codepoint, - hb_mask_t mask, - unsigned int cluster) -{ - hb_internal_glyph_info_t *glyph; - - hb_buffer_ensure (buffer, buffer->in_length + 1); - - glyph = &buffer->in_string[buffer->in_length]; - glyph->codepoint = codepoint; - glyph->mask = mask; - glyph->cluster = cluster; - glyph->component = 0; - glyph->lig_id = 0; - glyph->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; - - buffer->in_length++; -} - -void -hb_buffer_set_direction (hb_buffer_t *buffer, - hb_direction_t direction) - -{ - buffer->direction = direction; -} - - -/* HarfBuzz-Internal API */ - -void -_hb_buffer_clear_output (hb_buffer_t *buffer) -{ - buffer->have_output = TRUE; - buffer->out_length = 0; - buffer->out_pos = 0; - buffer->out_string = buffer->in_string; -} - -void -hb_buffer_clear_positions (hb_buffer_t *buffer) -{ - _hb_buffer_clear_output (buffer); - buffer->have_output = FALSE; - - if (HB_UNLIKELY (!buffer->positions)) - { - buffer->positions = calloc (buffer->allocated, sizeof (buffer->positions[0])); - return; - } - - memset (buffer->positions, 0, sizeof (buffer->positions[0]) * buffer->in_length); -} - -void -_hb_buffer_swap (hb_buffer_t *buffer) -{ - unsigned int tmp; - - assert (buffer->have_output); - - if (buffer->out_string != buffer->in_string) - { - hb_internal_glyph_info_t *tmp_string; - tmp_string = buffer->in_string; - buffer->in_string = buffer->out_string; - buffer->out_string = tmp_string; - buffer->positions = (hb_internal_glyph_position_t *) buffer->out_string; - } - - tmp = buffer->in_length; - buffer->in_length = buffer->out_length; - buffer->out_length = tmp; - - tmp = buffer->in_pos; - buffer->in_pos = buffer->out_pos; - buffer->out_pos = tmp; -} - -/* The following function copies `num_out' elements from `glyph_data' - to `buffer->out_string', advancing the in array pointer in the structure - by `num_in' elements, and the out array pointer by `num_out' elements. - Finally, it sets the `length' field of `out' equal to - `pos' of the `out' structure. - - If `component' is 0xFFFF, the component value from buffer->in_pos - will copied `num_out' times, otherwise `component' itself will - be used to fill the `component' fields. - - If `lig_id' is 0xFFFF, the lig_id value from buffer->in_pos - will copied `num_out' times, otherwise `lig_id' itself will - be used to fill the `lig_id' fields. - - The mask for all replacement glyphs are taken - from the glyph at position `buffer->in_pos'. - - The cluster value for the glyph at position buffer->in_pos is used - for all replacement glyphs */ -void -_hb_buffer_add_output_glyphs (hb_buffer_t *buffer, - unsigned int num_in, - unsigned int num_out, - const uint16_t *glyph_data_be, - unsigned short component, - unsigned short lig_id) -{ - unsigned int i; - unsigned int mask; - unsigned int cluster; - - if (buffer->out_string != buffer->in_string || - buffer->out_pos + num_out > buffer->in_pos + num_in) - { - hb_buffer_ensure_separate (buffer, buffer->out_pos + num_out); - } - - mask = buffer->in_string[buffer->in_pos].mask; - cluster = buffer->in_string[buffer->in_pos].cluster; - if (component == 0xFFFF) - component = buffer->in_string[buffer->in_pos].component; - if (lig_id == 0xFFFF) - lig_id = buffer->in_string[buffer->in_pos].lig_id; - - for (i = 0; i < num_out; i++) - { - hb_internal_glyph_info_t *info = &buffer->out_string[buffer->out_pos + i]; - info->codepoint = hb_be_uint16 (glyph_data_be[i]); - info->mask = mask; - info->cluster = cluster; - info->component = component; - info->lig_id = lig_id; - info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; - } - - buffer->in_pos += num_in; - buffer->out_pos += num_out; - buffer->out_length = buffer->out_pos; -} - - -void -_hb_buffer_add_output_glyph (hb_buffer_t *buffer, - hb_codepoint_t glyph_index, - unsigned short component, - unsigned short lig_id) -{ - hb_internal_glyph_info_t *info; - - if (buffer->out_string != buffer->in_string) - { - hb_buffer_ensure (buffer, buffer->out_pos + 1); - buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos]; - } - else if (buffer->out_pos != buffer->in_pos) - buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos]; - - info = &buffer->out_string[buffer->out_pos]; - info->codepoint = glyph_index; - if (component != 0xFFFF) - info->component = component; - if (lig_id != 0xFFFF) - info->lig_id = lig_id; - info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN; - - buffer->in_pos++; - buffer->out_pos++; - buffer->out_length = buffer->out_pos; -} - -void -_hb_buffer_next_glyph (hb_buffer_t *buffer) -{ - if (!buffer->have_output) - { - buffer->in_pos++; - return; - } - - if (buffer->out_string != buffer->in_string) - { - hb_buffer_ensure (buffer, buffer->out_pos + 1); - buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos]; - } - else if (buffer->out_pos != buffer->in_pos) - buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos]; - - buffer->in_pos++; - buffer->out_pos++; - buffer->out_length = buffer->out_pos; -} - -void -_hb_buffer_replace_glyph (hb_buffer_t *buffer, - hb_codepoint_t glyph_index) -{ - _hb_buffer_add_output_glyph (buffer, glyph_index, 0xFFFF, 0xFFFF); -} - -unsigned short -_hb_buffer_allocate_lig_id (hb_buffer_t *buffer) -{ - return ++buffer->max_lig_id; -} - - -unsigned int -hb_buffer_get_len (hb_buffer_t *buffer) -{ - return buffer->in_length; -} - -/* Return value valid as long as buffer not modified */ -hb_glyph_info_t * -hb_buffer_get_glyph_infos (hb_buffer_t *buffer) -{ - return (hb_glyph_info_t *) buffer->in_string; -} - -/* Return value valid as long as buffer not modified */ -hb_glyph_position_t * -hb_buffer_get_glyph_positions (hb_buffer_t *buffer) -{ - if (buffer->have_output || (buffer->in_length && !buffer->positions)) - hb_buffer_clear_positions (buffer); - - return (hb_glyph_position_t *) buffer->positions; -} - - -void -hb_buffer_reverse (hb_buffer_t *buffer) -{ - unsigned int i, j; - - for (i = 0, j = buffer->in_length - 1; i < buffer->in_length / 2; i++, j--) { - hb_internal_glyph_info_t t; - - t = buffer->in_string[i]; - buffer->in_string[i] = buffer->in_string[j]; - buffer->in_string[j] = t; - } - - if (buffer->positions) { - for (i = 0, j = buffer->in_length - 1; i < buffer->in_length / 2; i++, j--) { - hb_internal_glyph_position_t t; - - t = buffer->positions[i]; - buffer->positions[i] = buffer->positions[j]; - buffer->positions[j] = t; - } - } -} - - -#define ADD_UTF(T) \ - HB_STMT_START { \ - const T *next = (const T *) text + item_offset; \ - const T *end = next + item_length; \ - while (next < end) { \ - hb_codepoint_t u; \ - const T *old_next = next; \ - next = UTF_NEXT (next, end, u); \ - hb_buffer_add_glyph (buffer, u, 0, old_next - (const T *) text); \ - } \ - } HB_STMT_END - - -#define UTF8_COMPUTE(Char, Mask, Len) \ - if (Char < 128) { Len = 1; Mask = 0x7f; } \ - else if ((Char & 0xe0) == 0xc0) { Len = 2; Mask = 0x1f; } \ - else if ((Char & 0xf0) == 0xe0) { Len = 3; Mask = 0x0f; } \ - else if ((Char & 0xf8) == 0xf0) { Len = 4; Mask = 0x07; } \ - else Len = 0; - -static inline const uint8_t * -hb_utf8_next (const uint8_t *text, - const uint8_t *end, - hb_codepoint_t *unicode) -{ - uint8_t c = *text; - unsigned int mask, len; - - UTF8_COMPUTE (c, mask, len); - if (HB_UNLIKELY (!len || (unsigned int) (end - text) < len)) { - *unicode = -1; - return text + 1; - } else { - hb_codepoint_t result; - unsigned int i; - result = c & mask; - for (i = 1; i < len; i++) - { - if (HB_UNLIKELY ((text[i] & 0xc0) != 0x80)) - { - *unicode = -1; - return text + 1; - } - result <<= 6; - result |= (text[i] & 0x3f); - } - *unicode = result; - return text + len; - } -} - -void -hb_buffer_add_utf8 (hb_buffer_t *buffer, - const char *text, - unsigned int text_length, - unsigned int item_offset, - unsigned int item_length) -{ -#define UTF_NEXT(S, E, U) hb_utf8_next (S, E, &(U)) - ADD_UTF (uint8_t); -#undef UTF_NEXT -} - -static inline const uint16_t * -hb_utf16_next (const uint16_t *text, - const uint16_t *end, - hb_codepoint_t *unicode) -{ - uint16_t c = *text++; - - if (HB_UNLIKELY (c >= 0xd800 && c < 0xdc00)) { - /* high surrogate */ - uint16_t l; - if (text < end && ((l = *text), HB_UNLIKELY (l >= 0xdc00 && l < 0xe000))) { - /* low surrogate */ - *unicode = ((hb_codepoint_t) ((c) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000); - text++; - } else - *unicode = -1; - } else - *unicode = c; - - return text; -} - -void -hb_buffer_add_utf16 (hb_buffer_t *buffer, - const uint16_t *text, - unsigned int text_length, - unsigned int item_offset, - unsigned int item_length) -{ -#define UTF_NEXT(S, E, U) hb_utf16_next (S, E, &(U)) - ADD_UTF (uint16_t); -#undef UTF_NEXT -} - -void -hb_buffer_add_utf32 (hb_buffer_t *buffer, - const uint32_t *text, - unsigned int text_length, - unsigned int item_offset, - unsigned int item_length) -{ -#define UTF_NEXT(S, E, U) ((U) = *(S), (S)+1) - ADD_UTF (uint32_t); -#undef UTF_NEXT -} diff --git a/pango/opentype/hb-buffer.h b/pango/opentype/hb-buffer.h deleted file mode 100644 index b030ba9a..00000000 --- a/pango/opentype/hb-buffer.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 1998-2004 David Turner and Werner Lemberg - * Copyright (C) 2004,2007,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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): Owen Taylor, Behdad Esfahbod - */ - -#ifndef HB_BUFFER_H -#define HB_BUFFER_H - -#include "hb-common.h" - -HB_BEGIN_DECLS - -typedef struct _hb_buffer_t hb_buffer_t; - -typedef enum _hb_direction_t { - HB_DIRECTION_LTR, - HB_DIRECTION_RTL, - HB_DIRECTION_TTB, - HB_DIRECTION_BTT -} hb_direction_t; - -typedef struct _hb_glyph_info_t { - hb_codepoint_t codepoint; - hb_mask_t mask; - uint32_t cluster; - uint32_t internal1; - uint32_t internal2; -} hb_glyph_info_t; - -typedef struct _hb_glyph_position_t { - hb_position_t x_pos; - hb_position_t y_pos; - hb_position_t x_advance; - hb_position_t y_advance; - /* XXX these should all be replaced by "uint32_t internal" */ - uint32_t new_advance :1; /* if set, the advance width values are - absolute, i.e., they won't be - added to the original glyph's value - but rather replace them */ - uint32_t back : 15; /* number of glyphs to go back - for drawing current glyph */ - int32_t cursive_chain : 16; /* character to which this connects, - may be positive or negative; used - only internally */ -} hb_glyph_position_t; - - -hb_buffer_t * -hb_buffer_create (unsigned int pre_alloc_size); - -hb_buffer_t * -hb_buffer_reference (hb_buffer_t *buffer); - -unsigned int -hb_buffer_get_reference_count (hb_buffer_t *buffer); - -void -hb_buffer_destroy (hb_buffer_t *buffer); - - -void -hb_buffer_set_direction (hb_buffer_t *buffer, - hb_direction_t direction); - -hb_direction_t -hb_buffer_get_direction (hb_buffer_t *buffer); - - -void -hb_buffer_clear (hb_buffer_t *buffer); - -void -hb_buffer_clear_positions (hb_buffer_t *buffer); - -void -hb_buffer_ensure (hb_buffer_t *buffer, - unsigned int size); - -void -hb_buffer_reverse (hb_buffer_t *buffer); - - -/* Filling the buffer in */ - -void -hb_buffer_add_glyph (hb_buffer_t *buffer, - hb_codepoint_t codepoint, - hb_mask_t mask, - unsigned int cluster); - -void -hb_buffer_add_utf8 (hb_buffer_t *buffer, - const char *text, - unsigned int text_length, - unsigned int item_offset, - unsigned int item_length); - -void -hb_buffer_add_utf16 (hb_buffer_t *buffer, - const uint16_t *text, - unsigned int text_length, - unsigned int item_offset, - unsigned int item_length); - -void -hb_buffer_add_utf32 (hb_buffer_t *buffer, - const uint32_t *text, - unsigned int text_length, - unsigned int item_offset, - unsigned int item_length); - - -/* Getting glyphs out of the buffer */ - -/* Return value valid as long as buffer not modified */ -unsigned int -hb_buffer_get_len (hb_buffer_t *buffer); - -/* Return value valid as long as buffer not modified */ -hb_glyph_info_t * -hb_buffer_get_glyph_infos (hb_buffer_t *buffer); - -/* Return value valid as long as buffer not modified */ -hb_glyph_position_t * -hb_buffer_get_glyph_positions (hb_buffer_t *buffer); - - -HB_END_DECLS - -#endif /* HB_BUFFER_H */ diff --git a/pango/opentype/hb-common.h b/pango/opentype/hb-common.h deleted file mode 100644 index 11f64ed0..00000000 --- a/pango/opentype/hb-common.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2007,2008,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_COMMON_H -#define HB_COMMON_H - -#include <stdint.h> - -# ifdef __cplusplus -# define HB_BEGIN_DECLS extern "C" { -# define HB_END_DECLS } -# else /* !__cplusplus */ -# define HB_BEGIN_DECLS -# define HB_END_DECLS -# endif /* !__cplusplus */ - -typedef int hb_bool_t; - -typedef uint32_t hb_tag_t; -#define HB_TAG(a,b,c,d) ((hb_tag_t)(((uint8_t)a<<24)|((uint8_t)b<<16)|((uint8_t)c<<8)|(uint8_t)d)) -#define HB_TAG_STR(s) (HB_TAG(((const char *) s)[0], \ - ((const char *) s)[1], \ - ((const char *) s)[2], \ - ((const char *) s)[3])) -#define HB_TAG_NONE HB_TAG(0,0,0,0) - -typedef uint32_t hb_codepoint_t; -typedef int32_t hb_position_t; -typedef int32_t hb_16dot16_t; -typedef uint32_t hb_mask_t; - -typedef void (*hb_destroy_func_t) (void *user_data); - -#endif /* HB_COMMON_H */ diff --git a/pango/opentype/hb-font-private.h b/pango/opentype/hb-font-private.h deleted file mode 100644 index 8d921c71..00000000 --- a/pango/opentype/hb-font-private.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_FONT_PRIVATE_H -#define HB_FONT_PRIVATE_H - -#include "hb-private.h" - -#include "hb-font.h" - -#include "hb-unicode-private.h" -#include "hb-ot-layout-private.h" - -HB_BEGIN_DECLS - -/* - * hb_font_funcs_t - */ - -struct _hb_font_funcs_t { - hb_reference_count_t ref_count; - - hb_bool_t immutable; - - hb_font_get_glyph_func_t glyph_func; - hb_font_get_contour_point_func_t contour_point_func; - hb_font_get_glyph_metrics_func_t glyph_metrics_func; - hb_font_get_kerning_func_t kerning_func; -}; - -HB_INTERNAL hb_font_funcs_t -_hb_font_funcs_nil; - -/* - * hb_face_t - */ - -struct _hb_face_t { - hb_reference_count_t ref_count; - - hb_blob_t *blob; - unsigned int index; - - hb_get_table_func_t get_table; - hb_destroy_func_t destroy; - void *user_data; - - hb_unicode_funcs_t *unicode; - - hb_ot_layout_t ot_layout; -}; - - -/* - * hb_font_t - */ - -struct _hb_font_t { - hb_reference_count_t ref_count; - - hb_16dot16_t x_scale; - hb_16dot16_t y_scale; - - unsigned int x_ppem; - unsigned int y_ppem; - - hb_font_funcs_t *klass; -}; - - -HB_END_DECLS - -#endif /* HB_FONT_PRIVATE_H */ diff --git a/pango/opentype/hb-font.cc b/pango/opentype/hb-font.cc deleted file mode 100644 index df3d80b9..00000000 --- a/pango/opentype/hb-font.cc +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#include "hb-private.h" - -#include "hb-font-private.h" -#include "hb-unicode-private.h" -#include "hb-open-file-private.hh" -#include "hb-blob.h" - -#include "hb-ot-layout-private.h" - -/* - * hb_font_funcs_t - */ - -hb_font_funcs_t _hb_font_funcs_nil = { - HB_REFERENCE_COUNT_INVALID, /* ref_count */ - - TRUE, /* immutable */ - - NULL, /* glyph_func */ - NULL, /* contour_point_func */ - NULL, /* glyph_metrics_func */ - NULL /* kerning_func */ -}; - -hb_font_funcs_t * -hb_font_funcs_create (void) -{ - hb_font_funcs_t *ffuncs; - - if (!HB_OBJECT_DO_CREATE (hb_font_funcs_t, ffuncs)) - return &_hb_font_funcs_nil; - - return ffuncs; -} - -hb_font_funcs_t * -hb_font_funcs_reference (hb_font_funcs_t *ffuncs) -{ - HB_OBJECT_DO_REFERENCE (ffuncs); -} - -unsigned int -hb_font_funcs_get_reference_count (hb_font_funcs_t *ffuncs) -{ - HB_OBJECT_DO_GET_REFERENCE_COUNT (ffuncs); -} - -void -hb_font_funcs_destroy (hb_font_funcs_t *ffuncs) -{ - HB_OBJECT_DO_DESTROY (ffuncs); - - free (ffuncs); -} - -hb_font_funcs_t * -hb_font_funcs_copy (hb_font_funcs_t *other_ffuncs) -{ - hb_font_funcs_t *ffuncs; - - if (!HB_OBJECT_DO_CREATE (hb_font_funcs_t, ffuncs)) - return &_hb_font_funcs_nil; - - *ffuncs = *other_ffuncs; - - /* re-init refcount */ - HB_OBJECT_DO_INIT (ffuncs); - ffuncs->immutable = FALSE; - - return ffuncs; -} - -void -hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs) -{ - if (HB_OBJECT_IS_INERT (ffuncs)) - return; - - ffuncs->immutable = TRUE; -} - - - -/* - * hb_face_t - */ - -static hb_blob_t * -_hb_face_get_table_from_blob (hb_tag_t tag, void *user_data) -{ - hb_face_t *face = (hb_face_t *) user_data; - - const OpenTypeFontFile &ot_file = Sanitizer<OpenTypeFontFile>::lock_instance (face->blob); - const OpenTypeFontFace &ot_face = ot_file.get_face (face->index); - - const OpenTypeTable &table = ot_face.get_table_by_tag (tag); - - hb_blob_t *blob = hb_blob_create_sub_blob (face->blob, table.offset, table.length); - - hb_blob_unlock (face->blob); - - return blob; -} - -static hb_face_t _hb_face_nil = { - HB_REFERENCE_COUNT_INVALID, /* ref_count */ - - NULL, /* blob */ - 0, /* index */ - - NULL, /* get_table */ - NULL, /* destroy */ - NULL, /* user_data */ - - &_hb_unicode_funcs_nil, /* unicode */ - - {} /* ot_layout */ -}; - -hb_face_t * -hb_face_create_for_tables (hb_get_table_func_t get_table, - hb_destroy_func_t destroy, - void *user_data) -{ - hb_face_t *face; - - if (!HB_OBJECT_DO_CREATE (hb_face_t, face)) { - if (destroy) - destroy (user_data); - return &_hb_face_nil; - } - - face->get_table = get_table; - face->destroy = destroy; - face->user_data = user_data; - - _hb_ot_layout_init (face); - - return face; -} - -hb_face_t * -hb_face_create_for_data (hb_blob_t *blob, - unsigned int index) -{ - hb_face_t *face; - - if (!HB_OBJECT_DO_CREATE (hb_face_t, face)) - return &_hb_face_nil; - - face->blob = Sanitizer<OpenTypeFontFile>::sanitize (hb_blob_reference (blob)); - face->index = index; - face->get_table = _hb_face_get_table_from_blob; - face->user_data = face; - - _hb_ot_layout_init (face); - - return face; -} - -hb_face_t * -hb_face_reference (hb_face_t *face) -{ - HB_OBJECT_DO_REFERENCE (face); -} - -unsigned int -hb_face_get_reference_count (hb_face_t *face) -{ - HB_OBJECT_DO_GET_REFERENCE_COUNT (face); -} - -void -hb_face_destroy (hb_face_t *face) -{ - HB_OBJECT_DO_DESTROY (face); - - _hb_ot_layout_fini (face); - - hb_blob_destroy (face->blob); - - if (face->destroy) - face->destroy (face->user_data); - - hb_unicode_funcs_destroy (face->unicode); - - free (face); -} - -void -hb_face_set_unicode_funcs (hb_face_t *face, - hb_unicode_funcs_t *unicode) -{ - if (HB_OBJECT_IS_INERT (face)) - return; - - hb_unicode_funcs_reference (unicode); - hb_unicode_funcs_destroy (face->unicode); - face->unicode = unicode; -} - -hb_blob_t * -hb_face_get_table (hb_face_t *face, - hb_tag_t tag) -{ - if (HB_UNLIKELY (!face || !face->get_table)) - return hb_blob_create_empty (); - - return face->get_table (tag, face->user_data); -} - - -/* - * hb_font_t - */ - -static hb_font_t _hb_font_nil = { - HB_REFERENCE_COUNT_INVALID, /* ref_count */ - - 0, /* x_scale */ - 0, /* y_scale */ - - 0, /* x_ppem */ - 0, /* y_ppem */ - - NULL /* klass */ -}; - -hb_font_t * -hb_font_create (void) -{ - hb_font_t *font; - - if (!HB_OBJECT_DO_CREATE (hb_font_t, font)) - return &_hb_font_nil; - - return font; -} - -hb_font_t * -hb_font_reference (hb_font_t *font) -{ - HB_OBJECT_DO_REFERENCE (font); -} - -unsigned int -hb_font_get_reference_count (hb_font_t *font) -{ - HB_OBJECT_DO_GET_REFERENCE_COUNT (font); -} - -void -hb_font_destroy (hb_font_t *font) -{ - HB_OBJECT_DO_DESTROY (font); - - hb_font_funcs_destroy (font->klass); - - free (font); -} - -void -hb_font_set_funcs (hb_font_t *font, - hb_font_funcs_t *klass) -{ - if (HB_OBJECT_IS_INERT (font)) - return; - - hb_font_funcs_reference (klass); - hb_font_funcs_destroy (font->klass); - font->klass = klass; -} - -void -hb_font_set_scale (hb_font_t *font, - hb_16dot16_t x_scale, - hb_16dot16_t y_scale) -{ - if (HB_OBJECT_IS_INERT (font)) - return; - - font->x_scale = x_scale; - font->y_scale = y_scale; -} - -void -hb_font_set_ppem (hb_font_t *font, - unsigned int x_ppem, - unsigned int y_ppem) -{ - if (HB_OBJECT_IS_INERT (font)) - return; - - font->x_ppem = x_ppem; - font->y_ppem = y_ppem; -} - diff --git a/pango/opentype/hb-font.h b/pango/opentype/hb-font.h deleted file mode 100644 index e020bd83..00000000 --- a/pango/opentype/hb-font.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_FONT_H -#define HB_FONT_H - -#include "hb-common.h" -#include "hb-blob.h" -#include "hb-unicode.h" - -HB_BEGIN_DECLS - -typedef struct _hb_face_t hb_face_t; -typedef struct _hb_font_t hb_font_t; - -/* - * hb_face_t - */ - -hb_face_t * -hb_face_create_for_data (hb_blob_t *blob, - unsigned int index); - -typedef hb_blob_t * (*hb_get_table_func_t) (hb_tag_t tag, void *user_data); - -/* calls destroy() when not needing user_data anymore */ -hb_face_t * -hb_face_create_for_tables (hb_get_table_func_t get_table, - hb_destroy_func_t destroy, - void *user_data); - -hb_face_t * -hb_face_reference (hb_face_t *face); - -unsigned int -hb_face_get_reference_count (hb_face_t *face); - -void -hb_face_destroy (hb_face_t *face); - -void -hb_face_set_unicode_funcs (hb_face_t *face, - hb_unicode_funcs_t *unicode_funcs); - -hb_blob_t * -hb_face_get_table (hb_face_t *face, - hb_tag_t tag); - - -/* - * hb_font_funcs_t - */ - -typedef struct _hb_font_funcs_t hb_font_funcs_t; - -hb_font_funcs_t * -hb_font_funcs_create (void); - -hb_font_funcs_t * -hb_font_funcs_reference (hb_font_funcs_t *ffuncs); - -unsigned int -hb_font_funcs_get_reference_count (hb_font_funcs_t *ffuncs); - -void -hb_font_funcs_destroy (hb_font_funcs_t *ffuncs); - -hb_font_funcs_t * -hb_font_funcs_copy (hb_font_funcs_t *ffuncs); - -void -hb_font_funcs_make_immutable (hb_font_funcs_t *ffuncs); - - -/* funcs */ - -typedef struct _hb_glyph_metrics_t hb_glyph_metrics_t; -struct _hb_glyph_metrics_t -{ - hb_position_t x_advance; - hb_position_t y_advance; - hb_position_t x_offset; - hb_position_t y_offset; - hb_position_t width; - hb_position_t height; -}; - -typedef hb_codepoint_t (*hb_font_get_glyph_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data, - hb_codepoint_t unicode, hb_codepoint_t variant_selector); -typedef hb_bool_t (*hb_font_get_contour_point_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data, - unsigned int point_index, - hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y); -typedef void (*hb_font_get_glyph_metrics_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data, - hb_codepoint_t glyph, hb_glyph_metrics_t *metrics); -typedef hb_position_t (*hb_font_get_kerning_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data, - hb_codepoint_t first_glyph, hb_codepoint_t second_glyph); - - -void -hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_func_t glyph_func); - -void -hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs, - hb_font_get_contour_point_func_t contour_point_func); - -void -hb_font_funcs_set_glyph_metrics_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_metrics_func_t glyph_metrics_func); - -void -hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs, - hb_font_get_kerning_func_t kerning_func); - - -/* - * hb_font_t - */ - -/* Fonts are very light-weight objects */ - -hb_font_t * -hb_font_create (void); - -hb_font_t * -hb_font_reference (hb_font_t *font); - -unsigned int -hb_font_get_reference_count (hb_font_t *font); - -void -hb_font_destroy (hb_font_t *font); - -void -hb_font_set_funcs (hb_font_t *font, - hb_font_funcs_t *klass); - -/* - * XXX - * should we decompose this to units_per_EM and font-size? - * units_per_EM setting then can go into the face, or better, - * read from the 'head' table. - * - * Then we either need size+shape like freetype does, or a full - * matrix. - */ -void -hb_font_set_scale (hb_font_t *font, - hb_16dot16_t x_scale, - hb_16dot16_t y_scale); - -/* - * A zero value means "no hinting in that direction" - */ -void -hb_font_set_ppem (hb_font_t *font, - unsigned int x_ppem, - unsigned int y_ppem); - - -HB_END_DECLS - -#endif /* HB_FONT_H */ diff --git a/pango/opentype/hb-glib.c b/pango/opentype/hb-glib.c deleted file mode 100644 index 9fb3d914..00000000 --- a/pango/opentype/hb-glib.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#include "hb-private.h" - -#include "hb-glib.h" - -#include "hb-unicode-private.h" - -static hb_codepoint_t hb_glib_get_mirroring (hb_codepoint_t unicode) { g_unichar_get_mirror_char (unicode, &unicode); return unicode; } -static hb_category_t hb_glib_get_general_category (hb_codepoint_t unicode) { return g_unichar_type (unicode); } -static hb_script_t hb_glib_get_script (hb_codepoint_t unicode) { return g_unichar_get_script (unicode); } -static unsigned int hb_glib_get_combining_class (hb_codepoint_t unicode) { return g_unichar_combining_class (unicode); } -static unsigned int hb_glib_get_eastasian_width (hb_codepoint_t unicode) { return g_unichar_iswide (unicode); } - - -static hb_unicode_funcs_t glib_ufuncs = { - HB_REFERENCE_COUNT_INVALID, /* ref_count */ - - TRUE, /* immutable */ - - hb_glib_get_general_category, - hb_glib_get_combining_class, - hb_glib_get_mirroring, - hb_glib_get_script, - hb_glib_get_eastasian_width -}; - -hb_unicode_funcs_t * -hb_glib_get_unicode_funcs (void) -{ - return &glib_ufuncs; -} diff --git a/pango/opentype/hb-glib.h b/pango/opentype/hb-glib.h deleted file mode 100644 index 6c949932..00000000 --- a/pango/opentype/hb-glib.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_GLIB_H -#define HB_GLIB_H - -#include "hb.h" - -#include "hb-unicode.h" - -HB_BEGIN_DECLS - -hb_unicode_funcs_t * -hb_glib_get_unicode_funcs (void); - -HB_END_DECLS - -#endif /* HB_GLIB_H */ diff --git a/pango/opentype/hb-object-private.h b/pango/opentype/hb-object-private.h deleted file mode 100644 index 2186e58e..00000000 --- a/pango/opentype/hb-object-private.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2007 Chris Wilson - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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. - * - * Contributor(s): - * Chris Wilson <chris@chris-wilson.co.uk> - * Red Hat Author(s): Behdad Esfahbod - */ - -#ifndef HB_REFCOUNT_PRIVATE_H -#define HB_REFCOUNT_PRIVATE_H - - -/* Encapsulate operations on the object's reference count */ -typedef struct { - hb_atomic_int_t ref_count; -} hb_reference_count_t; - -#define hb_reference_count_inc(RC) hb_atomic_int_fetch_and_add ((RC).ref_count, 1) -#define hb_reference_count_dec(RC) hb_atomic_int_fetch_and_add ((RC).ref_count, -1) - -#define HB_REFERENCE_COUNT_INIT(RC, VALUE) ((RC).ref_count = (VALUE)) - -#define HB_REFERENCE_COUNT_GET_VALUE(RC) hb_atomic_int_get ((RC).ref_count) -#define HB_REFERENCE_COUNT_SET_VALUE(RC, VALUE) hb_atomic_int_set ((RC).ref_count, (VALUE)) - -#define HB_REFERENCE_COUNT_INVALID_VALUE ((hb_atomic_int_t) -1) -#define HB_REFERENCE_COUNT_INVALID {HB_REFERENCE_COUNT_INVALID_VALUE} - -#define HB_REFERENCE_COUNT_IS_INVALID(RC) (HB_REFERENCE_COUNT_GET_VALUE (RC) == HB_REFERENCE_COUNT_INVALID_VALUE) - -#define HB_REFERENCE_COUNT_HAS_REFERENCE(RC) (HB_REFERENCE_COUNT_GET_VALUE (RC) > 0) - - - -/* Helper macros */ - -#define HB_OBJECT_IS_INERT(obj) \ - (HB_UNLIKELY (HB_REFERENCE_COUNT_IS_INVALID ((obj)->ref_count))) - -#define HB_OBJECT_DO_INIT_EXPR(obj) \ - HB_REFERENCE_COUNT_INIT (obj->ref_count, 1) - -#define HB_OBJECT_DO_INIT(obj) \ - HB_STMT_START { \ - HB_OBJECT_DO_INIT_EXPR (obj); \ - } HB_STMT_END - -#define HB_OBJECT_DO_CREATE(Type, obj) \ - HB_LIKELY (( \ - (obj) = (Type *) calloc (1, sizeof (Type)), \ - HB_OBJECT_DO_INIT_EXPR (obj), \ - (obj) \ - )) - -#define HB_OBJECT_DO_REFERENCE(obj) \ - HB_STMT_START { \ - int old_count; \ - if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \ - return obj; \ - old_count = hb_reference_count_inc (obj->ref_count); \ - assert (old_count > 0); \ - return obj; \ - } HB_STMT_END - -#define HB_OBJECT_DO_GET_REFERENCE_COUNT(obj) \ - HB_STMT_START { \ - if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \ - return 0; \ - return HB_REFERENCE_COUNT_GET_VALUE (obj->ref_count); \ - } HB_STMT_END - -#define HB_OBJECT_DO_DESTROY(obj) \ - HB_STMT_START { \ - int old_count; \ - if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \ - return; \ - old_count = hb_reference_count_dec (obj->ref_count); \ - assert (old_count > 0); \ - if (old_count != 1) \ - return; \ - } HB_STMT_END - - -#endif /* HB_REFCOUNT_PRIVATE_H */ diff --git a/pango/opentype/hb-open-file-private.hh b/pango/opentype/hb-open-file-private.hh deleted file mode 100644 index 47d4e04f..00000000 --- a/pango/opentype/hb-open-file-private.hh +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (C) 2007,2008,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_OPEN_FILE_PRIVATE_HH -#define HB_OPEN_FILE_PRIVATE_HH - -#include "hb-open-type-private.hh" - - -/* - * - * The OpenType Font File - * - */ - - -/* - * Organization of an OpenType Font - */ - -struct OpenTypeFontFile; -struct OffsetTable; -struct TTCHeader; - -typedef struct TableDirectory -{ - inline bool sanitize (SANITIZE_ARG_DEF, const void *base) { - TRACE_SANITIZE (); - return SANITIZE_SELF () && SANITIZE (tag) && - SANITIZE_MEM (CONST_CHARP(base) + (unsigned long) offset, length); - } - - Tag tag; /* 4-byte identifier. */ - CheckSum checkSum; /* CheckSum for this table. */ - ULONG offset; /* Offset from beginning of TrueType font - * file. */ - ULONG length; /* Length of this table. */ -} OpenTypeTable; -ASSERT_SIZE (TableDirectory, 16); - -typedef struct OffsetTable -{ - friend struct OpenTypeFontFile; - friend struct TTCHeader; - - STATIC_DEFINE_GET_FOR_DATA (OffsetTable); - - inline unsigned int get_table_count (void) const - { return numTables; } - inline const Tag& get_table_tag (unsigned int i) const - { - if (HB_UNLIKELY (i >= numTables)) return Null(Tag); - return tableDir[i].tag; - } - inline const TableDirectory& get_table (unsigned int i) const - { - if (HB_UNLIKELY (i >= numTables)) return Null(TableDirectory); - return tableDir[i]; - } - inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const - { - const Tag t = tag; - // TODO bsearch - unsigned int count = numTables; - for (unsigned int i = 0; i < count; i++) - { - if (t == tableDir[i].tag) - { - if (table_index) *table_index = i; - return true; - } - } - if (table_index) *table_index = NO_INDEX; - return false; - } - inline const TableDirectory& get_table_by_tag (hb_tag_t tag) const - { - unsigned int table_index; - find_table_index (tag, &table_index); - return get_table (table_index); - } - - inline unsigned int get_face_count (void) const { return 1; } - - public: - inline bool sanitize (SANITIZE_ARG_DEF, const void *base) { - TRACE_SANITIZE (); - if (!(SANITIZE_SELF () && SANITIZE_MEM (tableDir, sizeof (tableDir[0]) * numTables))) return false; - unsigned int count = numTables; - for (unsigned int i = 0; i < count; i++) - if (!SANITIZE_BASE (tableDir[i], base)) - return false; - return true; - } - - private: - Tag sfnt_version; /* '\0\001\0\00' if TrueType / 'OTTO' if CFF */ - USHORT numTables; /* Number of tables. */ - USHORT searchRange; /* (Maximum power of 2 <= numTables) x 16 */ - USHORT entrySelector; /* Log2(maximum power of 2 <= numTables). */ - USHORT rangeShift; /* NumTables x 16-searchRange. */ - TableDirectory tableDir[]; /* TableDirectory entries. numTables items */ -} OpenTypeFontFace; -ASSERT_SIZE (OffsetTable, 12); - -/* - * TrueType Collections - */ - -struct TTCHeader -{ - friend struct OpenTypeFontFile; - - STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (TTCHeader, 1, 2); - - inline unsigned int get_face_count (void) const { return table.len; } - - inline const OpenTypeFontFace& get_face (unsigned int i) const - { - return this+table[i]; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (version)) return false; - if (version.major < 1 || version.major > 2) return true; - /* TODO Maybe we shouldn't NEUTER these offsets, they may cause a full copy - * of the whole font right now. */ - return table.sanitize (SANITIZE_ARG, CONST_CHARP(this), CONST_CHARP(this)); - } - - private: - Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ - FixedVersion version; /* Version of the TTC Header (1.0 or 2.0), - * 0x00010000 or 0x00020000 */ - LongOffsetLongArrayOf<OffsetTable> - table; /* Array of offsets to the OffsetTable for each font - * from the beginning of the file */ -}; -ASSERT_SIZE (TTCHeader, 12); - - -/* - * OpenType Font File - */ - -struct OpenTypeFontFile -{ - static const hb_tag_t TrueTypeTag = HB_TAG ( 0 , 1 , 0 , 0 ); - static const hb_tag_t CFFTag = HB_TAG ('O','T','T','O'); - static const hb_tag_t TTCTag = HB_TAG ('t','t','c','f'); - - STATIC_DEFINE_GET_FOR_DATA (OpenTypeFontFile); - - inline unsigned int get_face_count (void) const - { - switch (tag) { - default: return 0; - case TrueTypeTag: case CFFTag: return OffsetTable::get_for_data (CONST_CHARP(this)).get_face_count (); - case TTCTag: return TTCHeader::get_for_data (CONST_CHARP(this)).get_face_count (); - } - } - inline const OpenTypeFontFace& get_face (unsigned int i) const - { - switch (tag) { - default: return Null(OpenTypeFontFace); - /* Note: for non-collection SFNT data we ignore index. This is because - * Apple dfont container is a container of SFNT's. So each SFNT is a - * non-TTC, but the index is more than zero. */ - case TrueTypeTag: case CFFTag: return OffsetTable::get_for_data (CONST_CHARP(this)); - case TTCTag: return TTCHeader::get_for_data (CONST_CHARP(this)).get_face (i); - } - } - - /* This is how you get a table */ - inline const char* get_table_data (const OpenTypeTable& table) const - { - if (HB_UNLIKELY (table.offset == 0)) return NULL; - return ((const char*) this) + table.offset; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE_SELF ()) return false; - switch (tag) { - default: return true; - case TrueTypeTag: case CFFTag: return SANITIZE_THIS (CAST (OffsetTable, *this, 0)); - case TTCTag: return SANITIZE (CAST (TTCHeader, *this, 0)); - } - } - - Tag tag; /* 4-byte identifier. */ -}; -ASSERT_SIZE (OpenTypeFontFile, 4); - - -#endif /* HB_OPEN_FILE_PRIVATE_HH */ diff --git a/pango/opentype/hb-open-type-private.hh b/pango/opentype/hb-open-type-private.hh deleted file mode 100644 index 4061cfe8..00000000 --- a/pango/opentype/hb-open-type-private.hh +++ /dev/null @@ -1,636 +0,0 @@ -/* - * Copyright (C) 2007,2008,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_OPEN_TYPES_PRIVATE_HH -#define HB_OPEN_TYPES_PRIVATE_HH - -#include "hb-private.h" - -#include "hb-blob.h" - - -#define NO_INDEX ((unsigned int) 0xFFFF) - - -/* - * Casts - */ - -#define CONST_CHARP(X) (reinterpret_cast<const char *>(X)) -#define DECONST_CHARP(X) ((char *)reinterpret_cast<const char *>(X)) -#define CHARP(X) (reinterpret_cast<char *>(X)) - -#define CONST_CAST(T,X,Ofs) (*(reinterpret_cast<const T *>(CONST_CHARP(&(X)) + Ofs))) -#define DECONST_CAST(T,X,Ofs) (*(reinterpret_cast<T *>((char *)CONST_CHARP(&(X)) + Ofs))) -#define CAST(T,X,Ofs) (*(reinterpret_cast<T *>(CHARP(&(X)) + Ofs))) - -#define CONST_NEXT(T,X) (*(reinterpret_cast<const T *>(CONST_CHARP(&(X)) + (X).get_size ()))) -#define NEXT(T,X) (*(reinterpret_cast<T *>(CHARP(&(X)) + (X).get_size ()))) - -/* - * Class features - */ - - -/* Null objects */ - -/* Global nul-content Null pool. Enlarge as necessary. */ -static const char NullPool[16] = ""; - -/* Generic template for nul-content sizeof-sized Null objects. */ -template <typename Type> -struct Null -{ - ASSERT_STATIC (sizeof (Type) <= sizeof (NullPool)); - static inline const Type &get () { return CONST_CAST (Type, *NullPool, 0); } -}; - -/* Specializaiton for arbitrary-content arbitrary-sized Null objects. */ -#define DEFINE_NULL_DATA(Type, size, data) \ -static const char _Null##Type[size] = data; \ -template <> \ -struct Null <Type> \ -{ \ - static inline const Type &get () { return CONST_CAST (Type, *_Null##Type, 0); } \ -} - -/* Accessor macro. */ -#define Null(Type) (Null<Type>::get()) - - -#define ASSERT_SIZE_DATA(Type, size, data) \ - ASSERT_SIZE (Type, size); \ - DEFINE_NULL_DATA (Type, size, data) - -/* get_for_data() is a static class method returning a reference to an - * instance of Type located at the input data location. It's just a - * fancy, NULL-safe, cast! */ -#define STATIC_DEFINE_GET_FOR_DATA(Type) \ - static inline const Type& get_for_data (const char *data) \ - { \ - if (HB_UNLIKELY (data == NULL)) return Null(Type); \ - return CONST_CAST (Type, *data, 0); \ - } -/* Like get_for_data(), but checks major version first. */ -#define STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION(Type, MajorMin, MajorMax) \ - static inline const Type& get_for_data (const char *data) \ - { \ - if (HB_UNLIKELY (data == NULL)) return Null(Type); \ - const Type& t = CONST_CAST (Type, *data, 0); \ - if (HB_UNLIKELY (t.version.major < MajorMin || t.version.major > MajorMax)) return Null(Type); \ - return t; \ - } - - -/* - * Sanitize - */ - -#ifndef HB_DEBUG_SANITIZE -#define HB_DEBUG_SANITIZE HB_DEBUG -#endif - -#if HB_DEBUG_SANITIZE -#define TRACE_SANITIZE_ARG_DEF , unsigned int sanitize_depth -#define TRACE_SANITIZE_ARG , sanitize_depth + 1 -#define TRACE_SANITIZE_ARG_INIT , 1 -#define TRACE_SANITIZE() \ - HB_STMT_START { \ - if (sanitize_depth < HB_DEBUG_SANITIZE) \ - fprintf (stderr, "SANITIZE(%p) %-*d-> %s\n", \ - (CONST_CHARP (this) == NullPool) ? 0 : this, \ - sanitize_depth, sanitize_depth, \ - __PRETTY_FUNCTION__); \ - } HB_STMT_END -#else -#define TRACE_SANITIZE_ARG_DEF -#define TRACE_SANITIZE_ARG -#define TRACE_SANITIZE_ARG_INIT -#define TRACE_SANITIZE() HB_STMT_START {} HB_STMT_END -#endif - -#define SANITIZE_ARG_DEF \ - hb_sanitize_context_t *context TRACE_SANITIZE_ARG_DEF -#define SANITIZE_ARG \ - context TRACE_SANITIZE_ARG -#define SANITIZE_ARG_INIT \ - &context TRACE_SANITIZE_ARG_INIT - -typedef struct _hb_sanitize_context_t hb_sanitize_context_t; -struct _hb_sanitize_context_t -{ - const char *start, *end; - int edit_count; - hb_blob_t *blob; -}; - -static HB_GNUC_UNUSED void -_hb_sanitize_init (hb_sanitize_context_t *context, - hb_blob_t *blob) -{ - context->blob = blob; - context->start = hb_blob_lock (blob); - context->end = context->start + hb_blob_get_length (blob); - context->edit_count = 0; - -#if HB_DEBUG_SANITIZE - fprintf (stderr, "sanitize %p init [%p..%p] (%u bytes)\n", - context->blob, context->start, context->end, context->end - context->start); -#endif -} - -static HB_GNUC_UNUSED void -_hb_sanitize_fini (hb_sanitize_context_t *context, - bool unlock) -{ -#if HB_DEBUG_SANITIZE - fprintf (stderr, "sanitize %p fini [%p..%p] %u edit requests\n", - context->blob, context->start, context->end, context->edit_count); -#endif - - if (unlock) - hb_blob_unlock (context->blob); -} - -static HB_GNUC_UNUSED inline bool -_hb_sanitize_check (SANITIZE_ARG_DEF, - const char *base, - unsigned int len) -{ - bool ret = context->start <= base && - base <= context->end && - (unsigned int) (context->end - base) >= len; - -#if HB_DEBUG_SANITIZE - if (sanitize_depth < HB_DEBUG_SANITIZE) \ - fprintf (stderr, "SANITIZE(%p) %-*d-> check [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \ - base, - sanitize_depth, sanitize_depth, - base, base+len, len, - context->start, context->end, - ret ? "pass" : "FAIL"); -#endif - return ret; -} - -static HB_GNUC_UNUSED inline bool -_hb_sanitize_array (SANITIZE_ARG_DEF, - const char *base, - unsigned int record_size, - unsigned int len) -{ - bool overflows = len >= ((unsigned int) -1) / record_size; - -#if HB_DEBUG_SANITIZE - if (sanitize_depth < HB_DEBUG_SANITIZE) \ - fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n", \ - base, - sanitize_depth, sanitize_depth, - base, base + (record_size * len), record_size, len, (unsigned long) record_size * len, - context->start, context->end, - !overflows ? "does not overflow" : "OVERFLOWS FAIL"); -#endif - return HB_LIKELY (!overflows) && _hb_sanitize_check (SANITIZE_ARG, base, record_size * len); -} - -static HB_GNUC_UNUSED inline bool -_hb_sanitize_edit (SANITIZE_ARG_DEF, - const char *base HB_GNUC_UNUSED, - unsigned int len HB_GNUC_UNUSED) -{ - bool perm = hb_blob_try_writable_inplace (context->blob); - context->edit_count++; - -#if HB_DEBUG_SANITIZE - fprintf (stderr, "SANITIZE(%p) %-*d-> edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \ - base, - sanitize_depth, sanitize_depth, - context->edit_count, - base, base+len, len, - context->start, context->end, - perm ? "granted" : "REJECTED"); -#endif - return perm; -} - -#define SANITIZE(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG)) -#define SANITIZE2(X,Y) (SANITIZE (X) && SANITIZE (Y)) - -#define SANITIZE_THIS(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG, CONST_CHARP(this))) -#define SANITIZE_THIS2(X,Y) (SANITIZE_THIS (X) && SANITIZE_THIS (Y)) -#define SANITIZE_THIS3(X,Y,Z) (SANITIZE_THIS (X) && SANITIZE_THIS (Y) && SANITIZE_THIS(Z)) - -#define SANITIZE_BASE(X,B) HB_LIKELY ((X).sanitize (SANITIZE_ARG, B)) -#define SANITIZE_BASE2(X,Y,B) (SANITIZE_BASE (X,B) && SANITIZE_BASE (Y,B)) - -#define SANITIZE_SELF() SANITIZE_OBJ (*this) -#define SANITIZE_OBJ(X) SANITIZE_MEM(&(X), sizeof (X)) -#define SANITIZE_GET_SIZE() SANITIZE_SELF() && SANITIZE_MEM (this, this->get_size ()) - -/* TODO Optimize this if L is fixed (gcc magic) */ -#define SANITIZE_MEM(B,L) HB_LIKELY (_hb_sanitize_check (SANITIZE_ARG, CONST_CHARP(B), (L))) - -#define SANITIZE_ARRAY(A,S,L) HB_LIKELY (_hb_sanitize_array (SANITIZE_ARG, CONST_CHARP(A), S, L)) - -#define NEUTER(Var, Val) \ - (SANITIZE_OBJ (Var) && \ - _hb_sanitize_edit (SANITIZE_ARG, CONST_CHARP(&(Var)), sizeof (Var)) && \ - ((Var) = (Val), true)) - - -/* Template to sanitize an object. */ -template <typename Type> -struct Sanitizer -{ - static hb_blob_t *sanitize (hb_blob_t *blob) { - hb_sanitize_context_t context; - bool sane; - - /* TODO is_sane() stuff */ - - retry: -#if HB_DEBUG_SANITIZE - fprintf (stderr, "Sanitizer %p start %s\n", blob, __PRETTY_FUNCTION__); -#endif - - _hb_sanitize_init (&context, blob); - - Type *t = &CAST (Type, *DECONST_CHARP(context.start), 0); - - sane = t->sanitize (SANITIZE_ARG_INIT); - if (sane) { - if (context.edit_count) { -#if HB_DEBUG_SANITIZE - fprintf (stderr, "Sanitizer %p passed first round with %d edits; going a second round %s\n", - blob, context.edit_count, __PRETTY_FUNCTION__); -#endif - /* sanitize again to ensure no toe-stepping */ - context.edit_count = 0; - sane = t->sanitize (SANITIZE_ARG_INIT); - if (context.edit_count) { -#if HB_DEBUG_SANITIZE - fprintf (stderr, "Sanitizer %p requested %d edits in second round; FAILLING %s\n", - blob, context.edit_count, __PRETTY_FUNCTION__); -#endif - sane = false; - } - } - _hb_sanitize_fini (&context, true); - } else { - unsigned int edit_count = context.edit_count; - _hb_sanitize_fini (&context, true); - if (edit_count && !hb_blob_is_writable (blob) && hb_blob_try_writable (blob)) { - /* ok, we made it writable by relocating. try again */ -#if HB_DEBUG_SANITIZE - fprintf (stderr, "Sanitizer %p retry %s\n", blob, __PRETTY_FUNCTION__); -#endif - goto retry; - } - } - -#if HB_DEBUG_SANITIZE - fprintf (stderr, "Sanitizer %p %s %s\n", blob, sane ? "passed" : "FAILED", __PRETTY_FUNCTION__); -#endif - if (sane) - return blob; - else { - hb_blob_destroy (blob); - return hb_blob_create_empty (); - } - } - - static const Type& lock_instance (hb_blob_t *blob) { - return Type::get_for_data (hb_blob_lock (blob)); - } -}; - - -/* - * - * The OpenType Font File: Data Types - */ - - -/* "The following data types are used in the OpenType font file. - * All OpenType fonts use Motorola-style byte ordering (Big Endian):" */ - -/* - * Int types - */ - -/* TODO On machines that allow unaligned access, use this version. */ -#define _DEFINE_INT_TYPE1_UNALIGNED(NAME, TYPE, BIG_ENDIAN, BYTES) \ - struct NAME \ - { \ - inline NAME& operator = (TYPE i) { (TYPE&) v = BIG_ENDIAN (i); return *this; } \ - inline operator TYPE(void) const { return BIG_ENDIAN ((TYPE&) v); } \ - inline bool operator== (NAME o) const { return (TYPE&) v == (TYPE&) o.v; } \ - inline bool sanitize (SANITIZE_ARG_DEF) { \ - TRACE_SANITIZE (); \ - return SANITIZE_SELF (); \ - } \ - private: unsigned char v[BYTES]; \ - }; \ - ASSERT_SIZE (NAME, BYTES) - -#define DEFINE_INT_TYPE1(NAME, TYPE, BIG_ENDIAN, BYTES) \ - struct NAME \ - { \ - inline NAME& operator = (TYPE i) { BIG_ENDIAN##_put_unaligned(v, i); return *this; } \ - inline operator TYPE(void) const { return BIG_ENDIAN##_get_unaligned (v); } \ - inline bool operator== (NAME o) const { return BIG_ENDIAN##_cmp_unaligned (v, o.v); } \ - inline bool sanitize (SANITIZE_ARG_DEF) { \ - TRACE_SANITIZE (); \ - return SANITIZE_SELF (); \ - } \ - private: unsigned char v[BYTES]; \ - }; \ - ASSERT_SIZE (NAME, BYTES) -#define DEFINE_INT_TYPE0(NAME, type, b) DEFINE_INT_TYPE1 (NAME, type##_t, hb_be_##type, b) -#define DEFINE_INT_TYPE(NAME, u, w) DEFINE_INT_TYPE0 (NAME, u##int##w, (w / 8)) - - -DEFINE_INT_TYPE (USHORT, u, 16); /* 16-bit unsigned integer. */ -DEFINE_INT_TYPE (SHORT, , 16); /* 16-bit signed integer. */ -DEFINE_INT_TYPE (ULONG, u, 32); /* 32-bit unsigned integer. */ -DEFINE_INT_TYPE (LONG, , 32); /* 32-bit signed integer. */ - - -/* Array of four uint8s (length = 32 bits) used to identify a script, language - * system, feature, or baseline */ -struct Tag : ULONG -{ - inline Tag (const Tag &o) { *(ULONG*)this = (ULONG&) o; } - inline Tag (uint32_t i) { *(ULONG*)this = i; } - inline Tag (const char *c) { *(ULONG*)this = *(ULONG*)c; } - inline bool operator== (const char *c) const { return *(ULONG*)this == *(ULONG*)c; } - /* What the char* converters return is NOT nul-terminated. Print using "%.4s" */ - inline operator const char* (void) const { return CONST_CHARP(this); } - inline operator char* (void) { return CHARP(this); } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - /* Note: Only accept ASCII-visible tags (mind DEL) - * This is one of the few times (only time?) we check - * for data integrity, as opposed o just boundary checks - */ - return SANITIZE_SELF () && (((uint32_t) *this) & 0x80808080) == 0; - } -}; -ASSERT_SIZE (Tag, 4); -#define _NULL_TAG_INIT {' ', ' ', ' ', ' '} -DEFINE_NULL_DATA (Tag, 4, _NULL_TAG_INIT); -#undef _NULL_TAG_INIT - -/* Glyph index number, same as uint16 (length = 16 bits) */ -typedef USHORT GlyphID; - -/* Offset to a table, same as uint16 (length = 16 bits), Null offset = 0x0000 */ -typedef USHORT Offset; - -/* LongOffset to a table, same as uint32 (length = 32 bits), Null offset = 0x00000000 */ -typedef ULONG LongOffset; - - -/* CheckSum */ -struct CheckSum : ULONG -{ - static uint32_t CalcTableChecksum (ULONG *Table, uint32_t Length) - { - uint32_t Sum = 0L; - ULONG *EndPtr = Table+((Length+3) & ~3) / sizeof(ULONG); - - while (Table < EndPtr) - Sum += *Table++; - return Sum; - } -}; -ASSERT_SIZE (CheckSum, 4); - - -/* - * Version Numbers - */ - -struct FixedVersion -{ - inline operator uint32_t (void) const { return (major << 16) + minor; } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF (); - } - - USHORT major; - USHORT minor; -}; -ASSERT_SIZE (FixedVersion, 4); - - - -/* - * Template subclasses of Offset and LongOffset that do the dereferencing. - * Use: (this+memberName) - */ - -template <typename OffsetType, typename Type> -struct GenericOffsetTo : OffsetType -{ - inline const Type& operator() (const void *base) const - { - unsigned int offset = *this; - if (HB_UNLIKELY (!offset)) return Null(Type); - return CONST_CAST(Type, *CONST_CHARP(base), offset); - } - - inline bool sanitize (SANITIZE_ARG_DEF, const void *base) { - TRACE_SANITIZE (); - if (!SANITIZE_SELF ()) return false; - unsigned int offset = *this; - if (HB_UNLIKELY (!offset)) return true; - return SANITIZE (CAST(Type, *DECONST_CHARP(base), offset)) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0); - } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base, const void *base2) { - TRACE_SANITIZE (); - if (!SANITIZE_SELF ()) return false; - unsigned int offset = *this; - if (HB_UNLIKELY (!offset)) return true; - return SANITIZE_BASE (CAST(Type, *DECONST_CHARP(base), offset), base2) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0); - } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base, unsigned int user_data) { - TRACE_SANITIZE (); - if (!SANITIZE_SELF ()) return false; - unsigned int offset = *this; - if (HB_UNLIKELY (!offset)) return true; - return SANITIZE_BASE (CAST(Type, *DECONST_CHARP(base), offset), user_data) || NEUTER (DECONST_CAST(OffsetType,*this,0), 0); - } -}; -template <typename Base, typename OffsetType, typename Type> -inline const Type& operator + (const Base &base, GenericOffsetTo<OffsetType, Type> offset) { return offset (base); } - -template <typename Type> -struct OffsetTo : GenericOffsetTo<Offset, Type> {}; - -template <typename Type> -struct LongOffsetTo : GenericOffsetTo<LongOffset, Type> {}; - - -/* - * Array Types - */ - -template <typename LenType, typename Type> -struct GenericArrayOf -{ - inline const Type& operator [] (unsigned int i) const - { - if (HB_UNLIKELY (i >= len)) return Null(Type); - return array[i]; - } - inline unsigned int get_size () const - { return sizeof (len) + len * sizeof (array[0]); } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE_GET_SIZE()) return false; - /* Note: - * for non-recursive types, this is not much needed. - * But we keep the code to make sure the objects pointed to - * do have a simple sanitize(). */ - return true; - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - if (!SANITIZE (array[i])) - return false; - return true; - } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base) { - TRACE_SANITIZE (); - if (!SANITIZE_GET_SIZE()) return false; - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - if (!array[i].sanitize (SANITIZE_ARG, base)) - return false; - return true; - } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base, const void *base2) { - TRACE_SANITIZE (); - if (!SANITIZE_GET_SIZE()) return false; - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - if (!array[i].sanitize (SANITIZE_ARG, base, base2)) - return false; - return true; - } - inline bool sanitize (SANITIZE_ARG_DEF, const void *base, unsigned int user_data) { - TRACE_SANITIZE (); - if (!SANITIZE_GET_SIZE()) return false; - unsigned int count = len; - for (unsigned int i = 0; i < count; i++) - if (!array[i].sanitize (SANITIZE_ARG, base, user_data)) - return false; - return true; - } - - LenType len; - Type array[]; -}; - -/* An array with a USHORT number of elements. */ -template <typename Type> -struct ArrayOf : GenericArrayOf<USHORT, Type> {}; - -/* An array with a ULONG number of elements. */ -template <typename Type> -struct LongArrayOf : GenericArrayOf<ULONG, Type> {}; - -/* Array of Offset's */ -template <typename Type> -struct OffsetArrayOf : ArrayOf<OffsetTo<Type> > {}; - -/* Array of LongOffset's */ -template <typename Type> -struct LongOffsetArrayOf : ArrayOf<LongOffsetTo<Type> > {}; - -/* LongArray of LongOffset's */ -template <typename Type> -struct LongOffsetLongArrayOf : LongArrayOf<LongOffsetTo<Type> > {}; - -/* Array of offsets relative to the beginning of the array itself. */ -template <typename Type> -struct OffsetListOf : OffsetArrayOf<Type> -{ - inline const Type& operator [] (unsigned int i) const - { - if (HB_UNLIKELY (i >= this->len)) return Null(Type); - return this+this->array[i]; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, CONST_CHARP(this)); - } - inline bool sanitize (SANITIZE_ARG_DEF, unsigned int user_data) { - TRACE_SANITIZE (); - return OffsetArrayOf<Type>::sanitize (SANITIZE_ARG, CONST_CHARP(this), user_data); - } -}; - - -/* An array with a USHORT number of elements, - * starting at second element. */ -template <typename Type> -struct HeadlessArrayOf -{ - inline const Type& operator [] (unsigned int i) const - { - if (HB_UNLIKELY (i >= len || !i)) return Null(Type); - return array[i-1]; - } - inline unsigned int get_size () const - { return sizeof (len) + (len ? len - 1 : 0) * sizeof (array[0]); } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE_GET_SIZE()) return false; - /* Note: - * for non-recursive types, this is not much needed. - * But we keep the code to make sure the objects pointed to - * do have a simple sanitize(). */ - return true; - unsigned int count = len ? len - 1 : 0; - for (unsigned int i = 0; i < count; i++) - if (!SANITIZE (array[i])) - return false; - return true; - } - - USHORT len; - Type array[]; -}; - - -#endif /* HB_OPEN_TYPES_PRIVATE_HH */ diff --git a/pango/opentype/hb-ot-layout-common-private.hh b/pango/opentype/hb-ot-layout-common-private.hh deleted file mode 100644 index a1e625d9..00000000 --- a/pango/opentype/hb-ot-layout-common-private.hh +++ /dev/null @@ -1,603 +0,0 @@ -/* - * Copyright (C) 2007,2008,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_OT_LAYOUT_COMMON_PRIVATE_HH -#define HB_OT_LAYOUT_COMMON_PRIVATE_HH - -#include "hb-ot-layout-private.h" - -#include "hb-open-type-private.hh" - - -#define NO_CONTEXT ((unsigned int) 0x110000) -#define NOT_COVERED ((unsigned int) 0x110000) -#define MAX_NESTING_LEVEL 8 - - -/* - * - * OpenType Layout Common Table Formats - * - */ - - -/* - * Script, ScriptList, LangSys, Feature, FeatureList, Lookup, LookupList - */ - -template <typename Type> -struct Record -{ - inline bool sanitize (SANITIZE_ARG_DEF, const void *base) { - TRACE_SANITIZE (); - return SANITIZE (tag) && SANITIZE_BASE (offset, base); - } - - Tag tag; /* 4-byte Tag identifier */ - OffsetTo<Type> - offset; /* Offset from beginning of object holding - * the Record */ -}; - -template <typename Type> -struct RecordArrayOf : ArrayOf<Record<Type> > { - inline const Tag& get_tag (unsigned int i) const - { - if (HB_UNLIKELY (i >= this->len)) return Null(Tag); - return this->array[i].tag; - } - inline bool get_tags (unsigned int *record_count /* IN/OUT */, - hb_tag_t *record_tags /* OUT */) const - { - unsigned int count = MIN (this->len, *record_count); - for (unsigned int i = 0; i < count; i++) - record_tags[i] = this->array[i].tag; - - *record_count = this->len; - return !!this->len; - } - inline bool find_index (hb_tag_t tag, unsigned int *index) const - { - const Tag t = tag; - // TODO bsearch - unsigned int count = this->len; - for (unsigned int i = 0; i < count; i++) - { - if (t == this->array[i].tag) - { - if (index) *index = i; - return true; - } - } - if (index) *index = NO_INDEX; - return false; - } -}; - -template <typename Type> -struct RecordListOf : RecordArrayOf<Type> -{ - inline const Type& operator [] (unsigned int i) const - { return this+RecordArrayOf<Type>::operator[](i).offset; } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return RecordArrayOf<Type>::sanitize (SANITIZE_ARG, CONST_CHARP(this)); - } -}; - - -struct IndexArray : ArrayOf<USHORT> -{ - inline unsigned int operator [] (unsigned int i) const - { - if (HB_UNLIKELY (i >= this->len)) - return NO_INDEX; - return this->array[i]; - } - inline bool get_indexes (unsigned int *_count /* IN/OUT */, - unsigned int *_indexes /* OUT */) const - { - unsigned int count = MIN (this->len, *_count); - for (unsigned int i = 0; i < count; i++) - _indexes[i] = this->array[i]; - - *_count = this->len; - return !!this->len; - } -}; - - -struct Script; -struct LangSys; -struct Feature; - - -struct LangSys -{ - inline unsigned int get_feature_count (void) const - { return featureIndex.len; } - inline hb_tag_t get_feature_index (unsigned int i) const - { return featureIndex[i]; } - inline bool get_feature_indexes (unsigned int *feature_count /* IN/OUT */, - unsigned int *feature_indexes /* OUT */) const - { return featureIndex.get_indexes (feature_count, feature_indexes); } - - inline bool has_required_feature (void) const { return reqFeatureIndex != 0xffff; } - inline int get_required_feature_index (void) const - { - if (reqFeatureIndex == 0xffff) - return NO_INDEX; - return reqFeatureIndex;; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF () && SANITIZE (featureIndex); - } - - Offset lookupOrder; /* = Null (reserved for an offset to a - * reordering table) */ - USHORT reqFeatureIndex;/* Index of a feature required for this - * language system--if no required features - * = 0xFFFF */ - IndexArray featureIndex; /* Array of indices into the FeatureList */ -}; -ASSERT_SIZE_DATA (LangSys, 6, "\0\0\xFF\xFF"); - - -struct Script -{ - inline unsigned int get_lang_sys_count (void) const - { return langSys.len; } - inline const Tag& get_lang_sys_tag (unsigned int i) const - { return langSys.get_tag (i); } - inline bool get_lang_sys_tags (unsigned int *lang_sys_count /* IN/OUT */, - hb_tag_t *lang_sys_tags /* OUT */) const - { return langSys.get_tags (lang_sys_count, lang_sys_tags); } - inline const LangSys& get_lang_sys (unsigned int i) const - { - if (i == NO_INDEX) return get_default_lang_sys (); - return this+langSys[i].offset; - } - inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const - { return langSys.find_index (tag, index); } - - inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; } - inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS (defaultLangSys) && SANITIZE_THIS (langSys); - } - - private: - OffsetTo<LangSys> - defaultLangSys; /* Offset to DefaultLangSys table--from - * beginning of Script table--may be Null */ - RecordArrayOf<LangSys> - langSys; /* Array of LangSysRecords--listed - * alphabetically by LangSysTag */ -}; -ASSERT_SIZE (Script, 4); - -typedef RecordListOf<Script> ScriptList; -ASSERT_SIZE (ScriptList, 2); - - -struct Feature -{ - inline unsigned int get_lookup_count (void) const - { return lookupIndex.len; } - inline hb_tag_t get_lookup_index (unsigned int i) const - { return lookupIndex[i]; } - inline bool get_lookup_indexes (unsigned int *lookup_count /* IN/OUT */, - unsigned int *lookup_tags /* OUT */) const - { return lookupIndex.get_indexes (lookup_count, lookup_tags); } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF () && SANITIZE (lookupIndex); - } - - /* TODO: implement get_feature_parameters() */ - /* TODO: implement FeatureSize and other special features? */ - Offset featureParams; /* Offset to Feature Parameters table (if one - * has been defined for the feature), relative - * to the beginning of the Feature Table; = Null - * if not required */ - IndexArray lookupIndex; /* Array of LookupList indices */ -}; -ASSERT_SIZE (Feature, 4); - -typedef RecordListOf<Feature> FeatureList; -ASSERT_SIZE (FeatureList, 2); - - -struct LookupFlag : USHORT -{ - enum { - RightToLeft = 0x0001u, - IgnoreBaseGlyphs = 0x0002u, - IgnoreLigatures = 0x0004u, - IgnoreMarks = 0x0008u, - IgnoreFlags = 0x000Eu, - UseMarkFilteringSet = 0x0010u, - Reserved = 0x00E0u, - MarkAttachmentType = 0xFF00u - }; -}; -ASSERT_SIZE (LookupFlag, 2); - -struct LookupSubTable -{ - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF (); - } - - private: - USHORT format; /* Subtable format. Different for GSUB and GPOS */ -}; -ASSERT_SIZE (LookupSubTable, 2); - -struct Lookup -{ - inline const LookupSubTable& get_subtable (unsigned int i) const { return this+subTable[i]; } - inline unsigned int get_subtable_count (void) const { return subTable.len; } - - inline unsigned int get_type (void) const { return lookupType; } - inline unsigned int get_flag (void) const - { - unsigned int flag = lookupFlag; - if (HB_UNLIKELY (flag & LookupFlag::UseMarkFilteringSet)) - { - const USHORT &markFilteringSet = CONST_NEXT (USHORT, subTable); - flag += (markFilteringSet << 16); - } - return flag; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!(SANITIZE_SELF () && SANITIZE_THIS (subTable))) return false; - if (HB_UNLIKELY (lookupFlag & LookupFlag::UseMarkFilteringSet)) - { - USHORT &markFilteringSet = NEXT (USHORT, subTable); - if (!SANITIZE (markFilteringSet)) return false; - } - return true; - } - - USHORT lookupType; /* Different enumerations for GSUB and GPOS */ - USHORT lookupFlag; /* Lookup qualifiers */ - OffsetArrayOf<LookupSubTable> - subTable; /* Array of SubTables */ - USHORT markFilteringSetX[0]; /* Index (base 0) into GDEF mark glyph sets - * structure. This field is only present if bit - * UseMarkFilteringSet of lookup flags is set. */ -}; -ASSERT_SIZE (Lookup, 6); - -typedef OffsetListOf<Lookup> LookupList; -ASSERT_SIZE (LookupList, 2); - - -/* - * Coverage Table - */ - -struct CoverageFormat1 -{ - friend struct Coverage; - - private: - inline unsigned int get_coverage (hb_codepoint_t glyph_id) const - { - if (HB_UNLIKELY (glyph_id > 0xFFFF)) - return NOT_COVERED; - GlyphID gid; - gid = glyph_id; - // TODO: bsearch - unsigned int num_glyphs = glyphArray.len; - for (unsigned int i = 0; i < num_glyphs; i++) - if (gid == glyphArray[i]) - return i; - return NOT_COVERED; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE (glyphArray); - } - - private: - USHORT coverageFormat; /* Format identifier--format = 1 */ - ArrayOf<GlyphID> - glyphArray; /* Array of GlyphIDs--in numerical order */ -}; -ASSERT_SIZE (CoverageFormat1, 4); - -struct CoverageRangeRecord -{ - friend struct CoverageFormat2; - - private: - inline unsigned int get_coverage (hb_codepoint_t glyph_id) const - { - if (glyph_id >= start && glyph_id <= end) - return (unsigned int) startCoverageIndex + (glyph_id - start); - return NOT_COVERED; - } - - public: - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF (); - } - - private: - GlyphID start; /* First GlyphID in the range */ - GlyphID end; /* Last GlyphID in the range */ - USHORT startCoverageIndex; /* Coverage Index of first GlyphID in - * range */ -}; -ASSERT_SIZE_DATA (CoverageRangeRecord, 6, "\000\001"); - -struct CoverageFormat2 -{ - friend struct Coverage; - - private: - inline unsigned int get_coverage (hb_codepoint_t glyph_id) const - { - // TODO: bsearch - unsigned int count = rangeRecord.len; - for (unsigned int i = 0; i < count; i++) - { - unsigned int coverage = rangeRecord[i].get_coverage (glyph_id); - if (coverage != NOT_COVERED) - return coverage; - } - return NOT_COVERED; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE (rangeRecord); - } - - private: - USHORT coverageFormat; /* Format identifier--format = 2 */ - ArrayOf<CoverageRangeRecord> - rangeRecord; /* Array of glyph ranges--ordered by - * Start GlyphID. rangeCount entries - * long */ -}; -ASSERT_SIZE (CoverageFormat2, 4); - -struct Coverage -{ - inline unsigned int operator() (hb_codepoint_t glyph_id) const { return get_coverage (glyph_id); } - - inline unsigned int get_coverage (hb_codepoint_t glyph_id) const - { - switch (u.format) { - case 1: return u.format1->get_coverage(glyph_id); - case 2: return u.format2->get_coverage(glyph_id); - default:return NOT_COVERED; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - case 2: return u.format2->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - CoverageFormat1 format1[]; - CoverageFormat2 format2[]; - } u; -}; -ASSERT_SIZE (Coverage, 2); - - -/* - * Class Definition Table - */ - -struct ClassDefFormat1 -{ - friend struct ClassDef; - - private: - inline hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const - { - if ((unsigned int) (glyph_id - startGlyph) < classValue.len) - return classValue[glyph_id - startGlyph]; - return 0; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF () && SANITIZE (classValue); - } - - USHORT classFormat; /* Format identifier--format = 1 */ - GlyphID startGlyph; /* First GlyphID of the classValueArray */ - ArrayOf<USHORT> - classValue; /* Array of Class Values--one per GlyphID */ -}; -ASSERT_SIZE (ClassDefFormat1, 6); - -struct ClassRangeRecord -{ - friend struct ClassDefFormat2; - - private: - inline hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const - { - if (glyph_id >= start && glyph_id <= end) - return classValue; - return 0; - } - - public: - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF (); - } - - private: - GlyphID start; /* First GlyphID in the range */ - GlyphID end; /* Last GlyphID in the range */ - USHORT classValue; /* Applied to all glyphs in the range */ -}; -ASSERT_SIZE_DATA (ClassRangeRecord, 6, "\000\001"); - -struct ClassDefFormat2 -{ - friend struct ClassDef; - - private: - inline hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const - { - // TODO: bsearch - unsigned int count = rangeRecord.len; - for (unsigned int i = 0; i < count; i++) - { - int classValue = rangeRecord[i].get_class (glyph_id); - if (classValue > 0) - return classValue; - } - return 0; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE (rangeRecord); - } - - USHORT classFormat; /* Format identifier--format = 2 */ - ArrayOf<ClassRangeRecord> - rangeRecord; /* Array of glyph ranges--ordered by - * Start GlyphID */ -}; -ASSERT_SIZE (ClassDefFormat2, 4); - -struct ClassDef -{ - inline unsigned int operator() (hb_codepoint_t glyph_id) const { return get_class (glyph_id); } - - inline hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const - { - switch (u.format) { - case 1: return u.format1->get_class(glyph_id); - case 2: return u.format2->get_class(glyph_id); - default:return 0; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - case 2: return u.format2->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - ClassDefFormat1 format1[]; - ClassDefFormat2 format2[]; - } u; -}; -ASSERT_SIZE (ClassDef, 2); - - -/* - * Device Tables - */ - -struct Device -{ - inline int operator() (unsigned int ppem_size) const { return get_delta (ppem_size); } - - inline int get_delta (unsigned int ppem_size) const - { - unsigned int f = deltaFormat; - if (HB_UNLIKELY (f < 1 || f > 3)) - return 0; - - if (ppem_size < startSize || ppem_size > endSize) - return 0; - - unsigned int s = ppem_size - startSize; - - unsigned int byte = deltaValue[s >> (4 - f)]; - unsigned int bits = (byte >> (16 - (((s & ((1 << (4 - f)) - 1)) + 1) << f))); - unsigned int mask = (0xFFFF >> (16 - (1 << f))); - - int delta = bits & mask; - - if ((unsigned int) delta >= ((mask + 1) >> 1)) - delta -= mask + 1; - - return delta; - } - - inline unsigned int get_size () const - { - unsigned int f = deltaFormat; - if (HB_UNLIKELY (f < 1 || f > 3 || startSize > endSize)) return sizeof (*this); - return sizeof (*this) + ((endSize - startSize + (1 << (4 - f)) - 1) >> (4 - f)); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_GET_SIZE (); - } - - private: - USHORT startSize; /* Smallest size to correct--in ppem */ - USHORT endSize; /* Largest size to correct--in ppem */ - USHORT deltaFormat; /* Format of DeltaValue array data: 1, 2, or 3 */ - USHORT deltaValue[]; /* Array of compressed data */ -}; -ASSERT_SIZE (Device, 6); - - -#endif /* HB_OT_LAYOUT_COMMON_PRIVATE_HH */ diff --git a/pango/opentype/hb-ot-layout-gdef-private.hh b/pango/opentype/hb-ot-layout-gdef-private.hh deleted file mode 100644 index 1eb96c0d..00000000 --- a/pango/opentype/hb-ot-layout-gdef-private.hh +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright (C) 2007,2008,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_OT_LAYOUT_GDEF_PRIVATE_HH -#define HB_OT_LAYOUT_GDEF_PRIVATE_HH - -#include "hb-ot-layout-common-private.hh" - -#include "hb-font-private.h" - - -/* - * Attachment List Table - */ - -typedef ArrayOf<USHORT> AttachPoint; /* Array of contour point indices--in - * increasing numerical order */ -ASSERT_SIZE (AttachPoint, 2); - -struct AttachList -{ - inline bool get_attach_points (hb_codepoint_t glyph_id, - unsigned int *point_count /* IN/OUT */, - unsigned int *point_array /* OUT */) const - { - unsigned int index = (this+coverage) (glyph_id); - if (index == NOT_COVERED) - { - *point_count = 0; - return false; - } - const AttachPoint &points = this+attachPoint[index]; - - unsigned int count = MIN (points.len, *point_count); - for (unsigned int i = 0; i < count; i++) - point_array[i] = points[i]; - - *point_count = points.len; - - return true; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS2 (coverage, attachPoint); - } - - private: - OffsetTo<Coverage> - coverage; /* Offset to Coverage table -- from - * beginning of AttachList table */ - OffsetArrayOf<AttachPoint> - attachPoint; /* Array of AttachPoint tables - * in Coverage Index order */ -}; -ASSERT_SIZE (AttachList, 4); - -/* - * Ligature Caret Table - */ - -struct CaretValueFormat1 -{ - friend struct CaretValue; - - private: - inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const - { - /* TODO vertical */ - return context->font->x_scale * coordinate / 0x10000; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF (); - } - - private: - USHORT caretValueFormat; /* Format identifier--format = 1 */ - SHORT coordinate; /* X or Y value, in design units */ -}; -ASSERT_SIZE (CaretValueFormat1, 4); - -struct CaretValueFormat2 -{ - friend struct CaretValue; - - private: - inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const - { - return /* TODO contour point */ 0; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF (); - } - - private: - USHORT caretValueFormat; /* Format identifier--format = 2 */ - USHORT caretValuePoint; /* Contour point index on glyph */ -}; -ASSERT_SIZE (CaretValueFormat2, 4); - -struct CaretValueFormat3 -{ - friend struct CaretValue; - - inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const - { - /* TODO vertical */ - return context->font->x_scale * coordinate / 0x10000 + - ((this+deviceTable).get_delta (context->font->x_ppem) << 6); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF () && SANITIZE_THIS (deviceTable); - } - - private: - USHORT caretValueFormat; /* Format identifier--format = 3 */ - SHORT coordinate; /* X or Y value, in design units */ - OffsetTo<Device> - deviceTable; /* Offset to Device table for X or Y - * value--from beginning of CaretValue - * table */ -}; -ASSERT_SIZE (CaretValueFormat3, 6); - -struct CaretValue -{ - inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const - { - switch (u.format) { - case 1: return u.format1->get_caret_value (context, glyph_id); - case 2: return u.format2->get_caret_value (context, glyph_id); - case 3: return u.format3->get_caret_value (context, glyph_id); - default:return 0; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - case 2: return u.format2->sanitize (SANITIZE_ARG); - case 3: return u.format3->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - CaretValueFormat1 format1[]; - CaretValueFormat2 format2[]; - CaretValueFormat3 format3[]; - } u; -}; -ASSERT_SIZE (CaretValue, 2); - -struct LigGlyph -{ - inline void get_lig_carets (hb_ot_layout_context_t *context, - hb_codepoint_t glyph_id, - unsigned int *caret_count /* IN/OUT */, - int *caret_array /* OUT */) const - { - - unsigned int count = MIN (carets.len, *caret_count); - for (unsigned int i = 0; i < count; i++) - caret_array[i] = (this+carets[i]).get_caret_value (context, glyph_id); - - *caret_count = carets.len; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS (carets); - } - - private: - OffsetArrayOf<CaretValue> - carets; /* Offset array of CaretValue tables - * --from beginning of LigGlyph table - * --in increasing coordinate order */ -}; -ASSERT_SIZE (LigGlyph, 2); - -struct LigCaretList -{ - inline bool get_lig_carets (hb_ot_layout_context_t *context, - hb_codepoint_t glyph_id, - unsigned int *caret_count /* IN/OUT */, - int *caret_array /* OUT */) const - { - unsigned int index = (this+coverage) (glyph_id); - if (index == NOT_COVERED) - { - *caret_count = 0; - return false; - } - const LigGlyph &lig_glyph = this+ligGlyph[index]; - lig_glyph.get_lig_carets (context, glyph_id, caret_count, caret_array); - return true; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS2 (coverage, ligGlyph); - } - - private: - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of LigCaretList table */ - OffsetArrayOf<LigGlyph> - ligGlyph; /* Array of LigGlyph tables - * in Coverage Index order */ -}; -ASSERT_SIZE (LigCaretList, 4); - - -struct MarkGlyphSetsFormat1 -{ - inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const - { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS (coverage); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - LongOffsetArrayOf<Coverage> - coverage; /* Array of long offsets to mark set - * coverage tables */ -}; -ASSERT_SIZE (MarkGlyphSetsFormat1, 4); - -struct MarkGlyphSets -{ - inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const - { - switch (u.format) { - case 1: return u.format1->covers (set_index, glyph_id); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - MarkGlyphSetsFormat1 format1[]; - } u; -}; -ASSERT_SIZE (MarkGlyphSets, 2); - - -/* - * GDEF - */ - -struct GDEF -{ - static const hb_tag_t Tag = HB_OT_TAG_GDEF; - - enum { - UnclassifiedGlyph = 0, - BaseGlyph = 1, - LigatureGlyph = 2, - MarkGlyph = 3, - ComponentGlyph = 4 - }; - - STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GDEF, 1, 1); - - inline bool has_glyph_classes () const { return glyphClassDef != 0; } - inline hb_ot_layout_class_t get_glyph_class (hb_codepoint_t glyph) const - { return (this+glyphClassDef).get_class (glyph); } - - inline bool has_mark_attachment_types () const { return markAttachClassDef != 0; } - inline hb_ot_layout_class_t get_mark_attachment_type (hb_codepoint_t glyph) const - { return (this+markAttachClassDef).get_class (glyph); } - - inline bool has_attach_points () const { return attachList != 0; } - inline bool get_attach_points (hb_codepoint_t glyph_id, - unsigned int *point_count /* IN/OUT */, - unsigned int *point_array /* OUT */) const - { return (this+attachList).get_attach_points (glyph_id, point_count, point_array); } - - inline bool has_lig_carets () const { return ligCaretList != 0; } - inline bool get_lig_carets (hb_ot_layout_context_t *context, - hb_codepoint_t glyph_id, - unsigned int *caret_count /* IN/OUT */, - int *caret_array /* OUT */) const - { return (this+ligCaretList).get_lig_carets (context, glyph_id, caret_count, caret_array); } - - inline bool has_mark_sets () const { return version >= 0x00010002 && markGlyphSetsDef[0] != 0; } - inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const - { return version >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (version)) return false; - if (version.major != 1) return true; - return SANITIZE_THIS2 (glyphClassDef, attachList) && - SANITIZE_THIS2 (ligCaretList, markAttachClassDef) && - (version < 0x00010002 || SANITIZE_THIS (markGlyphSetsDef[0])); - } - - private: - FixedVersion version; /* Version of the GDEF table--currently - * 0x00010002 */ - OffsetTo<ClassDef> - glyphClassDef; /* Offset to class definition table - * for glyph type--from beginning of - * GDEF header (may be Null) */ - OffsetTo<AttachList> - attachList; /* Offset to list of glyphs with - * attachment points--from beginning - * of GDEF header (may be Null) */ - OffsetTo<LigCaretList> - ligCaretList; /* Offset to list of positioning points - * for ligature carets--from beginning - * of GDEF header (may be Null) */ - OffsetTo<ClassDef> - markAttachClassDef; /* Offset to class definition table for - * mark attachment type--from beginning - * of GDEF header (may be Null) */ - OffsetTo<MarkGlyphSets> - markGlyphSetsDef[0]; /* Offset to the table of mark set - * definitions--from beginning of GDEF - * header (may be NULL). Introduced - * in version 00010002. */ -}; -ASSERT_SIZE (GDEF, 12); - - -#endif /* HB_OT_LAYOUT_GDEF_PRIVATE_HH */ diff --git a/pango/opentype/hb-ot-layout-gpos-private.hh b/pango/opentype/hb-ot-layout-gpos-private.hh deleted file mode 100644 index 609ebe78..00000000 --- a/pango/opentype/hb-ot-layout-gpos-private.hh +++ /dev/null @@ -1,1538 +0,0 @@ -/* - * Copyright (C) 2007,2008,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_OT_LAYOUT_GPOS_PRIVATE_HH -#define HB_OT_LAYOUT_GPOS_PRIVATE_HH - -#include "hb-ot-layout-gsubgpos-private.hh" - -#define HB_OT_LAYOUT_GPOS_NO_LAST ((unsigned int) -1) - -/* Shared Tables: ValueRecord, Anchor Table, and MarkArray */ - -typedef SHORT Value; - -typedef Value ValueRecord[0]; -ASSERT_SIZE (ValueRecord, 0); - -struct ValueFormat : USHORT -{ - enum - { - xPlacement = 0x0001, /* Includes horizontal adjustment for placement */ - yPlacement = 0x0002, /* Includes vertical adjustment for placement */ - xAdvance = 0x0004, /* Includes horizontal adjustment for advance */ - yAdvance = 0x0008, /* Includes vertical adjustment for advance */ - xPlaDevice = 0x0010, /* Includes horizontal Device table for placement */ - yPlaDevice = 0x0020, /* Includes vertical Device table for placement */ - xAdvDevice = 0x0040, /* Includes horizontal Device table for advance */ - yAdvDevice = 0x0080, /* Includes vertical Device table for advance */ - ignored = 0x0F00, /* Was used in TrueType Open for MM fonts */ - reserved = 0xF000 /* For future use */ - }; - - inline unsigned int get_len () const - { return _hb_popcount32 ((unsigned int) *this); } - inline unsigned int get_size () const - { return get_len () * sizeof (Value); } - - void apply_value (hb_ot_layout_context_t *context, - const char *base, - const Value *values, - hb_internal_glyph_position_t *glyph_pos) const - { - unsigned int x_ppem, y_ppem; - hb_16dot16_t x_scale, y_scale; - unsigned int format = *this; - - if (!format) - return; - - /* All fields are options. Only those available advance the value - * pointer. */ -#if 0 -struct ValueRecord { - SHORT xPlacement; /* Horizontal adjustment for - * placement--in design units */ - SHORT yPlacement; /* Vertical adjustment for - * placement--in design units */ - SHORT xAdvance; /* Horizontal adjustment for - * advance--in design units (only used - * for horizontal writing) */ - SHORT yAdvance; /* Vertical adjustment for advance--in - * design units (only used for vertical - * writing) */ - Offset xPlaDevice; /* Offset to Device table for - * horizontal placement--measured from - * beginning of PosTable (may be NULL) */ - Offset yPlaDevice; /* Offset to Device table for vertical - * placement--measured from beginning - * of PosTable (may be NULL) */ - Offset xAdvDevice; /* Offset to Device table for - * horizontal advance--measured from - * beginning of PosTable (may be NULL) */ - Offset yAdvDevice; /* Offset to Device table for vertical - * advance--measured from beginning of - * PosTable (may be NULL) */ -}; -#endif - - x_scale = context->font->x_scale; - y_scale = context->font->y_scale; - /* design units -> fractional pixel */ - if (format & xPlacement) - glyph_pos->x_pos += _hb_16dot16_mul_trunc (x_scale, *(SHORT*)values++); - if (format & yPlacement) - glyph_pos->y_pos += _hb_16dot16_mul_trunc (y_scale, *(SHORT*)values++); - if (format & xAdvance) - glyph_pos->x_advance += _hb_16dot16_mul_trunc (x_scale, *(SHORT*)values++); - if (format & yAdvance) - glyph_pos->y_advance += _hb_16dot16_mul_trunc (y_scale, *(SHORT*)values++); - - x_ppem = context->font->x_ppem; - y_ppem = context->font->y_ppem; - /* pixel -> fractional pixel */ - if (format & xPlaDevice) { - if (x_ppem) - glyph_pos->x_pos += (base+*(OffsetTo<Device>*)values++).get_delta (x_ppem) << 6; - else - values++; - } - if (format & yPlaDevice) { - if (y_ppem) - glyph_pos->y_pos += (base+*(OffsetTo<Device>*)values++).get_delta (y_ppem) << 6; - else - values++; - } - if (format & xAdvDevice) { - if (x_ppem) - glyph_pos->x_advance += (base+*(OffsetTo<Device>*)values++).get_delta (x_ppem) << 6; - else - values++; - } - if (format & yAdvDevice) { - if (y_ppem) - glyph_pos->y_advance += (base+*(OffsetTo<Device>*)values++).get_delta (y_ppem) << 6; - else - values++; - } - } -}; -ASSERT_SIZE (ValueFormat, 2); - - -struct AnchorFormat1 -{ - friend struct Anchor; - - private: - inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id, - hb_position_t *x, hb_position_t *y) const - { - *x = _hb_16dot16_mul_trunc (context->font->x_scale, xCoordinate); - *y = _hb_16dot16_mul_trunc (context->font->y_scale, yCoordinate); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF (); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - SHORT xCoordinate; /* Horizontal value--in design units */ - SHORT yCoordinate; /* Vertical value--in design units */ -}; -ASSERT_SIZE (AnchorFormat1, 6); - -struct AnchorFormat2 -{ - friend struct Anchor; - - private: - inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id, - hb_position_t *x, hb_position_t *y) const - { - /* TODO Contour */ - *x = _hb_16dot16_mul_trunc (context->font->x_scale, xCoordinate); - *y = _hb_16dot16_mul_trunc (context->font->y_scale, yCoordinate); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF (); - } - - private: - USHORT format; /* Format identifier--format = 2 */ - SHORT xCoordinate; /* Horizontal value--in design units */ - SHORT yCoordinate; /* Vertical value--in design units */ - USHORT anchorPoint; /* Index to glyph contour point */ -}; -ASSERT_SIZE (AnchorFormat2, 8); - -struct AnchorFormat3 -{ - friend struct Anchor; - - private: - inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id, - hb_position_t *x, hb_position_t *y) const - { - *x = _hb_16dot16_mul_trunc (context->font->x_scale, xCoordinate); - *y = _hb_16dot16_mul_trunc (context->font->y_scale, yCoordinate); - - if (context->font->x_ppem) - *x += (this+xDeviceTable).get_delta (context->font->x_ppem) << 6; - if (context->font->y_ppem) - *y += (this+yDeviceTable).get_delta (context->font->y_ppem) << 6; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF () && SANITIZE_THIS2 (xDeviceTable, yDeviceTable); - } - - private: - USHORT format; /* Format identifier--format = 3 */ - SHORT xCoordinate; /* Horizontal value--in design units */ - SHORT yCoordinate; /* Vertical value--in design units */ - OffsetTo<Device> - xDeviceTable; /* Offset to Device table for X - * coordinate-- from beginning of - * Anchor table (may be NULL) */ - OffsetTo<Device> - yDeviceTable; /* Offset to Device table for Y - * coordinate-- from beginning of - * Anchor table (may be NULL) */ -}; -ASSERT_SIZE (AnchorFormat3, 10); - -struct Anchor -{ - inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id, - hb_position_t *x, hb_position_t *y) const - { - *x = *y = 0; - switch (u.format) { - case 1: u.format1->get_anchor (context, glyph_id, x, y); return; - case 2: u.format2->get_anchor (context, glyph_id, x, y); return; - case 3: u.format3->get_anchor (context, glyph_id, x, y); return; - default: return; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - case 2: return u.format2->sanitize (SANITIZE_ARG); - case 3: return u.format3->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - AnchorFormat1 format1[]; - AnchorFormat2 format2[]; - AnchorFormat3 format3[]; - } u; -}; -ASSERT_SIZE (Anchor, 2); - - -struct AnchorMatrix -{ - inline const Anchor& get_anchor (unsigned int row, unsigned int col, unsigned int cols) const { - if (HB_UNLIKELY (row >= rows || col >= cols)) return Null(Anchor); - return this+matrix[row * cols + col]; - } - - inline bool sanitize (SANITIZE_ARG_DEF, unsigned int cols) { - TRACE_SANITIZE (); - if (!SANITIZE_SELF ()) return false; - unsigned int count = rows * cols; - if (!SANITIZE_ARRAY (matrix, sizeof (matrix[0]), count)) return false; - for (unsigned int i = 0; i < count; i++) - if (!SANITIZE_THIS (matrix[i])) return false; - return true; - } - - USHORT rows; /* Number of rows */ - private: - OffsetTo<Anchor> - matrix[]; /* Matrix of offsets to Anchor tables-- - * from beginning of AnchorMatrix table */ -}; -ASSERT_SIZE (AnchorMatrix, 2); - - -struct MarkRecord -{ - friend struct MarkArray; - - inline bool sanitize (SANITIZE_ARG_DEF, const void *base) { - TRACE_SANITIZE (); - return SANITIZE_SELF () && SANITIZE_BASE (markAnchor, base); - } - - private: - USHORT klass; /* Class defined for this mark */ - OffsetTo<Anchor> - markAnchor; /* Offset to Anchor table--from - * beginning of MarkArray table */ -}; -ASSERT_SIZE (MarkRecord, 4); - -struct MarkArray -{ - inline bool apply (APPLY_ARG_DEF, - unsigned int mark_index, unsigned int glyph_index, - const AnchorMatrix &anchors, unsigned int class_count, - unsigned int glyph_pos) const - { - TRACE_APPLY (); - const MarkRecord &record = markRecord[mark_index]; - unsigned int mark_class = record.klass; - - const Anchor& mark_anchor = this + record.markAnchor; - const Anchor& glyph_anchor = anchors.get_anchor (glyph_index, mark_class, class_count); - - hb_position_t mark_x, mark_y, base_x, base_y; - - mark_anchor.get_anchor (context, IN_CURGLYPH (), &mark_x, &mark_y); - glyph_anchor.get_anchor (context, IN_GLYPH (glyph_pos), &base_x, &base_y); - - hb_internal_glyph_position_t *o = POSITION (buffer->in_pos); - o->x_pos = base_x - mark_x; - o->y_pos = base_y - mark_y; - o->x_advance = 0; - o->y_advance = 0; - o->back = buffer->in_pos - glyph_pos; - - buffer->in_pos++; - return true; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS (markRecord); - } - - private: - ArrayOf<MarkRecord> - markRecord; /* Array of MarkRecords--in Coverage order */ -}; -ASSERT_SIZE (MarkArray, 2); - - -/* Lookups */ - -struct SinglePosFormat1 -{ - friend struct SinglePos; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - unsigned int index = (this+coverage) (IN_CURGLYPH ()); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - valueFormat.apply_value (context, CONST_CHARP(this), values, CURPOSITION ()); - - buffer->in_pos++; - return true; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF () && SANITIZE_THIS (coverage) && - SANITIZE_MEM (values, valueFormat.get_size ()); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of subtable */ - ValueFormat valueFormat; /* Defines the types of data in the - * ValueRecord */ - ValueRecord values; /* Defines positioning - * value(s)--applied to all glyphs in - * the Coverage table */ -}; -ASSERT_SIZE (SinglePosFormat1, 6); - -struct SinglePosFormat2 -{ - friend struct SinglePos; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - unsigned int index = (this+coverage) (IN_CURGLYPH ()); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - if (HB_LIKELY (index >= valueCount)) - return false; - - valueFormat.apply_value (context, CONST_CHARP(this), - values + index * valueFormat.get_len (), - CURPOSITION ()); - - buffer->in_pos++; - return true; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF () && SANITIZE_THIS (coverage) && - SANITIZE_MEM (values, valueFormat.get_size () * valueCount); - } - - private: - USHORT format; /* Format identifier--format = 2 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of subtable */ - ValueFormat valueFormat; /* Defines the types of data in the - * ValueRecord */ - USHORT valueCount; /* Number of ValueRecords */ - ValueRecord values; /* Array of ValueRecords--positioning - * values applied to glyphs */ -}; -ASSERT_SIZE (SinglePosFormat2, 8); - -struct SinglePos -{ - friend struct PosLookupSubTable; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - switch (u.format) { - case 1: return u.format1->apply (APPLY_ARG); - case 2: return u.format2->apply (APPLY_ARG); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - case 2: return u.format2->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - SinglePosFormat1 format1[]; - SinglePosFormat2 format2[]; - } u; -}; -ASSERT_SIZE (SinglePos, 2); - - -struct PairValueRecord -{ - friend struct PairPosFormat1; - - private: - GlyphID secondGlyph; /* GlyphID of second glyph in the - * pair--first glyph is listed in the - * Coverage table */ - ValueRecord values; /* Positioning data for the first glyph - * followed by for second glyph */ -}; -ASSERT_SIZE (PairValueRecord, 2); - -struct PairSet -{ - friend struct PairPosFormat1; - - inline bool sanitize (SANITIZE_ARG_DEF, unsigned int format_len) { - TRACE_SANITIZE (); - if (!SANITIZE_SELF ()) return false; - unsigned int count = (1 + format_len) * len; - return SANITIZE_MEM (array, sizeof (array[0]) * count); - } - - private: - USHORT len; /* Number of PairValueRecords */ - PairValueRecord - array[]; /* Array of PairValueRecords--ordered - * by GlyphID of the second glyph */ -}; -ASSERT_SIZE (PairSet, 2); - -struct PairPosFormat1 -{ - friend struct PairPos; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length); - if (HB_UNLIKELY (buffer->in_pos + 2 > end)) - return false; - - unsigned int index = (this+coverage) (IN_CURGLYPH ()); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - unsigned int j = buffer->in_pos + 1; - while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, NULL)) - { - if (HB_UNLIKELY (j == end)) - return false; - j++; - } - - const PairSet &pair_set = this+pairSet[index]; - - unsigned int len1 = valueFormat1.get_len (); - unsigned int len2 = valueFormat2.get_len (); - unsigned int record_len = 1 + len1 + len2; - - unsigned int count = pair_set.len; - const PairValueRecord *record = pair_set.array; - for (unsigned int i = 0; i < count; i++) - { - if (IN_GLYPH (j) == record->secondGlyph) - { - valueFormat1.apply_value (context, CONST_CHARP(this), record->values, CURPOSITION ()); - valueFormat2.apply_value (context, CONST_CHARP(this), record->values + len1, POSITION (j)); - if (len2) - j++; - buffer->in_pos = j; - return true; - } - record += record_len; - } - - return false; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF () && SANITIZE_THIS (coverage) && - pairSet.sanitize (SANITIZE_ARG, CONST_CHARP(this), - valueFormat1.get_len () + valueFormat2.get_len ()); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of subtable */ - ValueFormat valueFormat1; /* Defines the types of data in - * ValueRecord1--for the first glyph - * in the pair--may be zero (0) */ - ValueFormat valueFormat2; /* Defines the types of data in - * ValueRecord2--for the second glyph - * in the pair--may be zero (0) */ - OffsetArrayOf<PairSet> - pairSet; /* Array of PairSet tables - * ordered by Coverage Index */ -}; -ASSERT_SIZE (PairPosFormat1, 10); - -struct PairPosFormat2 -{ - friend struct PairPos; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length); - if (HB_UNLIKELY (buffer->in_pos + 2 > end)) - return false; - - unsigned int index = (this+coverage) (IN_CURGLYPH ()); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - unsigned int j = buffer->in_pos + 1; - while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, NULL)) - { - if (HB_UNLIKELY (j == end)) - return false; - j++; - } - - unsigned int len1 = valueFormat1.get_len (); - unsigned int len2 = valueFormat2.get_len (); - unsigned int record_len = len1 + len2; - - unsigned int klass1 = (this+classDef1) (IN_CURGLYPH ()); - unsigned int klass2 = (this+classDef2) (IN_GLYPH (j)); - if (HB_UNLIKELY (klass1 >= class1Count || klass2 >= class2Count)) - return false; - - const Value *v = values + record_len * (klass1 * class2Count + klass2); - valueFormat1.apply_value (context, CONST_CHARP(this), v, CURPOSITION ()); - valueFormat2.apply_value (context, CONST_CHARP(this), v + len1, POSITION (j)); - - if (len2) - j++; - buffer->in_pos = j; - - return true; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!(SANITIZE_SELF () && SANITIZE_THIS (coverage) && - SANITIZE_THIS2 (classDef1, classDef2))) return false; - - unsigned int record_size =valueFormat1.get_size () + valueFormat2.get_size (); - unsigned int len = class1Count * class2Count; - return SANITIZE_ARRAY (values, record_size, len); - } - - private: - USHORT format; /* Format identifier--format = 2 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of subtable */ - ValueFormat valueFormat1; /* ValueRecord definition--for the - * first glyph of the pair--may be zero - * (0) */ - ValueFormat valueFormat2; /* ValueRecord definition--for the - * second glyph of the pair--may be - * zero (0) */ - OffsetTo<ClassDef> - classDef1; /* Offset to ClassDef table--from - * beginning of PairPos subtable--for - * the first glyph of the pair */ - OffsetTo<ClassDef> - classDef2; /* Offset to ClassDef table--from - * beginning of PairPos subtable--for - * the second glyph of the pair */ - USHORT class1Count; /* Number of classes in ClassDef1 - * table--includes Class0 */ - USHORT class2Count; /* Number of classes in ClassDef2 - * table--includes Class0 */ - ValueRecord values; /* Matrix of value pairs: - * class1-major, class2-minor, - * Each entry has value1 and value2 */ -}; -ASSERT_SIZE (PairPosFormat2, 16); - -struct PairPos -{ - friend struct PosLookupSubTable; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - switch (u.format) { - case 1: return u.format1->apply (APPLY_ARG); - case 2: return u.format2->apply (APPLY_ARG); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - case 2: return u.format2->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - PairPosFormat1 format1[]; - PairPosFormat2 format2[]; - } u; -}; -ASSERT_SIZE (PairPos, 2); - - -struct EntryExitRecord -{ - inline bool sanitize (SANITIZE_ARG_DEF, const void *base) { - TRACE_SANITIZE (); - return SANITIZE_BASE2 (entryAnchor, exitAnchor, base); - } - - OffsetTo<Anchor> - entryAnchor; /* Offset to EntryAnchor table--from - * beginning of CursivePos - * subtable--may be NULL */ - OffsetTo<Anchor> - exitAnchor; /* Offset to ExitAnchor table--from - * beginning of CursivePos - * subtable--may be NULL */ -}; -ASSERT_SIZE (EntryExitRecord, 4); - -struct CursivePosFormat1 -{ - friend struct CursivePos; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - /* Now comes the messiest part of the whole OpenType - specification. At first glance, cursive connections seem easy - to understand, but there are pitfalls! The reason is that - the specs don't mention how to compute the advance values - resp. glyph offsets. I was told it would be an omission, to - be fixed in the next OpenType version... Again many thanks to - Andrei Burago <andreib@microsoft.com> for clarifications. - - Consider the following example: - - | xadv1 | - +---------+ - | | - +-----+--+ 1 | - | | .| | - | 0+--+------+ - | 2 | - | | - 0+--------+ - | xadv2 | - - glyph1: advance width = 12 - anchor point = (3,1) - - glyph2: advance width = 11 - anchor point = (9,4) - - LSB is 1 for both glyphs (so the boxes drawn above are glyph - bboxes). Writing direction is R2L; `0' denotes the glyph's - coordinate origin. - - Now the surprising part: The advance width of the *left* glyph - (resp. of the *bottom* glyph) will be modified, no matter - whether the writing direction is L2R or R2L (resp. T2B or - B2T)! This assymetry is caused by the fact that the glyph's - coordinate origin is always the lower left corner for all - writing directions. - - Continuing the above example, we can compute the new - (horizontal) advance width of glyph2 as - - 9 - 3 = 6 , - - and the new vertical offset of glyph2 as - - 1 - 4 = -3 . - - - Vertical writing direction is far more complicated: - - a) Assuming that we recompute the advance height of the lower glyph: - - -- - +---------+ - -- | | - +-----+--+ 1 | yadv1 - | | .| | - yadv2 | 0+--+------+ -- BSB1 -- - | 2 | -- -- y_offset - | | - BSB2 -- 0+--------+ -- - -- -- - - glyph1: advance height = 6 - anchor point = (3,1) - - glyph2: advance height = 7 - anchor point = (9,4) - - TSB is 1 for both glyphs; writing direction is T2B. - - - BSB1 = yadv1 - (TSB1 + ymax1) - BSB2 = yadv2 - (TSB2 + ymax2) - y_offset = y2 - y1 - - vertical advance width of glyph2 - = y_offset + BSB2 - BSB1 - = (y2 - y1) + (yadv2 - (TSB2 + ymax2)) - (yadv1 - (TSB1 + ymax1)) - = y2 - y1 + yadv2 - TSB2 - ymax2 - (yadv1 - TSB1 - ymax1) - = y2 - y1 + yadv2 - TSB2 - ymax2 - yadv1 + TSB1 + ymax1 - - - b) Assuming that we recompute the advance height of the upper glyph: - - -- -- - +---------+ -- TSB1 - -- -- | | - TSB2 -- +-----+--+ 1 | yadv1 ymax1 - | | .| | - yadv2 | 0+--+------+ -- -- - ymax2 | 2 | -- y_offset - | | - -- 0+--------+ -- - -- - - glyph1: advance height = 6 - anchor point = (3,1) - - glyph2: advance height = 7 - anchor point = (9,4) - - TSB is 1 for both glyphs; writing direction is T2B. - - y_offset = y2 - y1 - - vertical advance width of glyph2 - = TSB1 + ymax1 + y_offset - (TSB2 + ymax2) - = TSB1 + ymax1 + y2 - y1 - TSB2 - ymax2 - - - Comparing a) with b) shows that b) is easier to compute. I'll wait - for a reply from Andrei to see what should really be implemented... - - Since horizontal advance widths or vertical advance heights - can be used alone but not together, no ambiguity occurs. */ - - struct hb_ot_layout_context_t::info_t::gpos_t *gpi = &context->info.gpos; - hb_codepoint_t last_pos = gpi->last; - gpi->last = HB_OT_LAYOUT_GPOS_NO_LAST; - - /* We don't handle mark glyphs here. */ - if (property == HB_OT_LAYOUT_GLYPH_CLASS_MARK) - return false; - - unsigned int index = (this+coverage) (IN_CURGLYPH ()); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - const EntryExitRecord &record = entryExitRecord[index]; - - if (last_pos == HB_OT_LAYOUT_GPOS_NO_LAST || !record.entryAnchor) - goto end; - - hb_position_t entry_x, entry_y; - (this+record.entryAnchor).get_anchor (context, IN_CURGLYPH (), &entry_x, &entry_y); - - /* TODO vertical */ - - if (buffer->direction == HB_DIRECTION_RTL) - { - POSITION (buffer->in_pos)->x_advance = entry_x - gpi->anchor_x; - POSITION (buffer->in_pos)->new_advance = TRUE; - } - else - { - POSITION (last_pos)->x_advance = gpi->anchor_x - entry_x; - POSITION (last_pos)->new_advance = TRUE; - } - - if (lookup_flag & LookupFlag::RightToLeft) - { - POSITION (last_pos)->cursive_chain = last_pos - buffer->in_pos; - POSITION (last_pos)->y_pos = entry_y - gpi->anchor_y; - } - else - { - POSITION (buffer->in_pos)->cursive_chain = buffer->in_pos - last_pos; - POSITION (buffer->in_pos)->y_pos = gpi->anchor_y - entry_y; - } - - end: - if (record.exitAnchor) - { - gpi->last = buffer->in_pos; - (this+record.exitAnchor).get_anchor (context, IN_CURGLYPH (), &gpi->anchor_x, &gpi->anchor_y); - } - - buffer->in_pos++; - return true; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS2 (coverage, entryExitRecord); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of subtable */ - ArrayOf<EntryExitRecord> - entryExitRecord; /* Array of EntryExit records--in - * Coverage Index order */ -}; -ASSERT_SIZE (CursivePosFormat1, 6); - -struct CursivePos -{ - friend struct PosLookupSubTable; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - switch (u.format) { - case 1: return u.format1->apply (APPLY_ARG); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - CursivePosFormat1 format1[]; - } u; -}; -ASSERT_SIZE (CursivePos, 2); - - -typedef AnchorMatrix BaseArray; /* base-major-- - * in order of BaseCoverage Index--, - * mark-minor-- - * ordered by class--zero-based. */ -ASSERT_SIZE (BaseArray, 2); - -struct MarkBasePosFormat1 -{ - friend struct MarkBasePos; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - unsigned int mark_index = (this+markCoverage) (IN_CURGLYPH ()); - if (HB_LIKELY (mark_index == NOT_COVERED)) - return false; - - /* now we search backwards for a non-mark glyph */ - unsigned int j = buffer->in_pos; - do - { - if (HB_UNLIKELY (!j)) - return false; - j--; - } while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property)); - -#if 0 - /* The following assertion is too strong. */ - if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH)) - return false; -#endif - - unsigned int base_index = (this+baseCoverage) (IN_GLYPH (j)); - if (base_index == NOT_COVERED) - return false; - - return (this+markArray).apply (APPLY_ARG, mark_index, base_index, this+baseArray, classCount, j); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF () && SANITIZE_THIS2 (markCoverage, baseCoverage) && - SANITIZE_THIS (markArray) && baseArray.sanitize (SANITIZE_ARG, CONST_CHARP(this), classCount); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - OffsetTo<Coverage> - markCoverage; /* Offset to MarkCoverage table--from - * beginning of MarkBasePos subtable */ - OffsetTo<Coverage> - baseCoverage; /* Offset to BaseCoverage table--from - * beginning of MarkBasePos subtable */ - USHORT classCount; /* Number of classes defined for marks */ - OffsetTo<MarkArray> - markArray; /* Offset to MarkArray table--from - * beginning of MarkBasePos subtable */ - OffsetTo<BaseArray> - baseArray; /* Offset to BaseArray table--from - * beginning of MarkBasePos subtable */ -}; -ASSERT_SIZE (MarkBasePosFormat1, 12); - -struct MarkBasePos -{ - friend struct PosLookupSubTable; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - switch (u.format) { - case 1: return u.format1->apply (APPLY_ARG); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - MarkBasePosFormat1 format1[]; - } u; -}; -ASSERT_SIZE (MarkBasePos, 2); - - -typedef AnchorMatrix LigatureAttach; /* component-major-- - * in order of writing direction--, - * mark-minor-- - * ordered by class--zero-based. */ -ASSERT_SIZE (LigatureAttach, 2); - -typedef OffsetListOf<LigatureAttach> LigatureArray; - /* Array of LigatureAttach - * tables ordered by - * LigatureCoverage Index */ -ASSERT_SIZE (LigatureArray, 2); - -struct MarkLigPosFormat1 -{ - friend struct MarkLigPos; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - unsigned int mark_index = (this+markCoverage) (IN_CURGLYPH ()); - if (HB_LIKELY (mark_index == NOT_COVERED)) - return false; - - /* now we search backwards for a non-mark glyph */ - unsigned int j = buffer->in_pos; - do - { - if (HB_UNLIKELY (!j)) - return false; - j--; - } while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), LookupFlag::IgnoreMarks, &property)); - -#if 0 - /* The following assertion is too strong. */ - if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)) - return false; -#endif - - unsigned int lig_index = (this+ligatureCoverage) (IN_GLYPH (j)); - if (lig_index == NOT_COVERED) - return false; - - const LigatureArray& lig_array = this+ligatureArray; - const LigatureAttach& lig_attach = lig_array[lig_index]; - - /* Find component to attach to */ - unsigned int comp_count = lig_attach.rows; - if (HB_UNLIKELY (!comp_count)) - return false; - unsigned int comp_index; - /* We must now check whether the ligature ID of the current mark glyph - * is identical to the ligature ID of the found ligature. If yes, we - * can directly use the component index. If not, we attach the mark - * glyph to the last component of the ligature. */ - if (IN_LIGID (j) == IN_LIGID (buffer->in_pos)) - { - comp_index = IN_COMPONENT (buffer->in_pos); - if (comp_index >= comp_count) - comp_index = comp_count - 1; - } - else - comp_index = comp_count - 1; - - return (this+markArray).apply (APPLY_ARG, mark_index, comp_index, lig_attach, classCount, j); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF () && - SANITIZE_THIS2 (markCoverage, ligatureCoverage) && - SANITIZE_THIS (markArray) && ligatureArray.sanitize (SANITIZE_ARG, CONST_CHARP(this), classCount); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - OffsetTo<Coverage> - markCoverage; /* Offset to Mark Coverage table--from - * beginning of MarkLigPos subtable */ - OffsetTo<Coverage> - ligatureCoverage; /* Offset to Ligature Coverage - * table--from beginning of MarkLigPos - * subtable */ - USHORT classCount; /* Number of defined mark classes */ - OffsetTo<MarkArray> - markArray; /* Offset to MarkArray table--from - * beginning of MarkLigPos subtable */ - OffsetTo<LigatureArray> - ligatureArray; /* Offset to LigatureArray table--from - * beginning of MarkLigPos subtable */ -}; -ASSERT_SIZE (MarkLigPosFormat1, 12); - -struct MarkLigPos -{ - friend struct PosLookupSubTable; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - switch (u.format) { - case 1: return u.format1->apply (APPLY_ARG); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - MarkLigPosFormat1 format1[]; - } u; -}; -ASSERT_SIZE (MarkLigPos, 2); - - -typedef AnchorMatrix Mark2Array; /* mark2-major-- - * in order of Mark2Coverage Index--, - * mark1-minor-- - * ordered by class--zero-based. */ -ASSERT_SIZE (Mark2Array, 2); - -struct MarkMarkPosFormat1 -{ - friend struct MarkMarkPos; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - unsigned int mark1_index = (this+mark1Coverage) (IN_CURGLYPH ()); - if (HB_LIKELY (mark1_index == NOT_COVERED)) - return false; - - /* now we search backwards for a suitable mark glyph until a non-mark glyph */ - unsigned int j = buffer->in_pos; - do - { - if (HB_UNLIKELY (!j)) - return false; - j--; - } while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, &property)); - - if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)) - return false; - - /* Two marks match only if they belong to the same base, or same component - * of the same ligature. */ - if (IN_LIGID (j) != IN_LIGID (buffer->in_pos) || - IN_COMPONENT (j) != IN_COMPONENT (buffer->in_pos)) - return false; - - unsigned int mark2_index = (this+mark2Coverage) (IN_GLYPH (j)); - if (mark2_index == NOT_COVERED) - return false; - - return (this+mark1Array).apply (APPLY_ARG, mark1_index, mark2_index, this+mark2Array, classCount, j); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF () && SANITIZE_THIS2 (mark1Coverage, mark2Coverage) && - SANITIZE_THIS (mark1Array) && mark2Array.sanitize (SANITIZE_ARG, CONST_CHARP(this), classCount); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - OffsetTo<Coverage> - mark1Coverage; /* Offset to Combining Mark1 Coverage - * table--from beginning of MarkMarkPos - * subtable */ - OffsetTo<Coverage> - mark2Coverage; /* Offset to Combining Mark2 Coverage - * table--from beginning of MarkMarkPos - * subtable */ - USHORT classCount; /* Number of defined mark classes */ - OffsetTo<MarkArray> - mark1Array; /* Offset to Mark1Array table--from - * beginning of MarkMarkPos subtable */ - OffsetTo<Mark2Array> - mark2Array; /* Offset to Mark2Array table--from - * beginning of MarkMarkPos subtable */ -}; -ASSERT_SIZE (MarkMarkPosFormat1, 12); - -struct MarkMarkPos -{ - friend struct PosLookupSubTable; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - switch (u.format) { - case 1: return u.format1->apply (APPLY_ARG); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - MarkMarkPosFormat1 format1[]; - } u; -}; -ASSERT_SIZE (MarkMarkPos, 2); - - -static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index); - -struct ContextPos : Context -{ - friend struct PosLookupSubTable; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - return Context::apply (APPLY_ARG, position_lookup); - } -}; -ASSERT_SIZE (ContextPos, 2); - -struct ChainContextPos : ChainContext -{ - friend struct PosLookupSubTable; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - return ChainContext::apply (APPLY_ARG, position_lookup); - } -}; -ASSERT_SIZE (ChainContextPos, 2); - - -struct ExtensionPos : Extension -{ - friend struct PosLookupSubTable; - - private: - inline const struct PosLookupSubTable& get_subtable (void) const - { return CONST_CAST (PosLookupSubTable, Extension::get_subtable (), 0); } - - inline bool apply (APPLY_ARG_DEF) const; - - inline bool sanitize (SANITIZE_ARG_DEF); -}; -ASSERT_SIZE (ExtensionPos, 2); - - - -/* - * PosLookup - */ - - -struct PosLookupSubTable -{ - friend struct PosLookup; - - enum { - Single = 1, - Pair = 2, - Cursive = 3, - MarkBase = 4, - MarkLig = 5, - MarkMark = 6, - Context = 7, - ChainContext = 8, - Extension = 9 - }; - - inline bool apply (APPLY_ARG_DEF, unsigned int lookup_type) const - { - TRACE_APPLY (); - switch (lookup_type) { - case Single: return u.single->apply (APPLY_ARG); - case Pair: return u.pair->apply (APPLY_ARG); - case Cursive: return u.cursive->apply (APPLY_ARG); - case MarkBase: return u.markBase->apply (APPLY_ARG); - case MarkLig: return u.markLig->apply (APPLY_ARG); - case MarkMark: return u.markMark->apply (APPLY_ARG); - case Context: return u.context->apply (APPLY_ARG); - case ChainContext: return u.chainContext->apply (APPLY_ARG); - case Extension: return u.extension->apply (APPLY_ARG); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case Single: return u.single->sanitize (SANITIZE_ARG); - case Pair: return u.pair->sanitize (SANITIZE_ARG); - case Cursive: return u.cursive->sanitize (SANITIZE_ARG); - case MarkBase: return u.markBase->sanitize (SANITIZE_ARG); - case MarkLig: return u.markLig->sanitize (SANITIZE_ARG); - case MarkMark: return u.markMark->sanitize (SANITIZE_ARG); - case Context: return u.context->sanitize (SANITIZE_ARG); - case ChainContext: return u.chainContext->sanitize (SANITIZE_ARG); - case Extension: return u.extension->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; - SinglePos single[]; - PairPos pair[]; - CursivePos cursive[]; - MarkBasePos markBase[]; - MarkLigPos markLig[]; - MarkMarkPos markMark[]; - ContextPos context[]; - ChainContextPos chainContext[]; - ExtensionPos extension[]; - } u; -}; -ASSERT_SIZE (PosLookupSubTable, 2); - - -struct PosLookup : Lookup -{ - inline const PosLookupSubTable& get_subtable (unsigned int i) const - { return (const PosLookupSubTable&) Lookup::get_subtable (i); } - - /* Like get_type(), but looks through extension lookups. - * Never returns Extension */ - inline unsigned int get_effective_type (void) const - { - unsigned int type = get_type (); - - if (HB_UNLIKELY (type == PosLookupSubTable::Extension)) - { - unsigned int count = get_subtable_count (); - type = get_subtable(0).u.extension->get_type (); - /* The spec says all subtables should have the same type. - * This is specially important if one has a reverse type! */ - for (unsigned int i = 1; i < count; i++) - if (get_subtable(i).u.extension->get_type () != type) - return 0; - } - - return type; - } - - inline bool apply_once (hb_ot_layout_context_t *context, - hb_buffer_t *buffer, - unsigned int context_length, - unsigned int nesting_level_left) const - { - unsigned int lookup_type = get_type (); - unsigned int lookup_flag = get_flag (); - unsigned int property; - - if (!_hb_ot_layout_check_glyph_property (context->face, IN_CURINFO (), lookup_flag, &property)) - return false; - - for (unsigned int i = 0; i < get_subtable_count (); i++) - if (get_subtable (i).apply (APPLY_ARG_INIT, lookup_type)) - return true; - - return false; - } - - inline bool apply_string (hb_ot_layout_context_t *context, - hb_buffer_t *buffer, - hb_mask_t mask) const - { - bool ret = false; - - if (HB_UNLIKELY (!buffer->in_length)) - return false; - - context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */ - - buffer->in_pos = 0; - while (buffer->in_pos < buffer->in_length) - { - bool done; - if (~IN_MASK (buffer->in_pos) & mask) - { - done = apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL); - ret |= done; - } - else - { - done = false; - /* Contrary to properties defined in GDEF, user-defined properties - will always stop a possible cursive positioning. */ - context->info.gpos.last = HB_OT_LAYOUT_GPOS_NO_LAST; - } - - if (!done) - buffer->in_pos++; - } - - return ret; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!Lookup::sanitize (SANITIZE_ARG)) return false; - OffsetArrayOf<PosLookupSubTable> &list = (OffsetArrayOf<PosLookupSubTable> &) subTable; - return SANITIZE_THIS (list); - } -}; -ASSERT_SIZE (PosLookup, 6); - -typedef OffsetListOf<PosLookup> PosLookupList; -ASSERT_SIZE (PosLookupList, 2); - -/* - * GPOS - */ - -struct GPOS : GSUBGPOS -{ - static const hb_tag_t Tag = HB_OT_TAG_GPOS; - - static inline const GPOS& get_for_data (const char *data) - { return (const GPOS&) GSUBGPOS::get_for_data (data); } - - inline const PosLookup& get_lookup (unsigned int i) const - { return (const PosLookup&) GSUBGPOS::get_lookup (i); } - - inline bool position_lookup (hb_ot_layout_context_t *context, - hb_buffer_t *buffer, - unsigned int lookup_index, - hb_mask_t mask) const - { return get_lookup (lookup_index).apply_string (context, buffer, mask); } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!GSUBGPOS::sanitize (SANITIZE_ARG)) return false; - OffsetTo<PosLookupList> &list = CAST(OffsetTo<PosLookupList>, lookupList, 0); - return SANITIZE_THIS (list); - } -}; -ASSERT_SIZE (GPOS, 10); - - -/* Out-of-class implementation for methods recursing */ - -inline bool ExtensionPos::apply (APPLY_ARG_DEF) const -{ - TRACE_APPLY (); - unsigned int lookup_type = get_type (); - - if (HB_UNLIKELY (lookup_type == PosLookupSubTable::Extension)) - return false; - - return get_subtable ().apply (APPLY_ARG, lookup_type); -} - -inline bool ExtensionPos::sanitize (SANITIZE_ARG_DEF) -{ - TRACE_SANITIZE (); - return Extension::sanitize (SANITIZE_ARG) && - (&(Extension::get_subtable ()) == &Null(LookupSubTable) || - get_type () == PosLookupSubTable::Extension || - DECONST_CAST (PosLookupSubTable, get_subtable (), 0).sanitize (SANITIZE_ARG)); -} - -static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index) -{ - const GPOS &gpos = *(context->face->ot_layout.gpos); - const PosLookup &l = gpos.get_lookup (lookup_index); - - if (HB_UNLIKELY (nesting_level_left == 0)) - return false; - nesting_level_left--; - - if (HB_UNLIKELY (context_length < 1)) - return false; - - return l.apply_once (context, buffer, context_length, nesting_level_left); -} - - -#endif /* HB_OT_LAYOUT_GPOS_PRIVATE_HH */ diff --git a/pango/opentype/hb-ot-layout-gsub-private.hh b/pango/opentype/hb-ot-layout-gsub-private.hh deleted file mode 100644 index bd29cf74..00000000 --- a/pango/opentype/hb-ot-layout-gsub-private.hh +++ /dev/null @@ -1,923 +0,0 @@ -/* - * Copyright (C) 2007,2008,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_OT_LAYOUT_GSUB_PRIVATE_HH -#define HB_OT_LAYOUT_GSUB_PRIVATE_HH - -#include "hb-ot-layout-gsubgpos-private.hh" - - -struct SingleSubstFormat1 -{ - friend struct SingleSubst; - - private: - - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - hb_codepoint_t glyph_id = IN_CURGLYPH (); - unsigned int index = (this+coverage) (glyph_id); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - glyph_id += deltaGlyphID; - _hb_buffer_replace_glyph (buffer, glyph_id); - - /* We inherit the old glyph class to the substituted glyph */ - if (_hb_ot_layout_has_new_glyph_classes (context->face)) - _hb_ot_layout_set_glyph_property (context->face, glyph_id, property); - - return true; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS (coverage) && SANITIZE (deltaGlyphID); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of Substitution table */ - SHORT deltaGlyphID; /* Add to original GlyphID to get - * substitute GlyphID */ -}; -ASSERT_SIZE (SingleSubstFormat1, 6); - -struct SingleSubstFormat2 -{ - friend struct SingleSubst; - - private: - - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - hb_codepoint_t glyph_id = IN_CURGLYPH (); - unsigned int index = (this+coverage) (glyph_id); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - if (HB_UNLIKELY (index >= substitute.len)) - return false; - - glyph_id = substitute[index]; - _hb_buffer_replace_glyph (buffer, glyph_id); - - /* We inherit the old glyph class to the substituted glyph */ - if (_hb_ot_layout_has_new_glyph_classes (context->face)) - _hb_ot_layout_set_glyph_property (context->face, glyph_id, property); - - return true; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS (coverage) && SANITIZE (substitute); - } - - private: - USHORT format; /* Format identifier--format = 2 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of Substitution table */ - ArrayOf<GlyphID> - substitute; /* Array of substitute - * GlyphIDs--ordered by Coverage Index */ -}; -ASSERT_SIZE (SingleSubstFormat2, 6); - -struct SingleSubst -{ - friend struct SubstLookupSubTable; - - private: - - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - switch (u.format) { - case 1: return u.format1->apply (APPLY_ARG); - case 2: return u.format2->apply (APPLY_ARG); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - case 2: return u.format2->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - SingleSubstFormat1 format1[]; - SingleSubstFormat2 format2[]; - } u; -}; -ASSERT_SIZE (SingleSubst, 2); - - -struct Sequence -{ - friend struct MultipleSubstFormat1; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - if (HB_UNLIKELY (!substitute.len)) - return false; - - _hb_buffer_add_output_glyphs (buffer, 1, - substitute.len, (const uint16_t *) substitute.array, - 0xFFFF, 0xFFFF); - - /* This is a guess only ... */ - if (_hb_ot_layout_has_new_glyph_classes (context->face)) - { - if (property == HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE) - property = HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH; - - unsigned int count = substitute.len; - for (unsigned int n = 0; n < count; n++) - _hb_ot_layout_set_glyph_property (context->face, substitute[n], property); - } - - return true; - } - - public: - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE (substitute); - } - - private: - ArrayOf<GlyphID> - substitute; /* String of GlyphIDs to substitute */ -}; -ASSERT_SIZE (Sequence, 2); - -struct MultipleSubstFormat1 -{ - friend struct MultipleSubst; - - private: - - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - - unsigned int index = (this+coverage) (IN_CURGLYPH ()); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - return (this+sequence[index]).apply (APPLY_ARG); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS2 (coverage, sequence); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of Substitution table */ - OffsetArrayOf<Sequence> - sequence; /* Array of Sequence tables - * ordered by Coverage Index */ -}; -ASSERT_SIZE (MultipleSubstFormat1, 6); - -struct MultipleSubst -{ - friend struct SubstLookupSubTable; - - private: - - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - switch (u.format) { - case 1: return u.format1->apply (APPLY_ARG); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - MultipleSubstFormat1 format1[]; - } u; -}; -ASSERT_SIZE (MultipleSubst, 2); - - -typedef ArrayOf<GlyphID> AlternateSet; /* Array of alternate GlyphIDs--in - * arbitrary order */ -ASSERT_SIZE (AlternateSet, 2); - -struct AlternateSubstFormat1 -{ - friend struct AlternateSubst; - - private: - - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - hb_codepoint_t glyph_id = IN_CURGLYPH (); - - unsigned int index = (this+coverage) (glyph_id); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - const AlternateSet &alt_set = this+alternateSet[index]; - - if (HB_UNLIKELY (!alt_set.len)) - return false; - - unsigned int alt_index = 0; - - /* XXX callback to user to choose alternate - if (context->face->altfunc) - alt_index = (context->face->altfunc)(context->layout, buffer, - buffer->out_pos, glyph_id, - alt_set.len, alt_set.array); - */ - - if (HB_UNLIKELY (alt_index >= alt_set.len)) - return false; - - glyph_id = alt_set[alt_index]; - - _hb_buffer_replace_glyph (buffer, glyph_id); - - /* We inherit the old glyph class to the substituted glyph */ - if (_hb_ot_layout_has_new_glyph_classes (context->face)) - _hb_ot_layout_set_glyph_property (context->face, glyph_id, property); - - return true; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS2 (coverage, alternateSet); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of Substitution table */ - OffsetArrayOf<AlternateSet> - alternateSet; /* Array of AlternateSet tables - * ordered by Coverage Index */ -}; -ASSERT_SIZE (AlternateSubstFormat1, 6); - -struct AlternateSubst -{ - friend struct SubstLookupSubTable; - - private: - - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - switch (u.format) { - case 1: return u.format1->apply (APPLY_ARG); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - AlternateSubstFormat1 format1[]; - } u; -}; -ASSERT_SIZE (AlternateSubst, 2); - - -struct Ligature -{ - friend struct LigatureSet; - - private: - inline bool apply (APPLY_ARG_DEF, bool is_mark) const - { - TRACE_APPLY (); - unsigned int i, j; - unsigned int count = component.len; - unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length); - if (HB_UNLIKELY (buffer->in_pos + count > end)) - return false; - - for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++) - { - while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, &property)) - { - if (HB_UNLIKELY (j + count - i == end)) - return false; - j++; - } - - if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)) - is_mark = FALSE; - - if (HB_LIKELY (IN_GLYPH (j) != component[i])) - return false; - } - /* This is just a guess ... */ - if (_hb_ot_layout_has_new_glyph_classes (context->face)) - _hb_ot_layout_set_glyph_class (context->face, ligGlyph, - is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK - : HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE); - - if (j == buffer->in_pos + i) /* No input glyphs skipped */ - /* We don't use a new ligature ID if there are no skipped - glyphs and the ligature already has an ID. */ - _hb_buffer_add_output_glyphs (buffer, i, - 1, (const uint16_t *) &ligGlyph, - 0xFFFF, - IN_LIGID (buffer->in_pos) ? - 0xFFFF : _hb_buffer_allocate_lig_id (buffer)); - else - { - unsigned int lig_id = _hb_buffer_allocate_lig_id (buffer); - _hb_buffer_add_output_glyph (buffer, ligGlyph, 0xFFFF, lig_id); - - /* Now we must do a second loop to copy the skipped glyphs to - `out' and assign component values to it. We start with the - glyph after the first component. Glyphs between component - i and i+1 belong to component i. Together with the lig_id - value it is later possible to check whether a specific - component value really belongs to a given ligature. */ - - for ( i = 1; i < count; i++ ) - { - while (_hb_ot_layout_skip_mark (context->face, IN_CURINFO (), lookup_flag, NULL)) - _hb_buffer_add_output_glyph (buffer, IN_CURGLYPH (), i - 1, lig_id); - - (buffer->in_pos)++; - } - - /* TODO We should possibly reassign lig_id and component for any - * components of a previous ligature that s now being removed as part of - * this ligature. */ - } - - return true; - } - - public: - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE2 (ligGlyph, component); - } - - private: - GlyphID ligGlyph; /* GlyphID of ligature to substitute */ - HeadlessArrayOf<GlyphID> - component; /* Array of component GlyphIDs--start - * with the second component--ordered - * in writing direction */ -}; -ASSERT_SIZE (Ligature, 4); - -struct LigatureSet -{ - friend struct LigatureSubstFormat1; - - private: - inline bool apply (APPLY_ARG_DEF, bool is_mark) const - { - TRACE_APPLY (); - unsigned int num_ligs = ligature.len; - for (unsigned int i = 0; i < num_ligs; i++) - { - const Ligature &lig = this+ligature[i]; - if (lig.apply (APPLY_ARG, is_mark)) - return true; - } - - return false; - } - - public: - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS (ligature); - } - - private: - OffsetArrayOf<Ligature> - ligature; /* Array LigatureSet tables - * ordered by preference */ -}; -ASSERT_SIZE (LigatureSet, 2); - -struct LigatureSubstFormat1 -{ - friend struct LigatureSubst; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - hb_codepoint_t glyph_id = IN_CURGLYPH (); - - bool first_is_mark = !!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK); - - unsigned int index = (this+coverage) (glyph_id); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - const LigatureSet &lig_set = this+ligatureSet[index]; - return lig_set.apply (APPLY_ARG, first_is_mark); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS2 (coverage, ligatureSet); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of Substitution table */ - OffsetArrayOf<LigatureSet> - ligatureSet; /* Array LigatureSet tables - * ordered by Coverage Index */ -}; -ASSERT_SIZE (LigatureSubstFormat1, 6); - -struct LigatureSubst -{ - friend struct SubstLookupSubTable; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - switch (u.format) { - case 1: return u.format1->apply (APPLY_ARG); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - LigatureSubstFormat1 format1[]; - } u; -}; -ASSERT_SIZE (LigatureSubst, 2); - - - -static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index); - -struct ContextSubst : Context -{ - friend struct SubstLookupSubTable; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - return Context::apply (APPLY_ARG, substitute_lookup); - } -}; -ASSERT_SIZE (ContextSubst, 2); - -struct ChainContextSubst : ChainContext -{ - friend struct SubstLookupSubTable; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - return ChainContext::apply (APPLY_ARG, substitute_lookup); - } -}; -ASSERT_SIZE (ChainContextSubst, 2); - - -struct ExtensionSubst : Extension -{ - friend struct SubstLookupSubTable; - - private: - inline const struct SubstLookupSubTable& get_subtable (void) const - { return CONST_CAST (SubstLookupSubTable, Extension::get_subtable (), 0); } - - inline bool apply (APPLY_ARG_DEF) const; - - inline bool sanitize (SANITIZE_ARG_DEF); -}; -ASSERT_SIZE (ExtensionSubst, 2); - - -struct ReverseChainSingleSubstFormat1 -{ - friend struct ReverseChainSingleSubst; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - if (HB_UNLIKELY (context_length != NO_CONTEXT)) - return false; /* No chaining to this type */ - - unsigned int index = (this+coverage) (IN_CURGLYPH ()); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - const OffsetArrayOf<Coverage> &lookahead = CONST_NEXT (OffsetArrayOf<Coverage>, backtrack); - const ArrayOf<GlyphID> &substitute = CONST_NEXT (ArrayOf<GlyphID>, lookahead); - - if (match_backtrack (APPLY_ARG, - backtrack.len, (USHORT *) backtrack.array, - match_coverage, DECONST_CHARP(this)) && - match_lookahead (APPLY_ARG, - lookahead.len, (USHORT *) lookahead.array, - match_coverage, DECONST_CHARP(this), - 1)) - { - IN_CURGLYPH () = substitute[index]; - buffer->in_pos--; /* Reverse! */ - return true; - } - - return false; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE_THIS2 (coverage, backtrack)) - return false; - OffsetArrayOf<Coverage> &lookahead = NEXT (OffsetArrayOf<Coverage>, backtrack); - if (!SANITIZE_THIS (lookahead)) - return false; - ArrayOf<GlyphID> &substitute = NEXT (ArrayOf<GlyphID>, lookahead); - return SANITIZE (substitute); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of table */ - OffsetArrayOf<Coverage> - backtrack; /* Array of coverage tables - * in backtracking sequence, in glyph - * sequence order */ - OffsetArrayOf<Coverage> - lookaheadX; /* Array of coverage tables - * in lookahead sequence, in glyph - * sequence order */ - ArrayOf<GlyphID> - substituteX; /* Array of substitute - * GlyphIDs--ordered by Coverage Index */ -}; -ASSERT_SIZE (ReverseChainSingleSubstFormat1, 10); - -struct ReverseChainSingleSubst -{ - friend struct SubstLookupSubTable; - - private: - inline bool apply (APPLY_ARG_DEF) const - { - TRACE_APPLY (); - switch (u.format) { - case 1: return u.format1->apply (APPLY_ARG); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - ReverseChainSingleSubstFormat1 format1[]; - } u; -}; -ASSERT_SIZE (ReverseChainSingleSubst, 2); - - - -/* - * SubstLookup - */ - -struct SubstLookupSubTable -{ - friend struct SubstLookup; - - enum { - Single = 1, - Multiple = 2, - Alternate = 3, - Ligature = 4, - Context = 5, - ChainContext = 6, - Extension = 7, - ReverseChainSingle = 8 - }; - - inline bool apply (APPLY_ARG_DEF, unsigned int lookup_type) const - { - TRACE_APPLY (); - switch (lookup_type) { - case Single: return u.single->apply (APPLY_ARG); - case Multiple: return u.multiple->apply (APPLY_ARG); - case Alternate: return u.alternate->apply (APPLY_ARG); - case Ligature: return u.ligature->apply (APPLY_ARG); - case Context: return u.context->apply (APPLY_ARG); - case ChainContext: return u.chainContext->apply (APPLY_ARG); - case Extension: return u.extension->apply (APPLY_ARG); - case ReverseChainSingle: return u.reverseChainContextSingle->apply (APPLY_ARG); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case Single: return u.single->sanitize (SANITIZE_ARG); - case Multiple: return u.multiple->sanitize (SANITIZE_ARG); - case Alternate: return u.alternate->sanitize (SANITIZE_ARG); - case Ligature: return u.ligature->sanitize (SANITIZE_ARG); - case Context: return u.context->sanitize (SANITIZE_ARG); - case ChainContext: return u.chainContext->sanitize (SANITIZE_ARG); - case Extension: return u.extension->sanitize (SANITIZE_ARG); - case ReverseChainSingle: return u.reverseChainContextSingle->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; - SingleSubst single[]; - MultipleSubst multiple[]; - AlternateSubst alternate[]; - LigatureSubst ligature[]; - ContextSubst context[]; - ChainContextSubst chainContext[]; - ExtensionSubst extension[]; - ReverseChainSingleSubst reverseChainContextSingle[]; - } u; -}; -ASSERT_SIZE (SubstLookupSubTable, 2); - - -struct SubstLookup : Lookup -{ - inline const SubstLookupSubTable& get_subtable (unsigned int i) const - { return CONST_CAST (SubstLookupSubTable, Lookup::get_subtable (i), 0); } - - /* Like get_type(), but looks through extension lookups. - * Never returns Extension */ - inline unsigned int get_effective_type (void) const - { - unsigned int type = get_type (); - - if (HB_UNLIKELY (type == SubstLookupSubTable::Extension)) - { - unsigned int count = get_subtable_count (); - type = get_subtable(0).u.extension->get_type (); - /* The spec says all subtables should have the same type. - * This is specially important if one has a reverse type! */ - for (unsigned int i = 1; i < count; i++) - if (get_subtable(i).u.extension->get_type () != type) - return 0; - } - - return type; - } - - inline bool is_reverse (void) const - { return HB_UNLIKELY (get_effective_type () == SubstLookupSubTable::ReverseChainSingle); } - - inline bool apply_once (hb_ot_layout_context_t *context, - hb_buffer_t *buffer, - unsigned int context_length, - unsigned int nesting_level_left) const - { - unsigned int lookup_type = get_type (); - unsigned int lookup_flag = get_flag (); - unsigned int property; - - if (!_hb_ot_layout_check_glyph_property (context->face, IN_CURINFO (), lookup_flag, &property)) - return false; - - unsigned int count = get_subtable_count (); - for (unsigned int i = 0; i < count; i++) - if (get_subtable (i).apply (APPLY_ARG_INIT, lookup_type)) - return true; - - return false; - } - - inline bool apply_string (hb_ot_layout_context_t *context, - hb_buffer_t *buffer, - hb_mask_t mask) const - { - bool ret = false; - - if (HB_UNLIKELY (!buffer->in_length)) - return false; - - if (HB_LIKELY (!is_reverse ())) - { - /* in/out forward substitution */ - _hb_buffer_clear_output (buffer); - buffer->in_pos = 0; - while (buffer->in_pos < buffer->in_length) - { - if ((~IN_MASK (buffer->in_pos) & mask) && - apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL)) - ret = true; - else - _hb_buffer_next_glyph (buffer); - - } - if (ret) - _hb_buffer_swap (buffer); - } - else - { - /* in-place backward substitution */ - buffer->in_pos = buffer->in_length - 1; - do - { - if ((~IN_MASK (buffer->in_pos) & mask) && - apply_once (context, buffer, NO_CONTEXT, MAX_NESTING_LEVEL)) - ret = true; - else - buffer->in_pos--; - - } - while ((int) buffer->in_pos >= 0); - } - - return ret; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!Lookup::sanitize (SANITIZE_ARG)) return false; - OffsetArrayOf<SubstLookupSubTable> &list = (OffsetArrayOf<SubstLookupSubTable> &) subTable; - return SANITIZE_THIS (list); - } -}; -ASSERT_SIZE (SubstLookup, 6); - -typedef OffsetListOf<SubstLookup> SubstLookupList; -ASSERT_SIZE (SubstLookupList, 2); - -/* - * GSUB - */ - -struct GSUB : GSUBGPOS -{ - static const hb_tag_t Tag = HB_OT_TAG_GSUB; - - static inline const GSUB& get_for_data (const char *data) - { return (const GSUB&) GSUBGPOS::get_for_data (data); } - - inline const SubstLookup& get_lookup (unsigned int i) const - { return (const SubstLookup&) GSUBGPOS::get_lookup (i); } - - inline bool substitute_lookup (hb_ot_layout_context_t *context, - hb_buffer_t *buffer, - unsigned int lookup_index, - hb_mask_t mask) const - { return get_lookup (lookup_index).apply_string (context, buffer, mask); } - - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!GSUBGPOS::sanitize (SANITIZE_ARG)) return false; - OffsetTo<SubstLookupList> &list = CAST(OffsetTo<SubstLookupList>, lookupList, 0); - return SANITIZE_THIS (list); - } -}; -ASSERT_SIZE (GSUB, 10); - - -/* Out-of-class implementation for methods recursing */ - -inline bool ExtensionSubst::apply (APPLY_ARG_DEF) const -{ - TRACE_APPLY (); - unsigned int lookup_type = get_type (); - - if (HB_UNLIKELY (lookup_type == SubstLookupSubTable::Extension)) - return false; - - return get_subtable ().apply (APPLY_ARG, lookup_type); -} - -inline bool ExtensionSubst::sanitize (SANITIZE_ARG_DEF) -{ - TRACE_SANITIZE (); - return Extension::sanitize (SANITIZE_ARG) && - (&(Extension::get_subtable ()) == &Null(LookupSubTable) || - get_type () == SubstLookupSubTable::Extension || - DECONST_CAST (SubstLookupSubTable, get_subtable (), 0).sanitize (SANITIZE_ARG)); -} - -static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index) -{ - const GSUB &gsub = *(context->face->ot_layout.gsub); - const SubstLookup &l = gsub.get_lookup (lookup_index); - - if (HB_UNLIKELY (nesting_level_left == 0)) - return false; - nesting_level_left--; - - if (HB_UNLIKELY (context_length < 1)) - return false; - - return l.apply_once (context, buffer, context_length, nesting_level_left); -} - - -#endif /* HB_OT_LAYOUT_GSUB_PRIVATE_HH */ diff --git a/pango/opentype/hb-ot-layout-gsubgpos-private.hh b/pango/opentype/hb-ot-layout-gsubgpos-private.hh deleted file mode 100644 index 8b9b1cd4..00000000 --- a/pango/opentype/hb-ot-layout-gsubgpos-private.hh +++ /dev/null @@ -1,958 +0,0 @@ -/* - * Copyright (C) 2007,2008,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH -#define HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH - -#include "hb-buffer-private.h" -#include "hb-ot-layout-gdef-private.hh" - - -#ifndef HB_DEBUG_APPLY -#define HB_DEBUG_APPLY HB_DEBUG -#endif - -#if HB_DEBUG_APPLY -#define TRACE_APPLY_ARG_DEF , unsigned int apply_depth -#define TRACE_APPLY_ARG , apply_depth + 1 -#define TRACE_APPLY_ARG_INIT , 1 -#define TRACE_APPLY() \ - HB_STMT_START { \ - if (apply_depth < HB_DEBUG_APPLY) \ - fprintf (stderr, "APPLY(%p) %-*d-> %s\n", \ - (CONST_CHARP (this) == NullPool) ? 0 : this, \ - apply_depth, apply_depth, \ - __PRETTY_FUNCTION__); \ - } HB_STMT_END -#else -#define TRACE_APPLY_ARG_DEF -#define TRACE_APPLY_ARG -#define TRACE_APPLY_ARG_INIT -#define TRACE_APPLY() HB_STMT_START {} HB_STMT_END -#endif - -#define APPLY_ARG_DEF \ - hb_ot_layout_context_t *context, \ - hb_buffer_t *buffer, \ - unsigned int context_length HB_GNUC_UNUSED, \ - unsigned int nesting_level_left HB_GNUC_UNUSED, \ - unsigned int lookup_flag, \ - unsigned int property HB_GNUC_UNUSED /* propety of first glyph */ \ - TRACE_APPLY_ARG_DEF -#define APPLY_ARG \ - context, \ - buffer, \ - context_length, \ - nesting_level_left, \ - lookup_flag, \ - property \ - TRACE_APPLY_ARG -#define APPLY_ARG_INIT \ - context, \ - buffer, \ - context_length, \ - nesting_level_left, \ - lookup_flag, \ - property \ - TRACE_APPLY_ARG_INIT - - -typedef bool (*match_func_t) (hb_codepoint_t glyph_id, const USHORT &value, char *data); -typedef bool (*apply_lookup_func_t) (APPLY_ARG_DEF, unsigned int lookup_index); - -struct ContextFuncs -{ - match_func_t match; - apply_lookup_func_t apply; -}; - - -static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, char *data) -{ - return glyph_id == value; -} - -static inline bool match_class (hb_codepoint_t glyph_id, const USHORT &value, char *data) -{ - const ClassDef &class_def = *reinterpret_cast<const ClassDef *>(data); - return class_def.get_class (glyph_id) == value; -} - -static inline bool match_coverage (hb_codepoint_t glyph_id, const USHORT &value, char *data) -{ - const OffsetTo<Coverage> &coverage = (const OffsetTo<Coverage>&)value; - return (data+coverage) (glyph_id) != NOT_COVERED; -} - - -static inline bool match_input (APPLY_ARG_DEF, - unsigned int count, /* Including the first glyph (not matched) */ - const USHORT input[], /* Array of input values--start with second glyph */ - match_func_t match_func, - char *match_data, - unsigned int *context_length_out) -{ - unsigned int i, j; - unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length); - if (HB_UNLIKELY (buffer->in_pos + count > end)) - return false; - - for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++) - { - while (_hb_ot_layout_skip_mark (context->face, IN_INFO (j), lookup_flag, NULL)) - { - if (HB_UNLIKELY (j + count - i == end)) - return false; - j++; - } - - if (HB_LIKELY (!match_func (IN_GLYPH (j), input[i - 1], match_data))) - return false; - } - - *context_length_out = j - buffer->in_pos; - - return true; -} - -static inline bool match_backtrack (APPLY_ARG_DEF, - unsigned int count, - const USHORT backtrack[], - match_func_t match_func, - char *match_data) -{ - if (HB_UNLIKELY (buffer->out_pos < count)) - return false; - - for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--) - { - while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), lookup_flag, NULL)) - { - if (HB_UNLIKELY (j + 1 == count - i)) - return false; - j--; - } - - if (HB_LIKELY (!match_func (OUT_GLYPH (j), backtrack[i], match_data))) - return false; - } - - return true; -} - -static inline bool match_lookahead (APPLY_ARG_DEF, - unsigned int count, - const USHORT lookahead[], - match_func_t match_func, - char *match_data, - unsigned int offset) -{ - unsigned int i, j; - unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length); - if (HB_UNLIKELY (buffer->in_pos + offset + count > end)) - return false; - - for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++) - { - while (_hb_ot_layout_skip_mark (context->face, OUT_INFO (j), lookup_flag, NULL)) - { - if (HB_UNLIKELY (j + count - i == end)) - return false; - j++; - } - - if (HB_LIKELY (!match_func (IN_GLYPH (j), lookahead[i], match_data))) - return false; - } - - return true; -} - - -struct LookupRecord -{ - public: - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF (); - } - - USHORT sequenceIndex; /* Index into current glyph - * sequence--first glyph = 0 */ - USHORT lookupListIndex; /* Lookup to apply to that - * position--zero--based */ -}; -ASSERT_SIZE (LookupRecord, 4); - -static inline bool apply_lookup (APPLY_ARG_DEF, - unsigned int count, /* Including the first glyph */ - unsigned int lookupCount, - const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */ - apply_lookup_func_t apply_func) -{ - unsigned int end = MIN (buffer->in_length, buffer->in_pos + context_length); - if (HB_UNLIKELY (buffer->in_pos + count > end)) - return false; - - /* TODO We don't support lookupRecord arrays that are not increasing: - * Should be easy for in_place ones at least. */ - - /* Note: If sublookup is reverse, i will underflow after the first loop - * and we jump out of it. Not entirely disastrous. So we don't check - * for reverse lookup here. - */ - for (unsigned int i = 0; i < count; /* NOP */) - { - while (_hb_ot_layout_skip_mark (context->face, IN_CURINFO (), lookup_flag, NULL)) - { - if (HB_UNLIKELY (buffer->in_pos == end)) - return true; - /* No lookup applied for this index */ - _hb_buffer_next_glyph (buffer); - } - - if (lookupCount && i == lookupRecord->sequenceIndex) - { - unsigned int old_pos = buffer->in_pos; - - /* Apply a lookup */ - bool done = apply_func (APPLY_ARG, lookupRecord->lookupListIndex); - - lookupRecord++; - lookupCount--; - /* Err, this is wrong if the lookup jumped over some glyphs */ - i += buffer->in_pos - old_pos; - if (HB_UNLIKELY (buffer->in_pos == end)) - return true; - - if (!done) - goto not_applied; - } - else - { - not_applied: - /* No lookup applied for this index */ - _hb_buffer_next_glyph (buffer); - i++; - } - } - - return true; -} - - -/* Contextual lookups */ - -struct ContextLookupContext -{ - ContextFuncs funcs; - char *match_data; -}; - -static inline bool context_lookup (APPLY_ARG_DEF, - unsigned int inputCount, /* Including the first glyph (not matched) */ - const USHORT input[], /* Array of input values--start with second glyph */ - unsigned int lookupCount, - const LookupRecord lookupRecord[], - ContextLookupContext &lookup_context) -{ - return match_input (APPLY_ARG, - inputCount, input, - lookup_context.funcs.match, lookup_context.match_data, - &context_length) && - apply_lookup (APPLY_ARG, - inputCount, - lookupCount, lookupRecord, - lookup_context.funcs.apply); -} - -struct Rule -{ - friend struct RuleSet; - - private: - inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const - { - TRACE_APPLY (); - const LookupRecord *lookupRecord = &CONST_CAST (LookupRecord, input, sizeof (input[0]) * (inputCount ? inputCount - 1 : 0)); - return context_lookup (APPLY_ARG, - inputCount, input, - lookupCount, lookupRecord, - lookup_context); - } - - public: - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE_SELF ()) return false; - return SANITIZE_MEM (input, - sizeof (input[0]) * inputCount + - sizeof (lookupRecordX[0]) * lookupCount); - } - - private: - USHORT inputCount; /* Total number of glyphs in input - * glyph sequence--includes the first - * glyph */ - USHORT lookupCount; /* Number of LookupRecords */ - USHORT input[]; /* Array of match inputs--start with - * second glyph */ - LookupRecord lookupRecordX[]; /* Array of LookupRecords--in - * design order */ -}; -ASSERT_SIZE (Rule, 4); - -struct RuleSet -{ - inline bool apply (APPLY_ARG_DEF, ContextLookupContext &lookup_context) const - { - TRACE_APPLY (); - unsigned int num_rules = rule.len; - for (unsigned int i = 0; i < num_rules; i++) - { - if ((this+rule[i]).apply (APPLY_ARG, lookup_context)) - return true; - } - - return false; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS (rule); - } - - private: - OffsetArrayOf<Rule> - rule; /* Array of Rule tables - * ordered by preference */ -}; - - -struct ContextFormat1 -{ - friend struct Context; - - private: - inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const - { - TRACE_APPLY (); - unsigned int index = (this+coverage) (IN_CURGLYPH ()); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - const RuleSet &rule_set = this+ruleSet[index]; - struct ContextLookupContext lookup_context = { - {match_glyph, apply_func}, - NULL - }; - return rule_set.apply (APPLY_ARG, lookup_context); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS2 (coverage, ruleSet); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of table */ - OffsetArrayOf<RuleSet> - ruleSet; /* Array of RuleSet tables - * ordered by Coverage Index */ -}; -ASSERT_SIZE (ContextFormat1, 6); - - -struct ContextFormat2 -{ - friend struct Context; - - private: - inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const - { - TRACE_APPLY (); - unsigned int index = (this+coverage) (IN_CURGLYPH ()); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - const ClassDef &class_def = this+classDef; - index = class_def (IN_CURGLYPH ()); - const RuleSet &rule_set = this+ruleSet[index]; - /* LONGTERMTODO: Old code fetches glyph classes at most once and caches - * them across subrule lookups. Not sure it's worth it. - */ - struct ContextLookupContext lookup_context = { - {match_class, apply_func}, - DECONST_CHARP(&class_def) - }; - return rule_set.apply (APPLY_ARG, lookup_context); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS3 (coverage, classDef, ruleSet); - } - - private: - USHORT format; /* Format identifier--format = 2 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of table */ - OffsetTo<ClassDef> - classDef; /* Offset to glyph ClassDef table--from - * beginning of table */ - OffsetArrayOf<RuleSet> - ruleSet; /* Array of RuleSet tables - * ordered by class */ -}; -ASSERT_SIZE (ContextFormat2, 8); - - -struct ContextFormat3 -{ - friend struct Context; - - private: - inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const - { - TRACE_APPLY (); - unsigned int index = (this+coverage[0]) (IN_CURGLYPH ()); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - const LookupRecord *lookupRecord = &CONST_CAST(LookupRecord, coverage, sizeof (coverage[0]) * glyphCount); - struct ContextLookupContext lookup_context = { - {match_coverage, apply_func}, - DECONST_CHARP(this) - }; - return context_lookup (APPLY_ARG, - glyphCount, (const USHORT *) (coverage + 1), - lookupCount, lookupRecord, - lookup_context); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE_SELF ()) return false; - unsigned int count = glyphCount; - for (unsigned int i = 0; i < count; i++) - if (!SANITIZE_THIS (coverage[i])) return false; - LookupRecord *lookupRecord = &CAST(LookupRecord, coverage, sizeof (coverage[0]) * glyphCount); - return SANITIZE_MEM (lookupRecord, sizeof (lookupRecord[0]) * lookupCount); - } - - private: - USHORT format; /* Format identifier--format = 3 */ - USHORT glyphCount; /* Number of glyphs in the input glyph - * sequence */ - USHORT lookupCount; /* Number of LookupRecords */ - OffsetTo<Coverage> - coverage[]; /* Array of offsets to Coverage - * table in glyph sequence order */ - LookupRecord lookupRecordX[]; /* Array of LookupRecords--in - * design order */ -}; -ASSERT_SIZE (ContextFormat3, 6); - -struct Context -{ - protected: - inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const - { - TRACE_APPLY (); - switch (u.format) { - case 1: return u.format1->apply (APPLY_ARG, apply_func); - case 2: return u.format2->apply (APPLY_ARG, apply_func); - case 3: return u.format3->apply (APPLY_ARG, apply_func); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - case 2: return u.format2->sanitize (SANITIZE_ARG); - case 3: return u.format3->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - ContextFormat1 format1[]; - ContextFormat2 format2[]; - ContextFormat3 format3[]; - } u; -}; -ASSERT_SIZE (Context, 2); - - -/* Chaining Contextual lookups */ - -struct ChainContextLookupContext -{ - ContextFuncs funcs; - char *match_data[3]; -}; - -static inline bool chain_context_lookup (APPLY_ARG_DEF, - unsigned int backtrackCount, - const USHORT backtrack[], - unsigned int inputCount, /* Including the first glyph (not matched) */ - const USHORT input[], /* Array of input values--start with second glyph */ - unsigned int lookaheadCount, - const USHORT lookahead[], - unsigned int lookupCount, - const LookupRecord lookupRecord[], - ChainContextLookupContext &lookup_context) -{ - /* First guess */ - if (HB_UNLIKELY (buffer->out_pos < backtrackCount || - buffer->in_pos + inputCount + lookaheadCount > buffer->in_length || - inputCount + lookaheadCount > context_length)) - return false; - - unsigned int offset; - return match_backtrack (APPLY_ARG, - backtrackCount, backtrack, - lookup_context.funcs.match, lookup_context.match_data[0]) && - match_input (APPLY_ARG, - inputCount, input, - lookup_context.funcs.match, lookup_context.match_data[1], - &offset) && - match_lookahead (APPLY_ARG, - lookaheadCount, lookahead, - lookup_context.funcs.match, lookup_context.match_data[2], - offset) && - (context_length = offset, true) && - apply_lookup (APPLY_ARG, - inputCount, - lookupCount, lookupRecord, - lookup_context.funcs.apply); -} - -struct ChainRule -{ - friend struct ChainRuleSet; - - private: - inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const - { - TRACE_APPLY (); - const HeadlessArrayOf<USHORT> &input = CONST_NEXT (HeadlessArrayOf<USHORT>, backtrack); - const ArrayOf<USHORT> &lookahead = CONST_NEXT (ArrayOf<USHORT>, input); - const ArrayOf<LookupRecord> &lookup = CONST_NEXT (ArrayOf<LookupRecord>, lookahead); - return chain_context_lookup (APPLY_ARG, - backtrack.len, backtrack.array, - input.len, input.array, - lookahead.len, lookahead.array, - lookup.len, lookup.array, - lookup_context); - return false; - } - - public: - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (backtrack)) return false; - HeadlessArrayOf<USHORT> &input = NEXT (HeadlessArrayOf<USHORT>, backtrack); - if (!SANITIZE (input)) return false; - ArrayOf<USHORT> &lookahead = NEXT (ArrayOf<USHORT>, input); - if (!SANITIZE (lookahead)) return false; - ArrayOf<LookupRecord> &lookup = NEXT (ArrayOf<LookupRecord>, lookahead); - return SANITIZE (lookup); - } - - private: - ArrayOf<USHORT> - backtrack; /* Array of backtracking values - * (to be matched before the input - * sequence) */ - HeadlessArrayOf<USHORT> - inputX; /* Array of input values (start with - * second glyph) */ - ArrayOf<USHORT> - lookaheadX; /* Array of lookahead values's (to be - * matched after the input sequence) */ - ArrayOf<LookupRecord> - lookupX; /* Array of LookupRecords--in - * design order) */ -}; -ASSERT_SIZE (ChainRule, 8); - -struct ChainRuleSet -{ - inline bool apply (APPLY_ARG_DEF, ChainContextLookupContext &lookup_context) const - { - TRACE_APPLY (); - unsigned int num_rules = rule.len; - for (unsigned int i = 0; i < num_rules; i++) - { - if ((this+rule[i]).apply (APPLY_ARG, lookup_context)) - return true; - } - - return false; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS (rule); - } - - private: - OffsetArrayOf<ChainRule> - rule; /* Array of ChainRule tables - * ordered by preference */ -}; -ASSERT_SIZE (ChainRuleSet, 2); - -struct ChainContextFormat1 -{ - friend struct ChainContext; - - private: - inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const - { - TRACE_APPLY (); - unsigned int index = (this+coverage) (IN_CURGLYPH ()); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - const ChainRuleSet &rule_set = this+ruleSet[index]; - struct ChainContextLookupContext lookup_context = { - {match_glyph, apply_func}, - {NULL, NULL, NULL} - }; - return rule_set.apply (APPLY_ARG, lookup_context); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS2 (coverage, ruleSet); - } - - private: - USHORT format; /* Format identifier--format = 1 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of table */ - OffsetArrayOf<ChainRuleSet> - ruleSet; /* Array of ChainRuleSet tables - * ordered by Coverage Index */ -}; -ASSERT_SIZE (ChainContextFormat1, 6); - -struct ChainContextFormat2 -{ - friend struct ChainContext; - - private: - inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const - { - TRACE_APPLY (); - unsigned int index = (this+coverage) (IN_CURGLYPH ()); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - const ClassDef &backtrack_class_def = this+backtrackClassDef; - const ClassDef &input_class_def = this+inputClassDef; - const ClassDef &lookahead_class_def = this+lookaheadClassDef; - - index = input_class_def (IN_CURGLYPH ()); - const ChainRuleSet &rule_set = this+ruleSet[index]; - /* LONGTERMTODO: Old code fetches glyph classes at most once and caches - * them across subrule lookups. Not sure it's worth it. - */ - struct ChainContextLookupContext lookup_context = { - {match_class, apply_func}, - {DECONST_CHARP(&backtrack_class_def), - DECONST_CHARP(&input_class_def), - DECONST_CHARP(&lookahead_class_def)} - }; - return rule_set.apply (APPLY_ARG, lookup_context); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_THIS2 (coverage, backtrackClassDef) && - SANITIZE_THIS2 (inputClassDef, lookaheadClassDef) && - SANITIZE_THIS (ruleSet); - } - - private: - USHORT format; /* Format identifier--format = 2 */ - OffsetTo<Coverage> - coverage; /* Offset to Coverage table--from - * beginning of table */ - OffsetTo<ClassDef> - backtrackClassDef; /* Offset to glyph ClassDef table - * containing backtrack sequence - * data--from beginning of table */ - OffsetTo<ClassDef> - inputClassDef; /* Offset to glyph ClassDef - * table containing input sequence - * data--from beginning of table */ - OffsetTo<ClassDef> - lookaheadClassDef; /* Offset to glyph ClassDef table - * containing lookahead sequence - * data--from beginning of table */ - OffsetArrayOf<ChainRuleSet> - ruleSet; /* Array of ChainRuleSet tables - * ordered by class */ -}; -ASSERT_SIZE (ChainContextFormat2, 12); - -struct ChainContextFormat3 -{ - friend struct ChainContext; - - private: - - inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const - { - TRACE_APPLY (); - const OffsetArrayOf<Coverage> &input = CONST_NEXT (OffsetArrayOf<Coverage>, backtrack); - - unsigned int index = (this+input[0]) (IN_CURGLYPH ()); - if (HB_LIKELY (index == NOT_COVERED)) - return false; - - const OffsetArrayOf<Coverage> &lookahead = CONST_NEXT (OffsetArrayOf<Coverage>, input); - const ArrayOf<LookupRecord> &lookup = CONST_NEXT (ArrayOf<LookupRecord>, lookahead); - struct ChainContextLookupContext lookup_context = { - {match_coverage, apply_func}, - {DECONST_CHARP(this), DECONST_CHARP(this), DECONST_CHARP(this)} - }; - return chain_context_lookup (APPLY_ARG, - backtrack.len, (USHORT *) backtrack.array, - input.len, (USHORT *) input.array + 1, - lookahead.len, (USHORT *) lookahead.array, - lookup.len, lookup.array, - lookup_context); - return false; - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE_THIS (backtrack)) return false; - OffsetArrayOf<Coverage> &input = NEXT (OffsetArrayOf<Coverage>, backtrack); - if (!SANITIZE_THIS (input)) return false; - OffsetArrayOf<Coverage> &lookahead = NEXT (OffsetArrayOf<Coverage>, input); - if (!SANITIZE_THIS (lookahead)) return false; - ArrayOf<LookupRecord> &lookup = NEXT (ArrayOf<LookupRecord>, lookahead); - return SANITIZE (lookup); - } - - private: - USHORT format; /* Format identifier--format = 3 */ - OffsetArrayOf<Coverage> - backtrack; /* Array of coverage tables - * in backtracking sequence, in glyph - * sequence order */ - OffsetArrayOf<Coverage> - inputX ; /* Array of coverage - * tables in input sequence, in glyph - * sequence order */ - OffsetArrayOf<Coverage> - lookaheadX; /* Array of coverage tables - * in lookahead sequence, in glyph - * sequence order */ - ArrayOf<LookupRecord> - lookupX; /* Array of LookupRecords--in - * design order) */ -}; -ASSERT_SIZE (ChainContextFormat3, 10); - -struct ChainContext -{ - protected: - inline bool apply (APPLY_ARG_DEF, apply_lookup_func_t apply_func) const - { - TRACE_APPLY (); - switch (u.format) { - case 1: return u.format1->apply (APPLY_ARG, apply_func); - case 2: return u.format2->apply (APPLY_ARG, apply_func); - case 3: return u.format3->apply (APPLY_ARG, apply_func); - default:return false; - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - case 2: return u.format2->sanitize (SANITIZE_ARG); - case 3: return u.format3->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - ChainContextFormat1 format1[]; - ChainContextFormat2 format2[]; - ChainContextFormat3 format3[]; - } u; -}; -ASSERT_SIZE (ChainContext, 2); - - -struct ExtensionFormat1 -{ - friend struct Extension; - - protected: - inline unsigned int get_type (void) const { return extensionLookupType; } - inline unsigned int get_offset (void) const { return (extensionOffset[0] << 16) + extensionOffset[1]; } - inline const LookupSubTable& get_subtable (void) const - { - unsigned int offset = get_offset (); - if (HB_UNLIKELY (!offset)) return Null(LookupSubTable); - return CONST_CAST (LookupSubTable, *this, offset); - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - return SANITIZE_SELF (); - } - - private: - USHORT format; /* Format identifier. Set to 1. */ - USHORT extensionLookupType; /* Lookup type of subtable referenced - * by ExtensionOffset (i.e. the - * extension subtable). */ - USHORT extensionOffset[2]; /* Offset to the extension subtable, - * of lookup type subtable. - * Defined as two shorts to avoid - * alignment requirements. */ -}; -ASSERT_SIZE (ExtensionFormat1, 8); - -struct Extension -{ - inline unsigned int get_type (void) const - { - switch (u.format) { - case 1: return u.format1->get_type (); - default:return 0; - } - } - inline const LookupSubTable& get_subtable (void) const - { - switch (u.format) { - case 1: return u.format1->get_subtable (); - default:return Null(LookupSubTable); - } - } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (u.format)) return false; - switch (u.format) { - case 1: return u.format1->sanitize (SANITIZE_ARG); - default:return true; - } - } - - private: - union { - USHORT format; /* Format identifier */ - ExtensionFormat1 format1[]; - } u; -}; -ASSERT_SIZE (Extension, 2); - - -/* - * GSUB/GPOS Common - */ - -struct GSUBGPOS -{ - static const hb_tag_t GSUBTag = HB_OT_TAG_GSUB; - static const hb_tag_t GPOSTag = HB_OT_TAG_GPOS; - - STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GSUBGPOS, 1, 1); - - inline unsigned int get_script_count (void) const - { return (this+scriptList).len; } - inline const Tag& get_script_tag (unsigned int i) const - { return (this+scriptList).get_tag (i); } - inline bool get_script_tags (unsigned int *script_count /* IN/OUT */, - hb_tag_t *script_tags /* OUT */) const - { return (this+scriptList).get_tags (script_count, script_tags); } - inline const Script& get_script (unsigned int i) const - { return (this+scriptList)[i]; } - inline bool find_script_index (hb_tag_t tag, unsigned int *index) const - { return (this+scriptList).find_index (tag, index); } - - inline unsigned int get_feature_count (void) const - { return (this+featureList).len; } - inline const Tag& get_feature_tag (unsigned int i) const - { return (this+featureList).get_tag (i); } - inline bool get_feature_tags (unsigned int *feature_count /* IN/OUT */, - hb_tag_t *feature_tags /* OUT */) const - { return (this+featureList).get_tags (feature_count, feature_tags); } - inline const Feature& get_feature (unsigned int i) const - { return (this+featureList)[i]; } - inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const - { return (this+featureList).find_index (tag, index); } - - inline unsigned int get_lookup_count (void) const - { return (this+lookupList).len; } - inline const Lookup& get_lookup (unsigned int i) const - { return (this+lookupList)[i]; } - - inline bool sanitize (SANITIZE_ARG_DEF) { - TRACE_SANITIZE (); - if (!SANITIZE (version)) return false; - if (version.major != 1) return true; - return SANITIZE_THIS3 (scriptList, featureList, lookupList); - } - - protected: - FixedVersion version; /* Version of the GSUB/GPOS table--initially set - * to 0x00010000 */ - OffsetTo<ScriptList> - scriptList; /* ScriptList table */ - OffsetTo<FeatureList> - featureList; /* FeatureList table */ - OffsetTo<LookupList> - lookupList; /* LookupList table */ -}; -ASSERT_SIZE (GSUBGPOS, 10); - - -#endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH */ diff --git a/pango/opentype/hb-ot-layout-private.h b/pango/opentype/hb-ot-layout-private.h deleted file mode 100644 index fb7bfe49..00000000 --- a/pango/opentype/hb-ot-layout-private.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2007,2008,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_OT_LAYOUT_PRIVATE_H -#define HB_OT_LAYOUT_PRIVATE_H - -#include "hb-private.h" - -#include "hb-ot-layout.h" - -#include "hb-font.h" -#include "hb-buffer-private.h" - - -HB_BEGIN_DECLS - -typedef unsigned int hb_ot_layout_class_t; - -/* - * hb_ot_layout_t - */ - -typedef struct _hb_ot_layout_t hb_ot_layout_t; - -struct _hb_ot_layout_t -{ - hb_blob_t *gdef_blob; - hb_blob_t *gsub_blob; - hb_blob_t *gpos_blob; - - const struct GDEF *gdef; - const struct GSUB *gsub; - const struct GPOS *gpos; - - struct - { - unsigned char *klasses; - unsigned int len; - } new_gdef; -}; - -typedef struct _hb_ot_layout_context_t hb_ot_layout_context_t; -struct _hb_ot_layout_context_t -{ - hb_face_t *face; - hb_font_t *font; - - union info_t - { - struct gpos_t - { - unsigned int last; /* the last valid glyph--used with cursive positioning */ - hb_position_t anchor_x; /* the coordinates of the anchor point */ - hb_position_t anchor_y; /* of the last valid glyph */ - } gpos; - } info; -}; - - -void -_hb_ot_layout_init (hb_face_t *face); - -void -_hb_ot_layout_fini (hb_face_t *face); - - -/* - * GDEF - */ - -HB_INTERNAL hb_bool_t -_hb_ot_layout_has_new_glyph_classes (hb_face_t *face); - -HB_INTERNAL void -_hb_ot_layout_set_glyph_property (hb_face_t *face, - hb_codepoint_t glyph, - unsigned int property); - -HB_INTERNAL void -_hb_ot_layout_set_glyph_class (hb_face_t *face, - hb_codepoint_t glyph, - hb_ot_layout_glyph_class_t klass); - -HB_INTERNAL hb_bool_t -_hb_ot_layout_check_glyph_property (hb_face_t *face, - hb_internal_glyph_info_t *ginfo, - unsigned int lookup_flags, - unsigned int *property); - -HB_INTERNAL hb_bool_t -_hb_ot_layout_skip_mark (hb_face_t *face, - hb_internal_glyph_info_t *ginfo, - unsigned int lookup_flags, - unsigned int *property); - -HB_END_DECLS - -#endif /* HB_OT_LAYOUT_PRIVATE_H */ diff --git a/pango/opentype/hb-ot-layout.cc b/pango/opentype/hb-ot-layout.cc deleted file mode 100644 index 67b2b9ae..00000000 --- a/pango/opentype/hb-ot-layout.cc +++ /dev/null @@ -1,558 +0,0 @@ -/* - * Copyright (C) 1998-2004 David Turner and Werner Lemberg - * Copyright (C) 2006 Behdad Esfahbod - * Copyright (C) 2007,2008,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#define HB_OT_LAYOUT_CC - -#include "hb-ot-layout-private.h" - -#include "hb-ot-layout-gdef-private.hh" -#include "hb-ot-layout-gsub-private.hh" -#include "hb-ot-layout-gpos-private.hh" - - -#include <stdlib.h> -#include <string.h> - - -void -_hb_ot_layout_init (hb_face_t *face) -{ - hb_ot_layout_t *layout = &face->ot_layout; - - layout->gdef_blob = Sanitizer<GDEF>::sanitize (hb_face_get_table (face, HB_OT_TAG_GDEF)); - layout->gdef = &Sanitizer<GDEF>::lock_instance (layout->gdef_blob); - - layout->gsub_blob = Sanitizer<GSUB>::sanitize (hb_face_get_table (face, HB_OT_TAG_GSUB)); - layout->gsub = &Sanitizer<GSUB>::lock_instance (layout->gsub_blob); - - layout->gpos_blob = Sanitizer<GPOS>::sanitize (hb_face_get_table (face, HB_OT_TAG_GPOS)); - layout->gpos = &Sanitizer<GPOS>::lock_instance (layout->gpos_blob); -} - -void -_hb_ot_layout_fini (hb_face_t *face) -{ - hb_ot_layout_t *layout = &face->ot_layout; - - hb_blob_unlock (layout->gdef_blob); - hb_blob_unlock (layout->gsub_blob); - hb_blob_unlock (layout->gpos_blob); - - hb_blob_destroy (layout->gdef_blob); - hb_blob_destroy (layout->gsub_blob); - hb_blob_destroy (layout->gpos_blob); - - free (layout->new_gdef.klasses); -} - -static const GDEF& -_get_gdef (hb_face_t *face) -{ - return HB_LIKELY (face->ot_layout.gdef) ? *face->ot_layout.gdef : Null(GDEF); -} - -static const GSUB& -_get_gsub (hb_face_t *face) -{ - return HB_LIKELY (face->ot_layout.gsub) ? *face->ot_layout.gsub : Null(GSUB); -} - -static const GPOS& -_get_gpos (hb_face_t *face) -{ - return HB_LIKELY (face->ot_layout.gpos) ? *face->ot_layout.gpos : Null(GPOS); -} - - -/* - * GDEF - */ - -/* TODO the public class_t is a mess */ - -hb_bool_t -hb_ot_layout_has_font_glyph_classes (hb_face_t *face) -{ - return _get_gdef (face).has_glyph_classes (); -} - -hb_bool_t -_hb_ot_layout_has_new_glyph_classes (hb_face_t *face) -{ - return face->ot_layout.new_gdef.len > 0; -} - -static unsigned int -_hb_ot_layout_get_glyph_property (hb_face_t *face, - hb_codepoint_t glyph) -{ - hb_ot_layout_class_t klass; - const GDEF &gdef = _get_gdef (face); - - klass = gdef.get_glyph_class (glyph); - - if (!klass && glyph < face->ot_layout.new_gdef.len) - klass = face->ot_layout.new_gdef.klasses[glyph]; - - switch (klass) { - default: - case GDEF::UnclassifiedGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED; - case GDEF::BaseGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH; - case GDEF::LigatureGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE; - case GDEF::ComponentGlyph: return HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT; - case GDEF::MarkGlyph: - klass = gdef.get_mark_attachment_type (glyph); - return HB_OT_LAYOUT_GLYPH_CLASS_MARK + (klass << 8); - } -} - -hb_bool_t -_hb_ot_layout_check_glyph_property (hb_face_t *face, - hb_internal_glyph_info_t *ginfo, - unsigned int lookup_flags, - unsigned int *property_out) -{ - unsigned int property; - - if (ginfo->gproperty == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN) - ginfo->gproperty = _hb_ot_layout_get_glyph_property (face, ginfo->codepoint); - property = ginfo->gproperty; - if (property_out) - *property_out = property; - - /* Not covered, if, for example, glyph class is ligature and - * lookup_flags includes LookupFlags::IgnoreLigatures - */ - if (property & lookup_flags & LookupFlag::IgnoreFlags) - return false; - - if (property & HB_OT_LAYOUT_GLYPH_CLASS_MARK) - { - /* If using mark filtering sets, the high short of - * lookup_flags has the set index. - */ - if (lookup_flags & LookupFlag::UseMarkFilteringSet) - return _get_gdef (face).mark_set_covers (lookup_flags >> 16, ginfo->codepoint); - - /* The second byte of lookup_flags has the meaning - * "ignore marks of attachment type different than - * the attachment type specified." - */ - if (lookup_flags & LookupFlag::MarkAttachmentType && property & LookupFlag::MarkAttachmentType) - return (lookup_flags & LookupFlag::MarkAttachmentType) == (property & LookupFlag::MarkAttachmentType); - } - - return true; -} - -hb_bool_t -_hb_ot_layout_skip_mark (hb_face_t *face, - hb_internal_glyph_info_t *ginfo, - unsigned int lookup_flags, - unsigned int *property_out) -{ - unsigned int property; - - if (ginfo->gproperty == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN) - ginfo->gproperty = _hb_ot_layout_get_glyph_property (face, ginfo->codepoint); - property = ginfo->gproperty; - if (property_out) - *property_out = property; - - if (property & HB_OT_LAYOUT_GLYPH_CLASS_MARK) - { - /* Skip mark if lookup_flags includes LookupFlags::IgnoreMarks */ - if (lookup_flags & LookupFlag::IgnoreMarks) - return true; - - /* If using mark filtering sets, the high short of lookup_flags has the set index. */ - if (lookup_flags & LookupFlag::UseMarkFilteringSet) - return !_get_gdef (face).mark_set_covers (lookup_flags >> 16, ginfo->codepoint); - - /* The second byte of lookup_flags has the meaning "ignore marks of attachment type - * different than the attachment type specified." */ - if (lookup_flags & LookupFlag::MarkAttachmentType && property & LookupFlag::MarkAttachmentType) - return (lookup_flags & LookupFlag::MarkAttachmentType) != (property & LookupFlag::MarkAttachmentType); - } - - return false; -} - -void -_hb_ot_layout_set_glyph_class (hb_face_t *face, - hb_codepoint_t glyph, - hb_ot_layout_glyph_class_t klass) -{ - if (HB_OBJECT_IS_INERT (face)) - return; - - /* TODO optimize this? similar to old harfbuzz code for example */ - - hb_ot_layout_t *layout = &face->ot_layout; - hb_ot_layout_class_t gdef_klass; - unsigned int len = layout->new_gdef.len; - - if (HB_UNLIKELY (glyph > 65535)) - return; - - /* XXX this is not threadsafe */ - if (glyph >= len) { - unsigned int new_len; - unsigned char *new_klasses; - - new_len = len == 0 ? 120 : 2 * len; - while (new_len <= glyph) - new_len *= 2; - - if (new_len > 65536) - new_len = 65536; - new_klasses = (unsigned char *) realloc (layout->new_gdef.klasses, new_len * sizeof (unsigned char)); - - if (HB_UNLIKELY (!new_klasses)) - return; - - memset (new_klasses + len, 0, new_len - len); - - layout->new_gdef.klasses = new_klasses; - layout->new_gdef.len = new_len; - } - - switch (klass) { - default: - case HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED: gdef_klass = GDEF::UnclassifiedGlyph; break; - case HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH: gdef_klass = GDEF::BaseGlyph; break; - case HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE: gdef_klass = GDEF::LigatureGlyph; break; - case HB_OT_LAYOUT_GLYPH_CLASS_MARK: gdef_klass = GDEF::MarkGlyph; break; - case HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT: gdef_klass = GDEF::ComponentGlyph; break; - } - - layout->new_gdef.klasses[glyph] = gdef_klass; - return; -} - -void -_hb_ot_layout_set_glyph_property (hb_face_t *face, - hb_codepoint_t glyph, - unsigned int property) -{ _hb_ot_layout_set_glyph_class (face, glyph, (hb_ot_layout_glyph_class_t) (property & 0xff)); } - - -hb_ot_layout_glyph_class_t -hb_ot_layout_get_glyph_class (hb_face_t *face, - hb_codepoint_t glyph) -{ - return (hb_ot_layout_glyph_class_t) (_hb_ot_layout_get_glyph_property (face, glyph) & 0xff); -} - -void -hb_ot_layout_set_glyph_class (hb_face_t *face, - hb_codepoint_t glyph, - hb_ot_layout_glyph_class_t klass) -{ - _hb_ot_layout_set_glyph_class (face, glyph, klass); -} - -void -hb_ot_layout_build_glyph_classes (hb_face_t *face, - uint16_t num_total_glyphs, - hb_codepoint_t *glyphs, - unsigned char *klasses, - uint16_t count) -{ - if (HB_OBJECT_IS_INERT (face)) - return; - - hb_ot_layout_t *layout = &face->ot_layout; - - if (HB_UNLIKELY (!count || !glyphs || !klasses)) - return; - - if (layout->new_gdef.len == 0) { - layout->new_gdef.klasses = (unsigned char *) calloc (num_total_glyphs, sizeof (unsigned char)); - layout->new_gdef.len = count; - } - - for (unsigned int i = 0; i < count; i++) - _hb_ot_layout_set_glyph_class (face, glyphs[i], (hb_ot_layout_glyph_class_t) klasses[i]); -} - -hb_bool_t -hb_ot_layout_get_attach_points (hb_face_t *face, - hb_codepoint_t glyph, - unsigned int *point_count /* IN/OUT */, - unsigned int *point_array /* OUT */) -{ - return _get_gdef (face).get_attach_points (glyph, point_count, point_array); -} - -hb_bool_t -hb_ot_layout_get_lig_carets (hb_face_t *face, - hb_font_t *font, - hb_codepoint_t glyph, - unsigned int *caret_count /* IN/OUT */, - int *caret_array /* OUT */) -{ - hb_ot_layout_context_t context; - context.font = font; - context.face = face; - return _get_gdef (face).get_lig_carets (&context, glyph, caret_count, caret_array); -} - -/* - * GSUB/GPOS - */ - -static const GSUBGPOS& -get_gsubgpos_table (hb_face_t *face, - hb_tag_t table_tag) -{ - switch (table_tag) { - case HB_OT_TAG_GSUB: return _get_gsub (face); - case HB_OT_TAG_GPOS: return _get_gpos (face); - default: return Null(GSUBGPOS); - } -} - - -hb_bool_t -hb_ot_layout_table_get_script_tags (hb_face_t *face, - hb_tag_t table_tag, - unsigned int *script_count /* IN/OUT */, - hb_tag_t *script_tags /* OUT */) -{ - const GSUBGPOS &g = get_gsubgpos_table (face, table_tag); - - return g.get_script_tags (script_count, script_tags); -} - -hb_bool_t -hb_ot_layout_table_find_script (hb_face_t *face, - hb_tag_t table_tag, - hb_tag_t script_tag, - unsigned int *script_index) -{ - ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX); - const GSUBGPOS &g = get_gsubgpos_table (face, table_tag); - - if (g.find_script_index (script_tag, script_index)) - return TRUE; - - /* try finding 'DFLT' */ - if (g.find_script_index (HB_OT_LAYOUT_TAG_DEFAULT_SCRIPT, script_index)) - return FALSE; - - /* try with 'dflt'; MS site has had typos and many fonts use it now :( */ - if (g.find_script_index (HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE, script_index)) - return FALSE; - - if (script_index) *script_index = HB_OT_LAYOUT_NO_SCRIPT_INDEX; - return FALSE; -} - -hb_bool_t -hb_ot_layout_table_get_feature_tags (hb_face_t *face, - hb_tag_t table_tag, - unsigned int *feature_count /* IN/OUT */, - hb_tag_t *feature_tags /* OUT */) -{ - const GSUBGPOS &g = get_gsubgpos_table (face, table_tag); - - return g.get_feature_tags (feature_count, feature_tags); -} - - -hb_bool_t -hb_ot_layout_script_get_language_tags (hb_face_t *face, - hb_tag_t table_tag, - unsigned int script_index, - unsigned int *language_count /* IN/OUT */, - hb_tag_t *language_tags /* OUT */) -{ - const Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index); - - return s.get_lang_sys_tags (language_count, language_tags); -} - -hb_bool_t -hb_ot_layout_script_find_language (hb_face_t *face, - hb_tag_t table_tag, - unsigned int script_index, - hb_tag_t language_tag, - unsigned int *language_index) -{ - ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX); - const Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index); - - if (s.find_lang_sys_index (language_tag, language_index)) - return TRUE; - - /* try with 'dflt'; MS site has had typos and many fonts use it now :( */ - if (s.find_lang_sys_index (HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE, language_index)) - return FALSE; - - if (language_index) *language_index = HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX; - return FALSE; -} - -hb_bool_t -hb_ot_layout_language_get_required_feature_index (hb_face_t *face, - hb_tag_t table_tag, - unsigned int script_index, - unsigned int language_index, - unsigned int *feature_index) -{ - const LangSys &l = get_gsubgpos_table (face, table_tag).get_script (script_index).get_lang_sys (language_index); - - if (feature_index) *feature_index = l.get_required_feature_index (); - - return l.has_required_feature (); -} - -hb_bool_t -hb_ot_layout_language_get_feature_indexes (hb_face_t *face, - hb_tag_t table_tag, - unsigned int script_index, - unsigned int language_index, - unsigned int *feature_count /* IN/OUT */, - unsigned int *feature_indexes /* OUT */) -{ - const GSUBGPOS &g = get_gsubgpos_table (face, table_tag); - const LangSys &l = g.get_script (script_index).get_lang_sys (language_index); - - return l.get_feature_indexes (feature_count, feature_indexes); -} - -hb_bool_t -hb_ot_layout_language_get_feature_tags (hb_face_t *face, - hb_tag_t table_tag, - unsigned int script_index, - unsigned int language_index, - unsigned int *feature_count /* IN/OUT */, - hb_tag_t *feature_tags /* OUT */) -{ - const GSUBGPOS &g = get_gsubgpos_table (face, table_tag); - const LangSys &l = g.get_script (script_index).get_lang_sys (language_index); - - ASSERT_STATIC (sizeof (unsigned int) == sizeof (hb_tag_t)); - hb_bool_t ret = l.get_feature_indexes (feature_count, (unsigned int *) feature_tags); - - if (feature_tags) { - unsigned int count = *feature_count; - for (unsigned int i = 0; i < count; i++) - feature_tags[i] = g.get_feature_tag ((unsigned int) feature_tags[i]); - } - - return ret; -} - - -hb_bool_t -hb_ot_layout_language_find_feature (hb_face_t *face, - hb_tag_t table_tag, - unsigned int script_index, - unsigned int language_index, - hb_tag_t feature_tag, - unsigned int *feature_index) -{ - ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX); - const GSUBGPOS &g = get_gsubgpos_table (face, table_tag); - const LangSys &l = g.get_script (script_index).get_lang_sys (language_index); - - unsigned int num_features = l.get_feature_count (); - for (unsigned int i = 0; i < num_features; i++) { - unsigned int f_index = l.get_feature_index (i); - - if (feature_tag == g.get_feature_tag (f_index)) { - if (feature_index) *feature_index = f_index; - return TRUE; - } - } - - if (feature_index) *feature_index = HB_OT_LAYOUT_NO_FEATURE_INDEX; - return FALSE; -} - -hb_bool_t -hb_ot_layout_feature_get_lookup_indexes (hb_face_t *face, - hb_tag_t table_tag, - unsigned int feature_index, - unsigned int *lookup_count /* IN/OUT */, - unsigned int *lookup_indexes /* OUT */) -{ - const GSUBGPOS &g = get_gsubgpos_table (face, table_tag); - const Feature &f = g.get_feature (feature_index); - - return f.get_lookup_indexes (lookup_count, lookup_indexes); -} - - -/* - * GSUB - */ - -hb_bool_t -hb_ot_layout_has_substitution (hb_face_t *face) -{ - return &_get_gsub (face) != &Null(GSUB); -} - -hb_bool_t -hb_ot_layout_substitute_lookup (hb_face_t *face, - hb_buffer_t *buffer, - unsigned int lookup_index, - hb_mask_t mask) -{ - hb_ot_layout_context_t context; - context.font = NULL; - context.face = face; - return _get_gsub (face).substitute_lookup (&context, buffer, lookup_index, mask); -} - - -/* - * GPOS - */ - -hb_bool_t -hb_ot_layout_has_positioning (hb_face_t *face) -{ - return &_get_gpos (face) != &Null(GPOS); -} - -hb_bool_t -hb_ot_layout_position_lookup (hb_face_t *face, - hb_font_t *font, - hb_buffer_t *buffer, - unsigned int lookup_index, - hb_mask_t mask) -{ - hb_ot_layout_context_t context; - context.font = font; - context.face = face; - return _get_gpos (face).position_lookup (&context, buffer, lookup_index, mask); -} diff --git a/pango/opentype/hb-ot-layout.h b/pango/opentype/hb-ot-layout.h deleted file mode 100644 index 54f785f6..00000000 --- a/pango/opentype/hb-ot-layout.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright (C) 2007,2008,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_OT_LAYOUT_H -#define HB_OT_LAYOUT_H - -#include "hb-common.h" -#include "hb-buffer.h" -#include "hb-font.h" - -HB_BEGIN_DECLS - -#define HB_OT_TAG_GDEF HB_TAG('G','D','E','F') -#define HB_OT_TAG_GSUB HB_TAG('G','S','U','B') -#define HB_OT_TAG_GPOS HB_TAG('G','P','O','S') - -/* - * GDEF - */ - -typedef enum { - HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0x0000, - HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH = 0x0002, - HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE = 0x0004, - HB_OT_LAYOUT_GLYPH_CLASS_MARK = 0x0008, - HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT = 0x0010 -} hb_ot_layout_glyph_class_t; - -/* XXX These should eventually be removed as we move synthesized glyph - * classes in harfbuzz. */ - -hb_bool_t -hb_ot_layout_has_font_glyph_classes (hb_face_t *face); - -hb_ot_layout_glyph_class_t -hb_ot_layout_get_glyph_class (hb_face_t *face, - hb_codepoint_t glyph); - -void -hb_ot_layout_set_glyph_class (hb_face_t *face, - hb_codepoint_t glyph, - hb_ot_layout_glyph_class_t klass); - -void -hb_ot_layout_build_glyph_classes (hb_face_t *face, - uint16_t num_total_glyphs, - hb_codepoint_t *glyphs, - unsigned char *klasses, - uint16_t count); - -/* Not that useful. Provides list of attach points for a glyph that a - * client may want to cache */ -hb_bool_t -hb_ot_layout_get_attach_points (hb_face_t *face, - hb_codepoint_t glyph, - unsigned int *point_count /* IN/OUT */, - unsigned int *point_array /* OUT */); - -/* Ligature caret positions */ -hb_bool_t -hb_ot_layout_get_lig_carets (hb_face_t *face, - hb_font_t *font, - hb_codepoint_t glyph, - unsigned int *caret_count /* IN/OUT */, - int *caret_array /* OUT */); - - -/* - * GSUB/GPOS feature query and enumeration interface - */ - -#define HB_OT_LAYOUT_NO_SCRIPT_INDEX ((unsigned int) 0xFFFF) -#define HB_OT_LAYOUT_NO_FEATURE_INDEX ((unsigned int) 0xFFFF) -#define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX ((unsigned int) 0xFFFF) -#define HB_OT_LAYOUT_TAG_DEFAULT_SCRIPT HB_TAG ('D', 'F', 'L', 'T') -#define HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE HB_TAG ('d', 'f', 'l', 't') - -hb_bool_t -hb_ot_layout_table_get_script_tags (hb_face_t *face, - hb_tag_t table_tag, - unsigned int *script_count /* IN/OUT */, - hb_tag_t *script_tags /* OUT */); - -hb_bool_t -hb_ot_layout_table_find_script (hb_face_t *face, - hb_tag_t table_tag, - hb_tag_t script_tag, - unsigned int *script_index); - -hb_bool_t -hb_ot_layout_table_get_feature_tags (hb_face_t *face, - hb_tag_t table_tag, - unsigned int *feature_count /* IN/OUT */, - hb_tag_t *feature_tags /* OUT */); - -hb_bool_t -hb_ot_layout_script_get_language_tags (hb_face_t *face, - hb_tag_t table_tag, - unsigned int script_index, - unsigned int *language_count /* IN/OUT */, - hb_tag_t *language_tags /* OUT */); - -hb_bool_t -hb_ot_layout_script_find_language (hb_face_t *face, - hb_tag_t table_tag, - unsigned int script_index, - hb_tag_t language_tag, - unsigned int *language_index); - -hb_bool_t -hb_ot_layout_language_get_required_feature_index (hb_face_t *face, - hb_tag_t table_tag, - unsigned int script_index, - unsigned int language_index, - unsigned int *feature_index); - -hb_bool_t -hb_ot_layout_language_get_feature_indexes (hb_face_t *face, - hb_tag_t table_tag, - unsigned int script_index, - unsigned int language_index, - unsigned int *feature_count /* IN/OUT */, - unsigned int *feature_indexes /* OUT */); - -hb_bool_t -hb_ot_layout_language_get_feature_tags (hb_face_t *face, - hb_tag_t table_tag, - unsigned int script_index, - unsigned int language_index, - unsigned int *feature_count /* IN/OUT */, - hb_tag_t *feature_tags /* OUT */); - -hb_bool_t -hb_ot_layout_language_find_feature (hb_face_t *face, - hb_tag_t table_tag, - unsigned int script_index, - unsigned int language_index, - hb_tag_t feature_tag, - unsigned int *feature_index); - -hb_bool_t -hb_ot_layout_feature_get_lookup_indexes (hb_face_t *face, - hb_tag_t table_tag, - unsigned int feature_index, - unsigned int *lookup_count /* IN/OUT */, - unsigned int *lookup_indexes /* OUT */); - - -/* - * GSUB - */ - -hb_bool_t -hb_ot_layout_has_substitution (hb_face_t *face); - -hb_bool_t -hb_ot_layout_substitute_lookup (hb_face_t *face, - hb_buffer_t *buffer, - unsigned int lookup_index, - hb_mask_t mask); - -/* - * GPOS - */ - -hb_bool_t -hb_ot_layout_has_positioning (hb_face_t *face); - -hb_bool_t -hb_ot_layout_position_lookup (hb_face_t *face, - hb_font_t *font, - hb_buffer_t *buffer, - unsigned int lookup_index, - hb_mask_t mask); - - -HB_END_DECLS - -#endif /* HB_OT_LAYOUT_H */ diff --git a/pango/opentype/hb-ot.h b/pango/opentype/hb-ot.h deleted file mode 100644 index c04216b8..00000000 --- a/pango/opentype/hb-ot.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_OT_H -#define HB_OT_H - -#include "hb.h" - -#include "hb-ot-layout.h" - -#endif /* HB_OT_H */ diff --git a/pango/opentype/hb-private.h b/pango/opentype/hb-private.h deleted file mode 100644 index 8d885aa4..00000000 --- a/pango/opentype/hb-private.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (C) 2007,2008,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_PRIVATE_H -#define HB_PRIVATE_H - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -/* #define HB_DEBUG 1 */ -#ifndef HB_DEBUG -#define HB_DEBUG 0 -#endif - -#include <stdlib.h> -#include <string.h> -#include <assert.h> -#if HB_DEBUG -#include <stdio.h> -#include <errno.h> -#endif - -#include "hb-common.h" - -#define hb_be_uint8 -#define hb_be_int8 -#define hb_be_uint16(v) ((uint16_t) hb_be_int16 ((uint16_t) v)) -#define hb_be_uint32(v) ((uint32_t) hb_be_int32 ((uint32_t) v)) - -/* We need external help for these */ - -#if HAVE_GLIB - -#include <glib.h> - -/* Macros to convert to/from BigEndian */ -#define hb_be_int16(v) GINT16_FROM_BE (v) -#define hb_be_int32(v) GINT32_FROM_BE (v) - -typedef int hb_atomic_int_t; -#define hb_atomic_int_fetch_and_add(AI, V) g_atomic_int_exchange_and_add (&(AI), V) -#define hb_atomic_int_get(AI) g_atomic_int_get (&(AI)) -#define hb_atomic_int_set(AI, V) g_atomic_int_set (&(AI), V) - -typedef GStaticMutex hb_mutex_t; -#define HB_MUTEX_INIT G_STATIC_MUTEX_INIT -#define hb_mutex_init(M) g_static_mutex_init (&M) -#define hb_mutex_lock(M) g_static_mutex_lock (&M) -#define hb_mutex_trylock(M) g_static_mutex_trylock (&M) -#define hb_mutex_unlock(M) g_static_mutex_unlock (&M) - -#else -#error "Could not find any system to define platform macros, see hb-private.h" -#endif - - -#define hb_be_uint8_put_unaligned(v,V) (v[0] = (V), 0) -#define hb_be_uint8_get_unaligned(v) (uint8_t) (v[0]) -#define hb_be_uint8_cmp_unaligned(a,b) (a[0] == b[0]) -#define hb_be_int8_put_unaligned hb_be_uint8_put_unaligned -#define hb_be_int8_get_unaligned (int8_t) hb_be_uint8_get_unaligned -#define hb_be_int8_cmp_unaligned hb_be_uint8_cmp_unaligned - -#define hb_be_uint16_put_unaligned(v,V) (v[0] = (V>>8), v[1] = (V), 0) -#define hb_be_uint16_get_unaligned(v) (uint16_t) ((v[0] << 8) + v[1]) -#define hb_be_uint16_cmp_unaligned(a,b) (a[0] == b[0] && a[1] == b[1]) -#define hb_be_int16_put_unaligned hb_be_uint16_put_unaligned -#define hb_be_int16_get_unaligned (int16_t) hb_be_uint16_get_unaligned -#define hb_be_int16_cmp_unaligned hb_be_uint16_cmp_unaligned - -#define hb_be_uint32_put_unaligned(v,V) (v[0] = (V>>24), v[1] = (V>>16), v[2] = (V>>8), v[3] = (V), 0) -#define hb_be_uint32_get_unaligned(v) (uint32_t) ((v[0] << 24) + (v[1] << 16) + (v[2] << 8) + v[3]) -#define hb_be_uint32_cmp_unaligned(a,b) (a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3]) -#define hb_be_int32_put_unaligned hb_be_uint32_put_unaligned -#define hb_be_int32_get_unaligned (int32_t) hb_be_uint32_get_unaligned -#define hb_be_int32_cmp_unaligned hb_be_uint32_cmp_unaligned - - -/* Basics */ - -#undef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - -#ifndef HB_INTERNAL -# define HB_INTERNAL extern -#endif - -#ifndef NULL -# define NULL ((void *)0) -#endif - -#ifndef FALSE -# define FALSE 0 -#endif - -#ifndef TRUE -# define TRUE 1 -#endif - -#define HB_STMT_START do -#define HB_STMT_END while (0) - -#define _ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1] -#define _ASSERT_STATIC0(_line, _cond) _ASSERT_STATIC1 (_line, (_cond)) -#define ASSERT_STATIC(_cond) _ASSERT_STATIC0 (__LINE__, (_cond)) - -#define ASSERT_SIZE(_type, _size) ASSERT_STATIC (sizeof (_type) == (_size)) - - -#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) -#define _HB_BOOLEAN_EXPR(expr) \ - __extension__ ({ \ - int _cairo_boolean_var_; \ - if (expr) \ - _cairo_boolean_var_ = 1; \ - else \ - _cairo_boolean_var_ = 0; \ - _cairo_boolean_var_; \ -}) -#define HB_LIKELY(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 1)) -#define HB_UNLIKELY(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 0)) -#else -#define HB_LIKELY(expr) (expr) -#define HB_UNLIKELY(expr) (expr) -#endif - -#ifndef __GNUC__ -#undef __attribute__ -#define __attribute__(x) -#endif - -#if __GNUC__ >= 3 -#define HB_GNUC_UNUSED __attribute__((unused)) -#define HB_GNUC_PURE __attribute__((pure)) -#define HB_GNUC_CONST __attribute__((const)) -#else -#define HB_GNUC_UNUSED -#define HB_GNUC_PURE -#define HB_GNUC_CONST -#endif - - -#if (defined(__WIN32__) && !defined(__WINE__)) || defined(_MSC_VER) -#define snprintf _snprintf -#endif - -#ifdef _MSC_VER -#undef inline -#define inline __inline -#endif - -#ifdef __STRICT_ANSI__ -#undef inline -#define inline __inline__ -#endif - - -/* Return the number of 1 bits in mask. - * - * GCC 3.4 supports a "population count" builtin, which on many targets is - * implemented with a single instruction. There is a fallback definition - * in libgcc in case a target does not have one, which should be just as - * good as the open-coded solution below, (which is "HACKMEM 169"). - */ -static HB_GNUC_UNUSED inline unsigned int -_hb_popcount32 (uint32_t mask) -{ -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - return __builtin_popcount (mask); -#else - register uint32_t y; - - y = (mask >> 1) &033333333333; - y = mask - y - ((y >>1) & 033333333333); - return (((y + (y >> 3)) & 030707070707) % 077); -#endif -} - - -/* Multiplies a 16dot16 value by another value, then truncates the result */ -#define _hb_16dot16_mul_trunc(A,B) ((int64_t) (A) * (B) / 0x10000) - -#include "hb-object-private.h" - -#endif /* HB_PRIVATE_H */ diff --git a/pango/opentype/hb-shape.c b/pango/opentype/hb-shape.c deleted file mode 100644 index 55e21507..00000000 --- a/pango/opentype/hb-shape.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#include "hb-private.h" - -#include "hb-shape.h" - - -void -hb_shape (hb_face_t *face, - hb_font_t *font, - hb_buffer_t *buffer, - hb_feature_t *features, - unsigned int num_features) -{ -} - diff --git a/pango/opentype/hb-shape.h b/pango/opentype/hb-shape.h deleted file mode 100644 index be205929..00000000 --- a/pango/opentype/hb-shape.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_SHAPE_H -#define HB_SHAPE_H - -#include "hb-common.h" -#include "hb-buffer.h" -#include "hb-font.h" - -HB_BEGIN_DECLS - -typedef struct _hb_feature_t { - const char *name; - const char *value; - unsigned int start; - unsigned int end; -} hb_feature_t; - -void -hb_shape (hb_face_t *face, - hb_font_t *font, - hb_buffer_t *buffer, - hb_feature_t *features, - unsigned int num_features); - - -HB_END_DECLS - -#endif /* HB_SHAPE_H */ diff --git a/pango/opentype/hb-unicode-private.h b/pango/opentype/hb-unicode-private.h deleted file mode 100644 index 88802455..00000000 --- a/pango/opentype/hb-unicode-private.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_UNICODE_PRIVATE_H -#define HB_UNICODE_PRIVATE_H - -#include "hb-private.h" - -#include "hb-unicode.h" - -HB_BEGIN_DECLS - -/* - * hb_unicode_funcs_t - */ - -struct _hb_unicode_funcs_t { - hb_reference_count_t ref_count; - - hb_bool_t immutable; - - hb_unicode_get_general_category_func_t get_general_category; - hb_unicode_get_combining_class_func_t get_combining_class; - hb_unicode_get_mirroring_func_t get_mirroring; - hb_unicode_get_script_func_t get_script; - hb_unicode_get_eastasian_width_func_t get_eastasian_width; -}; - -HB_INTERNAL hb_unicode_funcs_t -_hb_unicode_funcs_nil; - -HB_END_DECLS - -#endif /* HB_UNICODE_PRIVATE_H */ diff --git a/pango/opentype/hb-unicode.c b/pango/opentype/hb-unicode.c deleted file mode 100644 index 01b54f58..00000000 --- a/pango/opentype/hb-unicode.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#include "hb-private.h" - -#include "hb-unicode-private.h" - -/* - * hb_unicode_funcs_t - */ - -static hb_codepoint_t hb_unicode_get_mirroring_nil (hb_codepoint_t unicode) { return unicode; } -static hb_category_t hb_unicode_get_general_category_nil (hb_codepoint_t unicode) { return HB_CATEGORY_OTHER_LETTER; } -static hb_script_t hb_unicode_get_script_nil (hb_codepoint_t unicode) { return HB_SCRIPT_UNKNOWN; } -static unsigned int hb_unicode_get_combining_class_nil (hb_codepoint_t unicode) { return 0; } -static unsigned int hb_unicode_get_eastasian_width_nil (hb_codepoint_t unicode) { return 1; } - -hb_unicode_funcs_t _hb_unicode_funcs_nil = { - HB_REFERENCE_COUNT_INVALID, /* ref_count */ - - TRUE, /* immutable */ - - hb_unicode_get_general_category_nil, - hb_unicode_get_combining_class_nil, - hb_unicode_get_mirroring_nil, - hb_unicode_get_script_nil, - hb_unicode_get_eastasian_width_nil -}; - -hb_unicode_funcs_t * -hb_unicode_funcs_create (void) -{ - hb_unicode_funcs_t *ufuncs; - - if (!HB_OBJECT_DO_CREATE (hb_unicode_funcs_t, ufuncs)) - return &_hb_unicode_funcs_nil; - - *ufuncs = _hb_unicode_funcs_nil; - HB_OBJECT_DO_INIT (ufuncs); - - return ufuncs; -} - -hb_unicode_funcs_t * -hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs) -{ - HB_OBJECT_DO_REFERENCE (ufuncs); -} - -unsigned int -hb_unicode_funcs_get_reference_count (hb_unicode_funcs_t *ufuncs) -{ - HB_OBJECT_DO_GET_REFERENCE_COUNT (ufuncs); -} - -void -hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs) -{ - HB_OBJECT_DO_DESTROY (ufuncs); - - free (ufuncs); -} - -hb_unicode_funcs_t * -hb_unicode_funcs_copy (hb_unicode_funcs_t *other_ufuncs) -{ - hb_unicode_funcs_t *ufuncs; - - if (!HB_OBJECT_DO_CREATE (hb_unicode_funcs_t, ufuncs)) - return &_hb_unicode_funcs_nil; - - *ufuncs = *other_ufuncs; - HB_OBJECT_DO_INIT (ufuncs); - ufuncs->immutable = FALSE; - - return ufuncs; -} - -void -hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs) -{ - if (HB_OBJECT_IS_INERT (ufuncs)) - return; - - ufuncs->immutable = TRUE; -} - - -void -hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t *ufuncs, - hb_unicode_get_mirroring_func_t mirroring_func) -{ - if (ufuncs->immutable) - return; - - ufuncs->get_mirroring = mirroring_func ? mirroring_func : hb_unicode_get_mirroring_nil; -} - -void -hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs, - hb_unicode_get_general_category_func_t general_category_func) -{ - if (ufuncs->immutable) - return; - - ufuncs->get_general_category = general_category_func ? general_category_func : hb_unicode_get_general_category_nil; -} - -void -hb_unicode_funcs_set_script_func (hb_unicode_funcs_t *ufuncs, - hb_unicode_get_script_func_t script_func) -{ - if (ufuncs->immutable) - return; - - ufuncs->get_script = script_func ? script_func : hb_unicode_get_script_nil; -} - -void -hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs, - hb_unicode_get_combining_class_func_t combining_class_func) -{ - if (ufuncs->immutable) - return; - - ufuncs->get_combining_class = combining_class_func ? combining_class_func : hb_unicode_get_combining_class_nil; -} - -void -hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs, - hb_unicode_get_eastasian_width_func_t eastasian_width_func) -{ - if (ufuncs->immutable) - return; - - ufuncs->get_eastasian_width = eastasian_width_func ? eastasian_width_func : hb_unicode_get_eastasian_width_nil; -} - diff --git a/pango/opentype/hb-unicode.h b/pango/opentype/hb-unicode.h deleted file mode 100644 index 59f198db..00000000 --- a/pango/opentype/hb-unicode.h +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_UNICODE_H -#define HB_UNICODE_H - -#include "hb-common.h" - -HB_BEGIN_DECLS - -/* Unicode General Category property */ -typedef enum -{ - HB_CATEGORY_CONTROL, - HB_CATEGORY_FORMAT, - HB_CATEGORY_UNASSIGNED, - HB_CATEGORY_PRIVATE_USE, - HB_CATEGORY_SURROGATE, - HB_CATEGORY_LOWERCASE_LETTER, - HB_CATEGORY_MODIFIER_LETTER, - HB_CATEGORY_OTHER_LETTER, - HB_CATEGORY_TITLECASE_LETTER, - HB_CATEGORY_UPPERCASE_LETTER, - HB_CATEGORY_COMBINING_MARK, - HB_CATEGORY_ENCLOSING_MARK, - HB_CATEGORY_NON_SPACING_MARK, - HB_CATEGORY_DECIMAL_NUMBER, - HB_CATEGORY_LETTER_NUMBER, - HB_CATEGORY_OTHER_NUMBER, - HB_CATEGORY_CONNECT_PUNCTUATION, - HB_CATEGORY_DASH_PUNCTUATION, - HB_CATEGORY_CLOSE_PUNCTUATION, - HB_CATEGORY_FINAL_PUNCTUATION, - HB_CATEGORY_INITIAL_PUNCTUATION, - HB_CATEGORY_OTHER_PUNCTUATION, - HB_CATEGORY_OPEN_PUNCTUATION, - HB_CATEGORY_CURRENCY_SYMBOL, - HB_CATEGORY_MODIFIER_SYMBOL, - HB_CATEGORY_MATH_SYMBOL, - HB_CATEGORY_OTHER_SYMBOL, - HB_CATEGORY_LINE_SEPARATOR, - HB_CATEGORY_PARAGRAPH_SEPARATOR, - HB_CATEGORY_SPACE_SEPARATOR -} hb_category_t; - -/* Unicode Script property */ -typedef enum -{ /* ISO 15924 code */ - HB_SCRIPT_INVALID_CODE = -1, - HB_SCRIPT_COMMON = 0, /* Zyyy */ - HB_SCRIPT_INHERITED, /* Qaai */ - HB_SCRIPT_ARABIC, /* Arab */ - HB_SCRIPT_ARMENIAN, /* Armn */ - HB_SCRIPT_BENGALI, /* Beng */ - HB_SCRIPT_BOPOMOFO, /* Bopo */ - HB_SCRIPT_CHEROKEE, /* Cher */ - HB_SCRIPT_COPTIC, /* Qaac */ - HB_SCRIPT_CYRILLIC, /* Cyrl (Cyrs) */ - HB_SCRIPT_DESERET, /* Dsrt */ - HB_SCRIPT_DEVANAGARI, /* Deva */ - HB_SCRIPT_ETHIOPIC, /* Ethi */ - HB_SCRIPT_GEORGIAN, /* Geor (Geon, Geoa) */ - HB_SCRIPT_GOTHIC, /* Goth */ - HB_SCRIPT_GREEK, /* Grek */ - HB_SCRIPT_GUJARATI, /* Gujr */ - HB_SCRIPT_GURMUKHI, /* Guru */ - HB_SCRIPT_HAN, /* Hani */ - HB_SCRIPT_HANGUL, /* Hang */ - HB_SCRIPT_HEBREW, /* Hebr */ - HB_SCRIPT_HIRAGANA, /* Hira */ - HB_SCRIPT_KANNADA, /* Knda */ - HB_SCRIPT_KATAKANA, /* Kana */ - HB_SCRIPT_KHMER, /* Khmr */ - HB_SCRIPT_LAO, /* Laoo */ - HB_SCRIPT_LATIN, /* Latn (Latf, Latg) */ - HB_SCRIPT_MALAYALAM, /* Mlym */ - HB_SCRIPT_MONGOLIAN, /* Mong */ - HB_SCRIPT_MYANMAR, /* Mymr */ - HB_SCRIPT_OGHAM, /* Ogam */ - HB_SCRIPT_OLD_ITALIC, /* Ital */ - HB_SCRIPT_ORIYA, /* Orya */ - HB_SCRIPT_RUNIC, /* Runr */ - HB_SCRIPT_SINHALA, /* Sinh */ - HB_SCRIPT_SYRIAC, /* Syrc (Syrj, Syrn, Syre) */ - HB_SCRIPT_TAMIL, /* Taml */ - HB_SCRIPT_TELUGU, /* Telu */ - HB_SCRIPT_THAANA, /* Thaa */ - HB_SCRIPT_THAI, /* Thai */ - HB_SCRIPT_TIBETAN, /* Tibt */ - HB_SCRIPT_CANADIAN_ABORIGINAL, /* Cans */ - HB_SCRIPT_YI, /* Yiii */ - HB_SCRIPT_TAGALOG, /* Tglg */ - HB_SCRIPT_HANUNOO, /* Hano */ - HB_SCRIPT_BUHID, /* Buhd */ - HB_SCRIPT_TAGBANWA, /* Tagb */ - - /* Unicode-4.0 additions */ - HB_SCRIPT_BRAILLE, /* Brai */ - HB_SCRIPT_CYPRIOT, /* Cprt */ - HB_SCRIPT_LIMBU, /* Limb */ - HB_SCRIPT_OSMANYA, /* Osma */ - HB_SCRIPT_SHAVIAN, /* Shaw */ - HB_SCRIPT_LINEAR_B, /* Linb */ - HB_SCRIPT_TAI_LE, /* Tale */ - HB_SCRIPT_UGARITIC, /* Ugar */ - - /* Unicode-4.1 additions */ - HB_SCRIPT_NEW_TAI_LUE, /* Talu */ - HB_SCRIPT_BUGINESE, /* Bugi */ - HB_SCRIPT_GLAGOLITIC, /* Glag */ - HB_SCRIPT_TIFINAGH, /* Tfng */ - HB_SCRIPT_SYLOTI_NAGRI, /* Sylo */ - HB_SCRIPT_OLD_PERSIAN, /* Xpeo */ - HB_SCRIPT_KHAROSHTHI, /* Khar */ - - /* Unicode-5.0 additions */ - HB_SCRIPT_UNKNOWN, /* Zzzz */ - HB_SCRIPT_BALINESE, /* Bali */ - HB_SCRIPT_CUNEIFORM, /* Xsux */ - HB_SCRIPT_PHOENICIAN, /* Phnx */ - HB_SCRIPT_PHAGS_PA, /* Phag */ - HB_SCRIPT_NKO, /* Nkoo */ - - /* Unicode-5.1 additions */ - HB_SCRIPT_KAYAH_LI, /* Kali */ - HB_SCRIPT_LEPCHA, /* Lepc */ - HB_SCRIPT_REJANG, /* Rjng */ - HB_SCRIPT_SUNDANESE, /* Sund */ - HB_SCRIPT_SAURASHTRA, /* Saur */ - HB_SCRIPT_CHAM, /* Cham */ - HB_SCRIPT_OL_CHIKI, /* Olck */ - HB_SCRIPT_VAI, /* Vaii */ - HB_SCRIPT_CARIAN, /* Cari */ - HB_SCRIPT_LYCIAN, /* Lyci */ - HB_SCRIPT_LYDIAN /* Lydi */ -} hb_script_t; - - -/* - * hb_unicode_funcs_t - */ - -typedef struct _hb_unicode_funcs_t hb_unicode_funcs_t; - -hb_unicode_funcs_t * -hb_unicode_funcs_create (void); - -hb_unicode_funcs_t * -hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs); - -unsigned int -hb_unicode_funcs_get_reference_count (hb_unicode_funcs_t *ufuncs); - -void -hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs); - -hb_unicode_funcs_t * -hb_unicode_funcs_copy (hb_unicode_funcs_t *ufuncs); - -void -hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs); - - -/* funcs */ - -typedef hb_codepoint_t (*hb_unicode_get_mirroring_func_t) (hb_codepoint_t unicode); -typedef hb_category_t (*hb_unicode_get_general_category_func_t) (hb_codepoint_t unicode); -typedef hb_script_t (*hb_unicode_get_script_func_t) (hb_codepoint_t unicode); -typedef unsigned int (*hb_unicode_get_combining_class_func_t) (hb_codepoint_t unicode); -typedef unsigned int (*hb_unicode_get_eastasian_width_func_t) (hb_codepoint_t unicode); - - -void -hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t *ufuncs, - hb_unicode_get_mirroring_func_t mirroring_func); - -void -hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs, - hb_unicode_get_general_category_func_t general_category_func); - -void -hb_unicode_funcs_set_script_func (hb_unicode_funcs_t *ufuncs, - hb_unicode_get_script_func_t script_func); - -void -hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs, - hb_unicode_get_combining_class_func_t combining_class_func); - -void -hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs, - hb_unicode_get_eastasian_width_func_t eastasian_width_func); - - -HB_END_DECLS - -#endif /* HB_FONT_H */ diff --git a/pango/opentype/hb.h b/pango/opentype/hb.h deleted file mode 100644 index a948e134..00000000 --- a/pango/opentype/hb.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#ifndef HB_H -#define HB_H - -#include "hb-common.h" -#include "hb-blob.h" -#include "hb-buffer.h" -#include "hb-font.h" - -#endif /* HB_H */ diff --git a/pango/opentype/main.cc b/pango/opentype/main.cc deleted file mode 100644 index 31264a47..00000000 --- a/pango/opentype/main.cc +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2007,2008,2009 Red Hat, Inc. - * - * This is part of HarfBuzz, an OpenType Layout engine library. - * - * 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 - */ - -#define HB_OT_LAYOUT_CC -#include "hb-open-file-private.hh" -#include "hb-ot-layout-gdef-private.hh" -#include "hb-ot-layout-gsubgpos-private.hh" - -#include <glib.h> -#include <stdlib.h> -#include <stdio.h> - -int -main (int argc, char **argv) -{ - if (argc != 2) { - fprintf (stderr, "usage: %s font-file.ttf\n", argv[0]); - exit (1); - } - - GMappedFile *mf = g_mapped_file_new (argv[1], FALSE, NULL); - const char *font_data = g_mapped_file_get_contents (mf); - int len = g_mapped_file_get_length (mf); - - printf ("Opened font file %s: %d bytes long\n", argv[1], len); - - const OpenTypeFontFile &ot = OpenTypeFontFile::get_for_data (font_data); - - switch (ot.tag) { - case OpenTypeFontFile::TrueTypeTag: - printf ("OpenType font with TrueType outlines\n"); - break; - case OpenTypeFontFile::CFFTag: - printf ("OpenType font with CFF (Type1) outlines\n"); - break; - case OpenTypeFontFile::TTCTag: - printf ("TrueType Collection of OpenType fonts\n"); - break; - default: - printf ("Unknown font format\n"); - break; - } - - int num_fonts = ot.get_face_count (); - printf ("%d font(s) found in file\n", num_fonts); - for (int n_font = 0; n_font < num_fonts; n_font++) { - const OpenTypeFontFace &font = ot.get_face (n_font); - printf ("Font %d of %d:\n", n_font, num_fonts); - - int num_tables = font.get_table_count (); - printf (" %d table(s) found in font\n", num_tables); - for (int n_table = 0; n_table < num_tables; n_table++) { - const OpenTypeTable &table = font.get_table (n_table); - printf (" Table %2d of %2d: %.4s (0x%08x+0x%08x)\n", n_table, num_tables, - (const char *)table.tag, - (unsigned int) table.offset, - (unsigned int) table.length); - - switch (table.tag) { - - case GSUBGPOS::GSUBTag: - case GSUBGPOS::GPOSTag: - { - - const GSUBGPOS &g = GSUBGPOS::get_for_data (ot.get_table_data (table)); - - int num_scripts = g.get_script_count (); - printf (" %d script(s) found in table\n", num_scripts); - for (int n_script = 0; n_script < num_scripts; n_script++) { - const Script &script = g.get_script (n_script); - printf (" Script %2d of %2d: %.4s\n", n_script, num_scripts, - (const char *)g.get_script_tag(n_script)); - - if (!script.has_default_lang_sys()) - printf (" No default language system\n"); - int num_langsys = script.get_lang_sys_count (); - printf (" %d language system(s) found in script\n", num_langsys); - for (int n_langsys = script.has_default_lang_sys() ? -1 : 0; n_langsys < num_langsys; n_langsys++) { - const LangSys &langsys = n_langsys == -1 - ? script.get_default_lang_sys () - : script.get_lang_sys (n_langsys); - printf (n_langsys == -1 - ? " Default Language System\n" - : " Language System %2d of %2d: %.4s\n", n_langsys, num_langsys, - (const char *)script.get_lang_sys_tag (n_langsys)); - if (langsys.get_required_feature_index () == NO_INDEX) - printf (" No required feature\n"); - - int num_features = langsys.get_feature_count (); - printf (" %d feature(s) found in language system\n", num_features); - for (int n_feature = 0; n_feature < num_features; n_feature++) { - printf (" Feature index %2d of %2d: %d\n", n_feature, num_features, - langsys.get_feature_index (n_feature)); - } - } - } - - int num_features = g.get_feature_count (); - printf (" %d feature(s) found in table\n", num_features); - for (int n_feature = 0; n_feature < num_features; n_feature++) { - const Feature &feature = g.get_feature (n_feature); - printf (" Feature %2d of %2d: %.4s; %d lookup(s)\n", n_feature, num_features, - (const char *)g.get_feature_tag(n_feature), - feature.get_lookup_count()); - - int num_lookups = feature.get_lookup_count (); - printf (" %d lookup(s) found in feature\n", num_lookups); - for (int n_lookup = 0; n_lookup < num_lookups; n_lookup++) { - printf (" Lookup index %2d of %2d: %d\n", n_lookup, num_lookups, - feature.get_lookup_index (n_lookup)); - } - } - - int num_lookups = g.get_lookup_count (); - printf (" %d lookup(s) found in table\n", num_lookups); - for (int n_lookup = 0; n_lookup < num_lookups; n_lookup++) { - const Lookup &lookup = g.get_lookup (n_lookup); - printf (" Lookup %2d of %2d: type %d, flags 0x%04X\n", n_lookup, num_lookups, - lookup.get_type(), lookup.get_flag()); - } - - } - break; - - case GDEF::Tag: - { - - const GDEF &gdef = GDEF::get_for_data (ot.get_table_data (table)); - - printf (" Has %sglyph classes\n", - gdef.has_glyph_classes () ? "" : "no "); - printf (" Has %smark attachment types\n", - gdef.has_mark_attachment_types () ? "" : "no "); - printf (" Has %sattach points\n", - gdef.has_attach_points () ? "" : "no "); - printf (" Has %slig carets\n", - gdef.has_lig_carets () ? "" : "no "); - printf (" Has %smark sets\n", - gdef.has_mark_sets () ? "" : "no "); - break; - } - } - } - } - - return 0; -} diff --git a/pango/pango-ot-buffer.c b/pango/pango-ot-buffer.c index a4aacc3a..89653603 100644 --- a/pango/pango-ot-buffer.c +++ b/pango/pango-ot-buffer.c @@ -29,6 +29,17 @@ static hb_buffer_t *cached_buffer = NULL; G_LOCK_DEFINE_STATIC (cached_buffer); static hb_buffer_t * +create_buffer (void) +{ + hb_buffer_t *buffer; + + buffer = hb_buffer_create (32); + hb_buffer_set_unicode_funcs (buffer, hb_glib_get_unicode_funcs ()); + + return buffer; +} + +static hb_buffer_t * acquire_buffer (gboolean *free_buffer) { hb_buffer_t *buffer; @@ -36,14 +47,14 @@ acquire_buffer (gboolean *free_buffer) if (G_LIKELY (G_TRYLOCK (cached_buffer))) { if (G_UNLIKELY (!cached_buffer)) - cached_buffer = hb_buffer_create (64); + cached_buffer = create_buffer (); buffer = cached_buffer; *free_buffer = FALSE; } else { - buffer = hb_buffer_create (32); + buffer = create_buffer (); *free_buffer = TRUE; } diff --git a/pango/pango-ot-info.c b/pango/pango-ot-info.c index d6fa0da2..c06065d2 100644 --- a/pango/pango-ot-info.c +++ b/pango/pango-ot-info.c @@ -157,9 +157,6 @@ pango_ot_info_get (FT_Face face) info->hb_face = hb_face_create_for_tables (_get_table, NULL, info); } - - hb_face_set_unicode_funcs (info->hb_face, hb_glib_get_unicode_funcs ()); - /* XXX this is such a waste if not SFNT */ if (!hb_ot_layout_has_font_glyph_classes (info->hb_face)) synthesize_class_def (info); diff --git a/pango/pango-ot-private.h b/pango/pango-ot-private.h index a011b74d..9bd178fa 100644 --- a/pango/pango-ot-private.h +++ b/pango/pango-ot-private.h @@ -25,8 +25,8 @@ #include <glib-object.h> #include <pango/pango-ot.h> -#include "opentype/hb-ot.h" -#include "opentype/hb-glib.h" +#include <hb-ot.h> +#include <hb-glib.h> G_BEGIN_DECLS |