Werner Lemberg | eddd990 | 2000-10-12 05:05:40 +0000 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | /* */ |
| 3 | /* ftcimage.c */ |
| 4 | /* */ |
| 5 | /* FreeType Image cache (body). */ |
| 6 | /* */ |
David Turner | ece6379 | 2000-10-28 23:34:45 +0000 | [diff] [blame^] | 7 | /* Each image cache really manages FT_Glyph objects :-) */ |
| 8 | /* */ |
| 9 | /* */ |
Werner Lemberg | eddd990 | 2000-10-12 05:05:40 +0000 | [diff] [blame] | 10 | /* Copyright 2000 by */ |
| 11 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 12 | /* */ |
| 13 | /* This file is part of the FreeType project, and may only be used, */ |
| 14 | /* modified, and distributed under the terms of the FreeType project */ |
| 15 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 16 | /* this file you indicate that you have read the license and */ |
| 17 | /* understand and accept it fully. */ |
| 18 | /* */ |
| 19 | /***************************************************************************/ |
| 20 | |
| 21 | |
David Turner | b466a76 | 2000-08-23 11:22:30 +0000 | [diff] [blame] | 22 | #ifndef FTCIMAGE_H |
| 23 | #define FTCIMAGE_H |
| 24 | |
Werner Lemberg | eddd990 | 2000-10-12 05:05:40 +0000 | [diff] [blame] | 25 | |
David Turner | ebdce83 | 2000-09-19 01:11:11 +0000 | [diff] [blame] | 26 | #include <freetype/cache/ftcglyph.h> |
David Turner | 9b8f5c4 | 2000-10-28 07:26:59 +0000 | [diff] [blame] | 27 | #include <freetype/ftglyph.h> |
Werner Lemberg | 8728f29 | 2000-08-23 17:32:42 +0000 | [diff] [blame] | 28 | |
Werner Lemberg | eddd990 | 2000-10-12 05:05:40 +0000 | [diff] [blame] | 29 | #ifdef __cplusplus |
| 30 | extern "C" { |
| 31 | #endif |
| 32 | |
David Turner | ece6379 | 2000-10-28 23:34:45 +0000 | [diff] [blame^] | 33 | |
| 34 | /*************************************************************************/ |
| 35 | /*************************************************************************/ |
| 36 | /*************************************************************************/ |
| 37 | /***** *****/ |
| 38 | /***** IMAGE CACHE OBJECT *****/ |
| 39 | /***** *****/ |
| 40 | /*************************************************************************/ |
| 41 | /*************************************************************************/ |
| 42 | /*************************************************************************/ |
| 43 | |
| 44 | |
| 45 | #define FTC_IMAGE_FORMAT( x ) ( (x) & 7 ) |
| 46 | |
| 47 | /*************************************************************************/ |
| 48 | /* */ |
| 49 | /* <Enum> */ |
| 50 | /* FTC_Image_Type */ |
| 51 | /* */ |
| 52 | /* <Description> */ |
| 53 | /* An enumeration used to list the types of glyph images found in a */ |
| 54 | /* glyph image cache. */ |
| 55 | /* */ |
| 56 | /* <Fields> */ |
| 57 | /* ftc_image_mono :: Monochrome bitmap glyphs. */ |
| 58 | /* */ |
| 59 | /* ftc_image_grays :: Anti-aliased bitmap glyphs. */ |
| 60 | /* */ |
| 61 | /* ftc_image_outline :: Scaled (and hinted) outline glyphs. */ |
| 62 | /* */ |
| 63 | /* ftc_master_outline :: Unscaled original outline glyphs. */ |
| 64 | /* */ |
| 65 | /* <Note> */ |
| 66 | /* Other types may be defined in the future. */ |
| 67 | /* */ |
| 68 | typedef enum FTC_Image_Type_ |
David Turner | 9b8f5c4 | 2000-10-28 07:26:59 +0000 | [diff] [blame] | 69 | { |
David Turner | ece6379 | 2000-10-28 23:34:45 +0000 | [diff] [blame^] | 70 | ftc_image_format_bitmap = 0, |
| 71 | ftc_image_format_outline = 1, |
David Turner | 9b8f5c4 | 2000-10-28 07:26:59 +0000 | [diff] [blame] | 72 | |
David Turner | ece6379 | 2000-10-28 23:34:45 +0000 | [diff] [blame^] | 73 | ftc_image_flag_monochrome = 16, |
| 74 | ftc_image_flag_unhinted = 32, |
| 75 | ftc_image_flag_autohinted = 64, |
| 76 | ftc_image_flag_unscaled = 128, |
| 77 | ftc_image_flag_no_sbits = 256, |
| 78 | |
| 79 | ftc_image_mono = ftc_image_format_bitmap | |
| 80 | ftc_image_flag_monochrome, /* monochrome bitmap */ |
| 81 | ftc_image_grays = ftc_image_format_bitmap, /* anti-aliased bitmap */ |
| 82 | ftc_image_outline = ftc_image_format_outline /* scaled outline */ |
| 83 | |
| 84 | } FTC_Image_Type; |
David Turner | 9b8f5c4 | 2000-10-28 07:26:59 +0000 | [diff] [blame] | 85 | |
Werner Lemberg | eddd990 | 2000-10-12 05:05:40 +0000 | [diff] [blame] | 86 | |
David Turner | ece6379 | 2000-10-28 23:34:45 +0000 | [diff] [blame^] | 87 | /*************************************************************************/ |
| 88 | /* */ |
| 89 | /* <Struct> */ |
| 90 | /* FTC_Image_Desc */ |
| 91 | /* */ |
| 92 | /* <Description> */ |
| 93 | /* A simple structure used to describe a given glyph image category. */ |
| 94 | /* */ |
| 95 | /* <Fields> */ |
| 96 | /* size :: An FTC_SizeRec used to describe the glyph's face & */ |
| 97 | /* size. */ |
| 98 | /* */ |
| 99 | /* image_type :: The glyph image's type. */ |
| 100 | /* */ |
| 101 | typedef struct FTC_Image_Desc_ |
David Turner | ebdce83 | 2000-09-19 01:11:11 +0000 | [diff] [blame] | 102 | { |
David Turner | ece6379 | 2000-10-28 23:34:45 +0000 | [diff] [blame^] | 103 | FTC_FontRec font; |
| 104 | FT_UInt image_type; |
| 105 | |
| 106 | } FTC_Image_Desc; |
Werner Lemberg | 8728f29 | 2000-08-23 17:32:42 +0000 | [diff] [blame] | 107 | |
Werner Lemberg | eddd990 | 2000-10-12 05:05:40 +0000 | [diff] [blame] | 108 | |
David Turner | ece6379 | 2000-10-28 23:34:45 +0000 | [diff] [blame^] | 109 | /*************************************************************************/ |
| 110 | /* */ |
| 111 | /* <Type> */ |
| 112 | /* FTC_Image_Cache */ |
| 113 | /* */ |
| 114 | /* <Description> */ |
| 115 | /* A handle to an glyph image cache object. They are designed to */ |
| 116 | /* hold many distinct glyph images, while not exceeding a certain */ |
| 117 | /* memory threshold. */ |
| 118 | /* */ |
| 119 | typedef struct FTC_Image_CacheRec_* FTC_Image_Cache; |
| 120 | |
| 121 | |
| 122 | /*************************************************************************/ |
| 123 | /* */ |
| 124 | /* <Function> */ |
| 125 | /* FTC_Image_Cache_New */ |
| 126 | /* */ |
| 127 | /* <Description> */ |
| 128 | /* Creates a new glyph image cache. */ |
| 129 | /* */ |
| 130 | /* <Input> */ |
| 131 | /* manager :: The parent manager for the image cache. */ |
| 132 | /* */ |
| 133 | /* <Output> */ |
| 134 | /* acache :: A handle to the new glyph image cache object. */ |
| 135 | /* */ |
| 136 | /* <Return> */ |
| 137 | /* FreeType error code. 0 means success. */ |
| 138 | /* */ |
| 139 | FT_EXPORT_DEF( FT_Error ) FTC_Image_Cache_New( FTC_Manager manager, |
| 140 | FTC_Image_Cache* acache ); |
| 141 | |
| 142 | |
| 143 | /*************************************************************************/ |
| 144 | /* */ |
| 145 | /* <Function> */ |
| 146 | /* FTC_Image_Cache_Lookup */ |
| 147 | /* */ |
| 148 | /* <Description> */ |
| 149 | /* Retrieves a given glyph image from a glyph image cache. */ |
| 150 | /* */ |
| 151 | /* <Input> */ |
| 152 | /* cache :: A handle to the source glyph image cache. */ |
| 153 | /* */ |
| 154 | /* desc :: A pointer to a glyph image descriptor. */ |
| 155 | /* */ |
| 156 | /* gindex :: The glyph index to retrieve. */ |
| 157 | /* */ |
| 158 | /* <Output> */ |
| 159 | /* aglyph :: The corresponding FT_Glyph object. 0 in case of */ |
| 160 | /* failure. */ |
| 161 | /* */ |
| 162 | /* <Return> */ |
| 163 | /* error code, 0 means success */ |
| 164 | /* */ |
| 165 | /* <Note> */ |
| 166 | /* the returned glyph is owned and manager by the glyph image cache. */ |
| 167 | /* Never try to transform or discard it manually! You can however */ |
| 168 | /* create a copy with FT_Glyph_Copy() and modify the new one. */ |
| 169 | /* */ |
| 170 | /* Because the glyph image cache limits the total amount of memory */ |
| 171 | /* taken by the glyphs it holds, the returned glyph might disappear */ |
| 172 | /* on a later invocation of this function! It's a cache after all... */ |
| 173 | /* */ |
| 174 | FT_EXPORT_DEF( FT_Error ) |
| 175 | FTC_Image_Cache_Lookup( FTC_Image_Cache cache, |
| 176 | FTC_Image_Desc* desc, |
| 177 | FT_UInt gindex, |
| 178 | FT_Glyph* aglyph ); |
| 179 | |
David Turner | b466a76 | 2000-08-23 11:22:30 +0000 | [diff] [blame] | 180 | |
Werner Lemberg | eddd990 | 2000-10-12 05:05:40 +0000 | [diff] [blame] | 181 | |
| 182 | #ifdef __cplusplus |
| 183 | } |
| 184 | #endif |
| 185 | |
| 186 | |
David Turner | b466a76 | 2000-08-23 11:22:30 +0000 | [diff] [blame] | 187 | #endif /* FTCIMAGE_H */ |
Werner Lemberg | 8728f29 | 2000-08-23 17:32:42 +0000 | [diff] [blame] | 188 | |
Werner Lemberg | eddd990 | 2000-10-12 05:05:40 +0000 | [diff] [blame] | 189 | |
| 190 | /* END */ |