[aat/ltag] Implement the table parsing (#911)

This commit is contained in:
Ebrahim Byagowi 2018-03-26 12:04:30 +04:30 committed by GitHub
parent 9eee38a55c
commit 158f2810b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 93 additions and 10 deletions

View File

@ -82,7 +82,9 @@ HB_OT_sources = \
hb-aat-layout.cc \
hb-aat-layout-common-private.hh \
hb-aat-layout-ankr-table.hh \
hb-aat-layout-fmtx-table.hh \
hb-aat-layout-kerx-table.hh \
hb-aat-layout-ltag-table.hh \
hb-aat-layout-morx-table.hh \
hb-aat-layout-trak-table.hh \
hb-aat-layout-private.hh \

View File

@ -27,19 +27,19 @@
#include "hb-aat-layout-common-private.hh"
#define HB_AAT_TAG_FMTX HB_TAG('f','m','t','x')
#define HB_AAT_TAG_fmtx HB_TAG('f','m','t','x')
namespace AAT {
/*
* fmtx -- Font Metrics
* fmtx -- Font metrics
*/
struct fmtx
{
static const hb_tag_t tableTag = HB_AAT_TAG_FMTX;
static const hb_tag_t tableTag = HB_AAT_TAG_fmtx;
inline bool sanitize (hb_sanitize_context_t *c) const
{

View File

@ -31,7 +31,7 @@
#include "hb-open-type-private.hh"
#include "hb-aat-layout-common-private.hh"
#define HB_AAT_TAG_KERX HB_TAG('k','e','r','x')
#define HB_AAT_TAG_kerx HB_TAG('k','e','r','x')
namespace AAT {
@ -284,7 +284,7 @@ struct SubtableGlyphCoverageArray
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 AAT::ankr *ankr) const
{

View File

@ -0,0 +1,80 @@
/*
* 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_LTAG_TABLE_HH
#define HB_AAT_LAYOUT_LTAG_TABLE_HH
#include "hb-aat-layout-common-private.hh"
#define HB_AAT_TAG_ltag HB_TAG('l','t','a','g')
namespace AAT {
struct FTStringRange
{
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
tag (base).sanitize (c, length));
}
protected:
OffsetTo<UnsizedArrayOf<HBUINT8> >
tag; /* Offset from the start of the table to
the beginning of the string */
HBUINT16 length; /* String length (in bytes) */
public:
DEFINE_SIZE_STATIC (4);
};
/*
* ltag -- Language tags
*/
struct ltag
{
static const hb_tag_t tableTag = HB_AAT_TAG_ltag;
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
tagRanges.sanitize (c, this));
}
protected:
HBUINT32 version;/* Table version; currently 1 */
HBUINT32 flags; /* Table flags; currently none defined */
ArrayOf<FTStringRange, HBUINT32>
tagRanges; /* Range for each tag's string */
public:
DEFINE_SIZE_ARRAY (12, tagRanges);
};
} /* namespace AAT */
#endif /* HB_AAT_LAYOUT_LTAG_TABLE_HH */

View File

@ -30,7 +30,7 @@
#include "hb-open-type-private.hh"
#include "hb-aat-layout-common-private.hh"
#define HB_AAT_TAG_MORX HB_TAG('m','o','r','x')
#define HB_AAT_TAG_morx HB_TAG('m','o','r','x')
namespace AAT {
@ -677,7 +677,7 @@ struct Chain
struct morx
{
static const hb_tag_t tableTag = HB_AAT_TAG_MORX;
static const hb_tag_t tableTag = HB_AAT_TAG_morx;
inline void apply (hb_aat_apply_context_t *c) const
{

View File

@ -31,7 +31,7 @@
#include "hb-aat-layout-common-private.hh"
#include "hb-open-type-private.hh"
#define HB_AAT_TAG_TRAK HB_TAG('t','r','a','k')
#define HB_AAT_TAG_trak HB_TAG('t','r','a','k')
namespace AAT {
@ -135,7 +135,7 @@ struct TrackData
struct trak
{
static const hb_tag_t tableTag = HB_AAT_TAG_TRAK;
static const hb_tag_t tableTag = HB_AAT_TAG_trak;
inline bool sanitize (hb_sanitize_context_t *c) const
{

View File

@ -33,6 +33,7 @@
#include "hb-aat-layout-ankr-table.hh"
#include "hb-aat-layout-fmtx-table.hh" // Just so we compile it; unused otherwise.
#include "hb-aat-layout-kerx-table.hh"
#include "hb-aat-layout-ltag-table.hh" // Just so we compile it; unused otherwise.
#include "hb-aat-layout-morx-table.hh"
#include "hb-aat-layout-trak-table.hh"
@ -111,7 +112,7 @@ _get_trak (hb_face_t *face, hb_blob_t **blob = nullptr)
// {
// OT::Sanitizer<AAT::morx> sanitizer;
// sanitizer.set_num_glyphs (face->get_num_glyphs ());
// hb_blob_t *morx_blob = sanitizer.sanitize (face->reference_table (HB_AAT_TAG_MORX));
// hb_blob_t *morx_blob = sanitizer.sanitize (face->reference_table (HB_AAT_TAG_morx));
// OT::Sanitizer<AAT::morx>::lock_instance (morx_blob);
// if (0)