Blame src/hb-ot-shape-complex-arabic-win1256.hh

Packit 874993
/*
Packit 874993
 * Copyright © 2014  Google, Inc.
Packit 874993
 *
Packit 874993
 *  This is part of HarfBuzz, a text shaping library.
Packit 874993
 *
Packit 874993
 * Permission is hereby granted, without written agreement and without
Packit 874993
 * license or royalty fees, to use, copy, modify, and distribute this
Packit 874993
 * software and its documentation for any purpose, provided that the
Packit 874993
 * above copyright notice and the following two paragraphs appear in
Packit 874993
 * all copies of this software.
Packit 874993
 *
Packit 874993
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
Packit 874993
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
Packit 874993
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
Packit 874993
 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
Packit 874993
 * DAMAGE.
Packit 874993
 *
Packit 874993
 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
Packit 874993
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
Packit 874993
 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
Packit 874993
 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
Packit 874993
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
Packit 874993
 *
Packit 874993
 * Google Author(s): Behdad Esfahbod
Packit 874993
 */
Packit 874993
Packit 874993
#ifndef HB_OT_SHAPE_COMPLEX_ARABIC_WIN1256_HH
Packit 874993
Packit 874993
Packit 874993
/*
Packit 874993
 * The macros in the first part of this file are generic macros that can
Packit 874993
 * be used to define the bytes for OpenType table data in code in a
Packit 874993
 * readable manner.  We can move the macros to reside with their respective
Packit 874993
 * struct types, but since we only use these to define one data table, the
Packit 874993
 * Windows-1256 Arabic shaping table in this file, we keep them here.
Packit 874993
 */
Packit 874993
Packit 874993
Packit 874993
/* First we measure, then we cut. */
Packit 874993
#ifndef OT_MEASURE
Packit 874993
#define OT_MEASURE
Packit 874993
#define OT_TABLE_START			static const struct TABLE_NAME {
Packit 874993
#define OT_TABLE_END			}
Packit 874993
#define OT_LABEL_START(Name)		unsigned char Name[
Packit 874993
#define OT_LABEL_END			];
Packit 874993
#define OT_BYTE(u8)			+1/*byte*/
Packit 874993
#define OT_USHORT(u16)			+2/*bytes*/
Packit 874993
#else
Packit 874993
#undef  OT_MEASURE
Packit 874993
#define OT_TABLE_START			TABLE_NAME = {
Packit 874993
#define OT_TABLE_END			};
Packit 874993
#define OT_LABEL_START(Name)		{
Packit 874993
#define OT_LABEL_END			},
Packit 874993
#define OT_BYTE(u8)			(u8),
Packit 874993
#define OT_USHORT(u16)			(unsigned char)((u16)>>8), (unsigned char)((u16)&0xFFu),
Packit 874993
#define OT_COUNT(Name, ItemSize)	((unsigned int) sizeof(((struct TABLE_NAME*)0)->Name) \
Packit 874993
					 / (unsigned int)(ItemSize) \
Packit 874993
					 /* OT_ASSERT it's divisible (and positive). */)
Packit 874993
#define OT_DISTANCE(From,To)		((unsigned int) \
Packit 874993
					 ((char*)(&((struct TABLE_NAME*)0)->To) - \
Packit 874993
					  (char*)(&((struct TABLE_NAME*)0)->From)) \
Packit 874993
					 /* OT_ASSERT it's positive. */)
Packit 874993
#endif
Packit 874993
Packit 874993
Packit 874993
#define OT_LABEL(Name) \
Packit 874993
	OT_LABEL_END \
Packit 874993
	OT_LABEL_START(Name)
Packit 874993
Packit 874993
/* Whenever we receive an argument that is a list, it will expand to
Packit 874993
 * contain commas.  That cannot be passed to another macro because the
Packit 874993
 * commas will throw off the preprocessor.  The solution is to wrap
Packit 874993
 * the passed-in argument in OT_LIST() before passing to the next macro.
Packit 874993
 * Unfortunately this trick requires vararg macros. */
Packit 874993
#define OT_LIST(...) __VA_ARGS__
Packit 874993
Packit 874993
Packit 874993
/*
Packit 874993
 * Basic Types
Packit 874993
 */
Packit 874993
Packit 874993
#define OT_TAG(a,b,c,d) \
Packit 874993
	OT_BYTE(a) OT_BYTE(b) OT_BYTE(c) OT_BYTE(d)
Packit 874993
Packit 874993
#define OT_OFFSET(From, To) /* Offset from From to To in bytes */ \
Packit 874993
	OT_USHORT(OT_DISTANCE(From, To))
Packit 874993
Packit 874993
#define OT_GLYPHID /* GlyphID */ \
Packit 874993
	OT_USHORT
Packit 874993
Packit 874993
#define OT_UARRAY(Name, Items) \
Packit 874993
	OT_LABEL_START(Name) \
