/src/freetype/src/base/ftpfr.c

https://bitbucket.org/cabalistic/ogredeps/ · C · 144 lines · 86 code · 35 blank · 23 comment · 11 complexity · be7060b6a162a94f85a75784746f73fe MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* ftpfr.c */
  4. /* */
  5. /* FreeType API for accessing PFR-specific data (body). */
  6. /* */
  7. /* Copyright 2002, 2003, 2004, 2008, 2010 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_INTERNAL_OBJECTS_H
  19. #include FT_SERVICE_PFR_H
  20. /* check the format */
  21. static FT_Service_PfrMetrics
  22. ft_pfr_check( FT_Face face )
  23. {
  24. FT_Service_PfrMetrics service = NULL;
  25. if ( face )
  26. FT_FACE_LOOKUP_SERVICE( face, service, PFR_METRICS );
  27. return service;
  28. }
  29. /* documentation is in ftpfr.h */
  30. FT_EXPORT_DEF( FT_Error )
  31. FT_Get_PFR_Metrics( FT_Face face,
  32. FT_UInt *aoutline_resolution,
  33. FT_UInt *ametrics_resolution,
  34. FT_Fixed *ametrics_x_scale,
  35. FT_Fixed *ametrics_y_scale )
  36. {
  37. FT_Error error = FT_Err_Ok;
  38. FT_Service_PfrMetrics service;
  39. if ( !face )
  40. return FT_Err_Invalid_Argument;
  41. service = ft_pfr_check( face );
  42. if ( service )
  43. {
  44. error = service->get_metrics( face,
  45. aoutline_resolution,
  46. ametrics_resolution,
  47. ametrics_x_scale,
  48. ametrics_y_scale );
  49. }
  50. else
  51. {
  52. FT_Fixed x_scale, y_scale;
  53. /* this is not a PFR font */
  54. if ( aoutline_resolution )
  55. *aoutline_resolution = face->units_per_EM;
  56. if ( ametrics_resolution )
  57. *ametrics_resolution = face->units_per_EM;
  58. x_scale = y_scale = 0x10000L;
  59. if ( face->size )
  60. {
  61. x_scale = face->size->metrics.x_scale;
  62. y_scale = face->size->metrics.y_scale;
  63. }
  64. if ( ametrics_x_scale )
  65. *ametrics_x_scale = x_scale;
  66. if ( ametrics_y_scale )
  67. *ametrics_y_scale = y_scale;
  68. error = FT_Err_Unknown_File_Format;
  69. }
  70. return error;
  71. }
  72. /* documentation is in ftpfr.h */
  73. FT_EXPORT_DEF( FT_Error )
  74. FT_Get_PFR_Kerning( FT_Face face,
  75. FT_UInt left,
  76. FT_UInt right,
  77. FT_Vector *avector )
  78. {
  79. FT_Error error;
  80. FT_Service_PfrMetrics service;
  81. if ( !face )
  82. return FT_Err_Invalid_Argument;
  83. service = ft_pfr_check( face );
  84. if ( service )
  85. error = service->get_kerning( face, left, right, avector );
  86. else
  87. error = FT_Get_Kerning( face, left, right,
  88. FT_KERNING_UNSCALED, avector );
  89. return error;
  90. }
  91. /* documentation is in ftpfr.h */
  92. FT_EXPORT_DEF( FT_Error )
  93. FT_Get_PFR_Advance( FT_Face face,
  94. FT_UInt gindex,
  95. FT_Pos *aadvance )
  96. {
  97. FT_Error error;
  98. FT_Service_PfrMetrics service;
  99. service = ft_pfr_check( face );
  100. if ( service )
  101. {
  102. error = service->get_advance( face, gindex, aadvance );
  103. }
  104. else
  105. /* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */
  106. error = FT_Err_Invalid_Argument;
  107. return error;
  108. }
  109. /* END */