提交 f94b0aa6 编写于 作者: B Behdad Esfahbod

Add "closure" operation stubs to GSUB

Filling in.
上级 7d50d502
...@@ -39,6 +39,13 @@ struct SingleSubstFormat1 ...@@ -39,6 +39,13 @@ struct SingleSubstFormat1
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool would_apply (hb_codepoint_t glyph_id) const inline bool would_apply (hb_codepoint_t glyph_id) const
{ {
return (this+coverage) (glyph_id) != NOT_COVERED; return (this+coverage) (glyph_id) != NOT_COVERED;
...@@ -83,6 +90,13 @@ struct SingleSubstFormat2 ...@@ -83,6 +90,13 @@ struct SingleSubstFormat2
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool would_apply (hb_codepoint_t glyph_id) const inline bool would_apply (hb_codepoint_t glyph_id) const
{ {
return (this+coverage) (glyph_id) != NOT_COVERED; return (this+coverage) (glyph_id) != NOT_COVERED;
...@@ -129,6 +143,16 @@ struct SingleSubst ...@@ -129,6 +143,16 @@ struct SingleSubst
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
switch (u.format) {
case 1: return u.format1.closure (c);
case 2: return u.format2.closure (c);
default:return false;
}
}
inline bool would_apply (hb_codepoint_t glyph_id) const inline bool would_apply (hb_codepoint_t glyph_id) const
{ {
switch (u.format) { switch (u.format) {
...@@ -172,6 +196,14 @@ struct Sequence ...@@ -172,6 +196,14 @@ struct Sequence
friend struct MultipleSubstFormat1; friend struct MultipleSubstFormat1;
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool apply (hb_apply_context_t *c) const inline bool apply (hb_apply_context_t *c) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
...@@ -204,6 +236,13 @@ struct MultipleSubstFormat1 ...@@ -204,6 +236,13 @@ struct MultipleSubstFormat1
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool would_apply (hb_codepoint_t glyph_id) const inline bool would_apply (hb_codepoint_t glyph_id) const
{ {
return (this+coverage) (glyph_id) != NOT_COVERED; return (this+coverage) (glyph_id) != NOT_COVERED;
...@@ -244,6 +283,15 @@ struct MultipleSubst ...@@ -244,6 +283,15 @@ struct MultipleSubst
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
switch (u.format) {
case 1: return u.format1.closure (c);
default:return false;
}
}
inline bool would_apply (hb_codepoint_t glyph_id) const inline bool would_apply (hb_codepoint_t glyph_id) const
{ {
switch (u.format) { switch (u.format) {
...@@ -287,6 +335,13 @@ struct AlternateSubstFormat1 ...@@ -287,6 +335,13 @@ struct AlternateSubstFormat1
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool would_apply (hb_codepoint_t glyph_id) const inline bool would_apply (hb_codepoint_t glyph_id) const
{ {
return (this+coverage) (glyph_id) != NOT_COVERED; return (this+coverage) (glyph_id) != NOT_COVERED;
...@@ -347,6 +402,15 @@ struct AlternateSubst ...@@ -347,6 +402,15 @@ struct AlternateSubst
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
switch (u.format) {
case 1: return u.format1.closure (c);
default:return false;
}
}
inline bool would_apply (hb_codepoint_t glyph_id) const inline bool would_apply (hb_codepoint_t glyph_id) const
{ {
switch (u.format) { switch (u.format) {
...@@ -387,6 +451,13 @@ struct Ligature ...@@ -387,6 +451,13 @@ struct Ligature
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool would_apply (hb_codepoint_t second) const inline bool would_apply (hb_codepoint_t second) const
{ {
return component.len == 2 && component[1] == second; return component.len == 2 && component[1] == second;
...@@ -482,6 +553,13 @@ struct LigatureSet ...@@ -482,6 +553,13 @@ struct LigatureSet
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool would_apply (hb_codepoint_t second) const inline bool would_apply (hb_codepoint_t second) const
{ {
unsigned int num_ligs = ligature.len; unsigned int num_ligs = ligature.len;
...@@ -528,6 +606,13 @@ struct LigatureSubstFormat1 ...@@ -528,6 +606,13 @@ struct LigatureSubstFormat1
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool would_apply (hb_codepoint_t first, hb_codepoint_t second) const inline bool would_apply (hb_codepoint_t first, hb_codepoint_t second) const
{ {
unsigned int index; unsigned int index;
...@@ -572,6 +657,15 @@ struct LigatureSubst ...@@ -572,6 +657,15 @@ struct LigatureSubst
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
switch (u.format) {
case 1: return u.format1.closure (c);
default:return false;
}
}
inline bool would_apply (hb_codepoint_t first, hb_codepoint_t second) const inline bool would_apply (hb_codepoint_t first, hb_codepoint_t second) const
{ {
switch (u.format) { switch (u.format) {
...@@ -607,12 +701,20 @@ struct LigatureSubst ...@@ -607,12 +701,20 @@ struct LigatureSubst
static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index); static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index);
static inline bool closure_lookup (hb_closure_context_t *c, unsigned int lookup_index);
struct ContextSubst : Context struct ContextSubst : Context
{ {
friend struct SubstLookupSubTable; friend struct SubstLookupSubTable;
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
return Context::closure (c, closure_lookup);
}
inline bool apply (hb_apply_context_t *c) const inline bool apply (hb_apply_context_t *c) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
...@@ -625,6 +727,13 @@ struct ChainContextSubst : ChainContext ...@@ -625,6 +727,13 @@ struct ChainContextSubst : ChainContext
friend struct SubstLookupSubTable; friend struct SubstLookupSubTable;
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
return ChainContext::closure (c, closure_lookup);
}
inline bool apply (hb_apply_context_t *c) const inline bool apply (hb_apply_context_t *c) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
...@@ -646,6 +755,13 @@ struct ExtensionSubst : Extension ...@@ -646,6 +755,13 @@ struct ExtensionSubst : Extension
return StructAtOffset<SubstLookupSubTable> (this, offset); return StructAtOffset<SubstLookupSubTable> (this, offset);
} }
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool would_apply (hb_codepoint_t glyph_id) const; inline bool would_apply (hb_codepoint_t glyph_id) const;
inline bool would_apply (hb_codepoint_t first, hb_codepoint_t second) const; inline bool would_apply (hb_codepoint_t first, hb_codepoint_t second) const;
...@@ -662,6 +778,14 @@ struct ReverseChainSingleSubstFormat1 ...@@ -662,6 +778,14 @@ struct ReverseChainSingleSubstFormat1
friend struct ReverseChainSingleSubst; friend struct ReverseChainSingleSubst;
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool apply (hb_apply_context_t *c) const inline bool apply (hb_apply_context_t *c) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
...@@ -728,6 +852,16 @@ struct ReverseChainSingleSubst ...@@ -728,6 +852,16 @@ struct ReverseChainSingleSubst
friend struct SubstLookupSubTable; friend struct SubstLookupSubTable;
private: private:
inline bool closure (hb_closure_context_t *c) const
{
TRACE_CLOSURE ();
switch (u.format) {
case 1: return u.format1.closure (c);
default:return false;
}
}
inline bool apply (hb_apply_context_t *c) const inline bool apply (hb_apply_context_t *c) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
...@@ -774,6 +908,23 @@ struct SubstLookupSubTable ...@@ -774,6 +908,23 @@ struct SubstLookupSubTable
ReverseChainSingle = 8 ReverseChainSingle = 8
}; };
inline bool closure (hb_closure_context_t *c,
unsigned int lookup_type) const
{
TRACE_CLOSURE ();
switch (lookup_type) {
case Single: return u.single.closure (c);
case Multiple: return u.multiple.closure (c);
case Alternate: return u.alternate.closure (c);
case Ligature: return u.ligature.closure (c);
case Context: return u.c.closure (c);
case ChainContext: return u.chainContext.closure (c);
case Extension: return u.extension.closure (c);
case ReverseChainSingle: return u.reverseChainContextSingle.closure (c);
default:return false;
}
}
inline bool would_apply (hb_codepoint_t glyph_id, inline bool would_apply (hb_codepoint_t glyph_id,
unsigned int lookup_type) const unsigned int lookup_type) const
{ {
...@@ -860,6 +1011,15 @@ struct SubstLookup : Lookup ...@@ -860,6 +1011,15 @@ struct SubstLookup : Lookup
return lookup_type_is_reverse (type); return lookup_type_is_reverse (type);
} }
inline bool closure (hb_closure_context_t *c) const
{
unsigned int lookup_type = get_type ();
unsigned int count = get_subtable_count ();
bool ret = false;
for (unsigned int i = 0; i < count; i++)
ret = get_subtable (i).closure (c, lookup_type) || ret;
return ret;
}
inline bool would_apply (hb_codepoint_t glyph_id) const inline bool would_apply (hb_codepoint_t glyph_id) const
{ {
...@@ -984,6 +1144,10 @@ struct GSUB : GSUBGPOS ...@@ -984,6 +1144,10 @@ struct GSUB : GSUBGPOS
static inline void substitute_start (hb_buffer_t *buffer); static inline void substitute_start (hb_buffer_t *buffer);
static inline void substitute_finish (hb_buffer_t *buffer); static inline void substitute_finish (hb_buffer_t *buffer);
inline bool closure_lookup (hb_closure_context_t *c,
unsigned int lookup_index) const
{ return get_lookup (lookup_index).closure (c); }
inline bool sanitize (hb_sanitize_context_t *c) { inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE (); TRACE_SANITIZE ();
if (unlikely (!GSUBGPOS::sanitize (c))) return false; if (unlikely (!GSUBGPOS::sanitize (c))) return false;
...@@ -1048,6 +1212,21 @@ inline bool ExtensionSubst::is_reverse (void) const ...@@ -1048,6 +1212,21 @@ inline bool ExtensionSubst::is_reverse (void) const
return SubstLookup::lookup_type_is_reverse (type); return SubstLookup::lookup_type_is_reverse (type);
} }
static inline bool closure_lookup (hb_closure_context_t *c, unsigned int lookup_index)
{
const GSUB &gsub = *(c->face->ot_layout->gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index);
if (unlikely (c->nesting_level_left == 0))
return false;
c->nesting_level_left--;
bool ret = l.closure (c);
c->nesting_level_left++;
return ret;
}
static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index) static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index)
{ {
const GSUB &gsub = *(c->face->ot_layout->gsub); const GSUB &gsub = *(c->face->ot_layout->gsub);
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include "hb-buffer-private.hh" #include "hb-buffer-private.hh"
#include "hb-ot-layout-gdef-table.hh" #include "hb-ot-layout-gdef-table.hh"
#include "hb-ot-layout-closure.h"
/* buffer var allocations */ /* buffer var allocations */
...@@ -45,6 +47,35 @@ static inline uint8_t allocate_lig_id (hb_buffer_t *buffer) { ...@@ -45,6 +47,35 @@ static inline uint8_t allocate_lig_id (hb_buffer_t *buffer) {
#ifndef HB_DEBUG_CLOSURE
#define HB_DEBUG_CLOSURE (HB_DEBUG+0)
#endif
#define TRACE_CLOSURE() \
hb_auto_trace_t<HB_DEBUG_CLOSURE> trace (&c->debug_depth, "CLOSURE", this, NULL, HB_FUNC);
struct hb_closure_context_t
{
hb_face_t *face;
hb_glyph_map_t *glyphs;
unsigned int nesting_level_left;
unsigned int debug_depth;
hb_closure_context_t (hb_face_t *face_,
hb_glyph_map_t *glyphs_,
unsigned int nesting_level_left_ = MAX_NESTING_LEVEL) :
face (face_), glyphs (glyphs_),
nesting_level_left (nesting_level_left_),
debug_depth (0) {}
};
typedef bool (*closure_lookup_func_t) (hb_closure_context_t *c, unsigned int lookup_index);
#ifndef HB_DEBUG_APPLY #ifndef HB_DEBUG_APPLY
#define HB_DEBUG_APPLY (HB_DEBUG+0) #define HB_DEBUG_APPLY (HB_DEBUG+0)
#endif #endif
...@@ -56,7 +87,6 @@ static inline uint8_t allocate_lig_id (hb_buffer_t *buffer) { ...@@ -56,7 +87,6 @@ static inline uint8_t allocate_lig_id (hb_buffer_t *buffer) {
struct hb_apply_context_t struct hb_apply_context_t
{ {
unsigned int debug_depth;
hb_font_t *font; hb_font_t *font;
hb_face_t *face; hb_face_t *face;
hb_buffer_t *buffer; hb_buffer_t *buffer;
...@@ -66,6 +96,7 @@ struct hb_apply_context_t ...@@ -66,6 +96,7 @@ struct hb_apply_context_t
unsigned int nesting_level_left; unsigned int nesting_level_left;
unsigned int lookup_props; unsigned int lookup_props;
unsigned int property; /* propety of first glyph */ unsigned int property; /* propety of first glyph */
unsigned int debug_depth;
hb_apply_context_t (hb_font_t *font_, hb_apply_context_t (hb_font_t *font_,
...@@ -81,7 +112,7 @@ struct hb_apply_context_t ...@@ -81,7 +112,7 @@ struct hb_apply_context_t
context_length (context_length_), context_length (context_length_),
nesting_level_left (nesting_level_left_), nesting_level_left (nesting_level_left_),
lookup_props (l.get_props ()), lookup_props (l.get_props ()),
property (0) {} property (0), debug_depth (0) {}
hb_apply_context_t (const hb_apply_context_t &c, const Lookup &l) { hb_apply_context_t (const hb_apply_context_t &c, const Lookup &l) {
*this = c; *this = c;
...@@ -478,6 +509,14 @@ struct ContextFormat1 ...@@ -478,6 +509,14 @@ struct ContextFormat1
friend struct Context; friend struct Context;
private: private:
inline bool closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
...@@ -517,6 +556,14 @@ struct ContextFormat2 ...@@ -517,6 +556,14 @@ struct ContextFormat2
friend struct Context; friend struct Context;
private: private:
inline bool closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
...@@ -562,6 +609,14 @@ struct ContextFormat3 ...@@ -562,6 +609,14 @@ struct ContextFormat3
friend struct Context; friend struct Context;
private: private:
inline bool closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
...@@ -608,6 +663,18 @@ struct ContextFormat3 ...@@ -608,6 +663,18 @@ struct ContextFormat3
struct Context struct Context
{ {
protected: protected:
inline bool closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
TRACE_CLOSURE ();
switch (u.format) {
case 1: return u.format1.closure (c, closure_func);
case 2: return u.format2.closure (c, closure_func);
case 3: return u.format3.closure (c, closure_func);
default:return false;
}
}
inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
...@@ -765,6 +832,14 @@ struct ChainContextFormat1 ...@@ -765,6 +832,14 @@ struct ChainContextFormat1
friend struct ChainContext; friend struct ChainContext;
private: private:
inline bool closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
...@@ -803,6 +878,14 @@ struct ChainContextFormat2 ...@@ -803,6 +878,14 @@ struct ChainContextFormat2
friend struct ChainContext; friend struct ChainContext;
private: private:
inline bool closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
...@@ -864,6 +947,13 @@ struct ChainContextFormat3 ...@@ -864,6 +947,13 @@ struct ChainContextFormat3
private: private:
inline bool closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
TRACE_CLOSURE ();
/* TODO FILLME */
return false;
}
inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
...@@ -922,6 +1012,18 @@ struct ChainContextFormat3 ...@@ -922,6 +1012,18 @@ struct ChainContextFormat3
struct ChainContext struct ChainContext
{ {
protected: protected:
inline bool closure (hb_closure_context_t *c, closure_lookup_func_t closure_func) const
{
TRACE_CLOSURE ();
switch (u.format) {
case 1: return u.format1.closure (c, closure_func);
case 2: return u.format2.closure (c, closure_func);
case 3: return u.format3.closure (c, closure_func);
default:return false;
}
}
inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const inline bool apply (hb_apply_context_t *c, apply_lookup_func_t apply_func) const
{ {
TRACE_APPLY (); TRACE_APPLY ();
......
...@@ -469,6 +469,14 @@ hb_ot_layout_substitute_finish (hb_buffer_t *buffer HB_UNUSED) ...@@ -469,6 +469,14 @@ hb_ot_layout_substitute_finish (hb_buffer_t *buffer HB_UNUSED)
GSUB::substitute_finish (buffer); GSUB::substitute_finish (buffer);
} }
hb_bool_t
hb_ot_layout_closure_lookup (hb_face_t *face,
hb_glyph_map_t *glyphs,
unsigned int lookup_index)
{
hb_closure_context_t c (face, glyphs);
return _get_gsub (face).closure_lookup (&c, lookup_index);
}
/* /*
* GPOS * GPOS
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册