/src/compiler/android-ndk/jni/freetype/src/base/ftmm.c

http://ftk.googlecode.com/ · C · 202 lines · 119 code · 52 blank · 31 comment · 15 complexity · 0e69eb4c18ada8783647c180859a4921 MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* ftmm.c */
  4. /* */
  5. /* Multiple Master font support (body). */
  6. /* */
  7. /* Copyright 1996-2001, 2003, 2004, 2009 by */
  8. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  9. /* */
  10. /* This file is part of the FreeType project, and may only be used, */
  11. /* modified, and distributed under the terms of the FreeType project */
  12. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  13. /* this file you indicate that you have read the license and */
  14. /* understand and accept it fully. */
  15. /* */
  16. /***************************************************************************/
  17. #include <ft2build.h>
  18. #include FT_MULTIPLE_MASTERS_H
  19. #include FT_INTERNAL_OBJECTS_H
  20. #include FT_SERVICE_MULTIPLE_MASTERS_H
  21. /*************************************************************************/
  22. /* */
  23. /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
  24. /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
  25. /* messages during execution. */
  26. /* */
  27. #undef FT_COMPONENT
  28. #define FT_COMPONENT trace_mm
  29. static FT_Error
  30. ft_face_get_mm_service( FT_Face face,
  31. FT_Service_MultiMasters *aservice )
  32. {
  33. FT_Error error;
  34. *aservice = NULL;
  35. if ( !face )
  36. return FT_Err_Invalid_Face_Handle;
  37. error = FT_Err_Invalid_Argument;
  38. if ( FT_HAS_MULTIPLE_MASTERS( face ) )
  39. {
  40. FT_FACE_LOOKUP_SERVICE( face,
  41. *aservice,
  42. MULTI_MASTERS );
  43. if ( *aservice )
  44. error = FT_Err_Ok;
  45. }
  46. return error;
  47. }
  48. /* documentation is in ftmm.h */
  49. FT_EXPORT_DEF( FT_Error )
  50. FT_Get_Multi_Master( FT_Face face,
  51. FT_Multi_Master *amaster )
  52. {
  53. FT_Error error;
  54. FT_Service_MultiMasters service;
  55. error = ft_face_get_mm_service( face, &service );
  56. if ( !error )
  57. {
  58. error = FT_Err_Invalid_Argument;
  59. if ( service->get_mm )
  60. error = service->get_mm( face, amaster );
  61. }
  62. return error;
  63. }
  64. /* documentation is in ftmm.h */
  65. FT_EXPORT_DEF( FT_Error )
  66. FT_Get_MM_Var( FT_Face face,
  67. FT_MM_Var* *amaster )
  68. {
  69. FT_Error error;
  70. FT_Service_MultiMasters service;
  71. error = ft_face_get_mm_service( face, &service );
  72. if ( !error )
  73. {
  74. error = FT_Err_Invalid_Argument;
  75. if ( service->get_mm_var )
  76. error = service->get_mm_var( face, amaster );
  77. }
  78. return error;
  79. }
  80. /* documentation is in ftmm.h */
  81. FT_EXPORT_DEF( FT_Error )
  82. FT_Set_MM_Design_Coordinates( FT_Face face,
  83. FT_UInt num_coords,
  84. FT_Long* coords )
  85. {
  86. FT_Error error;
  87. FT_Service_MultiMasters service;
  88. error = ft_face_get_mm_service( face, &service );
  89. if ( !error )
  90. {
  91. error = FT_Err_Invalid_Argument;
  92. if ( service->set_mm_design )
  93. error = service->set_mm_design( face, num_coords, coords );
  94. }
  95. return error;
  96. }
  97. /* documentation is in ftmm.h */
  98. FT_EXPORT_DEF( FT_Error )
  99. FT_Set_Var_Design_Coordinates( FT_Face face,
  100. FT_UInt num_coords,
  101. FT_Fixed* coords )
  102. {
  103. FT_Error error;
  104. FT_Service_MultiMasters service;
  105. error = ft_face_get_mm_service( face, &service );
  106. if ( !error )
  107. {
  108. error = FT_Err_Invalid_Argument;
  109. if ( service->set_var_design )
  110. error = service->set_var_design( face, num_coords, coords );
  111. }
  112. return error;
  113. }
  114. /* documentation is in ftmm.h */
  115. FT_EXPORT_DEF( FT_Error )
  116. FT_Set_MM_Blend_Coordinates( FT_Face face,
  117. FT_UInt num_coords,
  118. FT_Fixed* coords )
  119. {
  120. FT_Error error;
  121. FT_Service_MultiMasters service;
  122. error = ft_face_get_mm_service( face, &service );
  123. if ( !error )
  124. {
  125. error = FT_Err_Invalid_Argument;
  126. if ( service->set_mm_blend )
  127. error = service->set_mm_blend( face, num_coords, coords );
  128. }
  129. return error;
  130. }
  131. /* documentation is in ftmm.h */
  132. /* This is exactly the same as the previous function. It exists for */
  133. /* orthogonality. */
  134. FT_EXPORT_DEF( FT_Error )
  135. FT_Set_Var_Blend_Coordinates( FT_Face face,
  136. FT_UInt num_coords,
  137. FT_Fixed* coords )
  138. {
  139. FT_Error error;
  140. FT_Service_MultiMasters service;
  141. error = ft_face_get_mm_service( face, &service );
  142. if ( !error )
  143. {
  144. error = FT_Err_Invalid_Argument;
  145. if ( service->set_mm_blend )
  146. error = service->set_mm_blend( face, num_coords, coords );
  147. }
  148. return error;
  149. }
  150. /* END */