2018-03-10 08:43:52 +01:00
|
|
|
/*
|
|
|
|
* 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_COLOR_SVG_TABLE_HH
|
|
|
|
#define HB_OT_COLOR_SVG_TABLE_HH
|
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
#include "hb-open-type.hh"
|
2018-03-10 08:43:52 +01:00
|
|
|
|
|
|
|
/*
|
2018-04-12 11:08:19 +02:00
|
|
|
* SVG -- SVG (Scalable Vector Graphics)
|
2018-03-10 08:43:52 +01:00
|
|
|
* https://docs.microsoft.com/en-us/typography/opentype/spec/svg
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define HB_OT_TAG_SVG HB_TAG('S','V','G',' ')
|
|
|
|
|
2018-04-12 11:08:19 +02:00
|
|
|
|
2018-03-10 08:43:52 +01:00
|
|
|
namespace OT {
|
|
|
|
|
|
|
|
|
|
|
|
struct SVGDocumentIndexEntry
|
|
|
|
{
|
2018-10-23 16:30:48 +02:00
|
|
|
inline int cmp (hb_codepoint_t g) const
|
|
|
|
{ return g < startGlyphID ? -1 : g > endGlyphID ? 1 : 0; }
|
|
|
|
|
2018-10-27 09:20:53 +02:00
|
|
|
inline hb_blob_t *reference_blob (hb_blob_t *svg_blob, unsigned int index_offset) const
|
2018-10-25 20:22:35 +02:00
|
|
|
{
|
2018-10-29 02:32:37 +01:00
|
|
|
return hb_blob_create_sub_blob (svg_blob,
|
|
|
|
index_offset + (unsigned int) svgDoc,
|
2018-10-25 20:22:35 +02:00
|
|
|
svgDocLength);
|
|
|
|
}
|
|
|
|
|
2018-10-29 19:14:37 +01:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
2018-03-10 08:43:52 +01:00
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
2018-10-29 19:14:37 +01:00
|
|
|
return_trace (c->check_struct (this) &&
|
|
|
|
svgDoc.sanitize (c, base, svgDocLength));
|
2018-03-10 08:43:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2018-04-11 14:43:20 +02:00
|
|
|
HBUINT16 startGlyphID; /* The first glyph ID in the range described by
|
|
|
|
* this index entry. */
|
|
|
|
HBUINT16 endGlyphID; /* The last glyph ID in the range described by
|
|
|
|
* this index entry. Must be >= startGlyphID. */
|
2018-09-15 19:43:33 +02:00
|
|
|
LOffsetTo<UnsizedArrayOf<HBUINT8>, false>
|
2018-04-11 14:43:20 +02:00
|
|
|
svgDoc; /* Offset from the beginning of the SVG Document Index
|
|
|
|
* to an SVG document. Must be non-zero. */
|
2018-10-23 16:30:48 +02:00
|
|
|
HBUINT32 svgDocLength; /* Length of the SVG document.
|
2018-04-11 14:43:20 +02:00
|
|
|
* Must be non-zero. */
|
2018-03-10 08:43:52 +01:00
|
|
|
public:
|
|
|
|
DEFINE_SIZE_STATIC (12);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SVG
|
|
|
|
{
|
2018-11-29 21:04:34 +01:00
|
|
|
enum { tableTag = HB_OT_TAG_SVG };
|
2018-03-10 08:43:52 +01:00
|
|
|
|
2018-11-03 21:15:30 +01:00
|
|
|
inline bool has_data (void) const { return svgDocEntries; }
|
|
|
|
|
2018-03-27 14:27:09 +02:00
|
|
|
struct accelerator_t
|
|
|
|
{
|
|
|
|
inline void init (hb_face_t *face)
|
|
|
|
{
|
2018-11-11 06:26:55 +01:00
|
|
|
table = hb_sanitize_context_t().reference_table<SVG> (face);
|
2018-03-27 14:27:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void fini (void)
|
|
|
|
{
|
2018-11-11 17:40:57 +01:00
|
|
|
table.destroy ();
|
2018-03-27 14:27:09 +02:00
|
|
|
}
|
|
|
|
|
2018-10-27 09:20:53 +02:00
|
|
|
inline hb_blob_t *reference_blob_for_glyph (hb_codepoint_t glyph_id) const
|
2018-10-23 16:30:48 +02:00
|
|
|
{
|
2018-11-11 06:26:55 +01:00
|
|
|
return table->get_glyph_entry (glyph_id).reference_blob (table.get_blob (),
|
|
|
|
table->svgDocEntries);
|
2018-03-27 14:27:09 +02:00
|
|
|
}
|
|
|
|
|
2018-11-03 21:15:30 +01:00
|
|
|
inline bool has_data () const { return table->has_data (); }
|
2018-10-23 16:30:48 +02:00
|
|
|
|
2018-03-27 14:27:09 +02:00
|
|
|
private:
|
2018-11-11 06:26:55 +01:00
|
|
|
hb_blob_ptr_t<SVG> table;
|
2018-03-27 14:27:09 +02:00
|
|
|
};
|
|
|
|
|
2018-10-25 21:09:58 +02:00
|
|
|
inline const SVGDocumentIndexEntry &get_glyph_entry (hb_codepoint_t glyph_id) const
|
|
|
|
{
|
2018-11-24 06:35:31 +01:00
|
|
|
return (this+svgDocEntries).bsearch (glyph_id);
|
2018-10-25 21:09:58 +02:00
|
|
|
}
|
|
|
|
|
2018-10-23 16:30:48 +02:00
|
|
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
|
|
{
|
|
|
|
TRACE_SANITIZE (this);
|
|
|
|
return_trace (likely (c->check_struct (this) &&
|
2018-10-25 21:09:58 +02:00
|
|
|
(this+svgDocEntries).sanitize_shallow (c)));
|
2018-10-23 16:30:48 +02:00
|
|
|
}
|
|
|
|
|
2018-03-10 08:43:52 +01:00
|
|
|
protected:
|
2018-03-12 11:30:11 +01:00
|
|
|
HBUINT16 version; /* Table version (starting at 0). */
|
2018-10-29 02:29:14 +01:00
|
|
|
LOffsetTo<SortedArrayOf<SVGDocumentIndexEntry> >
|
2018-10-25 21:09:58 +02:00
|
|
|
svgDocEntries; /* Offset (relative to the start of the SVG table) to the
|
2018-03-12 11:30:11 +01:00
|
|
|
* SVG Documents Index. Must be non-zero. */
|
2018-10-25 21:09:58 +02:00
|
|
|
/* Array of SVG Document Index Entries. */
|
2018-03-12 11:30:11 +01:00
|
|
|
HBUINT32 reserved; /* Set to 0. */
|
2018-03-10 08:43:52 +01:00
|
|
|
public:
|
|
|
|
DEFINE_SIZE_STATIC (10);
|
|
|
|
};
|
|
|
|
|
2018-10-23 16:30:48 +02:00
|
|
|
struct SVG_accelerator_t : SVG::accelerator_t {};
|
|
|
|
|
2018-03-10 08:43:52 +01:00
|
|
|
} /* namespace OT */
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* HB_OT_COLOR_SVG_TABLE_HH */
|