ftpfr.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /***************************************************************************/
  2. /* */
  3. /* ftpfr.c */
  4. /* */
  5. /* FreeType API for accessing PFR-specific data */
  6. /* */
  7. /* Copyright 2002 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_PFR_H
  19. #include FT_INTERNAL_OBJECTS_H
  20. /* check the format */
  21. static FT_Error
  22. ft_pfr_check( FT_Face face,
  23. FT_PFR_Service *aservice )
  24. {
  25. FT_Error error = FT_Err_Bad_Argument;
  26. if ( face && face->driver )
  27. {
  28. FT_Module module = (FT_Module) face->driver;
  29. const char* name = module->clazz->module_name;
  30. if ( name[0] == 'p' &&
  31. name[1] == 'f' &&
  32. name[2] == 'r' &&
  33. name[4] == 0 )
  34. {
  35. *aservice = (FT_PFR_Service) module->clazz->module_interface;
  36. error = 0;
  37. }
  38. }
  39. return error;
  40. }
  41. FT_EXPORT_DEF( FT_Error )
  42. FT_Get_PFR_Metrics( FT_Face face,
  43. FT_UInt *aoutline_resolution,
  44. FT_UInt *ametrics_resolution,
  45. FT_Fixed *ametrics_x_scale,
  46. FT_Fixed *ametrics_y_scale )
  47. {
  48. FT_Error error;
  49. FT_PFR_Service service;
  50. error = ft_pfr_check( face, &service );
  51. if ( !error )
  52. {
  53. error = service->get_metrics( face,
  54. aoutline_resolution,
  55. ametrics_resolution,
  56. ametrics_x_scale,
  57. ametrics_y_scale );
  58. }
  59. return error;
  60. }
  61. FT_EXPORT_DEF( FT_Error )
  62. FT_Get_PFR_Kerning( FT_Face face,
  63. FT_UInt left,
  64. FT_UInt right,
  65. FT_Vector *avector )
  66. {
  67. FT_Error error;
  68. FT_PFR_Service service;
  69. error = ft_pfr_check( face, &service );
  70. if ( !error )
  71. {
  72. error = service->get_kerning( face, left, right, avector );
  73. }
  74. return error;
  75. }
  76. FT_EXPORT_DEF( FT_Error )
  77. FT_Get_PFR_Advance( FT_Face face,
  78. FT_UInt gindex,
  79. FT_Pos *aadvance )
  80. {
  81. FT_Error error;
  82. FT_PFR_Service service;
  83. error = ft_pfr_check( face, &service );
  84. if ( !error )
  85. {
  86. error = service->get_advance( face, gindex, aadvance );
  87. }
  88. return error;
  89. }
  90. /* END */