godot/thirdparty/harfbuzz/src/hb-open-type.hh

/*
 * Copyright © 2007,2008,2009,2010  Red Hat, Inc.
 * Copyright © 2012  Google, Inc.
 *
 *  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
 * Google Author(s): Behdad Esfahbod
 */

#ifndef HB_OPEN_TYPE_HH
#define HB_OPEN_TYPE_HH

#include "hb.hh"
#include "hb-blob.hh"
#include "hb-face.hh"
#include "hb-machinery.hh"
#include "hb-meta.hh"
#include "hb-subset.hh"


namespace OT {


/*
 *
 * The OpenType Font File: Data Types
 */


/* "The following data types are used in the OpenType font file.
 *  All OpenType fonts use Motorola-style byte ordering (Big Endian):" */

/*
 * Int types
 */

/* Integer types in big-endian order and no alignment requirement */
template <typename Type,
	  unsigned int Size = sizeof (Type)>
struct IntType
{};

HBUINT8;	/* 8-bit unsigned integer. */
HBINT8;	/* 8-bit signed integer. */
HBUINT16;	/* 16-bit unsigned integer. */
HBINT16;	/* 16-bit signed integer. */
HBUINT32;	/* 32-bit unsigned integer. */
HBINT32;	/* 32-bit signed integer. */
/* Note: we cannot defined a signed HBINT24 because there's no corresponding C type.
 * Works for unsigned, but not signed, since we rely on compiler for sign-extension. */
HBUINT24;	/* 24-bit unsigned integer. */

/* 15-bit unsigned number; top bit used for extension. */
struct HBUINT15 : HBUINT16
{};

/* 32-bit unsigned integer with variable encoding. */
struct HBUINT32VAR
{};

/* 16-bit signed integer (HBINT16) that describes a quantity in FUnits. */
FWORD;

/* 32-bit signed integer (HBINT32) that describes a quantity in FUnits. */
FWORD32;

/* 16-bit unsigned integer (HBUINT16) that describes a quantity in FUnits. */
UFWORD;

template <typename Type, unsigned fraction_bits>
struct HBFixed : Type
{};

/* 16-bit signed fixed number with the low 14 bits of fraction (2.14). */
F2DOT14;
F4DOT12;
F6DOT10;

/* 32-bit signed fixed-point number (16.16). */
F16DOT16;

/* Date represented in number of seconds since 12:00 midnight, January 1,
 * 1904. The value is represented as a signed 64-bit integer. */
struct LONGDATETIME
{};

/* Array of four uint8s (length = 32 bits) used to identify a script, language
 * system, feature, or baseline */
struct Tag : HBUINT32
{};

/* Glyph index number, same as uint16 (length = 16 bits) */
struct HBGlyphID16 : HBUINT16
{};
struct HBGlyphID24 : HBUINT24
{};

/* Script/language-system/feature index */
struct Index : HBUINT16 {};
DECLARE_NULL_NAMESPACE_BYTES();

/* Offset, Null offset = 0 */
template <typename Type, bool has_null=true>
struct Offset : Type
{};

Offset16;
Offset24;
Offset32;


/* CheckSum */
struct CheckSum : HBUINT32
{};


/*
 * Version Numbers
 */

template <typename FixedType=HBUINT16>
struct FixedVersion
{};


/*
 * Template subclasses of Offset that do the dereferencing.
 * Use: (base+offset)
 */

template <typename Type, bool has_null>
struct _hb_has_null
{};
_hb_has_null<Type, true>;

template <typename Type, typename OffsetType, typename BaseType=void, bool has_null=true>
struct OffsetTo : Offset<OffsetType, has_null>
{};
/* Partial specializations. */
Offset16To;
Offset24To;
Offset32To;

NNOffsetTo;
NNOffset16To;
NNOffset24To;
NNOffset32To;


/*
 * Array Types
 */

template <typename Type>
struct UnsizedArrayOf
{};

/* Unsized array of offset's */
UnsizedArray16OfOffsetTo;

/* Unsized array of offsets relative to the beginning of the array itself. */
template <typename Type, typename OffsetType, typename BaseType=void, bool has_null=true>
struct UnsizedListOfOffset16To : UnsizedArray16OfOffsetTo<Type, OffsetType, BaseType, has_null>
{};

/* An array with sorted elements.  Supports binary searching. */
template <typename Type>
struct SortedUnsizedArrayOf : UnsizedArrayOf<Type>
{};


/* An array with a number of elements. */
template <typename Type, typename LenType>
struct ArrayOf
{};
Array16Of;
Array24Of;
Array32Of;
PString;

/* Array of Offset's */
Array8OfOffset24To;
Array16OfOffset16To;
Array16OfOffset32To;
Array32OfOffset32To;

/* Array of offsets relative to the beginning of the array itself. */
template <typename Type, typename OffsetType>
struct List16OfOffsetTo : ArrayOf<OffsetTo<Type, OffsetType>, HBUINT16>
{};

List16OfOffset16To;

/* An array starting at second element. */
template <typename Type, typename LenType>
struct HeadlessArrayOf
{};
HeadlessArray16Of;

/* An array storing length-1. */
template <typename Type, typename LenType=HBUINT16>
struct ArrayOfM1
{};

/* An array with sorted elements.  Supports binary searching. */
template <typename Type, typename LenType>
struct SortedArrayOf : ArrayOf<Type, LenType>
{};

SortedArray16Of;
SortedArray24Of;
SortedArray32Of;

/*
 * Binary-search arrays
 */

template <typename LenType=HBUINT16>
struct BinSearchHeader
{};

BinSearchArrayOf;


struct VarSizedBinSearchHeader
{};

template <typename Type>
struct VarSizedBinSearchArrayOf
{};


/* CFF INDEX */

template <typename COUNT>
struct CFFIndex
{};
CFF1Index;
CFF2Index;


/* TupleValues */
struct TupleValues
{};

struct TupleList : CFF2Index
{};


} /* namespace OT */


#endif /* HB_OPEN_TYPE_HH */