Add global shape_plan. Unused so far.
hb-buffer.cc \
hb-cache-private.hh \
hb-common.cc \
- hb-fallback-shape-private.hh \
hb-fallback-shape.cc \
hb-font-private.hh \
hb-font.cc \
hb-set-private.hh \
hb-set.cc \
hb-shape.cc \
+ hb-shape-plan-private.hh \
+ hb-shape-plan.cc \
+ hb-shape-plan.h \
+ hb-shaper-list.hh \
+ hb-shaper-impl-private.hh \
+ hb-shaper-private.hh \
hb-tt-font.cc \
hb-unicode-private.hh \
hb-unicode.cc \
if HAVE_GRAPHITE2
HBCFLAGS += $(GRAPHITE2_CFLAGS)
HBLIBS += $(GRAPHITE2_LIBS)
-HBSOURCES += hb-graphite2.cc hb-graphite2-private.hh
+HBSOURCES += hb-graphite2.cc
HBHEADERS += hb-graphite2.h
endif
if HAVE_UNISCRIBE
HBCFLAGS += $(UNISCRIBE_CFLAGS)
HBLIBS += $(UNISCRIBE_LIBS)
-HBSOURCES += hb-uniscribe.cc hb-uniscribe-private.hh
+HBSOURCES += hb-uniscribe.cc
HBHEADERS += hb-uniscribe.h
endif
if HAVE_CORETEXT
HBCFLAGS += $(CORETEXT_CFLAGS)
HBLIBS += $(CORETEXT_LIBS)
-HBSOURCES += hb-coretext.cc hb-coretext-private.hh
+HBSOURCES += hb-coretext.cc
HBHEADERS += hb-coretext.h
endif
SUBDIRS += hb-old
HBCFLAGS += -I$(srcdir)/hb-old
HBLIBS += hb-old/libhb-old.la
-HBSOURCES += hb-old.cc hb-old-private.hh
+HBSOURCES += hb-old.cc
endif
DIST_SUBDIRS += hb-old
+++ /dev/null
-/*
- * Copyright © 2012 Mozilla Foundation.
- *
- * This is part of HarfBuzz, a text shaping 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.
- *
- * Mozilla Author(s): Jonathan Kew
- */
-
-#ifndef HB_CORETEXT_PRIVATE_HH
-#define HB_CORETEXT_PRIVATE_HH
-
-#include "hb-private.hh"
-
-#include "hb-coretext.h"
-
-
-HB_INTERNAL hb_bool_t
-_hb_coretext_shape (hb_font_t *font,
- hb_buffer_t *buffer,
- const hb_feature_t *features,
- unsigned int num_features);
-
-
-#endif /* HB_CORETEXT_PRIVATE_HH */
* Mozilla Author(s): Jonathan Kew
*/
-#include "hb-private.hh"
+#define HB_SHAPER coretext
+#include "hb-shaper-private.hh"
#define GlyphID GlyphID_mac
#include <ApplicationServices/ApplicationServices.h>
#include "hb-coretext.h"
-#include "hb-ot-name-table.hh"
-#include "hb-ot-tag.h"
-
#include "hb-font-private.hh"
#include "hb-buffer-private.hh"
* Google Author(s): Behdad Esfahbod
*/
-#include "hb-fallback-shape-private.hh"
+#define HB_SHAPER fallback
+#include "hb-shaper-impl-private.hh"
-#include "hb-buffer-private.hh"
+
+/*
+ * shaper face data
+ */
+
+struct hb_fallback_shaper_face_data_t {};
+
+hb_fallback_shaper_face_data_t *
+_hb_fallback_shaper_face_data_create (hb_face_t *face)
+{
+ return (hb_fallback_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED;
+}
+
+void
+_hb_fallback_shaper_face_data_destroy (hb_fallback_shaper_face_data_t *data)
+{
+}
+
+
+/*
+ * shaper font data
+ */
+
+struct hb_fallback_shaper_font_data_t {};
+
+hb_fallback_shaper_font_data_t *
+_hb_fallback_shaper_font_data_create (hb_font_t *font)
+{
+ return (hb_fallback_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED;
+}
+
+void
+_hb_fallback_shaper_font_data_destroy (hb_fallback_shaper_font_data_t *data)
+{
+}
+
+
+/*
+ * shaper shape_plan data
+ */
+
+struct hb_fallback_shaper_shape_plan_data_t {};
+
+hb_fallback_shaper_shape_plan_data_t *
+_hb_fallback_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan)
+{
+ return (hb_fallback_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
+}
+
+void
+_hb_fallback_shaper_shape_plan_data_destroy (hb_fallback_shaper_shape_plan_data_t *data)
+{
+}
+
+
+/*
+ * shaper
+ */
hb_bool_t
_hb_fallback_shape (hb_font_t *font,
#include "hb-font.h"
#include "hb-object-private.hh"
+#include "hb-shaper-private.hh"
unsigned int index;
unsigned int upem;
+
+ struct hb_shaper_data_t shaper_data;
};
+#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, face);
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+
/*
* hb_font_t
void *user_data;
hb_destroy_func_t destroy;
+ struct hb_shaper_data_t shaper_data;
+
/* Convert from font-space to user-space */
inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, this->x_scale); }
inline hb_position_t em_scale (int16_t v, int scale) { return v * (int64_t) scale / hb_face_get_upem (this->face); }
};
+#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, font);
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
#endif /* HB_FONT_PRIVATE_HH */
/*
* Copyright © 2009 Red Hat, Inc.
+ * Copyright © 2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* Red Hat Author(s): Behdad Esfahbod
+ * Google Author(s): Behdad Esfahbod
*/
#include "hb-private.hh"
_hb_ot_layout_destroy (face->ot_layout);
+#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, face);
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+
if (face->destroy)
face->destroy (face->user_data);
{
if (!hb_object_destroy (font)) return;
+#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, font);
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+
+ if (font->destroy)
+ font->destroy (font->user_data);
+
hb_font_destroy (font->parent);
hb_face_destroy (font->face);
hb_font_funcs_destroy (font->klass);
- if (font->destroy)
- font->destroy (font->user_data);
free (font);
}
* Google Author(s): Behdad Esfahbod
*/
-#include "hb-private.hh"
-
-#include "hb-old-private.hh"
-
-#include "hb-font-private.hh"
-#include "hb-buffer-private.hh"
+#define HB_SHAPER old
+#define hb_old_shaper_face_data_t HB_FaceRec_
+#define hb_old_shaper_font_data_t HB_Font_
+#include "hb-shaper-impl-private.hh"
#include <harfbuzz.h>
-static hb_user_data_key_t hb_old_data_key;
-
static HB_Error
table_func (void *font, HB_Tag tag, HB_Byte *buffer, HB_UInt *length)
{
return HB_Err_Ok;
}
+
+/*
+ * shaper face data
+ */
+
+hb_old_shaper_face_data_t *
+_hb_old_shaper_face_data_create (hb_face_t *face)
+{
+ return HB_NewFace (face, table_func);
+}
+
+void
+_hb_old_shaper_face_data_destroy (hb_old_shaper_face_data_t *data)
+{
+ HB_FreeFace (data);
+}
+
+
+/*
+ * shaper font data
+ */
+
+hb_old_shaper_font_data_t *
+_hb_old_shaper_font_data_create (hb_font_t *font)
+{
+ HB_FontRec *data = (HB_FontRec *) calloc (1, sizeof (HB_FontRec));
+ if (unlikely (!data)) {
+ DEBUG_MSG (OLD, font, "malloc()ing HB_Font failed");
+ return NULL;
+ }
+
+ data->klass = &hb_old_font_class;
+ data->x_ppem = font->x_ppem;
+ data->y_ppem = font->y_ppem;
+ data->x_scale = font->x_scale; // XXX
+ data->y_scale = font->y_scale; // XXX
+ data->userData = font;
+
+ return data;
+}
+
+void
+_hb_old_shaper_font_data_destroy (hb_old_shaper_font_data_t *data)
+{
+ free (data);
+}
+
+
+/*
+ * shaper shape_plan data
+ */
+
+struct hb_old_shaper_shape_plan_data_t {};
+
+hb_old_shaper_shape_plan_data_t *
+_hb_old_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan)
+{
+ return (hb_old_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
+}
+
+void
+_hb_old_shaper_shape_plan_data_destroy (hb_old_shaper_shape_plan_data_t *data)
+{
+}
+
+
+/*
+ * shaper
+ */
+
+
+static hb_user_data_key_t hb_old_data_key;
+
static HB_Face
_hb_old_face_get (hb_face_t *face)
{
HB_Face data = (HB_Face) hb_face_get_user_data (face, &hb_old_data_key);
if (likely (data)) return data;
- data = HB_NewFace (face, table_func);
+ data = _hb_old_shaper_face_data_create (face);
if (unlikely (!data)) {
DEBUG_MSG (OLD, face, "HB_NewFace failed");
}
if (unlikely (!hb_face_set_user_data (face, &hb_old_data_key, data,
- (hb_destroy_func_t) HB_FreeFace,
+ (hb_destroy_func_t) _hb_old_shaper_face_data_destroy,
false)))
{
- HB_FreeFace (data);
+ _hb_old_shaper_face_data_destroy (data);
data = (HB_Face) hb_face_get_user_data (face, &hb_old_data_key);
if (data)
return data;
static HB_Font
_hb_old_font_get (hb_font_t *font)
{
- HB_Font data = (HB_Font) calloc (1, sizeof (HB_FontRec));
- if (unlikely (!data)) {
- DEBUG_MSG (OLD, font, "malloc()ing HB_Font failed");
+ /* Ouch, check user_data! */
+ HB_Font data = _hb_old_shaper_font_data_create (font);
+ if (!data)
return NULL;
- }
-
- data->klass = &hb_old_font_class;
- data->x_ppem = font->x_ppem;
- data->y_ppem = font->y_ppem;
- data->x_scale = font->x_scale; // XXX
- data->y_scale = font->y_scale; // XXX
- data->userData = font;
if (unlikely (!hb_font_set_user_data (font, &hb_old_data_key, data,
- (hb_destroy_func_t) free,
+ (hb_destroy_func_t) _hb_old_shaper_font_data_destroy,
false)))
{
- free (data);
+ _hb_old_shaper_font_data_destroy (data);
data = (HB_Font) hb_font_get_user_data (font, &hb_old_data_key);
if (data)
return data;
};
-
-HB_INTERNAL hb_bool_t
-_hb_ot_shape (hb_font_t *font,
- hb_buffer_t *buffer,
- const hb_feature_t *features,
- unsigned int num_features);
-
-
inline void
_hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unicode)
{
* Google Author(s): Behdad Esfahbod
*/
+#define HB_SHAPER ot
+#define hb_ot_shaper_face_data_t hb_ot_layout_t
+#include "hb-shaper-impl-private.hh"
+
#include "hb-ot-shape-private.hh"
#include "hb-ot-shape-normalize-private.hh"
#include "hb-ot-layout-private.hh"
-#include "hb-font-private.hh"
#include "hb-set-private.hh"
+/*
+ * shaper face data
+ */
+
+hb_ot_shaper_face_data_t *
+_hb_ot_shaper_face_data_create (hb_face_t *face)
+{
+ return (hb_ot_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED;
+}
+
+void
+_hb_ot_shaper_face_data_destroy (hb_ot_shaper_face_data_t *data)
+{
+}
+
+
+/*
+ * shaper font data
+ */
+
+struct hb_ot_shaper_font_data_t {};
+
+hb_ot_shaper_font_data_t *
+_hb_ot_shaper_font_data_create (hb_font_t *font)
+{
+ return (hb_ot_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED;
+}
+
+void
+_hb_ot_shaper_font_data_destroy (hb_ot_shaper_font_data_t *data)
+{
+}
+
+
+/*
+ * shaper shape_plan data
+ */
+
+struct hb_ot_shaper_shape_plan_data_t {};
+
+hb_ot_shaper_shape_plan_data_t *
+_hb_ot_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan)
+{
+ return (hb_ot_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
+}
+
+void
+_hb_ot_shaper_shape_plan_data_destroy (hb_ot_shaper_shape_plan_data_t *data)
+{
+}
+
+
+/*
+ * shaper
+ */
hb_tag_t common_features[] = {
HB_TAG('c','c','m','p'),
* Google Author(s): Behdad Esfahbod
*/
-#ifndef HB_GRAPHITE2_PRIVATE_HH
-#define HB_GRAPHITE2_PRIVATE_HH
+#ifndef HB_SHAPE_PLAN_PRIVATE_HH
+#define HB_SHAPE_PLAN_PRIVATE_HH
#include "hb-private.hh"
-#include "hb-graphite2.h"
+#include "hb-shape-plan.h"
+#include "hb-shaper-private.hh"
-HB_INTERNAL hb_bool_t
-_hb_graphite2_shape (hb_font_t *font,
- hb_buffer_t *buffer,
- const hb_feature_t *features,
- unsigned int num_features);
+struct hb_shape_plan_t
+{
+ hb_object_header_t header;
+ ASSERT_POD ();
-#endif /* HB_GRAPHITE2_PRIVATE_HH */
+ hb_shape_func_t *shapers[HB_NUM_SHAPERS];
+
+ struct hb_shaper_data_t shaper_data;
+};
+
+#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, shape_plan);
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+
+
+#endif /* HB_SHAPE_PLAN_PRIVATE_HH */
--- /dev/null
+/*
+ * Copyright © 2012 Google, Inc.
+ *
+ * This is part of HarfBuzz, a text shaping 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.
+ *
+ * Google Author(s): Behdad Esfahbod
+ */
+
+#include "hb-private.hh"
+
+#include "hb-shape-plan-private.hh"
+
+#include "hb-font-private.hh"
+
+
+/*
+ * hb_shape_plan_t
+ */
+
+hb_shape_plan_t *
+hb_shape_plan_create (hb_face_t *face,
+ const hb_segment_properties_t *props,
+ const hb_feature_t *user_features,
+ unsigned int num_user_features,
+ const char * const *shaper_list)
+{
+ hb_shape_plan_t *shape_plan;
+
+ if (unlikely (!face))
+ face = hb_face_get_empty ();
+ if (unlikely (!props || hb_object_is_inert (face)))
+ return hb_shape_plan_get_empty ();
+ if (!(shape_plan = hb_object_create<hb_shape_plan_t> ()))
+ return hb_shape_plan_get_empty ();
+
+ hb_face_make_immutable (face);
+
+ return shape_plan;
+}
+
+hb_shape_plan_t *
+hb_shape_plan_get_empty (void)
+{
+ static const hb_shape_plan_t _hb_shape_plan_nil = {
+ HB_OBJECT_HEADER_STATIC,
+ };
+
+ return const_cast<hb_shape_plan_t *> (&_hb_shape_plan_nil);
+}
+
+hb_shape_plan_t *
+hb_shape_plan_reference (hb_shape_plan_t *shape_plan)
+{
+ return hb_object_reference (shape_plan);
+}
+
+void
+hb_shape_plan_destroy (hb_shape_plan_t *shape_plan)
+{
+ if (!hb_object_destroy (shape_plan)) return;
+
+#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_DESTROY(shaper, shape_plan);
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+
+ free (shape_plan);
+}
/*
- * Copyright © 2011 Google, Inc.
+ * Copyright © 2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
* Google Author(s): Behdad Esfahbod
*/
-#ifndef HB_FALLBACK_SHAPE_PRIVATE_HH
-#define HB_FALLBACK_SHAPE_PRIVATE_HH
+#ifndef HB_SHAPE_PLAN_H
+#define HB_SHAPE_PLAN_H
+
+/* TODO To become public one day */
#include "hb-private.hh"
-#include "hb-shape.h"
+#include "hb-buffer-private.hh"
+
+
+typedef struct hb_shape_plan_t hb_shape_plan;
+
+/*
+ * hb_shape_plan_t
+ */
+
+HB_INTERNAL hb_shape_plan_t *
+hb_shape_plan_create (hb_face_t *face,
+ const hb_segment_properties_t *props,
+ const hb_feature_t *user_features,
+ unsigned int num_user_features,
+ const char * const *shaper_list);
+
+HB_INTERNAL hb_shape_plan_t *
+hb_shape_plan_get_empty (void);
+
+HB_INTERNAL hb_shape_plan_t *
+hb_shape_plan_reference (hb_shape_plan_t *shape_plan);
+HB_INTERNAL void
+hb_shape_plan_destroy (hb_shape_plan_t *shape_plan);
-HB_INTERNAL hb_bool_t
-_hb_fallback_shape (hb_font_t *font,
- hb_buffer_t *buffer,
- const hb_feature_t *features,
- unsigned int num_features);
-#endif /* HB_FALLBACK_SHAPE_PRIVATE_HH */
+#endif /* HB_SHAPE_PLAN_H */
#include "hb-private.hh"
-#include "hb-shape.h"
-
+#include "hb-shaper-private.hh"
#include "hb-buffer-private.hh"
-#ifdef HAVE_GRAPHITE
-#include "hb-graphite2-private.hh"
-#endif
-#ifdef HAVE_UNISCRIBE
-# include "hb-uniscribe-private.hh"
-#endif
-#ifdef HAVE_CORETEXT
-# include "hb-coretext-private.hh"
-#endif
-#ifdef HAVE_HB_OLD
-# include "hb-old-private.hh"
-#endif
-#ifdef HAVE_OT
-# include "hb-ot-shape-private.hh"
-#endif
-#include "hb-fallback-shape-private.hh"
-
-typedef hb_bool_t (*hb_shape_func_t) (hb_font_t *font,
- hb_buffer_t *buffer,
- const hb_feature_t *features,
- unsigned int num_features);
-#define HB_SHAPER_IMPLEMENT(name) {#name, _hb_##name##_shape}
static const struct hb_shaper_pair_t {
char name[16];
- hb_shape_func_t func;
+ hb_shape_func_t *func;
} all_shapers[] = {
- /* v--- Add new shapers in the right place here */
-#ifdef HAVE_GRAPHITE
- HB_SHAPER_IMPLEMENT (graphite2),
-#endif
-#ifdef HAVE_UNISCRIBE
- HB_SHAPER_IMPLEMENT (uniscribe),
-#endif
-#ifdef HAVE_CORETEXT
- HB_SHAPER_IMPLEMENT (coretext),
-#endif
-#ifdef HAVE_OT
- HB_SHAPER_IMPLEMENT (ot),
-#endif
-#ifdef HAVE_HB_OLD
- HB_SHAPER_IMPLEMENT (old),
-#endif
- HB_SHAPER_IMPLEMENT (fallback), /* This should be last. */
-};
+#define HB_SHAPER_IMPLEMENT(name) {#name, _hb_##name##_shape},
+#include "hb-shaper-list.hh"
#undef HB_SHAPER_IMPLEMENT
+};
/* Thread-safe, lock-free, shapers */
* Google Author(s): Behdad Esfahbod
*/
-#ifndef HB_UNISCRIBE_PRIVATE_HH
-#define HB_UNISCRIBE_PRIVATE_HH
+#ifndef HB_SHAPER_IMPL_PRIVATE_HH
+#define HB_SHAPER_IMPL_PRIVATE_HH
#include "hb-private.hh"
-#include "hb-uniscribe.h"
+#include "hb-shaper-private.hh"
+#include "hb-shape-plan-private.hh"
+#include "hb-font-private.hh"
+#include "hb-buffer-private.hh"
-HB_INTERNAL hb_bool_t
-_hb_uniscribe_shape (hb_font_t *font,
- hb_buffer_t *buffer,
- const hb_feature_t *features,
- unsigned int num_features);
+#ifdef HB_SHAPER
+/* For use in things like font->shaper_data() in the shaper implementations. */
+#define shaper_data() shaper_data.HB_SHAPER
+#endif
-#endif /* HB_UNISCRIBE_PRIVATE_HH */
+#endif /* HB_SHAPER_IMPL_PRIVATE_HH */
* Google Author(s): Behdad Esfahbod
*/
-#ifndef HB_OLD_PRIVATE_HH
-#define HB_OLD_PRIVATE_HH
+#ifndef HB_SHAPER_LIST_HH
+#define HB_SHAPER_LIST_HH
+#endif /* HB_SHAPER_LIST_HH */ /* Dummy header guards */
-#include "hb-private.hh"
+/* v--- Add new shapers in the right place here. */
+#ifdef HAVE_GRAPHITE
+HB_SHAPER_IMPLEMENT (graphite2)
+#endif
+#ifdef HAVE_UNISCRIBE
+HB_SHAPER_IMPLEMENT (uniscribe)
+#endif
+#ifdef HAVE_CORETEXT
+HB_SHAPER_IMPLEMENT (coretext)
+#endif
+#ifdef HAVE_OT
+HB_SHAPER_IMPLEMENT (ot) /* <--- This is our main OpenType shaper. */
+#endif
-HB_INTERNAL hb_bool_t
-_hb_old_shape (hb_font_t *font,
- hb_buffer_t *buffer,
- const hb_feature_t *features,
- unsigned int num_features);
+#ifdef HAVE_HB_OLD
+HB_SHAPER_IMPLEMENT (old)
+#endif
-
-#endif /* HB_OLD_PRIVATE_HH */
+HB_SHAPER_IMPLEMENT (fallback) /* <--- This should be last. */
--- /dev/null
+/*
+ * Copyright © 2012 Google, Inc.
+ *
+ * This is part of HarfBuzz, a text shaping 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.
+ *
+ * Google Author(s): Behdad Esfahbod
+ */
+
+#ifndef HB_SHAPER_PRIVATE_HH
+#define HB_SHAPER_PRIVATE_HH
+
+#include "hb-private.hh"
+
+typedef hb_bool_t hb_shape_func_t (hb_font_t *font,
+ hb_buffer_t *buffer,
+ const hb_feature_t *features,
+ unsigned int num_features);
+
+#define HB_SHAPER_IMPLEMENT(name) \
+ extern "C" HB_INTERNAL hb_shape_func_t _hb_##name##_shape;
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+
+/* For embedding in face / font / ... */
+struct hb_shaper_data_t {
+#define HB_SHAPER_IMPLEMENT(shaper) void *shaper;
+#include "hb-shaper-list.hh"
+#undef HB_SHAPER_IMPLEMENT
+};
+
+#define HB_NUM_SHAPERS (sizeof (hb_shaper_data_t) / sizeof (void *))
+
+/* Means: succeeded, but don't need to keep any data. */
+#define HB_SHAPER_DATA_SUCCEEDED ((void *) +1)
+
+/* Means: tried but failed to create. */
+#define HB_SHAPER_DATA_INVALID ((void *) -1)
+#define HB_SHAPER_DATA_IS_INVALID(data) ((void *) (data) == HB_SHAPER_DATA_INVALID)
+
+#define HB_SHAPER_DATA_TYPE(shaper, object) struct hb_##shaper##_shaper_##object##_data_t
+#define HB_SHAPER_DATA(shaper, object) ((HB_SHAPER_DATA_TYPE(shaper, object) *) (object)->shaper_data.shaper)
+#define HB_SHAPER_DATA_GET_FUNC(shaper, object) _hb_##shaper##_shaper_get_##object##_data
+#define HB_SHAPER_DATA_CREATE_FUNC(shaper, object) _hb_##shaper##_shaper_##object##_data_create
+#define HB_SHAPER_DATA_DESTROY_FUNC(shaper, object) _hb_##shaper##_shaper_##object##_data_destroy
+
+#define HB_SHAPER_DATA_PROTOTYPE(shaper, object) \
+ HB_SHAPER_DATA_TYPE (shaper, object); /* Type forward declaration. */ \
+ static inline HB_SHAPER_DATA_TYPE (shaper, object) * \
+ HB_SHAPER_DATA_GET_FUNC (shaper, object) (hb_##object##_t *object) \
+ { return HB_SHAPER_DATA (shaper, object); } \
+ extern "C" HB_INTERNAL HB_SHAPER_DATA_TYPE (shaper, object) * \
+ HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (hb_##object##_t *object); \
+ extern "C" HB_INTERNAL void \
+ HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (HB_SHAPER_DATA_TYPE (shaper, object) *data)
+
+#define HB_SHAPER_DATA_DESTROY(shaper, object) \
+ if (object->shaper_data.shaper && \
+ object->shaper_data.shaper != HB_SHAPER_DATA_INVALID && \
+ object->shaper_data.shaper != HB_SHAPER_DATA_SUCCEEDED) \
+ HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (HB_SHAPER_DATA (shaper, object));
+
+
+#endif /* HB_SHAPER_PRIVATE_HH */
#define _WIN32_WINNT 0x0600
-#include "hb-private.hh"
+#define HB_SHAPER uniscribe
+#include "hb-shaper-impl-private.hh"
#include <windows.h>
#include <usp10.h>
#include "hb-ot-name-table.hh"
#include "hb-ot-tag.h"
-#include "hb-font-private.hh"
-#include "hb-buffer-private.hh"
-
-
#ifndef HB_DEBUG_UNISCRIBE
#define HB_DEBUG_UNISCRIBE (HB_DEBUG+0)
}
-static hb_user_data_key_t hb_uniscribe_data_key;
-
+/*
+ * shaper face data
+ */
-static struct hb_uniscribe_face_data_t {
+struct hb_uniscribe_shaper_face_data_t {
HANDLE fh;
-} _hb_uniscribe_face_data_nil = {0};
-
-static void
-_hb_uniscribe_face_data_destroy (hb_uniscribe_face_data_t *data)
-{
- if (data->fh)
- RemoveFontMemResourceEx (data->fh);
- free (data);
-}
+};
-static hb_uniscribe_face_data_t *
-_hb_uniscribe_face_get_data (hb_face_t *face)
+hb_uniscribe_shaper_face_data_t *
+_hb_uniscribe_shaper_face_data_create (hb_face_t *face)
{
- hb_uniscribe_face_data_t *data = (hb_uniscribe_face_data_t *) hb_face_get_user_data (face, &hb_uniscribe_data_key);
- if (likely (data)) return data;
-
- data = (hb_uniscribe_face_data_t *) calloc (1, sizeof (hb_uniscribe_face_data_t));
+ hb_uniscribe_shaper_face_data_t *data = (hb_uniscribe_shaper_face_data_t *) calloc (1, sizeof (hb_uniscribe_shaper_face_data_t));
if (unlikely (!data))
- return &_hb_uniscribe_face_data_nil;
-
+ return NULL;
hb_blob_t *blob = hb_face_reference_blob (face);
unsigned int blob_length;
DWORD num_fonts_installed;
data->fh = AddFontMemResourceEx ((void *) blob_data, blob_length, 0, &num_fonts_installed);
hb_blob_destroy (blob);
- if (unlikely (!data->fh))
+ if (unlikely (!data->fh)) {
DEBUG_MSG (UNISCRIBE, face, "Face AddFontMemResourceEx() failed");
-
-
- if (unlikely (!hb_face_set_user_data (face, &hb_uniscribe_data_key, data,
- (hb_destroy_func_t) _hb_uniscribe_face_data_destroy,
- false)))
- {
- _hb_uniscribe_face_data_destroy (data);
- data = (hb_uniscribe_face_data_t *) hb_face_get_user_data (face, &hb_uniscribe_data_key);
- if (data)
- return data;
- else
- return &_hb_uniscribe_face_data_nil;
+ free (data);
+ return NULL;
}
return data;
}
+void
+_hb_uniscribe_shaper_face_data_destroy (hb_uniscribe_shaper_face_data_t *data)
+{
+ if (data->fh)
+ RemoveFontMemResourceEx (data->fh);
+ free (data);
+}
-static struct hb_uniscribe_font_data_t {
+
+/*
+ * shaper font data
+ */
+
+struct hb_uniscribe_shaper_font_data_t {
HDC hdc;
LOGFONTW log_font;
HFONT hfont;
SCRIPT_CACHE script_cache;
-} _hb_uniscribe_font_data_nil = {NULL, NULL, NULL};
+};
-static void
-_hb_uniscribe_font_data_destroy (hb_uniscribe_font_data_t *data)
+hb_uniscribe_shaper_font_data_t *
+_hb_uniscribe_shaper_font_data_create (hb_font_t *font)
+{
+ hb_uniscribe_shaper_font_data_t * data = (hb_uniscribe_shaper_font_data_t *) calloc (1, sizeof (hb_uniscribe_shaper_font_data_t));
+ if (unlikely (!data))
+ return NULL;
+
+ data->hdc = GetDC (NULL);
+
+ if (unlikely (!populate_log_font (&data->log_font, font))) {
+ DEBUG_MSG (UNISCRIBE, font, "Font populate_log_font() failed");
+ _hb_uniscribe_shaper_font_data_destroy (data);
+ return NULL;
+ }
+
+ data->hfont = CreateFontIndirectW (&data->log_font);
+ if (unlikely (!data->hfont)) {
+ DEBUG_MSG (UNISCRIBE, font, "Font CreateFontIndirectW() failed");
+ _hb_uniscribe_shaper_font_data_destroy (data);
+ return NULL;
+ }
+
+ if (!SelectObject (data->hdc, data->hfont)) {
+ DEBUG_MSG (UNISCRIBE, font, "Font SelectObject() failed");
+ _hb_uniscribe_shaper_font_data_destroy (data);
+ return NULL;
+ }
+
+ return data;
+}
+
+void
+_hb_uniscribe_shaper_font_data_destroy (hb_uniscribe_shaper_font_data_t *data)
{
if (data->hdc)
ReleaseDC (NULL, data->hdc);
free (data);
}
-static hb_uniscribe_font_data_t *
-_hb_uniscribe_font_get_data (hb_font_t *font)
+
+/*
+ * shaper shape_plan data
+ */
+
+struct hb_uniscribe_shaper_shape_plan_data_t {};
+
+hb_uniscribe_shaper_shape_plan_data_t *
+_hb_uniscribe_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan)
{
- hb_uniscribe_font_data_t *data = (hb_uniscribe_font_data_t *) hb_font_get_user_data (font, &hb_uniscribe_data_key);
- if (likely (data)) return data;
+ return (hb_uniscribe_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
+}
- data = (hb_uniscribe_font_data_t *) calloc (1, sizeof (hb_uniscribe_font_data_t));
- if (unlikely (!data))
- return &_hb_uniscribe_font_data_nil;
+void
+_hb_uniscribe_shaper_shape_plan_data_destroy (hb_uniscribe_shaper_shape_plan_data_t *data)
+{
+}
- data->hdc = GetDC (NULL);
- if (unlikely (!populate_log_font (&data->log_font, font)))
- DEBUG_MSG (UNISCRIBE, font, "Font populate_log_font() failed");
- else {
- data->hfont = CreateFontIndirectW (&data->log_font);
- if (unlikely (!data->hfont))
- DEBUG_MSG (UNISCRIBE, font, "Font CreateFontIndirectW() failed");
- if (!SelectObject (data->hdc, data->hfont))
- DEBUG_MSG (UNISCRIBE, font, "Font SelectObject() failed");
+/*
+ * shaper
+ */
+static hb_user_data_key_t hb_uniscribe_data_key;
+
+static hb_uniscribe_shaper_face_data_t *
+_hb_uniscribe_face_get_data (hb_face_t *face)
+{
+ hb_uniscribe_shaper_face_data_t *data = (hb_uniscribe_shaper_face_data_t *) hb_face_get_user_data (face, &hb_uniscribe_data_key);
+ if (likely (data)) return data;
+
+ data = _hb_uniscribe_shaper_face_data_create (face);
+ if (!data) return NULL;
+
+ if (unlikely (!hb_face_set_user_data (face, &hb_uniscribe_data_key, data,
+ (hb_destroy_func_t) _hb_uniscribe_shaper_face_data_destroy,
+ false)))
+ {
+ _hb_uniscribe_shaper_face_data_destroy (data);
+ data = (hb_uniscribe_shaper_face_data_t *) hb_face_get_user_data (face, &hb_uniscribe_data_key);
}
+ return data;
+}
+
+
+static hb_uniscribe_shaper_font_data_t *
+_hb_uniscribe_font_get_data (hb_font_t *font)
+{
+ hb_uniscribe_shaper_font_data_t *data = (hb_uniscribe_shaper_font_data_t *) hb_font_get_user_data (font, &hb_uniscribe_data_key);
+ if (likely (data)) return data;
+
+ data = _hb_uniscribe_shaper_font_data_create (font);
+ if (unlikely (!data))
+ return NULL;
+
if (unlikely (!hb_font_set_user_data (font, &hb_uniscribe_data_key, data,
- (hb_destroy_func_t) _hb_uniscribe_font_data_destroy,
+ (hb_destroy_func_t) _hb_uniscribe_shaper_font_data_destroy,
false)))
{
- _hb_uniscribe_font_data_destroy (data);
- data = (hb_uniscribe_font_data_t *) hb_font_get_user_data (font, &hb_uniscribe_data_key);
- if (data)
- return data;
- else
- return &_hb_uniscribe_font_data_nil;
+ _hb_uniscribe_shaper_font_data_destroy (data);
+ data = (hb_uniscribe_shaper_font_data_t *) hb_font_get_user_data (font, &hb_uniscribe_data_key);
}
return data;
LOGFONTW *
hb_uniscribe_font_get_logfontw (hb_font_t *font)
{
- hb_uniscribe_font_data_t *font_data = _hb_uniscribe_font_get_data (font);
+ hb_uniscribe_shaper_font_data_t *font_data = _hb_uniscribe_font_get_data (font);
if (unlikely (!font_data))
return NULL;
return &font_data->log_font;
HFONT
hb_uniscribe_font_get_hfont (hb_font_t *font)
{
- hb_uniscribe_font_data_t *font_data = _hb_uniscribe_font_get_data (font);
+ hb_uniscribe_shaper_font_data_t *font_data = _hb_uniscribe_font_get_data (font);
if (unlikely (!font_data))
return 0;
return font_data->hfont;
return false; \
} HB_STMT_END;
- hb_uniscribe_face_data_t *face_data = _hb_uniscribe_face_get_data (font->face);
+ hb_uniscribe_shaper_face_data_t *face_data = _hb_uniscribe_face_get_data (font->face);
if (unlikely (!face_data->fh))
FAIL ("Couldn't get face data");
- hb_uniscribe_font_data_t *font_data = _hb_uniscribe_font_get_data (font);
+ hb_uniscribe_shaper_font_data_t *font_data = _hb_uniscribe_font_get_data (font);
if (unlikely (!font_data->hfont))
FAIL ("Couldn't get font font");