Packit 874993
	OT_USHORT(OT_COUNT(Name##Data, 2)) \
Packit 874993
	OT_LABEL(Name##Data) \
Packit 874993
	Items \
Packit 874993
	OT_LABEL_END
Packit 874993
Packit 874993
#define OT_UHEADLESSARRAY(Name, Items) \
Packit 874993
	OT_LABEL_START(Name) \
Packit 874993
	OT_USHORT(OT_COUNT(Name##Data, 2) + 1) \
Packit 874993
	OT_LABEL(Name##Data) \
Packit 874993
	Items \
Packit 874993
	OT_LABEL_END
Packit 874993
Packit 874993
Packit 874993
/*
Packit 874993
 * Common Types
Packit 874993
 */
Packit 874993
Packit 874993
#define OT_LOOKUP_FLAG_IGNORE_MARKS	0x08u
Packit 874993
Packit 874993
#define OT_LOOKUP(Name, LookupType, LookupFlag, SubLookupOffsets) \
Packit 874993
	OT_LABEL_START(Name) \
Packit 874993
	OT_USHORT(LookupType) \
Packit 874993
	OT_USHORT(LookupFlag) \
Packit 874993
	OT_LABEL_END \
Packit 874993
	OT_UARRAY(Name##SubLookupOffsetsArray, OT_LIST(SubLookupOffsets))
Packit 874993
Packit 874993
#define OT_SUBLOOKUP(Name, SubFormat, Items) \
Packit 874993
	OT_LABEL_START(Name) \
Packit 874993
	OT_USHORT(SubFormat) \
Packit 874993
	Items
Packit 874993
Packit 874993
#define OT_COVERAGE1(Name, Items) \
Packit 874993
	OT_LABEL_START(Name) \
Packit 874993
	OT_USHORT(1) \
Packit 874993
	OT_LABEL_END \
Packit 874993
	OT_UARRAY(Name##Glyphs, OT_LIST(Items))
Packit 874993
Packit 874993
Packit 874993
/*
Packit 874993
 * GSUB
Packit 874993
 */
Packit 874993
Packit 874993
#define OT_LOOKUP_TYPE_SUBST_SINGLE	1u
Packit 874993
#define OT_LOOKUP_TYPE_SUBST_LIGATURE	4u
Packit 874993
Packit 874993
#define OT_SUBLOOKUP_SINGLE_SUBST_FORMAT2(Name, FromGlyphs, ToGlyphs) \
Packit 874993
	OT_SUBLOOKUP(Name, 2, \
Packit 874993
		OT_OFFSET(Name, Name##Coverage) \
Packit 874993
		OT_LABEL_END \
Packit 874993
		OT_UARRAY(Name##Substitute, OT_LIST(ToGlyphs)) \
Packit 874993
	) \
Packit 874993
	OT_COVERAGE1(Name##Coverage, OT_LIST(FromGlyphs)) \
Packit 874993
	/* ASSERT_STATIC_EXPR_ZERO (len(FromGlyphs) == len(ToGlyphs)) */
Packit 874993
Packit 874993
#define OT_SUBLOOKUP_LIGATURE_SUBST_FORMAT1(Name, FirstGlyphs, LigatureSetOffsets) \
Packit 874993
	OT_SUBLOOKUP(Name, 1, \
Packit 874993
		OT_OFFSET(Name, Name##Coverage) \
Packit 874993
		OT_LABEL_END \
Packit 874993
		OT_UARRAY(Name##LigatureSetOffsetsArray, OT_LIST(LigatureSetOffsets)) \
Packit 874993
	) \
Packit 874993
	OT_COVERAGE1(Name##Coverage, OT_LIST(FirstGlyphs)) \
Packit 874993
	/* ASSERT_STATIC_EXPR_ZERO (len(FirstGlyphs) == len(LigatureSetOffsets)) */
Packit 874993
Packit 874993
#define OT_LIGATURE_SET(Name, LigatureSetOffsets) \
Packit 874993
	OT_UARRAY(Name, OT_LIST(LigatureSetOffsets))
Packit 874993
Packit 874993
#define OT_LIGATURE(Name, Components, LigGlyph) \
Packit 874993
	OT_LABEL_START(Name) \
Packit 874993
	LigGlyph \
Packit 874993
	OT_LABEL_END \
Packit 874993
	OT_UHEADLESSARRAY(Name##ComponentsArray, OT_LIST(Components))
Packit 874993
Packit 874993
/*
Packit 874993
 *
Packit 874993
 * Start of Windows-1256 shaping table.
Packit 874993
 *
Packit 874993
 */
Packit 874993
Packit 874993
/* Table name. */
Packit 874993
#define TABLE_NAME arabic_win1256_gsub_lookups
Packit 874993
Packit 874993
/* Table manifest. */
Packit 874993
#define MANIFEST(Items) \
Packit 874993
	OT_LABEL_START(manifest) \
Packit 874993
	OT_USHORT(OT_COUNT(manifestData, 6)) \
Packit 874993
	OT_LABEL(manifestData) \
Packit 874993
	Items \
Packit 874993
	OT_LABEL_END
Packit 874993
Packit 874993
#define MANIFEST_LOOKUP(Tag, Name) \
Packit 874993
	Tag \
Packit 874993
	OT_OFFSET(manifest, Name)
Packit 874993
Packit 874993
/* Shorthand. */
Packit 874993
#define G	OT_GLYPHID
Packit 874993
Packit 874993
/*
Packit 874993
 * Table Start
Packit 874993
 */
Packit 874993
OT_TABLE_START
Packit 874993
Packit 874993
Packit 874993
/*
Packit 874993
 * Manifest
Packit 874993
 */
Packit 874993
MANIFEST(
Packit 874993
	MANIFEST_LOOKUP(OT_TAG('r','l','i','g'), rligLookup)
Packit 874993
	MANIFEST_LOOKUP(OT_TAG('i','n','i','t'), initLookup)
Packit 874993
	MANIFEST_LOOKUP(OT_TAG('m','e','d','i'), mediLookup)
Packit 874993
	MANIFEST_LOOKUP(OT_TAG('f','i','n','a'), finaLookup)
Packit 874993
	MANIFEST_LOOKUP(OT_TAG('r','l','i','g'), rligMarksLookup)
Packit 874993
)
Packit 874993
Packit 874993
/*
Packit 874993
 * Lookups
Packit 874993
 */
Packit 874993
OT_LOOKUP(initLookup, OT_LOOKUP_TYPE_SUBST_SINGLE, OT_LOOKUP_FLAG_IGNORE_MARKS,
Packit 874993
	OT_OFFSET(initLookup, initmediSubLookup)
Packit 874993
	OT_OFFSET(initLookup, initSubLookup)
Packit 874993
)
Packit 874993
OT_LOOKUP(mediLookup, OT_LOOKUP_TYPE_SUBST_SINGLE, OT_LOOKUP_FLAG_IGNORE_MARKS,
Packit 874993
	OT_OFFSET(mediLookup, initmediSubLookup)
Packit 874993
	OT_OFFSET(mediLookup, mediSubLookup)
Packit 874993
	OT_OFFSET(mediLookup, medifinaLamAlefSubLookup)
Packit 874993
)
Packit 874993
OT_LOOKUP(finaLookup, OT_LOOKUP_TYPE_SUBST_SINGLE, OT_LOOKUP_FLAG_IGNORE_MARKS,
Packit 874993
	OT_OFFSET(finaLookup, finaSubLookup)
Packit 874993
	/* We don't need this one currently as the sequence inherits masks
Packit 874993
	 * from the first item.  Just in case we change that in the future
Packit 874993
	 * to be smart about Arabic masks when ligating... */
Packit 874993
	OT_OFFSET(finaLookup, medifinaLamAlefSubLookup)
Packit 874993
)
Packit 874993
OT_LOOKUP(rligLookup, OT_LOOKUP_TYPE_SUBST_LIGATURE, OT_LOOKUP_FLAG_IGNORE_MARKS,
Packit 874993
	OT_OFFSET(rligLookup, lamAlefLigaturesSubLookup)
Packit 874993
)
Packit 874993
OT_LOOKUP(rligMarksLookup, OT_LOOKUP_TYPE_SUBST_LIGATURE, 0,
Packit 874993
	OT_OFFSET(rligMarksLookup, shaddaLigaturesSubLookup)
Packit 874993
)
Packit 874993
Packit 874993
/*
Packit 874993
 * init/medi/fina forms
Packit 874993
 */
Packit 874993
OT_SUBLOOKUP_SINGLE_SUBST_FORMAT2(initmediSubLookup,
Packit 874993
	G(198)	G(200)	G(201)	G(202)	G(203)	G(204)	G(205)	G(206)	G(211)
Packit 874993
	G(212)	G(213)	G(214)	G(223)	G(225)	G(227)	G(228)	G(236)	G(237),
Packit 874993
	G(162)	G(4)	G(5)	G(5)	G(6)	G(7)	G(9)	G(11)	G(13)
Packit 874993
	G(14)	G(15)	G(26)	G(140)	G(141)	G(142)	G(143)	G(154)	G(154)
Packit 874993
)
Packit 874993
OT_SUBLOOKUP_SINGLE_SUBST_FORMAT2(initSubLookup,
Packit 874993
	G(218)	G(219)	G(221)	G(222)	G(229),
Packit 874993
	G(27)	G(30)	G(128)	G(131)	G(144)
Packit 874993
)
Packit 874993
OT_SUBLOOKUP_SINGLE_SUBST_FORMAT2(mediSubLookup,
Packit 874993
	G(218)	G(219)	G(221)	G(222)	G(229),
Packit 874993
	G(28)	G(31)	G(129)	G(138)	G(149)
Packit 874993
)
Packit 874993
OT_SUBLOOKUP_SINGLE_SUBST_FORMAT2(finaSubLookup,
Packit 874993
	G(194)	G(195)	G(197)	G(198)	G(199)	G(201)	G(204)	G(205)	G(206)
Packit 874993
	G(218)	G(219)	G(229)	G(236)	G(237),
Packit 874993
	G(2)	G(1)	G(3)	G(181)	G(0)	G(159)	G(8)	G(10)	G(12)
Packit 874993
	G(29)	G(127)	G(152) G(160)	G(156)
Packit 874993
)
Packit 874993
OT_SUBLOOKUP_SINGLE_SUBST_FORMAT2(medifinaLamAlefSubLookup,
Packit 874993
	G(165)	G(178)	G(180)	G(252),
Packit 874993
	G(170)	G(179)	G(185)	G(255)
Packit 874993
)
Packit 874993
Packit 874993
/*
Packit 874993
 * Lam+Alef ligatures
Packit 874993
 */
Packit 874993
OT_SUBLOOKUP_LIGATURE_SUBST_FORMAT1(lamAlefLigaturesSubLookup,
Packit 874993
	G(225),
Packit 874993
	OT_OFFSET(lamAlefLigaturesSubLookup, lamLigatureSet)
Packit 874993
)
Packit 874993
OT_LIGATURE_SET(lamLigatureSet,
Packit 874993
	OT_OFFSET(lamLigatureSet, lamInitLigature1)
Packit 874993
	OT_OFFSET(lamLigatureSet, lamInitLigature2)
Packit 874993
	OT_OFFSET(lamLigatureSet, lamInitLigature3)
Packit 874993
	OT_OFFSET(lamLigatureSet, lamInitLigature4)
Packit 874993
)
Packit 874993
OT_LIGATURE(lamInitLigature1, G(199), G(165))
Packit 874993
OT_LIGATURE(lamInitLigature2, G(195), G(178))
Packit 874993
OT_LIGATURE(lamInitLigature3, G(194), G(180))
Packit 874993
OT_LIGATURE(lamInitLigature4, G(197), G(252))
Packit 874993
Packit 874993
/*
Packit 874993
 * Shadda ligatures
Packit 874993
 */
Packit 874993
OT_SUBLOOKUP_LIGATURE_SUBST_FORMAT1(shaddaLigaturesSubLookup,
Packit 874993
	G(248),
Packit 874993
	OT_OFFSET(shaddaLigaturesSubLookup, shaddaLigatureSet)
Packit 874993
)
Packit 874993
OT_LIGATURE_SET(shaddaLigatureSet,
Packit 874993
	OT_OFFSET(shaddaLigatureSet, shaddaLigature1)
Packit 874993
	OT_OFFSET(shaddaLigatureSet, shaddaLigature2)
Packit 874993
	OT_OFFSET(shaddaLigatureSet, shaddaLigature3)
Packit 874993
)
Packit 874993
OT_LIGATURE(shaddaLigature1, G(243), G(172))
Packit 874993
OT_LIGATURE(shaddaLigature2, G(245), G(173))
Packit 874993
OT_LIGATURE(shaddaLigature3, G(246), G(175))
Packit 874993
Packit 874993
/*
Packit 874993
 * Table end
Packit 874993
 */
Packit 874993
OT_TABLE_END
Packit 874993
Packit 874993
Packit 874993
/*
Packit 874993
 * Clean up
Packit 874993
 */
Packit 874993
#undef OT_TABLE_START
Packit 874993
#undef OT_TABLE_END
Packit 874993
#undef OT_LABEL_START
Packit 874993
#undef OT_LABEL_END
Packit 874993
#undef OT_BYTE
Packit 874993
#undef OT_USHORT
Packit 874993
#undef OT_DISTANCE
Packit 874993
#undef OT_COUNT
Packit 874993
Packit 874993
/*
Packit 874993
 * Include a second time to get the table data...
Packit 874993
 */
Packit 874993
#if 0
Packit 874993
#include "hb-private.hh" /* Make check-includes.sh happy. */
Packit 874993
#endif
Packit 874993
#ifdef OT_MEASURE
Packit 874993
#include "hb-ot-shape-complex-arabic-win1256.hh"
Packit 874993
#endif
Packit 874993
Packit 874993
#define HB_OT_SHAPE_COMPLEX_ARABIC_WIN1256_HH
Packit 874993
#endif /* HB_OT_SHAPE_COMPLEX_ARABIC_WIN1256_HH */