- Fix tt kern on/off
-- Remove synthesized GDEF
-
- Remove fixed-size feature/lookup arrays in hb-ot-map
- Use size_t in sanitize
HB_BEGIN_DECLS
-/* XXX */
-#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
-#define gproperty() var2.u32
-
ASSERT_STATIC (sizeof (hb_glyph_info_t) == 20);
ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
glyph->codepoint = codepoint;
glyph->mask = mask;
glyph->cluster = cluster;
- glyph->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
buffer->len++;
}
hb_glyph_info_t *info = &buffer->out_info[buffer->out_len + i];
*info = orig_info;
info->codepoint = hb_be_uint16 (glyph_data_be[i]);
- info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
}
buffer->i += num_in;
info = &buffer->out_info[buffer->out_len];
info->codepoint = glyph_index;
- info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
buffer->i++;
buffer->out_len++;
friend struct ClassDef;
private:
- inline hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const
+ inline unsigned int get_class (hb_codepoint_t glyph_id) const
{
if ((unsigned int) (glyph_id - startGlyph) < classValue.len)
return classValue[glyph_id - startGlyph];
friend struct ClassDef;
private:
- inline hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const
+ inline unsigned int get_class (hb_codepoint_t glyph_id) const
{
int i = rangeRecord.search (glyph_id);
if (i != -1)
struct ClassDef
{
- inline hb_ot_layout_class_t operator () (hb_codepoint_t glyph_id) const { return get_class (glyph_id); }
+ 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
+ inline unsigned int get_class (hb_codepoint_t glyph_id) const
{
switch (u.format) {
case 1: return u.format1.get_class(glyph_id);
/*
* Copyright (C) 2007,2008,2009 Red Hat, Inc.
+ * Copyright (C) 2010 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
*/
#ifndef HB_OT_LAYOUT_GDEF_PRIVATE_HH
};
inline bool has_glyph_classes (void) const { return glyphClassDef != 0; }
- inline hb_ot_layout_class_t get_glyph_class (hb_codepoint_t glyph) const
+ inline unsigned int get_glyph_class (hb_codepoint_t glyph) const
{ return (this+glyphClassDef).get_class (glyph); }
inline bool has_mark_attachment_types (void) const { return markAttachClassDef != 0; }
- inline hb_ot_layout_class_t get_mark_attachment_type (hb_codepoint_t glyph) const
+ inline unsigned int get_mark_attachment_type (hb_codepoint_t glyph) const
{ return (this+markAttachClassDef).get_class (glyph); }
inline bool has_attach_points (void) const { return attachList != 0; }
/*
* Copyright (C) 2007,2008,2009,2010 Red Hat, Inc.
+ * Copyright (C) 2010 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
*/
#ifndef HB_OT_LAYOUT_GPOS_PRIVATE_HH
TRACE_APPLY ();
/* We don't handle mark glyphs here. */
- if (c->property == HB_OT_LAYOUT_GLYPH_CLASS_MARK)
+ if (c->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)
return false;
unsigned int end = MIN (c->buffer->len, c->buffer->i + c->context_length);
/*
* Copyright (C) 2007,2008,2009,2010 Red Hat, Inc.
+ * Copyright (C) 2010 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
*/
#ifndef HB_OT_LAYOUT_GSUB_PRIVATE_HH
return false;
glyph_id += deltaGlyphID;
- c->buffer->replace_glyph (glyph_id);
-
- /* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (c->layout->face))
- _hb_ot_layout_set_glyph_property (c->layout->face, glyph_id, c->property);
+ c->replace_glyph (glyph_id);
return true;
}
return false;
glyph_id = substitute[index];
- c->buffer->replace_glyph (glyph_id);
-
- /* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (c->layout->face))
- _hb_ot_layout_set_glyph_property (c->layout->face, glyph_id, c->property);
+ c->replace_glyph (glyph_id);
return true;
}
if (unlikely (!substitute.len))
return false;
- c->buffer->replace_glyphs_be16 (1, substitute.len, (const uint16_t *) substitute.array);
-
- /* This is a guess only ... */
- if (_hb_ot_layout_has_new_glyph_classes (c->layout->face))
- {
- unsigned int property = c->property;
- 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 (c->layout->face, substitute[n], property);
- }
+ if (c->property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)
+ c->guess_glyph_class (HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH);
+ c->replace_glyphs_be16 (1, substitute.len, (const uint16_t *) substitute.array);
return true;
}
glyph_id = alt_set[alt_index - 1];
- c->buffer->replace_glyph (glyph_id);
-
- /* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (c->layout->face))
- _hb_ot_layout_set_glyph_property (c->layout->face, glyph_id, c->property);
+ c->replace_glyph (glyph_id);
return true;
}
friend struct LigatureSet;
private:
- inline bool apply (hb_apply_context_t *c, bool is_mark) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
unsigned int i, j;
if (unlikely (c->buffer->i + count > end))
return false;
+ bool first_was_mark = (c->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
+ bool found_non_mark = false;
+
for (i = 1, j = c->buffer->i + 1; i < count; i++, j++)
{
unsigned int property;
j++;
}
- if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
- is_mark = false;
+ found_non_mark |= !(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
if (likely (c->buffer->info[j].codepoint != component[i]))
return false;
}
- /* This is just a guess ... */
- if (_hb_ot_layout_has_new_glyph_classes (c->layout->face))
- _hb_ot_layout_set_glyph_class (c->layout->face, ligGlyph,
- is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK
- : HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
+
+ if (first_was_mark && found_non_mark)
+ c->guess_glyph_class (HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
/* Allocate new ligature id */
unsigned int lig_id = allocate_lig_id (c->buffer);
if (j == c->buffer->i + i) /* No input glyphs skipped */
{
- c->buffer->replace_glyphs_be16 (i, 1, (const uint16_t *) &ligGlyph);
+ c->replace_glyphs_be16 (i, 1, (const uint16_t *) &ligGlyph);
}
else
{
- c->buffer->replace_glyph (ligGlyph);
+ c->replace_glyph (ligGlyph);
/* Now we must do a second loop to copy the skipped glyphs to
`out' and assign component values to it. We start with the
{
c->buffer->info[c->buffer->i].component() = i;
c->buffer->info[c->buffer->i].lig_id() = lig_id;
- c->buffer->replace_glyph (c->buffer->info[c->buffer->i].codepoint);
+ c->replace_glyph (c->buffer->info[c->buffer->i].codepoint);
}
/* Skip the base glyph */
friend struct LigatureSubstFormat1;
private:
- inline bool apply (hb_apply_context_t *c, bool is_mark) const
+ inline bool apply (hb_apply_context_t *c) 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 (c, is_mark))
+ if (lig.apply (c))
return true;
}
TRACE_APPLY ();
hb_codepoint_t glyph_id = c->buffer->info[c->buffer->i].codepoint;
- bool first_is_mark = !!(c->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
-
unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED))
return false;
const LigatureSet &lig_set = this+ligatureSet[index];
- return lig_set.apply (c, first_is_mark);
+ return lig_set.apply (c);
}
inline bool sanitize (hb_sanitize_context_t *c) {
/*
* Copyright (C) 2007,2008,2009,2010 Red Hat, Inc.
+ * Copyright (C) 2010 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
*/
#ifndef HB_OT_LAYOUT_GSUBGPOS_PRIVATE_HH
unsigned int context_length;
unsigned int nesting_level_left;
unsigned int lookup_flag;
- unsigned int property; /* propety of first glyph (TODO remove) */
+ unsigned int property; /* propety of first glyph */
+
+
+ inline void replace_glyph (hb_codepoint_t glyph_index) const
+ {
+ clear_property ();
+ buffer->replace_glyph (glyph_index);
+ }
+ inline void replace_glyphs_be16 (unsigned int num_in,
+ unsigned int num_out,
+ const uint16_t *glyph_data_be) const
+ {
+ clear_property ();
+ buffer->replace_glyphs_be16 (num_in, num_out, glyph_data_be);
+ }
+
+ inline void guess_glyph_class (unsigned int klass)
+ {
+// buffer->info[buffer->i].gproperty() = klass;
+ }
+
+ private:
+ inline void clear_property (void) const
+ {
+ buffer->info[buffer->i].gproperty() = 0;
+ }
};
/* XXX */
#define component() var1.u16[0]
#define lig_id() var1.u16[1]
+#define gproperty() var2.u32
#define back() var.u16[0] /* number of glyphs to go back for drawing current glyph */
#define cursive_chain() var.i16[1] /* character to which this connects, may be positive or negative */
-typedef unsigned int hb_ot_layout_class_t;
+typedef enum {
+ 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_UNCLASSIFIED = 0x0020
+} hb_ot_layout_glyph_class_t;
+
/*
* hb_ot_layout_t
const struct GDEF *gdef;
const struct GSUB *gsub;
const struct GPOS *gpos;
-
- struct
- {
- unsigned char *klasses;
- unsigned int len;
- } new_gdef;
};
struct hb_ot_layout_context_t
*/
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_glyph_info_t *ginfo,
unsigned int lookup_flags,
hb_blob_destroy (layout->gsub_blob);
hb_blob_destroy (layout->gpos_blob);
- free (layout->new_gdef.klasses);
-
free (layout);
}
* GDEF
*/
-/* TODO the public class_t is a mess */
-
hb_bool_t
hb_ot_layout_has_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_get_glyph_property_from_gdef (hb_face_t *face,
+ hb_glyph_info_t *info)
{
- hb_ot_layout_class_t klass;
+ hb_codepoint_t glyph = info->codepoint;
+
+ unsigned int 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::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);
+ return HB_OT_LAYOUT_GLYPH_CLASS_MARK | (klass << 8);
}
}
+static inline unsigned int
+_hb_ot_layout_get_glyph_property (hb_face_t *face,
+ hb_glyph_info_t *info)
+{
+ if (!info->gproperty())
+ info->gproperty() = _hb_ot_layout_get_glyph_property_from_gdef (face, info);
+
+ return info->gproperty();
+}
+
hb_bool_t
_hb_ot_layout_check_glyph_property (hb_face_t *face,
hb_glyph_info_t *ginfo,
{
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();
+ property = _hb_ot_layout_get_glyph_property (face, ginfo);
if (property_out)
*property_out = property;
{
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();
+ property = _hb_ot_layout_get_glyph_property (face, ginfo);
if (property_out)
*property_out = property;
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 (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 (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,
- 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 (unlikely (!count || !glyphs || !klasses))
- return;
-
- if (layout->new_gdef.len == 0) {
- layout->new_gdef.klasses = (unsigned char *) calloc (count, 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]);
-}
-
unsigned int
hb_ot_layout_get_attach_points (hb_face_t *face,
hb_codepoint_t glyph,
* 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_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,
- 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 */
unsigned int
}
}
+static void
+hb_reset_glyph_infos (hb_ot_shape_context_t *c)
+{
+ unsigned int count = c->buffer->len;
+ for (unsigned int i = 0; i < count; i++)
+ c->buffer->info[i].var1.u32 = c->buffer->info[i].var2.u32 = 0;
+}
+
/* Substitute */
hb_ot_shape_setup_masks (c);
+ hb_reset_glyph_infos (c);
+
/* SUBSTITUTE */
{
/* Mirroring needs to see the original direction */