ftcglyph.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /***************************************************************************/
  2. /* */
  3. /* ftcglyph.c */
  4. /* */
  5. /* FreeType Glyph Image (FT_Glyph) cache (body). */
  6. /* */
  7. /* Copyright 2000-2001 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_CACHE_H
  19. #include FT_CACHE_INTERNAL_GLYPH_H
  20. #include FT_ERRORS_H
  21. #include FT_LIST_H
  22. #include FT_INTERNAL_OBJECTS_H
  23. #include FT_INTERNAL_DEBUG_H
  24. #include "ftcerror.h"
  25. /* create a new chunk node, setting its cache index and ref count */
  26. FT_EXPORT_DEF( void )
  27. ftc_glyph_node_init( FTC_GlyphNode gnode,
  28. FT_UInt gindex,
  29. FTC_GlyphFamily gfam )
  30. {
  31. FT_UInt len;
  32. FT_UInt start = FTC_GLYPH_FAMILY_START( gfam, gindex );
  33. gnode->item_start = (FT_UShort)start;
  34. len = gfam->item_total - start;
  35. if ( len > gfam->item_count )
  36. len = gfam->item_count;
  37. gnode->item_count = (FT_UShort)len;
  38. gfam->family.num_nodes++;
  39. }
  40. FT_EXPORT_DEF( void )
  41. ftc_glyph_node_done( FTC_GlyphNode gnode,
  42. FTC_Cache cache )
  43. {
  44. /* finalize the node */
  45. gnode->item_count = 0;
  46. gnode->item_start = 0;
  47. ftc_node_done( FTC_NODE( gnode ), cache );
  48. }
  49. FT_EXPORT_DEF( FT_Bool )
  50. ftc_glyph_node_compare( FTC_GlyphNode gnode,
  51. FTC_GlyphQuery gquery )
  52. {
  53. FT_UInt start = (FT_UInt)gnode->item_start;
  54. FT_UInt count = (FT_UInt)gnode->item_count;
  55. return FT_BOOL( (FT_UInt)( gquery->gindex - start ) < count );
  56. }
  57. /*************************************************************************/
  58. /*************************************************************************/
  59. /***** *****/
  60. /***** CHUNK SETS *****/
  61. /***** *****/
  62. /*************************************************************************/
  63. /*************************************************************************/
  64. FT_EXPORT_DEF( FT_Error )
  65. ftc_glyph_family_init( FTC_GlyphFamily gfam,
  66. FT_UInt32 hash,
  67. FT_UInt item_count,
  68. FT_UInt item_total,
  69. FTC_GlyphQuery gquery,
  70. FTC_Cache cache )
  71. {
  72. FT_Error error;
  73. error = ftc_family_init( FTC_FAMILY( gfam ), FTC_QUERY( gquery ), cache );
  74. if ( !error )
  75. {
  76. gfam->hash = hash;
  77. gfam->item_total = item_total;
  78. gfam->item_count = item_count;
  79. FTC_GLYPH_FAMILY_FOUND( gfam, gquery );
  80. }
  81. return error;
  82. }
  83. FT_EXPORT_DEF( void )
  84. ftc_glyph_family_done( FTC_GlyphFamily gfam )
  85. {
  86. ftc_family_done( FTC_FAMILY( gfam ) );
  87. }
  88. /* END */