[aat] Implement ankr
This commit is contained in:
parent
a8d3c2c030
commit
ae14dd0fb0
|
@ -80,8 +80,9 @@ HB_FALLBACK_sources = \
|
||||||
HB_OT_sources = \
|
HB_OT_sources = \
|
||||||
hb-aat-layout.cc \
|
hb-aat-layout.cc \
|
||||||
hb-aat-layout-common-private.hh \
|
hb-aat-layout-common-private.hh \
|
||||||
hb-aat-layout-morx-table.hh \
|
hb-aat-layout-ankr-table.hh \
|
||||||
hb-aat-layout-kerx-table.hh \
|
hb-aat-layout-kerx-table.hh \
|
||||||
|
hb-aat-layout-morx-table.hh \
|
||||||
hb-aat-layout-trak-table.hh \
|
hb-aat-layout-trak-table.hh \
|
||||||
hb-aat-layout-private.hh \
|
hb-aat-layout-private.hh \
|
||||||
hb-ot-font.cc \
|
hb-ot-font.cc \
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2018 Ebrahim Byagowi
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HB_AAT_LAYOUT_ANKR_TABLE_HH
|
||||||
|
#define HB_AAT_LAYOUT_ANKR_TABLE_HH
|
||||||
|
|
||||||
|
#include "hb-aat-layout-common-private.hh"
|
||||||
|
|
||||||
|
#define HB_AAT_TAG_ankr HB_TAG('a','n','k','r')
|
||||||
|
|
||||||
|
|
||||||
|
namespace AAT {
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ankr -- Anchor point
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct GlyphDataTable
|
||||||
|
{
|
||||||
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||||
|
{
|
||||||
|
TRACE_SANITIZE (this);
|
||||||
|
return_trace (c->check_struct (this) &&
|
||||||
|
(numPoints == 0) &&
|
||||||
|
(anchorPoints.sanitize (c, numPoints)));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
HBUINT32 numPoints; /* Number of anchor points for this glyph */
|
||||||
|
UnsizedArrayOf<HBUINT32> anchorPoints; /* Individual anchor points. Each anchor point is a two-byte
|
||||||
|
* signed x-coordinate followed by a two-byte signed y-coordinate */
|
||||||
|
|
||||||
|
public:
|
||||||
|
DEFINE_SIZE_ARRAY (4, anchorPoints);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ankr
|
||||||
|
{
|
||||||
|
static const hb_tag_t tableTag = HB_AAT_TAG_ankr;
|
||||||
|
|
||||||
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||||
|
{
|
||||||
|
TRACE_SANITIZE (this);
|
||||||
|
return_trace (c->check_struct (this) &&
|
||||||
|
(version == 0) &&
|
||||||
|
(flags == 0) &&
|
||||||
|
(lookupTableOffset == 0x0000000C) &&
|
||||||
|
(glyphDataTableOffset.sanitize (c, this)));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
HBUINT16 version; /* Version number (set to zero) */
|
||||||
|
HBUINT16 flags; /* Flags (currently unused; set to zero) */
|
||||||
|
LOffsetTo<const void*> lookupTableOffset; /* Offset to the table's lookup table */
|
||||||
|
LOffsetTo<GlyphDataTable> glyphDataTableOffset; /* Offset to the glyph data table */
|
||||||
|
|
||||||
|
public:
|
||||||
|
DEFINE_SIZE_MIN (12);
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* namespace AAT */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* HB_AAT_LAYOUT_ANKR_TABLE_HH */
|
|
@ -263,7 +263,7 @@ struct kerx
|
||||||
{
|
{
|
||||||
static const hb_tag_t tableTag = HB_AAT_TAG_kerx;
|
static const hb_tag_t tableTag = HB_AAT_TAG_kerx;
|
||||||
|
|
||||||
inline bool apply (hb_aat_apply_context_t *c) const
|
inline bool apply (hb_aat_apply_context_t *c, const AAT::ankr *ankr) const
|
||||||
{
|
{
|
||||||
TRACE_APPLY (this);
|
TRACE_APPLY (this);
|
||||||
/* TODO */
|
/* TODO */
|
||||||
|
|
|
@ -30,29 +30,29 @@
|
||||||
#include "hb-ot-layout-gsubgpos-private.hh"
|
#include "hb-ot-layout-gsubgpos-private.hh"
|
||||||
|
|
||||||
#include "hb-aat-layout-private.hh"
|
#include "hb-aat-layout-private.hh"
|
||||||
#include "hb-aat-layout-morx-table.hh"
|
#include "hb-aat-layout-ankr-table.hh"
|
||||||
#include "hb-aat-layout-kerx-table.hh"
|
#include "hb-aat-layout-kerx-table.hh"
|
||||||
|
#include "hb-aat-layout-morx-table.hh"
|
||||||
#include "hb-aat-layout-trak-table.hh"
|
#include "hb-aat-layout-trak-table.hh"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* mort/morx
|
* mort/morx
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline const AAT::morx&
|
static inline const AAT::ankr&
|
||||||
_get_morx (hb_face_t *face, hb_blob_t **blob = nullptr)
|
_get_ankr (hb_face_t *face, hb_blob_t **blob = nullptr)
|
||||||
{
|
{
|
||||||
if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
|
if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
|
||||||
{
|
{
|
||||||
if (blob)
|
if (blob)
|
||||||
*blob = hb_blob_get_empty ();
|
*blob = hb_blob_get_empty ();
|
||||||
return OT::Null(AAT::morx);
|
return OT::Null(AAT::ankr);
|
||||||
}
|
}
|
||||||
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
|
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
|
||||||
/* XXX this doesn't call set_num_glyphs on sanitizer. */
|
const AAT::ankr& ankr = *(layout->ankr.get ());
|
||||||
const AAT::morx& morx = *(layout->morx.get ());
|
|
||||||
if (blob)
|
if (blob)
|
||||||
*blob = layout->morx.blob;
|
*blob = layout->ankr.blob;
|
||||||
return morx;
|
return ankr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const AAT::kerx&
|
static inline const AAT::kerx&
|
||||||
|
@ -72,6 +72,23 @@ _get_kerx (hb_face_t *face, hb_blob_t **blob = nullptr)
|
||||||
return kerx;
|
return kerx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline const AAT::morx&
|
||||||
|
_get_morx (hb_face_t *face, hb_blob_t **blob = nullptr)
|
||||||
|
{
|
||||||
|
if (unlikely (!hb_ot_shaper_face_data_ensure (face)))
|
||||||
|
{
|
||||||
|
if (blob)
|
||||||
|
*blob = hb_blob_get_empty ();
|
||||||
|
return OT::Null(AAT::morx);
|
||||||
|
}
|
||||||
|
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
|
||||||
|
/* XXX this doesn't call set_num_glyphs on sanitizer. */
|
||||||
|
const AAT::morx& morx = *(layout->morx.get ());
|
||||||
|
if (blob)
|
||||||
|
*blob = layout->morx.blob;
|
||||||
|
return morx;
|
||||||
|
}
|
||||||
|
|
||||||
static inline const AAT::trak&
|
static inline const AAT::trak&
|
||||||
_get_trak (hb_face_t *face, hb_blob_t **blob = nullptr)
|
_get_trak (hb_face_t *face, hb_blob_t **blob = nullptr)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +99,6 @@ _get_trak (hb_face_t *face, hb_blob_t **blob = nullptr)
|
||||||
return OT::Null(AAT::trak);
|
return OT::Null(AAT::trak);
|
||||||
}
|
}
|
||||||
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
|
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
|
||||||
/* XXX this doesn't call set_num_glyphs on sanitizer. */
|
|
||||||
const AAT::trak& trak = *(layout->trak.get ());
|
const AAT::trak& trak = *(layout->trak.get ());
|
||||||
if (blob)
|
if (blob)
|
||||||
*blob = layout->trak.blob;
|
*blob = layout->trak.blob;
|
||||||
|
@ -117,10 +133,11 @@ void
|
||||||
hb_aat_layout_position (hb_font_t *font, hb_buffer_t *buffer)
|
hb_aat_layout_position (hb_font_t *font, hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
hb_blob_t *blob;
|
hb_blob_t *blob;
|
||||||
|
const AAT::ankr& ankr = _get_ankr (font->face, &blob);
|
||||||
const AAT::kerx& kerx = _get_kerx (font->face, &blob);
|
const AAT::kerx& kerx = _get_kerx (font->face, &blob);
|
||||||
const AAT::trak& trak = _get_trak (font->face, &blob);
|
const AAT::trak& trak = _get_trak (font->face, &blob);
|
||||||
|
|
||||||
AAT::hb_aat_apply_context_t c (font, buffer, blob);
|
AAT::hb_aat_apply_context_t c (font, buffer, blob);
|
||||||
kerx.apply (&c);
|
kerx.apply (&c, &ankr);
|
||||||
trak.apply (&c);
|
trak.apply (&c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,8 +131,9 @@ namespace OT {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace AAT {
|
namespace AAT {
|
||||||
struct morx;
|
struct ankr;
|
||||||
struct kerx;
|
struct kerx;
|
||||||
|
struct morx;
|
||||||
struct trak;
|
struct trak;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,8 +172,9 @@ struct hb_ot_layout_t
|
||||||
OT::hb_lazy_table_loader_t<struct OT::MATH> math;
|
OT::hb_lazy_table_loader_t<struct OT::MATH> math;
|
||||||
OT::hb_lazy_table_loader_t<struct OT::fvar> fvar;
|
OT::hb_lazy_table_loader_t<struct OT::fvar> fvar;
|
||||||
OT::hb_lazy_table_loader_t<struct OT::avar> avar;
|
OT::hb_lazy_table_loader_t<struct OT::avar> avar;
|
||||||
OT::hb_lazy_table_loader_t<struct AAT::morx> morx;
|
OT::hb_lazy_table_loader_t<struct AAT::ankr> ankr;
|
||||||
OT::hb_lazy_table_loader_t<struct AAT::kerx> kerx;
|
OT::hb_lazy_table_loader_t<struct AAT::kerx> kerx;
|
||||||
|
OT::hb_lazy_table_loader_t<struct AAT::morx> morx;
|
||||||
OT::hb_lazy_table_loader_t<struct AAT::trak> trak;
|
OT::hb_lazy_table_loader_t<struct AAT::trak> trak;
|
||||||
|
|
||||||
unsigned int gsub_lookup_count;
|
unsigned int gsub_lookup_count;
|
||||||
|
|
|
@ -64,8 +64,9 @@ _hb_ot_layout_create (hb_face_t *face)
|
||||||
layout->math.init (face);
|
layout->math.init (face);
|
||||||
layout->fvar.init (face);
|
layout->fvar.init (face);
|
||||||
layout->avar.init (face);
|
layout->avar.init (face);
|
||||||
layout->morx.init (face);
|
layout->ankr.init (face);
|
||||||
layout->kerx.init (face);
|
layout->kerx.init (face);
|
||||||
|
layout->morx.init (face);
|
||||||
layout->trak.init (face);
|
layout->trak.init (face);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -216,8 +217,9 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout)
|
||||||
layout->math.fini ();
|
layout->math.fini ();
|
||||||
layout->fvar.fini ();
|
layout->fvar.fini ();
|
||||||
layout->avar.fini ();
|
layout->avar.fini ();
|
||||||
layout->morx.fini ();
|
layout->ankr.fini ();
|
||||||
layout->kerx.fini ();
|
layout->kerx.fini ();
|
||||||
|
layout->morx.fini ();
|
||||||
layout->trak.fini ();
|
layout->trak.fini ();
|
||||||
|
|
||||||
free (layout);
|
free (layout);
|
||||||
|
|
Loading…
Reference in New Issue