aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/extras/freetype2/src/otlayout
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/extras/freetype2/src/otlayout')
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlayout.h205
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlbase.c181
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlbase.h14
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlcommn.c940
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlcommn.h277
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlconf.h78
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlgdef.c175
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlgdef.h14
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlgpos.c980
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlgpos.h14
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlgsub.c867
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlgsub.h26
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otljstf.c189
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otljstf.h14
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlparse.c142
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlparse.h99
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otltable.h60
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otltags.h88
-rw-r--r--nx-X11/extras/freetype2/src/otlayout/otlutils.h33
19 files changed, 4396 insertions, 0 deletions
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlayout.h b/nx-X11/extras/freetype2/src/otlayout/otlayout.h
new file mode 100644
index 000000000..2cd67f568
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlayout.h
@@ -0,0 +1,205 @@
+#ifndef __OT_LAYOUT_H__
+#define __OT_LAYOUT_H__
+
+
+#include "otlconf.h"
+
+OTL_BEGIN_HEADER
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** BASE DATA TYPES *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ typedef unsigned char OTL_Byte;
+ typedef const OTL_Byte* OTL_Bytes;
+
+ typedef int OTL_Error;
+
+ typedef void* OTL_Pointer;
+
+ typedef int OTL_Int;
+ typedef unsigned int OTL_UInt;
+
+ typedef long OTL_Long;
+ typedef unsigned long OTL_ULong;
+
+ typedef short OTL_Int16;
+ typedef unsigned short OTL_UInt16;
+
+
+#if OTL_SIZEOF_INT == 4
+
+ typedef int OTL_Int32;
+ typedef unsigned int OTL_UInt32;
+
+#elif OTL_SIZEOF_LONG == 4
+
+ typedef long OTL_Int32;
+ typedef unsigned long OTL_UInt32;
+
+#else
+# error "no 32-bits type found"
+#endif
+
+ typedef OTL_UInt32 OTL_Tag;
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** ERROR CODES *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ typedef enum
+ {
+ OTL_Err_Ok = 0,
+ OTL_Err_InvalidArgument,
+ OTL_Err_InvalidFormat,
+ OTL_Err_InvalidOffset,
+
+ OTL_Err_Max
+
+ } OTL_Error;
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** MEMORY MANAGEMENT *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ typedef OTL_Pointer (*OTL_AllocFunc)( OTL_ULong size,
+ OTL_Pointer data );
+
+ typedef OTL_Pointer (*OTL_ReallocFunc)( OTL_Pointer block,
+ OTL_ULong size,
+ OTL_Pointer data );
+
+ typedef void (*OTL_FreeFunc)( OTL_Pointer block,
+ OTL_Pointer data );
+
+ typedef struct OTL_MemoryRec_
+ {
+ OTL_Pointer mem_data;
+ OTL_AllocFunc mem_alloc;
+ OTL_ReallocFunc mem_realloc;
+ OTL_FreeFunc mem_free;
+
+ } OTL_MemoryRec, *OTL_Memory;
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** ENUMERATIONS *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+/* re-define OTL_MAKE_TAG to something different if you're not */
+/* using an ASCII-based character set (Vaxes anyone ?) */
+#ifndef OTL_MAKE_TAG
+#define OTL_MAKE_TAG(c1,c2,c3,c4) \
+ ( ( (OTL_UInt32)(c1) << 24 ) | \
+ (OTL_UInt32)(c2) << 16 ) | \
+ (OTL_UInt32)(c3) << 8 ) | \
+ (OTL_UInt32)(c4) )
+#endif
+
+ typedef enum OTL_ScriptTag_
+ {
+ OTL_SCRIPT_NONE = 0,
+
+#define OTL_SCRIPT_TAG(c1,c2,c3,c4,s,n) OTL_SCRIPT_TAG_ ## n = OTL_MAKE_TAG(c1,c2,c3,c4),
+#include "otltags.h"
+
+ OTL_SCRIPT_MAX
+
+ } OTL_ScriptTag;
+
+
+ typedef enum OTL_LangTag_
+ {
+ OTL_LANG_DEFAULT = 0,
+
+#define OTL_LANG_TAG(c1,c2,c3,c4,s,n) OTL_LANG_TAG_ ## n = OTL_MAKE_TAG(c1,c2,c3,c4),
+#include "otltags.h"
+
+ OTL_LANG_MAX
+
+ } OTL_LangTag;
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** MEMORY READS *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+#define OTL_PEEK_USHORT(p) ( ((OTL_UInt)((p)[0]) << 8) | \
+ ((OTL_UInt)((p)[1]) ) )
+
+#define OTL_PEEK_ULONG(p) ( ((OTL_UInt32)((p)[0]) << 24) | \
+ ((OTL_UInt32)((p)[1]) << 16) | \
+ ((OTL_UInt32)((p)[2]) << 8) | \
+ ((OTL_UInt32)((p)[3]) ) )
+
+#define OTL_PEEK_SHORT(p) ((OTL_Int16)OTL_PEEK_USHORT(p))
+
+#define OTL_PEEK_LONG(p) ((OTL_Int32)OTL_PEEK_ULONG(p))
+
+#define OTL_NEXT_USHORT(p) ( (p) += 2, OTL_PEEK_USHORT((p)-2) )
+#define OTL_NEXT_ULONG(p) ( (p) += 4, OTL_PEEK_ULONG((p)-4) )
+
+#define OTL_NEXT_SHORT(p) ((OTL_Int16)OTL_NEXT_USHORT(p))
+#define OTL_NEXT_LONG(p) ((OTL_Int32)OTL_NEXT_ULONG(p))
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** VALIDATION *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ typedef struct OTL_ValidatorRec_* OTL_Validator;
+
+ typedef struct OTL_ValidatorRec_
+ {
+ OTL_Bytes limit;
+ OTL_Bytes base;
+ OTL_Error error;
+ OTL_jmp_buf jump_buffer;
+
+ } OTL_ValidatorRec;
+
+ typedef void (*OTL_ValidateFunc)( OTL_Bytes table,
+ OTL_Valid valid );
+
+ OTL_API( void )
+ otl_validator_error( OTL_Validator validator,
+ OTL_Error error );
+
+#define OTL_INVALID(e) otl_validator_error( valid, e )
+
+#define OTL_INVALID_TOO_SHORT OTL_INVALID( OTL_Err_InvalidOffset )
+#define OTL_INVALID_DATA OTL_INVALID( OTL_Err_InvalidFormat )
+
+#define OTL_CHECK(_count) OTL_BEGIN_STMNT \
+ if ( p + (_count) > valid->limit ) \
+ OTL_INVALID_TOO_SHORT; \
+ OTL_END_STMNT
+
+ /* */
+
+OTL_END_HEADER
+
+#endif /* __OPENTYPE_LAYOUT_H__ */
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlbase.c b/nx-X11/extras/freetype2/src/otlayout/otlbase.c
new file mode 100644
index 000000000..614e13c1a
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlbase.c
@@ -0,0 +1,181 @@
+#include "otlbase.h"
+#include "otlcommn.h"
+
+ static void
+ otl_base_coord_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format;
+
+ OTL_CHECK( 4 );
+
+ format = OTL_NEXT_USHORT( p );
+ p += 2;
+
+ switch ( format )
+ {
+ case 1:
+ break;
+
+ case 2:
+ OTL_CHECK( 4 );
+ break;
+
+ case 3:
+ OTL_CHECK( 2 );
+ otl_device_table_validate( table + OTL_PEEK_USHORT( p ) );
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ static void
+ otl_base_tag_list_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK(2);
+
+ count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( count*4 );
+ }
+
+
+
+ static void
+ otl_base_values_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 4 );
+
+ p += 2; /* skip default index */
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( count*2 );
+
+ for ( ; count > 0; count-- )
+ otl_base_coord_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+ static void
+ otl_base_minmax_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt min_coord, max_coord, count;
+
+ OTL_CHECK(6);
+ min_coord = OTL_NEXT_USHORT( p );
+ max_coord = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ if ( min_coord )
+ otl_base_coord_validate( table + min_coord, valid );
+
+ if ( max_coord )
+ otl_base_coord_validate( table + max_coord, valid );
+
+ OTL_CHECK( count*8 );
+ for ( ; count > 0; count-- )
+ {
+ p += 4; /* ignore tag */
+ min_coord = OTL_NEXT_USHORT( p );
+ max_coord = OTL_NEXT_USHORT( p );
+
+ if ( min_coord )
+ otl_base_coord_validate( table + min_coord, valid );
+
+ if ( max_coord )
+ otl_base_coord_validate( table + max_coord, valid );
+ }
+ }
+
+
+ static void
+ otl_base_script_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt values, default_minmax;
+
+ OTL_CHECK(6);
+
+ values = OTL_NEXT_USHORT( p );
+ default_minmax = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ if ( values )
+ otl_base_values_validate( table + values, valid );
+
+ if ( default_minmax )
+ otl_base_minmax_validate( table + default_minmax, valid );
+
+ OTL_CHECK( count*6 );
+ for ( ; count > 0; count-- )
+ {
+ p += 4; /* ignore tag */
+ otl_base_minmax_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+ }
+
+
+ static void
+ otl_base_script_list_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK(2);
+
+ count = OTL_NEXT_USHORT( p );
+ OTL_CHECK(count*6);
+
+ for ( ; count > 0; count-- )
+ {
+ p += 4; /* ignore script tag */
+ otl_base_script_validate( table + OTL_NEXT_USHORT( p ) );
+ }
+ }
+
+ static void
+ otl_axis_table_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt tags;
+
+ OTL_CHECK(4);
+
+ tags = OTL_NEXT_USHORT( p );
+ if ( tags )
+ otl_base_tag_list_validate ( table + tags );
+
+ otl_base_script_list_validate( table + OTL_NEXT_USHORT( p ) );
+ }
+
+
+ OTL_LOCALDEF( void )
+ otl_base_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+
+ OTL_CHECK(6);
+
+ if ( OTL_NEXT_ULONG( p ) != 0x10000UL )
+ OTL_INVALID_DATA;
+
+ otl_axis_table_validate( table + OTL_NEXT_USHORT( p ) );
+ otl_axis_table_validate( table + OTL_NEXT_USHORT( p ) );
+ } \ No newline at end of file
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlbase.h b/nx-X11/extras/freetype2/src/otlayout/otlbase.h
new file mode 100644
index 000000000..563d3002d
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlbase.h
@@ -0,0 +1,14 @@
+#ifndef __OTL_BASE_H__
+#define __OTL_BASE_H__
+
+#include "otlayout.h"
+
+OTL_BEGIN_HEADER
+
+ OTL_LOCAL( void )
+ otl_base_validate( OTL_Bytes table,
+ OTL_Validator valid );
+
+OTL_END_HEADER
+
+#endif /* __OTL_BASE_H__ */
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlcommn.c b/nx-X11/extras/freetype2/src/otlayout/otlcommn.c
new file mode 100644
index 000000000..742ff5b36
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlcommn.c
@@ -0,0 +1,940 @@
+/***************************************************************************/
+/* */
+/* otlcommn.c */
+/* */
+/* OpenType layout support, common tables (body). */
+/* */
+/* Copyright 2002 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#include "otlayout.h"
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** COVERAGE TABLE *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ OTL_LOCALDEF( void )
+ otl_coverage_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p;
+ OTL_UInt format;
+
+
+ if ( table + 4 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ format = OTL_NEXT_USHORT( p );
+ switch ( format )
+ {
+ case 1:
+ {
+ OTL_UInt count = OTL_NEXT_USHORT( p );
+
+
+ if ( p + count * 2 >= valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ /* XXX: check glyph indices */
+ }
+ break;
+
+ case 2:
+ {
+ OTL_UInt n, num_ranges = OTL_NEXT_USHORT( p );
+ OTL_UInt start, end, start_cover, total = 0, last = 0;
+
+
+ if ( p + num_ranges * 6 >= valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ for ( n = 0; n < num_ranges; n++ )
+ {
+ start = OTL_NEXT_USHORT( p );
+ end = OTL_NEXT_USHORT( p );
+ start_cover = OTL_NEXT_USHORT( p );
+
+ if ( start > end || start_cover != total )
+ OTL_INVALID_DATA;
+
+ if ( n > 0 && start <= last )
+ OTL_INVALID_DATA;
+
+ total += end - start + 1;
+ last = end;
+ }
+ }
+ break;
+
+ default:
+ OTL_INVALID_FORMAT;
+ }
+ }
+
+
+ OTL_LOCALDEF( OTL_UInt )
+ otl_coverage_get_count( OTL_Bytes table )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format = OTL_NEXT_USHORT( p );
+ OTL_UInt count = OTL_NEXT_USHORT( p );
+ OTL_UInt result = 0;
+
+
+ switch ( format )
+ {
+ case 1:
+ return count;
+
+ case 2:
+ {
+ OTL_UInt start, end;
+
+
+ for ( ; count > 0; count-- )
+ {
+ start = OTL_NEXT_USHORT( p );
+ end = OTL_NEXT_USHORT( p );
+ p += 2; /* skip start_index */
+
+ result += end - start + 1;
+ }
+ }
+ break;
+
+ default:
+ ;
+ }
+
+ return result;
+ }
+
+
+ OTL_LOCALDEF( OTL_Int )
+ otl_coverage_get_index( OTL_Bytes table,
+ OTL_UInt glyph_index )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format = OTL_NEXT_USHORT( p );
+ OTL_UInt count = OTL_NEXT_USHORT( p );
+
+
+ switch ( format )
+ {
+ case 1:
+ {
+ OTL_UInt min = 0, max = count, mid, gindex;
+
+
+ table += 4;
+ while ( min < max )
+ {
+ mid = ( min + max ) >> 1;
+ p = table + 2 * mid;
+ gindex = OTL_PEEK_USHORT( p );
+
+ if ( glyph_index == gindex )
+ return (OTL_Int)mid;
+
+ if ( glyph_index < gindex )
+ max = mid;
+ else
+ min = mid + 1;
+ }
+ }
+ break;
+
+ case 2:
+ {
+ OTL_UInt min = 0, max = count, mid;
+ OTL_UInt start, end, delta, start_cover;
+
+
+ table += 4;
+ while ( min < max )
+ {
+ mid = ( min + max ) >> 1;
+ p = table + 6 * mid;
+ start = OTL_NEXT_USHORT( p );
+ end = OTL_NEXT_USHORT( p );
+
+ if ( glyph_index < start )
+ max = mid;
+ else if ( glyph_index > end )
+ min = mid + 1;
+ else
+ return (OTL_Int)( glyph_index + OTL_NEXT_USHORT( p ) - start );
+ }
+ }
+ break;
+
+ default:
+ ;
+ }
+
+ return -1;
+ }
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** CLASS DEFINITION TABLE *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ OTL_LOCALDEF( void )
+ otl_class_definition_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format;
+
+
+ if ( p + 4 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ format = OTL_NEXT_USHORT( p );
+ switch ( format )
+ {
+ case 1:
+ {
+ OTL_UInt count, start = OTL_NEXT_USHORT( p );
+
+
+ if ( p + 2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ count = OTL_NEXT_USHORT( p );
+
+ if ( p + count * 2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ /* XXX: check glyph indices */
+ }
+ break;
+
+ case 2:
+ {
+ OTL_UInt n, num_ranges = OTL_NEXT_USHORT( p );
+ OTL_UInt start, end, value, last = 0;
+
+
+ if ( p + num_ranges * 6 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ for ( n = 0; n < num_ranges; n++ )
+ {
+ start = OTL_NEXT_USHORT( p );
+ end = OTL_NEXT_USHORT( p );
+ value = OTL_NEXT_USHORT( p ); /* ignored */
+
+ if ( start > end || ( n > 0 && start <= last ) )
+ OTL_INVALID_DATA;
+
+ last = end;
+ }
+ }
+ break;
+
+ default:
+ OTL_INVALID_FORMAT;
+ }
+ }
+
+
+ OTL_LOCALDEF( OTL_UInt )
+ otl_class_definition_get_value( OTL_Bytes table,
+ OTL_UInt glyph_index )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format = OTL_NEXT_USHORT( p );
+
+
+ switch ( format )
+ {
+ case 1:
+ {
+ OTL_UInt start = OTL_NEXT_USHORT( p );
+ OTL_UInt count = OTL_NEXT_USHORT( p );
+ OTL_UInt idx = (OTL_UInt)( glyph_index - start );
+
+
+ if ( idx < count )
+ {
+ p += 2 * idx;
+ return OTL_PEEK_USHORT( p );
+ }
+ }
+ break;
+
+ case 2:
+ {
+ OTL_UInt count = OTL_NEXT_USHORT( p );
+ OTL_UInt min = 0, max = count, mid, gindex;
+
+
+ table += 4;
+ while ( min < max )
+ {
+ mid = ( min + max ) >> 1;
+ p = table + 6 * mid;
+ start = OTL_NEXT_USHORT( p );
+ end = OTL_NEXT_USHORT( p );
+
+ if ( glyph_index < start )
+ max = mid;
+ else if ( glyph_index > end )
+ min = mid + 1;
+ else
+ return OTL_PEEK_USHORT( p );
+ }
+ }
+ break;
+
+ default:
+ ;
+ }
+
+ return 0;
+ }
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** DEVICE TABLE *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ OTL_LOCALDEF( void )
+ otl_device_table_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt start, end, count, format, count;
+
+
+ if ( p + 8 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ start = OTL_NEXT_USHORT( p );
+ end = OTL_NEXT_USHORT( p );
+ format = OTL_NEXT_USHORT( p );
+
+ if ( format < 1 || format > 3 || end < start )
+ OTL_INVALID_DATA;
+
+ count = (OTL_UInt)( end - start + 1 );
+
+ if ( p + ( ( 1 << format ) * count ) / 8 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+ }
+
+
+ OTL_LOCALDEF( OTL_UInt )
+ otl_device_table_get_start( OTL_Bytes table )
+ {
+ OTL_Bytes p = table;
+
+
+ return OTL_PEEK_USHORT( p );
+ }
+
+
+ OTL_LOCALDEF( OTL_UInt )
+ otl_device_table_get_end( OTL_Bytes table )
+ {
+ OTL_Bytes p = table + 2;
+
+
+ return OTL_PEEK_USHORT( p );
+ }
+
+
+ OTL_LOCALDEF( OTL_Int )
+ otl_device_table_get_delta( OTL_Bytes table,
+ OTL_UInt size )
+ {
+ OTL_Bytes p = table;
+ OTL_Int result = 0;
+ OTL_UInt start, end, format, idx, value;
+
+
+ start = OTL_NEXT_USHORT( p );
+ end = OTL_NEXT_USHORT( p );
+ format = OTL_NEXT_USHORT( p );
+
+ if ( size >= start && size <= end )
+ {
+ /* we could do that with clever bit operations, but a switch is */
+ /* much simpler to understand and maintain */
+ /* */
+ switch ( format )
+ {
+ case 1:
+ idx = (OTL_UInt)( ( size - start ) * 2 );
+ p += idx / 16;
+ value = OTL_PEEK_USHORT( p );
+ shift = idx & 15;
+ result = (OTL_Short)( value << shift ) >> ( 14 - shift );
+
+ break;
+
+ case 2:
+ idx = (OTL_UInt)( ( size - start ) * 4 );
+ p += idx / 16;
+ value = OTL_PEEK_USHORT( p );
+ shift = idx & 15;
+ result = (OTL_Short)( value << shift ) >> ( 12 - shift );
+
+ break;
+
+ case 3:
+ idx = (OTL_UInt)( ( size - start ) * 8 );
+ p += idx / 16;
+ value = OTL_PEEK_USHORT( p );
+ shift = idx & 15;
+ result = (OTL_Short)( value << shift ) >> ( 8 - shift );
+
+ break;
+
+ default:
+ ;
+ }
+ }
+
+ return result;
+ }
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** LOOKUP LISTS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ OTL_LOCALDEF( void )
+ otl_lookup_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt num_tables;
+
+
+ if ( table + 6 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ p += 4;
+ num_tables = OTL_NEXT_USHORT( p );
+
+ if ( p + num_tables * 2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ for ( ; num_tables > 0; num_tables-- )
+ {
+ offset = OTL_NEXT_USHORT( p );
+
+ if ( table + offset >= valid->limit )
+ OTL_INVALID_OFFSET;
+ }
+
+ /* XXX: check sub-tables? */
+ }
+
+
+ OTL_LOCALDEF( OTL_UInt )
+ otl_lookup_get_count( OTL_Bytes table )
+ {
+ OTL_Bytes p = table + 4;
+
+
+ return OTL_PEEK_USHORT( p );
+ }
+
+
+ OTL_LOCALDEF( OTL_Bytes )
+ otl_lookup_get_table( OTL_Bytes table,
+ OTL_UInt idx )
+ {
+ OTL_Bytes p, result = NULL;
+ OTL_UInt count;
+
+
+ p = table + 4;
+ count = OTL_NEXT_USHORT( p );
+ if ( idx < count )
+ {
+ p += idx * 2;
+ result = table + OTL_PEEK_USHORT( p );
+ }
+
+ return result;
+ }
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** LOOKUP LISTS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ OTL_LOCALDEF( void )
+ otl_lookup_list_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table, q;
+ OTL_UInt num_lookups, offset;
+
+
+ if ( p + 2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ num_lookups = OTL_NEXT_USHORT( p );
+
+ if ( p + num_lookups * 2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ for ( ; num_lookups > 0; num_lookups-- )
+ {
+ offset = OTL_NEXT_USHORT( p );
+
+ otl_lookup_validate( table + offset, valid );
+ }
+ }
+
+
+ OTL_LOCALDEF( OTL_UInt )
+ otl_lookup_list_get_count( OTL_Bytes table )
+ {
+ OTL_Bytes p = table;
+
+
+ return OTL_PEEK_USHORT( p );
+ }
+
+
+ OTL_LOCALDEF( OTL_Bytes )
+ otl_lookup_list_get_lookup( OTL_Bytes table,
+ OTL_UInt idx )
+ {
+ OTL_Bytes p, result = 0;
+ OTL_UInt count;
+
+
+ p = table;
+ count = OTL_NEXT_USHORT( p );
+ if ( idx < count )
+ {
+ p += idx * 2;
+ result = table + OTL_PEEK_USHORT( p );
+ }
+
+ return result;
+ }
+
+
+ OTL_LOCALDEF( OTL_Bytes )
+ otl_lookup_list_get_table( OTL_Bytes table,
+ OTL_UInt lookup_index,
+ OTL_UInt table_index )
+ {
+ OTL_Bytes result = NULL;
+
+
+ result = otl_lookup_list_get_lookup( table, lookup_index );
+ if ( result )
+ result = otl_lookup_get_table( result, table_index );
+
+ return result;
+ }
+
+
+ OTL_LOCALDEF( void )
+ otl_lookup_list_foreach( OTL_Bytes table,
+ OTL_ForeachFunc func,
+ OTL_Pointer func_data )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count = OTL_NEXT_USHORT( p );
+
+
+ for ( ; count > 0; count-- )
+ func( table + OTL_NEXT_USHORT( p ), func_data );
+ }
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** FEATURES *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ OTL_LOCALDEF( void )
+ otl_feature_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt feat_params, num_lookups;
+
+
+ if ( p + 4 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ feat_params = OTL_NEXT_USHORT( p ); /* ignored */
+ num_lookups = OTL_NEXT_USHORT( p );
+
+ if ( p + num_lookups * 2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ /* XXX: check lookup indices */
+ }
+
+
+ OTL_LOCALDEF( OTL_UInt )
+ otl_feature_get_count( OTL_Bytes table )
+ {
+ OTL_Bytes p = table + 4;
+
+
+ return OTL_PEEK_USHORT( p );
+ }
+
+
+ OTL_LOCALDEF( OTL_UInt )
+ otl_feature_get_lookups( OTL_Bytes table,
+ OTL_UInt start,
+ OTL_UInt count,
+ OTL_UInt *lookups )
+ {
+ OTL_Bytes p;
+ OTL_UInt num_features, result = 0;
+
+
+ p = table + 4;
+ num_features = OTL_NEXT_USHORT( p );
+
+ p += start * 2;
+
+ for ( ; count > 0 && start < num_features; count--, start++ )
+ {
+ lookups[0] = OTL_NEXT_USHORT(p);
+ lookups++;
+ result++;
+ }
+
+ return result;
+ }
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** FEATURE LIST *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ OTL_LOCALDEF( void )
+ otl_feature_list_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt num_features, offset;
+
+
+ if ( table + 2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ num_features = OTL_NEXT_USHORT( p );
+
+ if ( p + num_features * 2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ for ( ; num_features > 0; num_features-- )
+ {
+ p += 4; /* skip tag */
+ offset = OTL_NEXT_USHORT( p );
+
+ otl_feature_table_validate( table + offset, valid );
+ }
+ }
+
+
+ OTL_LOCALDEF( OTL_UInt )
+ otl_feature_list_get_count( OTL_Bytes table )
+ {
+ OTL_Bytes p = table;
+
+
+ return OTL_PEEK_USHORT( p );
+ }
+
+
+ OTL_LOCALDEF( OTL_Bytes )
+ otl_feature_list_get_feature( OTL_Bytes table,
+ OTL_UInt idx )
+ {
+ OTL_Bytes p, result = NULL;
+ OTL_UInt count;
+
+
+ p = table;
+ count = OTL_NEXT_USHORT( p );
+
+ if ( idx < count )
+ {
+ p += idx * 2;
+ result = table + OTL_PEEK_USHORT( p );
+ }
+
+ return result;
+ }
+
+
+ OTL_LOCALDEF( void )
+ otl_feature_list_foreach( OTL_Bytes table,
+ OTL_ForeachFunc func,
+ OTL_Pointer func_data )
+ {
+ OTL_Bytes p;
+ OTL_UInt count;
+
+
+ p = table;
+ count = OTL_NEXT_USHORT( p );
+
+ for ( ; count > 0; count-- )
+ func( table + OTL_NEXT_USHORT( p ), func_data );
+ }
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** LANGUAGE SYSTEM *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ OTL_LOCALDEF( void )
+ otl_lang_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt lookup_order;
+ OTL_UInt req_feature;
+ OTL_UInt num_features;
+
+
+ if ( table + 6 >= valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ lookup_order = OTL_NEXT_USHORT( p );
+ req_feature = OTL_NEXT_USHORT( p );
+ num_features = OTL_NEXT_USHORT( p );
+
+ /* XXX: check req_feature if not 0xFFFFU */
+
+ if ( p + 2 * num_features >= valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ /* XXX: check features indices! */
+ }
+
+
+ OTL_LOCALDEF( OTL_UInt )
+ otl_lang_get_count( OTL_Bytes table )
+ {
+ OTL_Bytes p = table + 4;
+
+ return OTL_PEEK_USHORT( p );
+ }
+
+
+ OTL_LOCALDEF( OTL_UInt )
+ otl_lang_get_req_feature( OTL_Bytes table )
+ {
+ OTL_Bytes p = table + 2;
+
+
+ return OTL_PEEK_USHORT( p );
+ }
+
+
+ OTL_LOCALDEF( OTL_UInt )
+ otl_lang_get_features( OTL_Bytes table,
+ OTL_UInt start,
+ OTL_UInt count,
+ OTL_UInt *features )
+ {
+ OTL_Bytes p = table + 4;
+ OTL_UInt num_features = OTL_NEXT_USHORT( p );
+ OTL_UInt result = 0;
+
+
+ p += start * 2;
+
+ for ( ; count > 0 && start < num_features; start++, count-- )
+ {
+ features[0] = OTL_NEXT_USHORT( p );
+ features++;
+ result++;
+ }
+
+ return result;
+ }
+
+
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** SCRIPTS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ OTL_LOCALDEF( void )
+ otl_script_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_UInt default_lang;
+ OTL_Bytes p = table;
+
+
+ if ( table + 4 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ default_lang = OTL_NEXT_USHORT( p );
+ num_langs = OTL_NEXT_USHORT( p );
+
+ if ( default_lang != 0 )
+ {
+ if ( table + default_lang >= valid->limit )
+ OTL_INVALID_OFFSET;
+ }
+
+ if ( p + num_langs * 6 >= valid->limit )
+ OTL_INVALID_OFFSET;
+
+ for ( ; num_langs > 0; num_langs-- )
+ {
+ OTL_UInt offset;
+
+
+ p += 4; /* skip tag */
+ offset = OTL_NEXT_USHORT( p );
+
+ otl_lang_validate( table + offset, valid );
+ }
+ }
+
+
+ OTL_LOCALDEF( void )
+ otl_script_list_validate( OTL_Bytes list,
+ OTL_Validator valid )
+ {
+ OTL_UInt num_scripts;
+ OTL_Bytes p = list;
+
+
+ if ( list + 2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ num_scripts = OTL_NEXT_USHORT( p );
+
+ if ( p + num_scripts * 6 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ for ( ; num_scripts > 0; num_scripts-- )
+ {
+ OTL_UInt offset;
+
+
+ p += 4; /* skip tag */
+ offset = OTL_NEXT_USHORT( p );
+
+ otl_script_table_validate( list + offset, valid );
+ }
+ }
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** LOOKUP LISTS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ static void
+ otl_lookup_table_validate( OTL_Bytes table,
+ OTL_UInt type_count,
+ OTL_ValidateFunc* type_funcs,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt lookup_type, lookup_flag, count;
+ OTL_ValidateFunc validate;
+
+ OTL_CHECK( 6 );
+ lookup_type = OTL_NEXT_USHORT( p );
+ lookup_flag = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ if ( lookup_type == 0 || lookup_type >= type_count )
+ OTL_INVALID_DATA;
+
+ validate = type_funcs[ lookup_type - 1 ];
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+ OTL_LOCALDEF( void )
+ otl_lookup_list_validate( OTL_Bytes table,
+ OTL_UInt type_count,
+ OTL_ValidateFunc* type_funcs,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_lookup_table_validate( table + OTL_NEXT_USHORT( p ),
+ type_count, type_funcs, valid );
+ }
+
+/* END */
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlcommn.h b/nx-X11/extras/freetype2/src/otlayout/otlcommn.h
new file mode 100644
index 000000000..25914fb9f
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlcommn.h
@@ -0,0 +1,277 @@
+/***************************************************************************/
+/* */
+/* otlcommn.h */
+/* */
+/* OpenType layout support, common tables (specification). */
+/* */
+/* Copyright 2002 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef __OTLCOMMN_H__
+#define __OTLCOMMN_H__
+
+#include "otlayout.h"
+
+OTL_BEGIN_HEADER
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** COVERAGE TABLE *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* validate coverage table */
+ OTL_LOCALDEF( void )
+ otl_coverage_validate( OTL_Bytes base,
+ OTL_Validator valid );
+
+ /* return number of covered glyphs */
+ OTL_LOCALDEF( OTL_UInt )
+ otl_coverage_get_count( OTL_Bytes base );
+
+ /* Return the coverage index corresponding to a glyph glyph index. */
+ /* Return -1 if the glyph isn't covered. */
+ OTL_LOCALDEF( OTL_Int )
+ otl_coverage_get_index( OTL_Bytes base,
+ OTL_UInt glyph_index );
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** CLASS DEFINITION TABLE *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* validate class definition table */
+ OTL_LOCALDEF( void )
+ otl_class_definition_validate( OTL_Bytes table,
+ OTL_Validator valid );
+
+ /* return class value for a given glyph index */
+ OTL_LOCALDEF( OTL_UInt )
+ otl_class_definition_get_value( OTL_Bytes table,
+ OTL_UInt glyph_index );
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** DEVICE TABLE *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* validate a device table */
+ OTL_LOCALDEF( void )
+ otl_device_table_validate( OTL_Bytes table,
+ OTL_Validator valid );
+
+ /* return a device table's first size */
+ OTL_LOCALDEF( OTL_UInt )
+ otl_device_table_get_start( OTL_Bytes table );
+
+ /* return a device table's last size */
+ OTL_LOCALDEF( OTL_UInt )
+ otl_device_table_get_end( OTL_Bytes table );
+
+ /* return pixel adjustment for a given size */
+ OTL_LOCALDEF( OTL_Int )
+ otl_device_table_get_delta( OTL_Bytes table,
+ OTL_UInt size );
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** LOOKUPS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* validate lookup table */
+ OTL_LOCALDEF( void )
+ otl_lookup_validate( OTL_Bytes table,
+ OTL_Validator valid );
+
+ /* return number of sub-tables in a lookup */
+ OTL_LOCALDEF( OTL_UInt )
+ otl_lookup_get_count( OTL_Bytes table );
+
+
+ /* return lookup sub-table */
+ OTL_LOCALDEF( OTL_Bytes )
+ otl_lookup_get_table( OTL_Bytes table,
+ OTL_UInt idx );
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** LOOKUP LISTS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* validate lookup list */
+ OTL_LOCALDEF( void )
+ otl_lookup_list_validate( OTL_Bytes table,
+ OTL_Validator valid );
+
+ /* return number of lookups in list */
+ OTL_LOCALDEF( OTL_UInt )
+ otl_lookup_list_get_count( OTL_Bytes table );
+
+ /* return a given lookup from a list */
+ OTL_LOCALDEF( OTL_Bytes )
+ otl_lookup_list_get_lookup( OTL_Bytes table,
+ OTL_UInt idx );
+
+ /* return lookup sub-table from a list */
+ OTL_LOCALDEF( OTL_Bytes )
+ otl_lookup_list_get_table( OTL_Bytes table,
+ OTL_UInt lookup_index,
+ OTL_UInt table_index );
+
+ /* iterate over lookup list */
+ OTL_LOCALDEF( void )
+ otl_lookup_list_foreach( OTL_Bytes table,
+ OTL_ForeachFunc func,
+ OTL_Pointer func_data );
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** FEATURES *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* validate feature table */
+ OTL_LOCALDEF( void )
+ otl_feature_validate( OTL_Bytes table,
+ OTL_Validator valid );
+
+ /* return feature's lookup count */
+ OTL_LOCALDEF( OTL_UInt )
+ otl_feature_get_count( OTL_Bytes table );
+
+ /* get several lookups indices from a feature. returns the number of */
+ /* lookups grabbed */
+ OTL_LOCALDEF( OTL_UInt )
+ otl_feature_get_lookups( OTL_Bytes table,
+ OTL_UInt start,
+ OTL_UInt count,
+ OTL_UInt *lookups );
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** FEATURE LIST *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ /* validate a feature list */
+ OTL_LOCALDEF( void )
+ otl_feature_list_validate( OTL_Bytes table,
+ OTL_Validator valid );
+
+ /* return number of features in list */
+ OTL_LOCALDEF( OTL_UInt )
+ otl_feature_list_get_count( OTL_Bytes table );
+
+
+ /* return a given feature from a list */
+ OTL_LOCALDEF( OTL_Bytes )
+ otl_feature_list_get_feature( OTL_Bytes table,
+ OTL_UInt idx );
+
+ /* iterate over all features in a list */
+ OTL_LOCALDEF( void )
+ otl_feature_list_foreach( OTL_Bytes table,
+ OTL_ForeachFunc func,
+ OTL_Pointer func_data );
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** LANGUAGE SYSTEM *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ OTL_LOCAL( void )
+ otl_lang_validate( OTL_Bytes table,
+ OTL_Validator valid );
+
+
+ OTL_LOCAL( OTL_UInt )
+ otl_lang_get_req_feature( OTL_Bytes table );
+
+
+ OTL_LOCAL( OTL_UInt )
+ otl_lang_get_count( OTL_Bytes table );
+
+
+ OTL_LOCAL( OTL_UInt )
+ otl_lang_get_features( OTL_Bytes table,
+ OTL_UInt start,
+ OTL_UInt count,
+ OTL_UInt *features );
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** SCRIPTS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ OTL_LOCAL( void )
+ otl_script_list_validate( OTL_Bytes list,
+ OTL_Validator valid );
+
+ OTL_LOCAL( OTL_Bytes )
+ otl_script_list_get_script( OTL_Bytes table );
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /***** *****/
+ /***** LOOKUP LISTS *****/
+ /***** *****/
+ /*************************************************************************/
+ /*************************************************************************/
+
+ OTL_LOCAL( void )
+ otl_lookup_list_validate( OTL_Bytes list,
+ OTL_UInt type_count,
+ OTL_ValidateFunc* type_funcs,
+ OTL_Validator valid );
+
+ /* */
+
+OTL_END_HEADER
+
+#endif /* __OTLCOMMN_H__ */
+
+
+/* END */
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlconf.h b/nx-X11/extras/freetype2/src/otlayout/otlconf.h
new file mode 100644
index 000000000..3ef17a079
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlconf.h
@@ -0,0 +1,78 @@
+#ifndef __OT_LAYOUT_CONFIG_H__
+#define __OT_LAYOUT_CONFIG_H__
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** CONFIGURATION MACROS *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+#ifdef __cplusplus
+# define OTL_BEGIN_HEADER extern "C" {
+#else
+# define OTL_BEGIN_HEADER /* nothing */
+#endif
+
+#ifdef __cplusplus
+# define OTL_END_HEADER }
+#else
+# define OTL_END_HEADER /* nothing */
+#endif
+
+#ifndef OTL_API
+# ifdef __cplusplus
+# define OTL_API( x ) extern "C"
+# else
+# define OTL_API( x ) extern x
+# endif
+#endif
+
+#ifndef OTL_APIDEF
+# define OTL_APIDEF( x ) x
+#endif
+
+#ifndef OTL_LOCAL
+# define OTL_LOCAL( x ) extern x
+#endif
+
+#ifndef OTL_LOCALDEF
+# define OTL_LOCALDEF( x ) x
+#endif
+
+#define OTL_BEGIN_STMNT do {
+#define OTL_END_STMNT } while (0)
+#define OTL_DUMMY_STMNT OTL_BEGIN_STMNT OTL_END_STMNT
+
+#define OTL_UNUSED( x ) (x)=(x)
+#define OTL_UNUSED_CONST(x) (void)(x)
+
+
+#include <limits.h>
+#if UINT_MAX == 0xFFFFU
+# define OTL_SIZEOF_INT 2
+#elif UINT_MAX == 0xFFFFFFFFU
+# define OTL_SIZEOF_INT 4
+#elif UINT_MAX > 0xFFFFFFFFU && UINT_MAX == 0xFFFFFFFFFFFFFFFFU
+# define OTL_SIZEOF_INT 8
+#else
+# error "unsupported number of bytes in 'int' type!"
+#endif
+
+#if ULONG_MAX == 0xFFFFFFFFU
+# define OTL_SIZEOF_LONG 4
+#elif ULONG_MAX > 0xFFFFFFFFU && ULONG_MAX == 0xFFFFFFFFFFFFFFFFU
+# define OTL_SIZEOF_LONG 8
+#else
+# error "unsupported number of bytes in 'long' type!"
+#endif
+
+#include <setjmp.h>
+#define OTL_jmp_buf jmp_buf
+#define otl_setjmp setjmp
+#define otl_longjmp longjmp
+
+/* */
+
+#endif /* __OT_LAYOUT_CONFIG_H__ */
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlgdef.c b/nx-X11/extras/freetype2/src/otlayout/otlgdef.c
new file mode 100644
index 000000000..ff1c2a1e8
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlgdef.c
@@ -0,0 +1,175 @@
+#include "otlgdef.h"
+#include "otlcommn.h"
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** ATTACHMENTS LIST *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static void
+ otl_attach_point_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ if ( p + 2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ count = OTL_NEXT_USHORT( p );
+ if ( table + count*2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+ }
+
+
+ static void
+ otl_attach_list_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_Bytes coverage;
+ OTL_UInt count;
+
+ if ( p + 4 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ coverage = table + OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( coverage, valid );
+ if ( count != otl_coverage_get_count( coverage ) )
+ OTL_INVALID_DATA;
+
+ if ( p + count*2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ for ( ; count > 0; count-- )
+ otl_attach_point_validate( table + OTL_NEXT_USHORT( p ) );
+ }
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** LIGATURE CARETS *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static void
+ otl_caret_value_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+
+ if ( p + 4 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ format = OTL_NEXT_USHORT( p );
+ switch ( format )
+ {
+ case 1:
+ case 2:
+ break;
+
+ case 3:
+ {
+ OTL_Bytes device;
+
+ p += 2;
+ if ( p + 2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ otl_device_table_validate( table + OTL_PEEK_USHORT( p ) );
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ static void
+ otl_ligature_glyph_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ if ( p + 2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ count = OTL_NEXT_USHORT( p );
+
+ if ( p + count*2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ for ( ; count > 0; count-- )
+ otl_caret_value_validate( table + OTL_NEXT_USHORT( p ) );
+ }
+
+
+ static void
+ otl_ligature_caret_list_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_Bytes coverage;
+ OTL_UInt count;
+
+ if ( p + 4 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ coverage = table + OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( coverage, valid );
+ if ( count != otl_coverage_get_count( coverage ) )
+ OTL_INVALID_DATA;
+
+ if ( p + count*2 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ for ( ; count > 0; count-- )
+ otl_ligature_glyph_validate( table + OTL_NEXT_USHORT( p ) );
+ }
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GDEF TABLE *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ OTL_APIDEF( void )
+ otl_gdef_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+
+ if ( p + 12 > valid->limit )
+ OTL_INVALID_TOO_SHORT;
+
+ /* check format */
+ if ( OTL_NEXT_ULONG( p ) != 0x00010000UL )
+ OTL_INVALID_FORMAT;
+
+ /* validate class definition table */
+ otl_class_definition_validate( table + OTL_NEXT_USHORT( p ) );
+
+ /* validate attachment point list */
+ otl_attach_list_validate( table + OTL_NEXT_USHORT( p ) );
+
+ /* validate ligature caret list */
+ otl_ligature_caret_list_validate( table + OTL_NEXT_USHORT( p ) );
+
+ /* validate mark attach class */
+ otl_class_definition_validate( table + OTL_NEXT_USHORT( p ) );
+ }
+
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlgdef.h b/nx-X11/extras/freetype2/src/otlayout/otlgdef.h
new file mode 100644
index 000000000..5046cc436
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlgdef.h
@@ -0,0 +1,14 @@
+#ifndef __OTL_GDEF_H__
+#define __OTL_GDEF_H__
+
+#include "otltable.h"
+
+OTL_BEGIN_HEADER
+
+ OTL_API( void )
+ otl_gdef_validate( OTL_Bytes table,
+ OTL_Valid valid );
+
+OTL_END_HEADER
+
+#endif /* __OTL_GDEF_H__ */
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlgpos.c b/nx-X11/extras/freetype2/src/otlayout/otlgpos.c
new file mode 100644
index 000000000..01942d7f0
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlgpos.c
@@ -0,0 +1,980 @@
+#include "otlgpos.h"
+#include "otlcommn.h"
+
+ /* forward declaration */
+ static OTL_ValidateFunc otl_gpos_validate_funcs[];
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** VALUE RECORDS *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static OTL_UInt
+ otl_value_length( OTL_UInt format )
+ {
+ FT_UInt count;
+
+ count = (( format & 0xAA ) >> 1) + ( format & 0x55 );
+ count = (( count & 0xCC ) >> 2) + ( count & 0x33 );
+ count = (( count & 0xF0 ) >> 4) + ( count & 0x0F );
+
+ return count;
+ }
+
+
+ static void
+ otl_value_validate( OTL_Bytes table,
+ OTL_Bytes pos_table,
+ OTL_UInt format,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count, device;
+
+ if ( format >= 0x100U )
+ OTL_INVALID_DATA;
+
+ for ( count = 4; count > 0; count-- )
+ {
+ if ( format & 1 )
+ {
+ OTL_CHECK( 2 );
+ p += 2;
+ }
+
+ format >>= 1;
+ }
+
+ for ( count = 4; count > 0; count-- )
+ {
+ if ( format & 1 )
+ {
+ OTL_CHECK( 2 );
+ device = OTL_NEXT_USHORT( p );
+ if ( device )
+ otl_device_table_validate( pos_table + device, valid );
+ }
+ format >>= 1;
+ }
+ }
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** ANCHORS *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static void
+ otl_anchor_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format;
+
+ OTL_CHECK( 6 );
+ format = OTL_NEXT_USHORT( p );
+ p += 4;
+
+ switch ( format )
+ {
+ case 1:
+ break;
+
+ case 2:
+ OTL_CHECK( 2 ); /* anchor point */
+ break;
+
+ case 3:
+ {
+ OTL_UInt x_device, y_device;
+
+ OTL_CHECK( 4 );
+ x_device = OTL_NEXT_USHORT( p );
+ y_device = OTL_NEXT_USHORT( p );
+
+ if ( x_device )
+ otl_device_table_validate( table + x_device, valid );
+
+ if ( y_device )
+ otl_device_table_validate( table + y_device, valid );
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** MARK ARRAY *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static void
+ otl_mark_array_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+
+ count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( count * 4 );
+ for ( ; count > 0; count-- )
+ {
+ p += 2; /* ignore class index */
+ otl_anchor_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+ }
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GPOS LOOKUP TYPE 1 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static void
+ otl_gpos_lookup1_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch ( format )
+ {
+ case 1:
+ {
+ FT_UInt coverage, value_format;
+
+ OTL_CHECK( 4 );
+ coverage = OTL_NEXT_USHORT( p );
+ value_format = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+ otl_value_validate( p, table, value_format, valid );
+ }
+ break;
+
+ case 2:
+ {
+ FT_UInt coverage, value_format, count, len;
+
+ OTL_CHECK( 6 );
+ coverage = OTL_NEXT_USHORT( p );
+ value_format = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+ len = otl_value_length( value_format );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ OTL_CHECK( count * len );
+ for ( ; count > 0; count-- )
+ {
+ otl_value_validate( p, table, value_format, valid );
+ p += len;
+ }
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GPOS LOOKUP TYPE 2 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static otl_gpos_pairset_validate( OTL_Bytes table,
+ OTL_Bytes pos_table,
+ OTL_UInt format1,
+ OTL_UInt format2,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt len1, len2, count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+ len1 = otl_value_length( format1 );
+ len2 = otl_value_length( format2 );
+
+ OTL_CHECK( count * (len1+len2+2) );
+ for ( ; count > 0; count-- )
+ {
+ p += 2; /* ignore glyph id */
+ otl_value_validate( p, pos_table, format1, valid );
+ p += len1;
+
+ otl_value_validate( p, pos_table, format2, valid );
+ p += len2;
+ }
+ }
+
+ static void
+ otl_gpos_lookup2_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch (format)
+ {
+ case 1:
+ {
+ OTL_UInt coverage, value1, value2, count;
+
+ OTL_CHECK( 8 );
+ coverage = OTL_NEXT_USHORT( p );
+ value1 = OTL_NEXT_USHORT( p );
+ value2 = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ OTL_CHECK( count*2 );
+ for ( ; count > 0; count-- )
+ {
+ otl_gpos_pairset_validate( table + OTL_NEXT_USHORT( p ),
+ table, value1, value2, valid );
+ }
+ }
+ break;
+
+ case 2:
+ {
+ OTL_UInt coverage, value1, value2, class1, class2, count1, count2;
+ OTL_UInt len1, len2;
+
+ OTL_CHECK( 14 );
+ coverage = OTL_NEXT_USHORT( p );
+ value1 = OTL_NEXT_USHORT( p );
+ value2 = OTL_NEXT_USHORT( p );
+ class1 = OTL_NEXT_USHORT( p );
+ class2 = OTL_NEXT_USHORT( p );
+ count1 = OTL_NEXT_USHORT( p );
+ count2 = OTL_NEXT_USHORT( p );
+
+ len1 = otl_value_length( value1 );
+ len2 = otl_value_length( value2 );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ OTL_CHECK( count1*count2*(len1+len2) );
+ for ( ; count1 > 0; count1-- )
+ {
+ for ( ; count2 > 0; count2-- )
+ {
+ otl_value_validate( p, table, value1, valid );
+ p += len1;
+
+ otl_value_validate( p, table, value2, valid );
+ p += len2;
+ }
+ }
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GPOS LOOKUP TYPE 3 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static void
+ otl_gpos_lookup3_validate( OTL_Bytes table,
+ OTL_Valid valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch (format)
+ {
+ case 1:
+ {
+ OTL_UInt coverage, count, anchor1, anchor2;
+
+ OTL_CHECK( 4 );
+ coverage = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ OTL_CHECK( count*4 );
+ for ( ; count > 0; count-- )
+ {
+ anchor1 = OTL_NEXT_USHORT( p );
+ anchor2 = OTL_NEXT_USHORT( p );
+
+ if ( anchor1 )
+ otl_anchor_validate( table + anchor1, valid );
+
+ if ( anchor2 )
+ otl_anchor_validate( table + anchor2, valid );
+ }
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GPOS LOOKUP TYPE 4 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static void
+ otl_base_array_validate( OTL_Bytes table,
+ OTL_UInt class_count,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count, count2;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( count*class_count*2 );
+ for ( ; count > 0; count-- )
+ for ( count2 = class_count; count2 > 0; count2-- )
+ otl_anchor_validate( table + OTL_NEXT_USHORT( p ) );
+ }
+
+
+ static void
+ otl_gpos_lookup4_validate( OTL_Bytes table,
+ OTL_Valid valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch (format)
+ {
+ case 1:
+ {
+ OTL_UInt mark_coverage, base_coverage, class_count;
+ OTL_UInt mark_array, base_array;
+
+ OTL_CHECK( 10 );
+ mark_coverage = OTL_NEXT_USHORT( p );
+ base_coverage = OTL_NEXT_USHORT( p );
+ class_count = OTL_NEXT_USHORT( p );
+ mark_array = OTL_NEXT_USHORT( p );
+ base_array = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + mark_coverage, valid );
+ otl_coverage_validate( table + base_coverage, valid );
+
+ otl_mark_array_validate( table + mark_array, valid );
+ otl_base_array_validate( table, class_count, valid );
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GPOS LOOKUP TYPE 5 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static void
+ otl_liga_attach_validate( OTL_Bytes table,
+ OTL_UInt class_count,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count, count2;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( count*class_count*2 );
+ for ( ; count > 0; count-- )
+ for ( count2 = class_count; class_count > 0; class_count-- )
+ otl_anchor_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+ static void
+ otl_liga_array_validate( OTL_Bytes table,
+ OTL_UInt class_count,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count, count2;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( count*2 );
+ for ( ; count > 0; count-- )
+ otl_liga_attach_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+ static void
+ otl_gpos_lookup5_validate( OTL_Bytes table,
+ OTL_Valid valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch (format)
+ {
+ case 1:
+ {
+ OTL_UInt mark_coverage, lig_coverage, class_count;
+ OTL_UInt mar_array, lig_array;
+
+ OTL_CHECK( 10 );
+ mark_coverage = OTL_NEXT_USHORT( p );
+ liga_coverage = OTL_NEXT_USHORT( p );
+ class_count = OTL_NEXT_USHORT( p );
+ mark_array = OTL_NEXT_USHORT( p );
+ liga_array = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + mark_coverage, valid );
+ otl_coverage_validate( table + liga_coverage, valid );
+
+ otl_mark_array_validate( table + mark_array, valid );
+ otl_liga_array_validate( table + liga_array, class_count, valid );
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GPOS LOOKUP TYPE 6 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+
+ static void
+ otl_mark2_array_validate( OTL_Bytes table,
+ OTL_UInt class_count,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count, count2;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( count*class_count*2 );
+ for ( ; count > 0; count-- )
+ for ( count2 = class_count; class_count > 0; class_count-- )
+ otl_anchor_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+ static void
+ otl_gpos_lookup6_validate( OTL_Bytes table,
+ OTL_Valid valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch (format)
+ {
+ case 1:
+ {
+ OTL_UInt coverage1, coverage2, class_count, array1, array2;
+
+ OTL_CHECK( 10 );
+ coverage1 = OTL_NEXT_USHORT( p );
+ coverage2 = OTL_NEXT_USHORT( p );
+ class_count = OTL_NEXT_USHORT( p );
+ array1 = OTL_NEXT_USHORT( p );
+ array2 = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage1, valid );
+ otl_coverage_validate( table + coverage2, valid );
+
+ otl_mark_array_validate( table + array1, valid );
+ otl_mark2_array_validate( table + array2, valid );
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GPOS LOOKUP TYPE 7 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static void
+ otl_pos_rule_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt glyph_count, pos_count;
+
+ OTL_CHECK( 4 );
+ glyph_count = OTL_NEXT_USHORT( p );
+ pos_count = OTL_NEXT_USHORT( p );
+
+ if ( glyph_count == 0 )
+ OTL_INVALID_DATA;
+
+ OTL_CHECK( (glyph_count-1)*2 + pos_count*4 );
+
+ /* XXX: check glyph indices and pos lookups */
+ }
+
+
+ static void
+ otl_pos_rule_set_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( count*2 );
+ for ( ; count > 0; count-- )
+ otl_pos_rule_validate( table + OTL_NEXT_USHORT(p), valid );
+ }
+
+
+
+ static void
+ otl_pos_class_rule_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt glyph_count, pos_count;
+
+ OTL_CHECK( 4 );
+ glyph_count = OTL_NEXT_USHORT( p );
+ pos_count = OTL_NEXT_USHORT( p );
+
+ if ( glyph_count == 0 )
+ OTL_INVALID_DATA;
+
+ OTL_CHECK( (glyph_count-1)*2 + pos_count*4 );
+
+ /* XXX: check glyph indices and pos lookups */
+ }
+
+
+ static void
+ otl_pos_class_set_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( count*2 );
+ for ( ; count > 0; count-- )
+ otl_pos_rule_validate( table + OTL_NEXT_USHORT(p), valid );
+ }
+
+
+ static void
+ otl_gpos_lookup7_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch (format)
+ {
+ case 1:
+ {
+ OTL_UInt coverage, count;
+
+ OTL_CHECK( 4 );
+ coverage = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ OTL_CHECK( count*2 );
+ for ( ; count > 0; count-- )
+ otl_pos_rule_set_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+ break;
+
+ case 2:
+ {
+ OTL_UInt coverage, class_def, count;
+
+ OTL_CHECK( 6 );
+ coverage = OTL_NEXT_USHORT( p );
+ class_def = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate ( table + coverage, valid );
+ otl_class_definition_validate( table + class_def, valid );
+
+ OTL_CHECK( count*2 );
+ for ( ; count > 0; count-- )
+ otl_
+ }
+ break;
+
+ case 3:
+ {
+ OTL_UInt glyph_count, pos_count;
+
+ OTL_CHECK( 4 );
+ glyph_count = OTL_NEXT_USHORT( p );
+ pos_count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( glyph_count*2 + pos_count*4 );
+ for ( ; glyph_count > 0; glyph_count )
+ otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid );
+
+ /* XXX: check pos lookups */
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GPOS LOOKUP TYPE 8 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static void
+ otl_chain_pos_rule_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt back_count, input_count, ahead_count, pos_count;
+
+ OTL_CHECK( 2 );
+ back_count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( back_count*2 + 2 );
+ p += back_count*2;
+
+ input_count = OTL_NEXT_USHORT( p );
+ if ( input_count == 0 )
+ OTL_INVALID_DATA;
+
+ OTL_CHECK( input_count*2 );
+ p += (input_count-1)*2;
+
+ ahead_count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( ahead_count*2 + 2 );
+ p += ahead_count*2;
+
+ pos_count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( pos_count*4 );
+ }
+
+
+ static void
+ otl_chain_pos_rule_set_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_chain_pos_rule_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+
+ static void
+ otl_chain_pos_class_rule_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt back_count, input_count, ahead_count, pos_count;
+
+ OTL_CHECK( 2 );
+ back_count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( back_count*2 + 2 );
+ p += back_count*2;
+
+ input_count = OTL_NEXT_USHORT( p );
+ if ( input_count == 0 )
+ OTL_INVALID_DATA;
+
+ OTL_CHECK( input_count*2 );
+ p += (input_count-1)*2;
+
+ ahead_count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( ahead_count*2 + 2 );
+ p += ahead_count*2;
+
+ pos_count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( pos_count*4 );
+ }
+
+
+ static void
+ otl_chain_pos_class_set_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_chain_pos_class_rule_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+ static void
+ otl_gpos_lookup8_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch (format)
+ {
+ case 1:
+ {
+ OTL_UInt coverage, count;
+
+ OTL_CHECK( 4 );
+ coverage = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ OTL_CHECK( count*2 );
+ for ( ; count > 0; count-- )
+ otl_chain_pos_rule_set_validate( table + OTL_NEXT_USHORT( p ),
+ valid );
+ }
+ break;
+
+ case 2:
+ {
+ OTL_UInt coverage, back_class, input_class, ahead_class, count;
+
+ OTL_CHECK( 10 );
+ coverage = OTL_NEXT_USHORT( p );
+ back_class = OTL_NEXT_USHORT( p );
+ input_class = OTL_NEXT_USHORT( p );
+ ahead_class = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ otl_class_definition_validate( table + back_class, valid );
+ otl_class_definition_validate( table + input_class, valid );
+ otl_class_definition_validate( table + ahead_class, valid );
+
+ OTL_CHECK( count*2 );
+ for ( ; count > 0; count-- )
+ otl_chain_pos_class_set_validate( table + OTL_NEXT_USHORT( p ),
+ valid );
+ }
+ break;
+
+ case 3:
+ {
+ OTL_UInt back_count, input_count, ahead_count, pos_count, count;
+
+ OTL_CHECK( 2 );
+ back_count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*back_count+2 );
+ for ( count = back_count; count > 0; count-- )
+ otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid );
+
+ input_count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*input_count+2 );
+ for ( count = input_count; count > 0; count-- )
+ otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid );
+
+ ahead_count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*ahead_count+2 );
+ for ( count = ahead_count; count > 0; count-- )
+ otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid );
+
+ pos_count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( pos_count*4 );
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GPOS LOOKUP TYPE 9 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static void
+ otl_gpos_lookup9_validate( OTL_Bytes table,
+ OTL_Valid valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch (format)
+ {
+ case 1:
+ {
+ OTL_UInt lookup_type, lookup_offset;
+ OTL_ValidateFunc validate;
+
+ OTL_CHECK( 6 );
+ lookup_type = OTL_NEXT_USHORT( p );
+ lookup_offset = OTL_NEXT_ULONG( p );
+
+ if ( lookup_type == 0 || lookup_type >= 9 )
+ OTL_INVALID_DATA;
+
+ validate = otl_gpos_validate_funcs[ lookup_type-1 ];
+ validate( table + lookup_offset, valid );
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+ static OTL_ValidateFunc otl_gpos_validate_funcs[ 9 ] =
+ {
+ otl_gpos_lookup1_validate,
+ otl_gpos_lookup2_validate,
+ otl_gpos_lookup3_validate,
+ otl_gpos_lookup4_validate,
+ otl_gpos_lookup5_validate,
+ otl_gpos_lookup6_validate,
+ otl_gpos_lookup7_validate,
+ otl_gpos_lookup8_validate,
+ otl_gpos_lookup9_validate,
+ };
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GPOS TABLE *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+
+ OTL_LOCALDEF( void )
+ otl_gpos_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt scripts, features, lookups;
+
+ OTL_CHECK( 10 );
+
+ if ( OTL_NEXT_USHORT( p ) != 0x10000UL )
+ OTL_INVALID_DATA;
+
+ scripts = OTL_NEXT_USHORT( p );
+ features = OTL_NEXT_USHORT( p );
+ lookups = OTL_NEXT_USHORT( p );
+
+ otl_script_list_validate ( table + scripts, valid );
+ otl_feature_list_validate( table + features, valid );
+
+ otl_lookup_list_validate( table + lookups, 9, otl_gpos_validate_funcs,
+ valid );
+ }
+ \ No newline at end of file
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlgpos.h b/nx-X11/extras/freetype2/src/otlayout/otlgpos.h
new file mode 100644
index 000000000..1d10cab49
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlgpos.h
@@ -0,0 +1,14 @@
+#ifndef __OTL_GPOS_H__
+#define __OTL_GPOS_H__
+
+#include "otlayout.h"
+
+OTL_BEGIN_HEADER
+
+ OTL_LOCAL( void )
+ otl_gpos_validate( OTL_Bytes table,
+ OTL_Validator valid );
+
+OTL_END_HEADER
+
+#endif /* __OTL_GPOS_H__ */
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlgsub.c b/nx-X11/extras/freetype2/src/otlayout/otlgsub.c
new file mode 100644
index 000000000..13a8eae98
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlgsub.c
@@ -0,0 +1,867 @@
+#include "otlgsub.h"
+#include "otlcommn.h"
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GSUB LOOKUP TYPE 1 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ /*
+ * 1: Single Substitution - Table format(s)
+ *
+ * This table is used to substiture individual glyph indices
+ * with another one. There are only two sub-formats:
+ *
+ * Name Offset Size Description
+ * ------------------------------------------
+ * format 0 2 sub-table format (1)
+ * offset 2 2 offset to coverage table
+ * delta 4 2 16-bit delta to apply on all
+ * covered glyph indices
+ *
+ * Name Offset Size Description
+ * ------------------------------------------
+ * format 0 2 sub-table format (2)
+ * offset 2 2 offset to coverage table
+ * count 4 2 coverage table count
+ * substs[] 6 2*count substituted glyph indices,
+ *
+ */
+
+ static void
+ otl_gsub_lookup1_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch ( format )
+ {
+ case 1:
+ {
+ OTL_UInt coverage;
+
+ OTL_CHECK( 4 );
+ coverage = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+ }
+ break;
+
+ case 2:
+ {
+ OTL_UInt coverage, count;
+
+ OTL_CHECK( 4 );
+ coverage = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ OTL_CHECK( 2*count );
+
+ /* NB: we don't check that there are at most 'count' */
+ /* elements in the coverage table. This is delayed */
+ /* to the lookup function... */
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ static OTL_Bool
+ otl_gsub_lookup1_apply( OTL_Bytes table,
+ OTL_Parser parser )
+ {
+ OTL_Bytes p = table;
+ OTL_Bytes coverage;
+ OTL_UInt format, gindex, property;
+ OTL_Int index;
+ OTL_Bool subst = 0;
+
+ if ( parser->context_len != 0xFFFFU && parser->context_len < 1 )
+ goto Exit;
+
+ gindex = otl_parser_get_gindex( parser );
+
+ if ( !otl_parser_check_property( parser, gindex, &property ) )
+ goto Exit;
+
+ format = OTL_NEXT_USHORT(p);
+ coverage = table + OTL_NEXT_USHORT(p);
+ index = otl_coverage_lookup( coverage, gindex );
+
+ if ( index >= 0 )
+ {
+ switch ( format )
+ {
+ case 1:
+ {
+ OTL_Int delta = OTL_NEXT_SHORT(p);
+
+ gindex = ( gindex + delta ) & 0xFFFFU;
+ otl_parser_replace_1( parser, gindex );
+ subst = 1;
+ }
+ break;
+
+ case 2:
+ {
+ OTL_UInt count = OTL_NEXT_USHORT(p);
+
+ if ( (OTL_UInt) index < count )
+ {
+ p += index*2;
+ otl_parser_replace_1( parser, OTL_PEEK_USHORT(p) );
+ subst = 1;
+ }
+ }
+ break;
+
+ default:
+ ;
+ }
+ }
+ Exit:
+ return subst;
+ }
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GSUB LOOKUP TYPE 2 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ /*
+ * 2: Multiple Substitution - Table format(s)
+ *
+ * Replaces a single glyph with one or more glyphs.
+ *
+ * Name Offset Size Description
+ * -----------------------------------------------------------
+ * format 0 2 sub-table format (1)
+ * offset 2 2 offset to coverage table
+ * count 4 2 coverage table count
+ * sequencess[] 6 2*count offsets to sequence items
+ *
+ * each sequence item has the following format:
+ *
+ * Name Offset Size Description
+ * -----------------------------------------------------------
+ * count 0 2 number of replacement glyphs
+ * gindices[] 2 2*count string of glyph indices
+ */
+
+ static void
+ otl_seq_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ /* XXX: according to the spec, 'count' should be > 0 */
+ /* we can deal with these cases pretty well however */
+
+ OTL_CHECK( 2*count );
+ /* check glyph indices */
+ }
+
+
+ static void
+ otl_gsub_lookup2_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format, coverage;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch ( format )
+ {
+ case 1:
+ {
+ OTL_UInt coverage, seq_count;
+
+ OTL_CHECK( 4 );
+ coverage = OTL_NEXT_USHORT( p );
+ seq_count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ OTL_CHECK( seq_count*2 );
+ for ( ; seq_count > 0; seq_count-- )
+ otl_seq_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ static OTL_Bool
+ otl_gsub_lookup2_apply( OTL_Bytes table,
+ OTL_Parser parser )
+ {
+ OTL_Bytes p = table;
+ OTL_Bytes coverage, sequence;
+ OTL_UInt format, gindex, index, property;
+ OTL_Int index;
+ OTL_Bool subst = 0;
+
+ if ( context_len != 0xFFFFU && context_len < 1 )
+ goto Exit;
+
+ gindex = otl_parser_get_gindex( parser );
+
+ if ( !otl_parser_check_property( parser, gindex, &property ) )
+ goto Exit;
+
+ p += 2; /* skip format */
+ coverage = table + OTL_NEXT_USHORT(p);
+ seq_count = OTL_NEXT_USHORT(p);
+ index = otl_coverage_lookup( coverage, gindex );
+
+ if ( (OTL_UInt) index >= seq_count )
+ goto Exit;
+
+ p += index*2;
+ sequence = table + OTL_PEEK_USHORT(p);
+ p = sequence;
+ count = OTL_NEXT_USHORT(p);
+
+ otl_parser_replace_n( parser, count, p );
+ subst = 1;
+
+ Exit:
+ return subst;
+ }
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GSUB LOOKUP TYPE 3 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ /*
+ * 3: Alternate Substitution - Table format(s)
+ *
+ * Replaces a single glyph by another one taken liberally
+ * in a list of alternatives
+ *
+ * Name Offset Size Description
+ * -----------------------------------------------------------
+ * format 0 2 sub-table format (1)
+ * offset 2 2 offset to coverage table
+ * count 4 2 coverage table count
+ * alternates[] 6 2*count offsets to alternate items
+ *
+ * each alternate item has the following format:
+ *
+ * Name Offset Size Description
+ * -----------------------------------------------------------
+ * count 0 2 number of replacement glyphs
+ * gindices[] 2 2*count string of glyph indices, each one
+ * is a valid alternative
+ */
+
+ static void
+ otl_alternate_set_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*count );
+ /* XXX: check glyph indices */
+ }
+
+
+ static void
+ otl_gsub_lookup3_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format, coverage;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch ( format )
+ {
+ case 1:
+ {
+ OTL_UInt coverage, count;
+
+ OTL_CHECK( 4 );
+ coverage = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_alternate_set_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ static OTL_Bool
+ otl_gsub_lookup3_apply( OTL_Bytes table,
+ OTL_Parser parser )
+ {
+ OTL_Bytes p = table;
+ OTL_Bytes coverage, alternates;
+ OTL_UInt format, gindex, index, property;
+ OTL_Int index;
+ OTL_Bool subst = 0;
+
+ OTL_GSUB_Alternate alternate = parser->alternate;
+
+ if ( context_len != 0xFFFFU && context_len < 1 )
+ goto Exit;
+
+ if ( alternate == NULL )
+ goto Exit;
+
+ gindex = otl_parser_get_gindex( parser );
+
+ if ( !otl_parser_check_property( parser, gindex, &property ) )
+ goto Exit;
+
+ p += 2; /* skip format */
+ coverage = table + OTL_NEXT_USHORT(p);
+ seq_count = OTL_NEXT_USHORT(p);
+ index = otl_coverage_lookup( coverage, gindex );
+
+ if ( (OTL_UInt) index >= seq_count )
+ goto Exit;
+
+ p += index*2;
+ alternates = table + OTL_PEEK_USHORT(p);
+ p = alternates;
+ count = OTL_NEXT_USHORT(p);
+
+ gindex = alternate->handler_func(
+ gindex, count, p, alternate->handler_data );
+
+ otl_parser_replace_1( parser, gindex );
+ subst = 1;
+
+ Exit:
+ return subst;
+ }
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GSUB LOOKUP TYPE 4 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static void
+ otl_ligature_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_UInt glyph_id, count;
+
+ OTL_CHECK( 4 );
+ glyph_id = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ if ( count == 0 )
+ OTL_INVALID_DATA;
+
+ OTL_CHECK( 2*(count-1) );
+ /* XXX: check glyph indices */
+ }
+
+
+ static void
+ otl_ligature_set_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_ligature_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+ static void
+ otl_gsub_lookup4_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format, coverage;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch ( format )
+ {
+ case 1:
+ {
+ OTL_UInt coverage, count;
+
+ OTL_CHECK( 4 );
+ coverage = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_ligature_set_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GSUB LOOKUP TYPE 5 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+
+ static void
+ otl_sub_rule_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt glyph_count, subst_count;
+
+ OTL_CHECK( 4 );
+ glyph_count = OTL_NEXT_USHORT( p );
+ subst_count = OTL_NEXT_USHORT( p );
+
+ if ( glyph_count == 0 )
+ OTL_INVALID_DATA;
+
+ OTL_CHECK( (glyph_count-1)*2 + substcount*4 );
+
+ /* XXX: check glyph indices and subst lookups */
+ }
+
+
+ static void
+ otl_sub_rule_set_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_sub_rule_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+ static void
+ otl_sub_class_rule_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_UInt glyph_count, subst_count;
+
+ OTL_CHECK( 4 );
+ glyph_count = OTL_NEXT_USHORT( p );
+ subst_count = OTL_NEXT_USHORT( p );
+
+ if ( glyph_count == 0 )
+ OTL_INVALID_DATA;
+
+ OTL_CHECK( (glyph_count-1)*2 + substcount*4 );
+
+ /* XXX: check glyph indices and subst lookups */
+ }
+
+
+ static void
+ otl_sub_class_rule_set_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_sub_class_rule_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+ static void
+ otl_gsub_lookup5_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format, coverage;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch ( format )
+ {
+ case 1:
+ {
+ OTL_UInt coverage, count;
+
+ OTL_CHECK( 4 );
+ coverage = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_sub_rule_set_validate( table + coverage, valid );
+ }
+ break;
+
+ case 2:
+ {
+ OTL_UInt coverage, class_def, count;
+
+ OTL_CHECK( 6 );
+ coverage = OTL_NEXT_USHORT( p );
+ class_def = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate ( table + coverage, valid );
+ otl_class_definition_validate( table + class_def, valid );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_sub_class_rule_set_validate( table + coveragen valid );
+ }
+ break;
+
+ case 3:
+ {
+ OTL_UInt glyph_count, subst_count, count;
+
+ OTL_CHECK( 4 );
+ glyph_count = OTL_NEXT_USHORT( p );
+ subst_count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*glyph_count + 4*subst_count );
+ for ( count = glyph_count; count > 0; count-- )
+ otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GSUB LOOKUP TYPE 6 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+
+ static void
+ otl_chain_sub_rule_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt back_count, input_count, ahead_count, subst_count, count;
+
+ OTL_CHECK( 2 );
+ back_count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*back_count+2 );
+ p += 2*back_count;
+
+ input_count = OTL_NEXT_USHORT( p );
+ if ( input_count == 0 )
+ OTL_INVALID_DATA;
+
+ OTL_CHECK( 2*input_count );
+ p += 2*(input_count-1);
+
+ ahead_count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( 2*ahead_count + 2 );
+ p += 2*ahead_count;
+
+ count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( 4*count );
+
+ /* XXX: check glyph indices and subst lookups */
+ }
+
+
+ static void
+ otl_chain_sub_rule_set_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_chain_sub_rule_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+ static void
+ otl_chain_sub_class_rule_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt back_count, input_count, ahead_count, subst_count, count;
+
+ OTL_CHECK( 2 );
+ back_count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*back_count+2 );
+ p += 2*back_count;
+
+ input_count = OTL_NEXT_USHORT( p );
+ if ( input_count == 0 )
+ OTL_INVALID_DATA;
+
+ OTL_CHECK( 2*input_count );
+ p += 2*(input_count-1);
+
+ ahead_count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( 2*ahead_count + 2 );
+ p += 2*ahead_count;
+
+ count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( 4*count );
+
+ /* XXX: check class indices and subst lookups */
+ }
+
+
+
+ static void
+ otl_chain_sub_class_set_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_chain_sub_rule_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+ static void
+ otl_gsub_lookup6_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format, coverage;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch ( format )
+ {
+ case 1:
+ {
+ OTL_UInt coverage, count;
+
+ OTL_CHECK( 4 );
+ coverage = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_chain_sub_rule_set_validate( table + coverage, valid );
+ }
+ break;
+
+ case 2:
+ {
+ OTL_UInt coverage, back_class, input_class, ahead_class, count;
+
+ OTL_CHECK( 10 );
+ coverage = OTL_NEXT_USHORT( p );
+ back_class = OTL_NEXT_USHORT( p );
+ input_class = OTL_NEXT_USHORT( p );
+ ahead_class = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ otl_coverage_validate( table + coverage, valid );
+
+ otl_class_definition_validate( table + back_class, valid );
+ otl_class_definition_validate( table + input_class, valid );
+ otl_class_definition_validate( table + ahead_class, valid );
+
+ OTL_CHECK( 2*count );
+ for ( ; count > 0; count-- )
+ otl_chain_sub_class_set( table + OTL_NEXT_USHORT( p ), valid );
+ }
+ break;
+
+ case 3:
+ {
+ OTL_UInt back_count, input_count, ahead_count, subst_count, count;
+
+ OTL_CHECK( 2 );
+ back_count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*back_count+2 );
+ for ( count = back_count; count > 0; count-- )
+ otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid );
+
+ input_count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*input_count+2 );
+ for ( count = input_count; count > 0; count-- )
+ otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid );
+
+ ahead_count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( 2*ahead_count+2 );
+ for ( count = ahead_count; count > 0; count-- )
+ otl_coverage_validate( table + OTL_NEXT_USHORT( p ), valid );
+
+ subst_count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( subst_count*4 );
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GSUB LOOKUP TYPE 6 *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+ static void
+ otl_gsub_lookup7_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt format, coverage;
+
+ OTL_CHECK( 2 );
+ format = OTL_NEXT_USHORT( p );
+ switch ( format )
+ {
+ case 1:
+ {
+ OTL_UInt lookup_type, lookup_offset;
+ OTL_ValidateFunc validate;
+
+ OTL_CHECK( 6 );
+ lookup_type = OTL_NEXT_USHORT( p );
+ lookup_offset = OTL_NEXT_ULONG( p );
+
+ if ( lookup_type == 0 || lookup_type >= 7 )
+ OTL_INVALID_DATA;
+
+ validate = otl_gsub_validate_funcs[ lookup_type-1 ];
+ validate( table + lookup_offset, valid );
+ }
+ break;
+
+ default:
+ OTL_INVALID_DATA;
+ }
+ }
+
+
+ static const OTL_ValidateFunc otl_gsub_validate_funcs[ 7 ] =
+ {
+ otl_gsub_lookup1_validate,
+ otl_gsub_lookup2_validate,
+ otl_gsub_lookup3_validate,
+ otl_gsub_lookup4_validate,
+ otl_gsub_lookup5_validate,
+ otl_gsub_lookup6_validate
+ };
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** GSUB TABLE *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+
+ OTL_LOCALDEF( void )
+ otl_gsub_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt scripts, features, lookups;
+
+ OTL_CHECK( 10 );
+
+ if ( OTL_NEXT_USHORT( p ) != 0x10000UL )
+ OTL_INVALID_DATA;
+
+ scripts = OTL_NEXT_USHORT( p );
+ features = OTL_NEXT_USHORT( p );
+ lookups = OTL_NEXT_USHORT( p );
+
+ otl_script_list_validate ( table + scripts, valid );
+ otl_feature_list_validate( table + features, valid );
+
+ otl_lookup_list_validate( table + lookups, 7, otl_gsub_validate_funcs,
+ valid );
+ }
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlgsub.h b/nx-X11/extras/freetype2/src/otlayout/otlgsub.h
new file mode 100644
index 000000000..db5edecf1
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlgsub.h
@@ -0,0 +1,26 @@
+#ifndef __OTL_GSUB_H__
+#define __OTL_GSUB_H__
+
+#include "otlayout.h"
+
+OTL_BEGIN_HEADER
+
+ typedef OTL_UInt (*OTL_GSUB_AlternateFunc)( OTL_UInt gindex,
+ OTL_UInt count,
+ OTL_Bytes alternates,
+ OTL_Pointer data );
+
+ typedef struct OTL_GSUB_AlternateRec_
+ {
+ OTL_GSUB_AlternateFunc handler_func;
+ OTL_Pointer handler_data;
+
+ } OTL_GSUB_AlternateRec, *OTL_GSUB_Alternate;
+
+ OTL_LOCAL( void )
+ otl_gsub_validate( OTL_Bytes table,
+ OTL_Validator valid );
+
+OTL_END_HEADER
+
+#endif /* __OTL_GSUB_H__ */
diff --git a/nx-X11/extras/freetype2/src/otlayout/otljstf.c b/nx-X11/extras/freetype2/src/otlayout/otljstf.c
new file mode 100644
index 000000000..b0fa9f406
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otljstf.c
@@ -0,0 +1,189 @@
+#include "otljstf.h"
+#include "otlcommn.h"
+#include "otlgpos.h"
+
+ static void
+ otl_jstf_extender_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( count*2 );
+ }
+
+
+ static void
+ otl_jstf_gsub_mods_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( count*2 );
+
+ /* XXX: check GSUB lookup indices */
+ }
+
+
+ static void
+ otl_jstf_gpos_mods_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+ count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( count*2 );
+
+ /* XXX: check GPOS lookup indices */
+ }
+
+
+ static void
+ otl_jstf_max_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( count*2 );
+ for ( ; count > 0; count-- )
+ otl_gpos_subtable_check( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+ static void
+ otl_jstf_priority_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt offset;
+
+ OTL_CHECK( 20 );
+
+ /* shrinkage GSUB enable/disable */
+ val = OTL_NEXT_USHORT( p );
+ if ( val )
+ otl_jstf_gsub_mods_validate( table + val, valid );
+
+ val = OTL_NEXT_USHORT( p );
+ if ( val )
+ otl_jstf_gsub_mods_validate( table + val, valid );
+
+ /* shrinkage GPOS enable/disable */
+ val = OTL_NEXT_USHORT( p );
+ if ( val )
+ otl_jstf_gpos_mods_validate( table + val, valid );
+
+ val = OTL_NEXT_USHORT( p );
+ if ( val )
+ otl_jstf_gpos_mods_validate( table + val, valid );
+
+ /* shrinkage JSTF max */
+ val = OTL_NEXT_USHORT( p );
+ if ( val )
+ otl_jstf_max_validate( table + val, valid );
+
+ /* extension GSUB enable/disable */
+ val = OTL_NEXT_USHORT( p );
+ if ( val )
+ otl_jstf_gsub_mods_validate( table + val, valid );
+
+ val = OTL_NEXT_USHORT( p );
+ if ( val )
+ otl_jstf_gsub_mods_validate( table + val, valid );
+
+ /* extension GPOS enable/disable */
+ val = OTL_NEXT_USHORT( p );
+ if ( val )
+ otl_jstf_gpos_mods_validate( table + val, valid );
+
+ val = OTL_NEXT_USHORT( p );
+ if ( val )
+ otl_jstf_gpos_mods_validate( table + val, valid );
+
+ /* extension JSTF max */
+ val = OTL_NEXT_USHORT( p );
+ if ( val )
+ otl_jstf_max_validate( table + val, valid );
+ }
+
+ static void
+ otl_jstf_lang_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 2 );
+
+ count = OTL_NEXT_USHORT( p );
+
+ OTL_CHECK( count*2 );
+ for ( ; count > 0; count-- )
+ otl_jstf_priority_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+
+
+ static void
+ otl_jstf_script_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count, extender, default_lang;
+
+ OTL_CHECK( 6 );
+ extender = OTL_NEXT_USHORT( p );
+ default_lang = OTL_NEXT_USHORT( p );
+ count = OTL_NEXT_USHORT( p );
+
+ if ( extender )
+ otl_jstf_extender_validate( table + extender, valid );
+
+ if ( default_lang )
+ otl_jstf_lang_validate( table + default_lang, valid );
+
+ OTL_CHECK( 6*count );
+
+ for ( ; count > 0; count-- )
+ {
+ p += 4; /* ignore tag */
+ otl_jstf_lang_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+ }
+
+
+ OTL_LOCALDEF( void )
+ otl_jstf_validate( OTL_Bytes table,
+ OTL_Validator valid )
+ {
+ OTL_Bytes p = table;
+ OTL_UInt count;
+
+ OTL_CHECK( 4 );
+
+ if ( OTL_NEXT_ULONG( p ) != 0x10000UL )
+ OTL_INVALID_DATA;
+
+ count = OTL_NEXT_USHORT( p );
+ OTL_CHECK( count*6 );
+
+ for ( ; count > 0; count++ )
+ {
+ p += 4; /* ignore tag */
+ otl_jstf_script_validate( table + OTL_NEXT_USHORT( p ), valid );
+ }
+ }
+ \ No newline at end of file
diff --git a/nx-X11/extras/freetype2/src/otlayout/otljstf.h b/nx-X11/extras/freetype2/src/otlayout/otljstf.h
new file mode 100644
index 000000000..c8a98a64a
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otljstf.h
@@ -0,0 +1,14 @@
+#ifndef __OTL_JSTF_H__
+#define __OTL_JSTF_H__
+
+#include "otlayout.h"
+
+OTL_BEGIN_HEADER
+
+ OTL_LOCAL( void )
+ otl_jstf_validate( OTL_Bytes table,
+ OTL_Validator valid );
+
+OTL_END_HEADER
+
+#endif /* __OTL_JSTF_H__ */ \ No newline at end of file
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlparse.c b/nx-X11/extras/freetype2/src/otlayout/otlparse.c
new file mode 100644
index 000000000..705c0c60f
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlparse.c
@@ -0,0 +1,142 @@
+#include "otlparse.h"
+#include "otlutils.h"
+
+ static void
+ otl_string_ensure( OTL_String string,
+ OTL_UInt count,
+ OTL_Parser parser )
+ {
+ count += string->length;
+
+ if ( count > string->capacity )
+ {
+ OTL_UInt old_count = string->capacity;
+ OTL_UInt new_count = old_count;
+ OTL_Memory memory = parser->memory;
+
+ while ( new_count < count )
+ new_count += (new_count >> 1) + 16;
+
+ if ( OTL_MEM_RENEW_ARRAY( string->glyphs, old_count, new_count ) )
+ otl_parser_error( parser, OTL_Parse_Err_Memory );
+
+ string->capacity = new_count;
+ }
+ }
+
+#define OTL_STRING_ENSURE(str,count,parser) \
+ OTL_BEGIN_STMNT \
+ if ( (str)->length + (count) > (str)>capacity ) \
+ otl_string_ensure( str, count, parser ); \
+ OTL_END_STMNT
+
+
+ OTL_LOCALDEF( OTL_UInt )
+ otl_parser_get_gindex( OTL_Parser parser )
+ {
+ OTL_String in = parser->str_in;
+
+ if ( in->cursor >= in->num_glyphs )
+ otl_parser_error( parser, OTL_Err_Parser_Internal );
+
+ return in->str[ in->cursor ].gindex;
+ }
+
+
+ OTL_LOCALDEF( void )
+ otl_parser_error( OTL_Parser parser,
+ OTL_ParseError error; )
+ {
+ parser->error = error;
+ otl_longjmp( parser->jump_buffer, 1 );
+ }
+
+#define OTL_PARSER_UNCOVERED(x) otl_parser_error( x, OTL_Parse_Err_UncoveredGlyph );
+
+ OTL_LOCAL( void )
+ otl_parser_check_property( OTL_Parser parser,
+ OTL_UInt gindex,
+ OTL_UInt flags,
+ OTL_UInt *aproperty );
+
+ OTL_LOCALDEF( void )
+ otl_parser_replace_1( OTL_Parser parser,
+ OTL_UInt gindex )
+ {
+ OTL_String in = parser->str_in;
+ OTL_String out = parser->str_out;
+ OTL_StringGlyph glyph, in_glyph;
+
+ /* sanity check */
+ if ( in == NULL ||
+ out == NULL ||
+ in->length == 0 ||
+ in->cursor >= in->length )
+ {
+ /* report as internal error, since these should */
+ /* never happen !! */
+ otl_parser_error( parser, OTL_Err_Parse_Internal );
+ }
+
+ OTL_STRING_ENSURE( out, 1, parser );
+ glyph = out->glyphs + out->length;
+ in_glyph = in->glyphs + in->cursor;
+
+ glyph->gindex = gindex;
+ glyph->property = in_glyph->property;
+ glyph->lig_component = in_glyph->lig_component;
+ glyph->lig_id = in_glyph->lig_id;
+
+ out->length += 1;
+ out->cursor = out->length;
+ in->cursor += 1;
+ }
+
+ OTL_LOCALDEF( void )
+ otl_parser_replace_n( OTL_Parser parser,
+ OTL_UInt count,
+ OTL_Bytes indices )
+ {
+ OTL_UInt lig_component, lig_id, property;
+ OTL_String in = parser->str_in;
+ OTL_String out = parser->str_out;
+ OTL_StringGlyph glyph, in_glyph;
+ OTL_Bytes p = indices;
+
+ /* sanity check */
+ if ( in == NULL ||
+ out == NULL ||
+ in->length == 0 ||
+ in->cursor >= in->length )
+ {
+ /* report as internal error, since these should */
+ /* never happen !! */
+ otl_parser_error( parser, OTL_Err_Parse_Internal );
+ }
+
+ OTL_STRING_ENSURE( out, count, parser );
+ glyph = out->glyphs + out->length;
+ in_glyph = in->glyphs + in->cursor;
+
+ glyph->gindex = gindex;
+
+ lig_component = in_glyph->lig_component;
+ lig_id = in_glyph->lid_id;
+ property = in_glyph->property;
+
+ for ( ; count > 0; count-- )
+ {
+ glyph->gindex = OTL_NEXT_USHORT(p);
+ glyph->property = property;
+ glyph->lig_component = lig_component;
+ glyph->lig_id = lig_id;
+
+ out->length ++;
+ }
+
+ out->cursor = out->length;
+ in->cursor += 1;
+ }
+
+
+
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlparse.h b/nx-X11/extras/freetype2/src/otlayout/otlparse.h
new file mode 100644
index 000000000..92f34bfdc
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlparse.h
@@ -0,0 +1,99 @@
+#ifndef __OTL_PARSER_H__
+#define __OTL_PARSER_H__
+
+#include "otlayout.h"
+#include "otlgdef.h"
+#include "otlgsub.h"
+#include "otlgpos.h"
+
+OTL_BEGIN_HEADER
+
+ typedef struct OTL_ParserRec_* OTL_Parser;
+
+ typedef struct OTL_StringRec_* OTL_String;
+
+ typedef struct OTL_StringGlyphRec_
+ {
+ OTL_UInt gindex;
+ OTL_UInt properties;
+ OTL_UInt lig_component;
+ OTL_UInt lig_id;
+
+ } OTL_StringGlyphRec, *OTL_StringGlyph;
+
+ typedef struct OTL_StringRec_
+ {
+ OTL_StringGlyph glyphs;
+ OTL_UInt cursor;
+ OTL_UInt length;
+ OTL_UInt capacity;
+
+ } OTL_StringRec;
+
+ typedef struct OTL_ParserRec_
+ {
+ OTL_Bytes tab_gdef;
+ OTL_Bytes tab_gsub;
+ OTL_Bytes tab_gpos;
+ OTL_Bytes tab_base;
+ OTL_Bytes tab_jstf;
+
+ OTL_Alternate alternate; /* external alternate handler */
+
+ OTL_UInt context_len;
+ OTL_UInt markup_flags;
+
+ OTL_jmp_buf jump_buffer;
+ OTL_Memory memory;
+ OTL_Error error;
+
+ OTL_StringRec strings[2];
+ OTL_String str_in;
+ OTL_String str_out;
+
+ } OTL_ParserRec;
+
+ typedef enum
+ {
+ OTL_Err_Parser_Ok = 0,
+ OTL_Err_Parser_InvalidData,
+ OTL_Err_Parser_UncoveredGlyph
+
+ } OTL_ParseError;
+
+ OTL_LOCAL( OTL_UInt )
+ otl_parser_get_gindex( OTL_Parser parser );
+
+
+ OTL_LOCAL( void )
+ otl_parser_error( OTL_Parser parser, OTL_ParserError error );
+
+#define OTL_PARSER_UNCOVERED(x) \
+ otl_parser_error( x, OTL_Err_Parser_UncoveredGlyph )
+
+ OTL_LOCAL( void )
+ otl_parser_check_property( OTL_Parser parser,
+ OTL_UInt gindex,
+ OTL_UInt flags,
+ OTL_UInt *aproperty );
+
+ /* copy current input glyph to output */
+ OTL_LOCAL( void )
+ otl_parser_copy_1( OTL_Parser parser );
+
+ /* copy current input glyph to output, replacing its index */
+ OTL_LOCAL( void )
+ otl_parser_replace_1( OTL_Parser parser,
+ OTL_UInt gindex );
+
+ /* copy current input glyph to output, replacing it by several indices */
+ /* read directly from the table */
+ OTL_LOCAL( void )
+ otl_parser_replace_n( OTL_Parser parser,
+ OTL_UInt count,
+ OTL_Bytes indices );
+
+OTL_END_HEADER
+
+#endif /* __OTL_PARSER_H__ */
+
diff --git a/nx-X11/extras/freetype2/src/otlayout/otltable.h b/nx-X11/extras/freetype2/src/otlayout/otltable.h
new file mode 100644
index 000000000..af7bd78a5
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otltable.h
@@ -0,0 +1,60 @@
+#ifndef __OTL_TABLE_H__
+#define __OTL_TABLE_H__
+
+#include "otlayout.h"
+
+OTL_BEGIN_HEADER
+
+ typedef struct OTL_TableRec_* OTL_Table;
+
+ typedef enum
+ {
+ OTL_TABLE_TYPE_GDEF = 1,
+ OTL_TABLE_TYPE_GSUB,
+ OTL_TABLE_TYPE_GPOS,
+ OTL_TABLE_TYPE_BASE,
+ OTL_TABLE_TYPE_JSTF
+
+ } OTL_TableType;
+
+
+ /* this may become a private structure later */
+ typedef struct OTL_TableRec_
+ {
+ OTL_TableType type;
+ OTL_Bytes base;
+ OTL_Bytes limit;
+
+ OTL_Tag script_tag;
+ OTL_Tag lang_tag;
+
+ OTL_UInt lookup_count;
+ OTL_Byte* lookup_flags;
+
+ OTL_UInt feature_count;
+ OTL_Tag feature_tags;
+ OTL_Byte* feature_flags;
+
+ } OTL_TableRec;
+
+
+ OTL_API( OTL_Error )
+ otl_table_validate( OTL_Bytes table,
+ OTL_Size size,
+ OTL_TableType type,
+ OTL_Size *abyte_size );
+
+ OTL_API( void )
+ otl_table_init( OTL_Table table,
+ OTL_TableType type,
+ OTL_Bytes base,
+ OTL_Size size );
+
+ OTL_API( void )
+ otl_table_set_script( OTL_Table table,
+ OTL_ScriptTag script,
+ OTL_LangTag language );
+
+OTL_END_HEADER
+
+#endif /* __OTL_TABLE_H__ */
diff --git a/nx-X11/extras/freetype2/src/otlayout/otltags.h b/nx-X11/extras/freetype2/src/otlayout/otltags.h
new file mode 100644
index 000000000..d954b5851
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otltags.h
@@ -0,0 +1,88 @@
+/* this file may be included several times by other parts of */
+/* the OpenType Layout library.. don't add #ifdef .. #endif */
+/* delimiters to it... */
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** SCRIPT TAGS *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+#ifndef OTL_SCRIPT_TAG
+#define OTL_SCRIPT_TAG(c1,c2,c3,c4,s,n) /* void */
+#endif
+
+OTL_SCRIPT_TAG( 'a','r','a','b', "Arabic", ARABIC )
+OTL_SCRIPT_TAG( 'a','r','m','n', "Armenian", ARMENIAN )
+OTL_SCRIPT_TAG( 'b','e','n','g', "Bengali", BENGALI )
+OTL_SCRIPT_TAG( 'b','o','p','o', "Bopomofo", BOPOMOFO )
+OTL_SCRIPT_TAG( 'b','r','a','i', "Braille", BRAILLE )
+OTL_SCRIPT_TAG( 'b','y','z','m', "Byzantine Music", BYZANTINE_MUSIC )
+OTL_SCRIPT_TAG( 'c','a','n','s', "Canadian Syllabic", CANADIAN )
+OTL_SCRIPT_TAG( 'c','h','e','r', "Cherokee", CHEROKEE )
+OTL_SCRIPT_TAG( 'h','a','n','i', "CJK Ideographic", CJK )
+OTL_SCRIPT_TAG( 'c','y','r','l', "Cyrillic", CYRILLIC )
+OTL_SCRIPT_TAG( 'd','f','l','t', "Default", DEFAULT )
+OTL_SCRIPT_TAG( 'd','e','v','a', "Devanagari", DEVANAGARI )
+OTL_SCRIPT_TAG( 'e','t','h','i', "Ethiopic", ETHIOPIC )
+OTL_SCRIPT_TAG( 'g','e','o','r', "Georgian", GEORGIAN )
+OTL_SCRIPT_TAG( 'g','r','e','k', "Greek", GREEK )
+OTL_SCRIPT_TAG( 'g','u','j','r', "Gujarati", GUJARATI )
+OTL_SCRIPT_TAG( 'g','u','r','u', "Gurmukhi", GURMUKHI )
+OTL_SCRIPT_TAG( 'j','a','m','o', "Hangul Jamo", JAMO )
+OTL_SCRIPT_TAG( 'h','a','n','g', "Hangul", HANGUL )
+OTL_SCRIPT_TAG( 'h','e','b','r', "Hebrew", HEBREW )
+OTL_SCRIPT_TAG( 'h','i','r','a', "Hiragana", HIRAGANA ) /* not in TAGS.txt */
+OTL_SCRIPT_TAG( 'k','n','d','a', "Kannada", KANNADA )
+OTL_SCRIPT_TAG( 'k','a','n','a', "Katakana", KATAKANA ) /* in TAGS.txt, means Hiragana _and_ Katakana */
+OTL_SCRIPT_TAG( 'k','h','m','r', "Khmer", KHMER )
+OTL_SCRIPT_TAG( 'l','a','o',' ', "Lao", LAO )
+OTL_SCRIPT_TAG( 'l','a','t','n', "Latin", LATIN )
+OTL_SCRIPT_TAG( 'm','l','y','m', "Malayalam", MALAYALAM )
+OTL_SCRIPT_TAG( 'm','o','n','g', "Mongolian", MONGOLIAN )
+OTL_SCRIPT_TAG( 'm','y','m','r', "Myanmar", MYANMAR )
+OTL_SCRIPT_TAG( 'o','g','a','m', "Ogham", OGHAM )
+OTL_SCRIPT_TAG( 'o','r','y','a', "Oriya", ORIYA )
+OTL_SCRIPT_TAG( 'r','u','n','r', "Runic", RUNIC )
+OTL_SCRIPT_TAG( 's','i','n','h', "Sinhala", SINHALA )
+OTL_SCRIPT_TAG( 's','y','r','c', "Syriac", SYRIAC )
+OTL_SCRIPT_TAG( 't','a','m','l', "Tamil", TAMIL )
+OTL_SCRIPT_TAG( 't','e','l','u', "Telugu", TELUGU )
+OTL_SCRIPT_TAG( 't','h','a','a', "Thaana", THAANA )
+OTL_SCRIPT_TAG( 't','h','a','i', "Thai", THAI )
+OTL_SCRIPT_TAG( 't','i','b','t', "Tibetan", TIBETAN )
+OTL_SCRIPT_TAG( 'y','i',' ',' ', "Yi", YI )
+
+#undef OTL_SCRIPT_TAG
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** LANGUAGE TAGS *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+#ifndef OTL_LANG_TAG
+#define OTL_LANG_TAG(c1,c2,c3,c4,s,n) /* void */
+#endif
+
+#undef OTL_LANG_TAG
+
+
+ /************************************************************************/
+ /************************************************************************/
+ /***** *****/
+ /***** FEATURE TAGS *****/
+ /***** *****/
+ /************************************************************************/
+ /************************************************************************/
+
+#ifndef OTL_FEATURE_TAG
+#define OTL_FEATURE_TAG(c1,c2,c3,c4,s,n) /* void */
+#endif
+
+#undef OTL_FEATURE_TAG
+
diff --git a/nx-X11/extras/freetype2/src/otlayout/otlutils.h b/nx-X11/extras/freetype2/src/otlayout/otlutils.h
new file mode 100644
index 000000000..de50f66f0
--- /dev/null
+++ b/nx-X11/extras/freetype2/src/otlayout/otlutils.h
@@ -0,0 +1,33 @@
+#ifndef __OTLAYOUT_UTILS_H__
+#define __OTLAYOUT_UTILS_H__
+
+#include "otlayout.h"
+
+OTL_BEGIN_HEADER
+
+ OTL_LOCAL( OTL_Error )
+ otl_mem_alloc( OTL_Pointer* pblock,
+ OTL_ULong size,
+ OTL_Memory memory );
+
+ OTL_LOCAL( void )
+ otl_mem_free( OTL_Pointer* pblock,
+ OTL_Memory memory );
+
+ OTL_LOCAL( OTL_Error )
+ otl_mem_realloc( OTL_Pointer *pblock,
+ OTL_ULong cur_size,
+ OTL_ULong new_size,
+ OTL_Memory memory );
+
+#define OTL_MEM_ALLOC(p,s) otl_mem_alloc( (void**)&(p), (s), memory )
+#define OTL_MEM_FREE(p) otl_mem_free( (void**)&(p), memory )
+#define OTL_MEM_REALLOC(p,c,n) otl_mem_realloc( (void**)&(p), (c), (s), memory )
+
+#define OTL_MEM_NEW(p) OTL_MEM_ALLOC(p,sizeof(*(p)))
+#define OTL_MEM_NEW_ARRAY(p,c) OTL_MEM_ALLOC(p,(c)*sizeof(*(p)))
+#define OTL_MEM_RENEW_ARRAY(p,c,n) OTL_MEM_REALLOC(p,(c)*sizeof(*(p)),(n)*sizeof(*(p)))
+
+OTL_END_HEADER
+
+#endif /* __OTLAYOUT_UTILS_H__ */