[colr] Implement
This commit is contained in:
parent
772274625e
commit
f671f7f0a8
@ -97,6 +97,7 @@ HB_OT_sources = \
|
||||
hb-ot-layout-jstf-table.hh \
|
||||
hb-ot-layout-private.hh \
|
||||
hb-ot-color.cc \
|
||||
hb-ot-colr-table.hh \
|
||||
hb-ot-cpal-table.hh \
|
||||
hb-ot-map.cc \
|
||||
hb-ot-map-private.hh \
|
||||
|
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#include "hb-open-type-private.hh"
|
||||
#include "hb-ot-colr-table.hh"
|
||||
#include "hb-ot-cpal-table.hh"
|
||||
#include "hb-ot.h"
|
||||
|
||||
@ -40,6 +41,14 @@ HB_MARK_AS_FLAG_T (hb_ot_color_palette_flags_t)
|
||||
//HB_SHAPER_DATA_ENSURE_DECLARE(ot, face) Hmm?
|
||||
|
||||
|
||||
static inline const OT::COLR&
|
||||
_get_colr (hb_face_t *face)
|
||||
{
|
||||
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return OT::Null(OT::COLR);
|
||||
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
|
||||
return *(layout->colr.get ());
|
||||
}
|
||||
|
||||
static inline const OT::CPAL&
|
||||
_get_cpal (hb_face_t *face)
|
||||
{
|
||||
|
@ -37,15 +37,6 @@
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* HB_OT_TAG_CPAL:
|
||||
* a four-letter tag for identifying the CPAL table with color palettes
|
||||
*
|
||||
* Since: REPLACEME
|
||||
*/
|
||||
#define HB_OT_TAG_CPAL HB_TAG('C','P','A','L')
|
||||
|
||||
|
||||
/**
|
||||
* hb_ot_color_t:
|
||||
* @red: the intensity of the red channel
|
||||
|
98
src/hb-ot-colr-table.hh
Normal file
98
src/hb-ot-colr-table.hh
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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_OT_COLR_TABLE_HH
|
||||
#define HB_OT_COLR_TABLE_HH
|
||||
|
||||
#include "hb-open-type-private.hh"
|
||||
|
||||
/*
|
||||
* Color Palette
|
||||
* http://www.microsoft.com/typography/otspec/colr.htm
|
||||
*/
|
||||
|
||||
#define HB_OT_TAG_COLR HB_TAG('C','O','L','R')
|
||||
|
||||
namespace OT {
|
||||
|
||||
|
||||
struct LayerRecord
|
||||
{
|
||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
HBUINT16 gID; /* Glyph ID of layer glyph */
|
||||
HBUINT16 paletteIndex; /* Index value to use with a selected color palette */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (4);
|
||||
};
|
||||
|
||||
struct BaseGlyphRecord
|
||||
{
|
||||
inline bool sanitize (hb_sanitize_context_t *c, unsigned int palettes) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this));
|
||||
}
|
||||
|
||||
HBUINT16 gID; /* Glyph ID of reference glyph */
|
||||
OffsetTo<LayerRecord>
|
||||
firstLayerIndex; /* Index to the layer record */
|
||||
HBUINT16 numLayers; /* Number of color layers associated with this glyph */
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (6);
|
||||
};
|
||||
|
||||
struct COLR
|
||||
{
|
||||
static const hb_tag_t tableTag = HB_OT_TAG_COLR;
|
||||
|
||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (c->check_struct (this) &&
|
||||
c->check_array ((const void*) &baseGlyphRecords, sizeof (BaseGlyphRecord), numBaseGlyphRecords) &&
|
||||
c->check_array ((const void*) &layerRecordsOffset, sizeof (LayerRecord), numLayerRecords));
|
||||
}
|
||||
|
||||
protected:
|
||||
HBUINT16 version; /* Table version number */
|
||||
HBUINT16 numBaseGlyphRecords; /* Number of Base Glyph Records */
|
||||
LOffsetTo<BaseGlyphRecord>
|
||||
baseGlyphRecords; /* Offset to Base Glyph records. */
|
||||
LOffsetTo<LayerRecord>
|
||||
layerRecordsOffset; /* Offset to Layer Records */
|
||||
HBUINT16 numLayerRecords; /* Number of Layer Records */
|
||||
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (14);
|
||||
};
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
|
||||
#endif /* HB_OT_COLR_TABLE_HH */
|
@ -30,9 +30,6 @@
|
||||
|
||||
#include "hb-open-type-private.hh"
|
||||
|
||||
|
||||
namespace OT {
|
||||
|
||||
/*
|
||||
* Color Palette
|
||||
* http://www.microsoft.com/typography/otspec/cpal.htm
|
||||
@ -40,6 +37,9 @@ namespace OT {
|
||||
|
||||
#define HB_OT_TAG_CPAL HB_TAG('C','P','A','L')
|
||||
|
||||
namespace OT {
|
||||
|
||||
|
||||
struct ColorRecord
|
||||
{
|
||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||
|
@ -123,10 +123,11 @@ hb_ot_layout_position_finish_offsets (hb_font_t *font,
|
||||
|
||||
namespace OT {
|
||||
struct BASE;
|
||||
struct COLR;
|
||||
struct CPAL;
|
||||
struct GDEF;
|
||||
struct GSUB;
|
||||
struct GPOS;
|
||||
struct CPAL;
|
||||
struct MATH;
|
||||
struct fvar;
|
||||
struct avar;
|
||||
@ -172,8 +173,9 @@ struct hb_ot_layout_t
|
||||
|
||||
/* TODO Move the following out of this struct. */
|
||||
OT::hb_lazy_table_loader_t<struct OT::BASE> base;
|
||||
OT::hb_lazy_table_loader_t<struct OT::MATH> math;
|
||||
OT::hb_lazy_table_loader_t<struct OT::COLR> colr;
|
||||
OT::hb_lazy_table_loader_t<struct OT::CPAL> cpal;
|
||||
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::avar> avar;
|
||||
OT::hb_lazy_table_loader_t<struct AAT::ankr> ankr;
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "hb-ot-layout-gpos-table.hh"
|
||||
#include "hb-ot-layout-jstf-table.hh" // Just so we compile it; unused otherwise.
|
||||
#include "hb-ot-name-table.hh" // Just so we compile it; unused otherwise.
|
||||
#include "hb-ot-colr-table.hh"
|
||||
#include "hb-ot-cpal-table.hh"
|
||||
|
||||
#include "hb-ot-map-private.hh"
|
||||
@ -63,9 +64,10 @@ _hb_ot_layout_create (hb_face_t *face)
|
||||
layout->gpos_blob = OT::Sanitizer<OT::GPOS>().sanitize (face->reference_table (HB_OT_TAG_GPOS));
|
||||
layout->gpos = OT::Sanitizer<OT::GPOS>::lock_instance (layout->gpos_blob);
|
||||
|
||||
layout->math.init (face);
|
||||
layout->cpal.init (face);
|
||||
layout->base.init (face);
|
||||
layout->colr.init (face);
|
||||
layout->cpal.init (face);
|
||||
layout->math.init (face);
|
||||
layout->fvar.init (face);
|
||||
layout->avar.init (face);
|
||||
layout->ankr.init (face);
|
||||
@ -218,9 +220,10 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout)
|
||||
hb_blob_destroy (layout->gsub_blob);
|
||||
hb_blob_destroy (layout->gpos_blob);
|
||||
|
||||
layout->math.fini ();
|
||||
layout->cpal.fini ();
|
||||
layout->base.fini ();
|
||||
layout->colr.fini ();
|
||||
layout->cpal.fini ();
|
||||
layout->math.fini ();
|
||||
layout->fvar.fini ();
|
||||
layout->avar.fini ();
|
||||
layout->ankr.fini ();
|
||||
|
Loading…
Reference in New Issue
Block a user