2010-07-23 20:54:22 +02:00
|
|
|
|
/*
|
2011-04-21 23:14:28 +02:00
|
|
|
|
* Copyright © 2010 Red Hat, Inc.
|
2012-05-11 01:25:34 +02:00
|
|
|
|
* Copyright © 2012 Google, Inc.
|
2010-07-23 20:54:22 +02:00
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* Red Hat Author(s): Behdad Esfahbod
|
2012-05-11 01:25:34 +02:00
|
|
|
|
* Google Author(s): Behdad Esfahbod
|
2010-07-23 20:54:22 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2011-08-17 14:19:59 +02:00
|
|
|
|
#ifndef HB_OT_HEAD_TABLE_HH
|
|
|
|
|
#define HB_OT_HEAD_TABLE_HH
|
2010-07-23 20:54:22 +02:00
|
|
|
|
|
2018-08-26 07:36:36 +02:00
|
|
|
|
#include "hb-open-type.hh"
|
2010-07-23 20:54:22 +02:00
|
|
|
|
|
|
|
|
|
/*
|
2011-08-17 14:43:45 +02:00
|
|
|
|
* head -- Font Header
|
2018-04-12 11:08:19 +02:00
|
|
|
|
* https://docs.microsoft.com/en-us/typography/opentype/spec/head
|
2010-07-23 20:54:22 +02:00
|
|
|
|
*/
|
|
|
|
|
#define HB_OT_TAG_head HB_TAG('h','e','a','d')
|
|
|
|
|
|
2018-04-12 11:08:19 +02:00
|
|
|
|
|
|
|
|
|
namespace OT {
|
|
|
|
|
|
|
|
|
|
|
2010-07-23 20:54:22 +02:00
|
|
|
|
struct head
|
|
|
|
|
{
|
2021-02-17 19:34:47 +01:00
|
|
|
|
friend struct OpenTypeOffsetTable;
|
2018-02-24 01:42:06 +01:00
|
|
|
|
|
2019-01-22 12:08:57 +01:00
|
|
|
|
static constexpr hb_tag_t tableTag = HB_OT_TAG_head;
|
2010-07-23 20:54:22 +02:00
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
|
unsigned int get_upem () const
|
2015-02-17 15:27:44 +01:00
|
|
|
|
{
|
2010-10-02 01:09:23 +02:00
|
|
|
|
unsigned int upem = unitsPerEm;
|
2012-11-12 22:02:20 +01:00
|
|
|
|
/* If no valid head table found, assume 1000, which matches typical Type1 usage. */
|
2010-10-02 01:09:23 +02:00
|
|
|
|
return 16 <= upem && upem <= 16384 ? upem : 1000;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-04 19:36:51 +01:00
|
|
|
|
bool serialize (hb_serialize_context_t *c) const
|
|
|
|
|
{
|
|
|
|
|
TRACE_SERIALIZE (this);
|
|
|
|
|
return_trace ((bool) c->embed (this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool subset (hb_subset_context_t *c) const
|
|
|
|
|
{
|
|
|
|
|
TRACE_SUBSET (this);
|
2023-04-04 19:33:58 +02:00
|
|
|
|
head *out = c->serializer->embed (this);
|
|
|
|
|
if (unlikely (!out)) return_trace (false);
|
|
|
|
|
|
|
|
|
|
if (c->plan->normalized_coords)
|
|
|
|
|
{
|
|
|
|
|
if (unlikely (!c->serializer->check_assign (out->xMin, c->plan->head_maxp_info.xMin,
|
|
|
|
|
HB_SERIALIZE_ERROR_INT_OVERFLOW)))
|
|
|
|
|
return_trace (false);
|
|
|
|
|
if (unlikely (!c->serializer->check_assign (out->xMax, c->plan->head_maxp_info.xMax,
|
|
|
|
|
HB_SERIALIZE_ERROR_INT_OVERFLOW)))
|
|
|
|
|
return_trace (false);
|
|
|
|
|
if (unlikely (!c->serializer->check_assign (out->yMin, c->plan->head_maxp_info.yMin,
|
|
|
|
|
HB_SERIALIZE_ERROR_INT_OVERFLOW)))
|
|
|
|
|
return_trace (false);
|
|
|
|
|
if (unlikely (!c->serializer->check_assign (out->yMax, c->plan->head_maxp_info.yMax,
|
|
|
|
|
HB_SERIALIZE_ERROR_INT_OVERFLOW)))
|
|
|
|
|
return_trace (false);
|
|
|
|
|
}
|
|
|
|
|
return_trace (true);
|
2020-02-04 19:36:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-08 07:50:25 +01:00
|
|
|
|
enum mac_style_flag_t {
|
|
|
|
|
BOLD = 1u<<0,
|
|
|
|
|
ITALIC = 1u<<1,
|
|
|
|
|
UNDERLINE = 1u<<2,
|
|
|
|
|
OUTLINE = 1u<<3,
|
|
|
|
|
SHADOW = 1u<<4,
|
2021-10-21 17:54:02 +02:00
|
|
|
|
CONDENSED = 1u<<5,
|
|
|
|
|
EXPANDED = 1u<<6,
|
2018-12-08 07:50:25 +01:00
|
|
|
|
};
|
|
|
|
|
|
2018-12-17 19:01:01 +01:00
|
|
|
|
bool is_bold () const { return macStyle & BOLD; }
|
|
|
|
|
bool is_italic () const { return macStyle & ITALIC; }
|
|
|
|
|
bool is_condensed () const { return macStyle & CONDENSED; }
|
2021-10-21 17:54:02 +02:00
|
|
|
|
bool is_expanded () const { return macStyle & EXPANDED; }
|
2018-12-08 07:50:25 +01:00
|
|
|
|
|
2018-12-16 20:08:10 +01:00
|
|
|
|
bool sanitize (hb_sanitize_context_t *c) const
|
2015-02-17 15:27:44 +01:00
|
|
|
|
{
|
2012-11-23 21:32:14 +01:00
|
|
|
|
TRACE_SANITIZE (this);
|
2016-01-02 14:25:18 +01:00
|
|
|
|
return_trace (c->check_struct (this) &&
|
|
|
|
|
version.major == 1 &&
|
|
|
|
|
magicNumber == 0x5F0F3CF5u);
|
2010-07-23 20:54:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-24 21:40:37 +02:00
|
|
|
|
protected:
|
2016-02-22 03:44:45 +01:00
|
|
|
|
FixedVersion<>version; /* Version of the head table--currently
|
2014-07-11 20:54:42 +02:00
|
|
|
|
* 0x00010000u for version 1.0. */
|
2016-02-22 03:44:45 +01:00
|
|
|
|
FixedVersion<>fontRevision; /* Set by font manufacturer. */
|
2018-01-17 21:46:08 +01:00
|
|
|
|
HBUINT32 checkSumAdjustment; /* To compute: set it to 0, sum the
|
2018-01-10 03:07:30 +01:00
|
|
|
|
* entire font as HBUINT32, then store
|
2014-07-11 20:54:42 +02:00
|
|
|
|
* 0xB1B0AFBAu - sum. */
|
2018-01-17 21:46:08 +01:00
|
|
|
|
HBUINT32 magicNumber; /* Set to 0x5F0F3CF5u. */
|
2023-01-25 20:01:08 +01:00
|
|
|
|
public:
|
2018-01-10 03:07:30 +01:00
|
|
|
|
HBUINT16 flags; /* Bit 0: Baseline for font at y=0;
|
2010-07-23 20:54:22 +02:00
|
|
|
|
* Bit 1: Left sidebearing point at x=0;
|
|
|
|
|
* Bit 2: Instructions may depend on point size;
|
|
|
|
|
* Bit 3: Force ppem to integer values for all
|
|
|
|
|
* internal scaler math; may use fractional
|
|
|
|
|
* ppem sizes if this bit is clear;
|
|
|
|
|
* Bit 4: Instructions may alter advance width
|
|
|
|
|
* (the advance widths might not scale linearly);
|
|
|
|
|
* Bits 5-10: These should be set according to
|
|
|
|
|
* Apple's specification. However, they are not
|
|
|
|
|
* implemented in OpenType.
|
|
|
|
|
* Bit 5: This bit should be set in fonts that are
|
|
|
|
|
* intended to e laid out vertically, and in
|
|
|
|
|
* which the glyphs have been drawn such that an
|
|
|
|
|
* x-coordinate of 0 corresponds to the desired
|
|
|
|
|
* vertical baseline.
|
|
|
|
|
* Bit 6: This bit must be set to zero.
|
|
|
|
|
* Bit 7: This bit should be set if the font
|
|
|
|
|
* requires layout for correct linguistic
|
|
|
|
|
* rendering (e.g. Arabic fonts).
|
|
|
|
|
* Bit 8: This bit should be set for a GX font
|
|
|
|
|
* which has one or more metamorphosis effects
|
|
|
|
|
* designated as happening by default.
|
|
|
|
|
* Bit 9: This bit should be set if the font
|
|
|
|
|
* contains any strong right-to-left glyphs.
|
|
|
|
|
* Bit 10: This bit should be set if the font
|
|
|
|
|
* contains Indic-style rearrangement effects.
|
|
|
|
|
* Bit 11: Font data is 'lossless,' as a result
|
|
|
|
|
* of having been compressed and decompressed
|
|
|
|
|
* with the Agfa MicroType Express engine.
|
|
|
|
|
* Bit 12: Font converted (produce compatible metrics)
|
|
|
|
|
* Bit 13: Font optimized for ClearType™.
|
|
|
|
|
* Note, fonts that rely on embedded bitmaps (EBDT)
|
|
|
|
|
* for rendering should not be considered optimized
|
|
|
|
|
* for ClearType, and therefore should keep this bit
|
|
|
|
|
* cleared.
|
2010-12-13 21:54:56 +01:00
|
|
|
|
* Bit 14: Last Resort font. If set, indicates that
|
|
|
|
|
* the glyphs encoded in the cmap subtables are simply
|
|
|
|
|
* generic symbolic representations of code point
|
|
|
|
|
* ranges and don’t truly represent support for those
|
|
|
|
|
* code points. If unset, indicates that the glyphs
|
|
|
|
|
* encoded in the cmap subtables represent proper
|
|
|
|
|
* support for those code points.
|
2010-07-23 20:54:22 +02:00
|
|
|
|
* Bit 15: Reserved, set to 0. */
|
2023-01-25 20:01:08 +01:00
|
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
|
HBUINT16 unitsPerEm; /* Valid range is from 16 to 16384. This value
|
2010-07-23 20:54:22 +02:00
|
|
|
|
* should be a power of 2 for fonts that have
|
|
|
|
|
* TrueType outlines. */
|
|
|
|
|
LONGDATETIME created; /* Number of seconds since 12:00 midnight,
|
|
|
|
|
January 1, 1904. 64-bit integer */
|
|
|
|
|
LONGDATETIME modified; /* Number of seconds since 12:00 midnight,
|
|
|
|
|
January 1, 1904. 64-bit integer */
|
2023-01-18 19:15:47 +01:00
|
|
|
|
public:
|
2018-01-17 21:46:08 +01:00
|
|
|
|
HBINT16 xMin; /* For all glyph bounding boxes. */
|
|
|
|
|
HBINT16 yMin; /* For all glyph bounding boxes. */
|
|
|
|
|
HBINT16 xMax; /* For all glyph bounding boxes. */
|
|
|
|
|
HBINT16 yMax; /* For all glyph bounding boxes. */
|
2023-01-18 19:15:47 +01:00
|
|
|
|
protected:
|
2018-01-10 03:07:30 +01:00
|
|
|
|
HBUINT16 macStyle; /* Bit 0: Bold (if set to 1);
|
2010-07-23 20:54:22 +02:00
|
|
|
|
* Bit 1: Italic (if set to 1)
|
|
|
|
|
* Bit 2: Underline (if set to 1)
|
|
|
|
|
* Bit 3: Outline (if set to 1)
|
|
|
|
|
* Bit 4: Shadow (if set to 1)
|
|
|
|
|
* Bit 5: Condensed (if set to 1)
|
|
|
|
|
* Bit 6: Extended (if set to 1)
|
|
|
|
|
* Bits 7-15: Reserved (set to 0). */
|
2018-01-10 03:07:30 +01:00
|
|
|
|
HBUINT16 lowestRecPPEM; /* Smallest readable size in pixels. */
|
2018-01-17 21:46:08 +01:00
|
|
|
|
HBINT16 fontDirectionHint; /* Deprecated (Set to 2).
|
2010-07-23 20:54:22 +02:00
|
|
|
|
* 0: Fully mixed directional glyphs;
|
|
|
|
|
* 1: Only strongly left to right;
|
|
|
|
|
* 2: Like 1 but also contains neutrals;
|
|
|
|
|
* -1: Only strongly right to left;
|
|
|
|
|
* -2: Like -1 but also contains neutrals. */
|
2015-08-23 15:42:20 +02:00
|
|
|
|
public:
|
2018-08-06 15:30:12 +02:00
|
|
|
|
HBUINT16 indexToLocFormat; /* 0 for short offsets, 1 for long. */
|
|
|
|
|
HBUINT16 glyphDataFormat; /* 0 for current format. */
|
2015-08-23 15:42:20 +02:00
|
|
|
|
|
2010-07-23 20:54:22 +02:00
|
|
|
|
DEFINE_SIZE_STATIC (54);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2012-11-17 03:49:54 +01:00
|
|
|
|
} /* namespace OT */
|
2012-08-28 23:57:49 +02:00
|
|
|
|
|
2010-07-23 21:11:18 +02:00
|
|
|
|
|
2011-08-17 14:19:59 +02:00
|
|
|
|
#endif /* HB_OT_HEAD_TABLE_HH */
|