/modules/freetype2/src/gxvalid/gxvmort0.c

http://github.com/zpao/v8monkey · C · 137 lines · 79 code · 27 blank · 31 comment · 1 complexity · f5e0b2a1623d35b143de17a3df651817 MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* gxvmort0.c */
  4. /* */
  5. /* TrueTypeGX/AAT mort table validation */
  6. /* body for type0 (Indic Script Rearrangement) subtable. */
  7. /* */
  8. /* Copyright 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
  9. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  10. /* */
  11. /* This file is part of the FreeType project, and may only be used, */
  12. /* modified, and distributed under the terms of the FreeType project */
  13. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  14. /* this file you indicate that you have read the license and */
  15. /* understand and accept it fully. */
  16. /* */
  17. /***************************************************************************/
  18. /***************************************************************************/
  19. /* */
  20. /* gxvalid is derived from both gxlayout module and otvalid module. */
  21. /* Development of gxlayout is supported by the Information-technology */
  22. /* Promotion Agency(IPA), Japan. */
  23. /* */
  24. /***************************************************************************/
  25. #include "gxvmort.h"
  26. /*************************************************************************/
  27. /* */
  28. /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
  29. /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
  30. /* messages during execution. */
  31. /* */
  32. #undef FT_COMPONENT
  33. #define FT_COMPONENT trace_gxvmort
  34. static const char* GXV_Mort_IndicScript_Msg[] =
  35. {
  36. "no change",
  37. "Ax => xA",
  38. "xD => Dx",
  39. "AxD => DxA",
  40. "ABx => xAB",
  41. "ABx => xBA",
  42. "xCD => CDx",
  43. "xCD => DCx",
  44. "AxCD => CDxA",
  45. "AxCD => DCxA",
  46. "ABxD => DxAB",
  47. "ABxD => DxBA",
  48. "ABxCD => CDxAB",
  49. "ABxCD => CDxBA",
  50. "ABxCD => DCxAB",
  51. "ABxCD => DCxBA",
  52. };
  53. static void
  54. gxv_mort_subtable_type0_entry_validate(
  55. FT_Byte state,
  56. FT_UShort flags,
  57. GXV_StateTable_GlyphOffsetCPtr glyphOffset_p,
  58. FT_Bytes table,
  59. FT_Bytes limit,
  60. GXV_Validator valid )
  61. {
  62. FT_UShort markFirst;
  63. FT_UShort dontAdvance;
  64. FT_UShort markLast;
  65. FT_UShort reserved;
  66. FT_UShort verb = 0;
  67. FT_UNUSED( state );
  68. FT_UNUSED( table );
  69. FT_UNUSED( limit );
  70. FT_UNUSED( GXV_Mort_IndicScript_Msg[verb] ); /* for the non-debugging */
  71. FT_UNUSED( glyphOffset_p ); /* case */
  72. markFirst = (FT_UShort)( ( flags >> 15 ) & 1 );
  73. dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 );
  74. markLast = (FT_UShort)( ( flags >> 13 ) & 1 );
  75. reserved = (FT_UShort)( flags & 0x1FF0 );
  76. verb = (FT_UShort)( flags & 0x000F );
  77. GXV_TRACE(( " IndicScript MorphRule for glyphOffset 0x%04x",
  78. glyphOffset_p->u ));
  79. GXV_TRACE(( " markFirst=%01d", markFirst ));
  80. GXV_TRACE(( " dontAdvance=%01d", dontAdvance ));
  81. GXV_TRACE(( " markLast=%01d", markLast ));
  82. GXV_TRACE(( " %02d", verb ));
  83. GXV_TRACE(( " %s\n", GXV_Mort_IndicScript_Msg[verb] ));
  84. if ( 0 < reserved )
  85. {
  86. GXV_TRACE(( " non-zero bits found in reserved range\n" ));
  87. FT_INVALID_DATA;
  88. }
  89. else
  90. GXV_TRACE(( "\n" ));
  91. }
  92. FT_LOCAL_DEF( void )
  93. gxv_mort_subtable_type0_validate( FT_Bytes table,
  94. FT_Bytes limit,
  95. GXV_Validator valid )
  96. {
  97. FT_Bytes p = table;
  98. GXV_NAME_ENTER(
  99. "mort chain subtable type0 (Indic-Script Rearrangement)" );
  100. GXV_LIMIT_CHECK( GXV_STATETABLE_HEADER_SIZE );
  101. valid->statetable.optdata = NULL;
  102. valid->statetable.optdata_load_func = NULL;
  103. valid->statetable.subtable_setup_func = NULL;
  104. valid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
  105. valid->statetable.entry_validate_func =
  106. gxv_mort_subtable_type0_entry_validate;
  107. gxv_StateTable_validate( p, limit, valid );
  108. GXV_EXIT;
  109. }
  110. /* END */