/modules/freetype2/src/base/ftgasp.c

http://github.com/zpao/v8monkey · C · 61 lines · 29 code · 14 blank · 18 comment · 7 complexity · 4c98fa68f3288dbf4994c48ef2d1e5c8 MD5 · raw file

  1. /***************************************************************************/
  2. /* */
  3. /* ftgasp.c */
  4. /* */
  5. /* Access of TrueType's `gasp' table (body). */
  6. /* */
  7. /* Copyright 2007 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_GASP_H
  19. #include FT_INTERNAL_TRUETYPE_TYPES_H
  20. FT_EXPORT_DEF( FT_Int )
  21. FT_Get_Gasp( FT_Face face,
  22. FT_UInt ppem )
  23. {
  24. FT_Int result = FT_GASP_NO_TABLE;
  25. if ( face && FT_IS_SFNT( face ) )
  26. {
  27. TT_Face ttface = (TT_Face)face;
  28. if ( ttface->gasp.numRanges > 0 )
  29. {
  30. TT_GaspRange range = ttface->gasp.gaspRanges;
  31. TT_GaspRange range_end = range + ttface->gasp.numRanges;
  32. while ( ppem > range->maxPPEM )
  33. {
  34. range++;
  35. if ( range >= range_end )
  36. goto Exit;
  37. }
  38. result = range->gaspFlag;
  39. /* ensure that we don't have spurious bits */
  40. if ( ttface->gasp.version == 0 )
  41. result &= 3;
  42. }
  43. }
  44. Exit:
  45. return result;
  46. }
  47. /* END */