Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /***************************************************************************/ |
michael@0 | 2 | /* */ |
michael@0 | 3 | /* ftgzip.h */ |
michael@0 | 4 | /* */ |
michael@0 | 5 | /* Gzip-compressed stream support. */ |
michael@0 | 6 | /* */ |
michael@0 | 7 | /* Copyright 2002-2004, 2006, 2013 by */ |
michael@0 | 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
michael@0 | 9 | /* */ |
michael@0 | 10 | /* This file is part of the FreeType project, and may only be used, */ |
michael@0 | 11 | /* modified, and distributed under the terms of the FreeType project */ |
michael@0 | 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
michael@0 | 13 | /* this file you indicate that you have read the license and */ |
michael@0 | 14 | /* understand and accept it fully. */ |
michael@0 | 15 | /* */ |
michael@0 | 16 | /***************************************************************************/ |
michael@0 | 17 | |
michael@0 | 18 | |
michael@0 | 19 | #ifndef __FTGZIP_H__ |
michael@0 | 20 | #define __FTGZIP_H__ |
michael@0 | 21 | |
michael@0 | 22 | #include <ft2build.h> |
michael@0 | 23 | #include FT_FREETYPE_H |
michael@0 | 24 | |
michael@0 | 25 | #ifdef FREETYPE_H |
michael@0 | 26 | #error "freetype.h of FreeType 1 has been loaded!" |
michael@0 | 27 | #error "Please fix the directory search order for header files" |
michael@0 | 28 | #error "so that freetype.h of FreeType 2 is found first." |
michael@0 | 29 | #endif |
michael@0 | 30 | |
michael@0 | 31 | |
michael@0 | 32 | FT_BEGIN_HEADER |
michael@0 | 33 | |
michael@0 | 34 | /*************************************************************************/ |
michael@0 | 35 | /* */ |
michael@0 | 36 | /* <Section> */ |
michael@0 | 37 | /* gzip */ |
michael@0 | 38 | /* */ |
michael@0 | 39 | /* <Title> */ |
michael@0 | 40 | /* GZIP Streams */ |
michael@0 | 41 | /* */ |
michael@0 | 42 | /* <Abstract> */ |
michael@0 | 43 | /* Using gzip-compressed font files. */ |
michael@0 | 44 | /* */ |
michael@0 | 45 | /* <Description> */ |
michael@0 | 46 | /* This section contains the declaration of Gzip-specific functions. */ |
michael@0 | 47 | /* */ |
michael@0 | 48 | /*************************************************************************/ |
michael@0 | 49 | |
michael@0 | 50 | |
michael@0 | 51 | /************************************************************************ |
michael@0 | 52 | * |
michael@0 | 53 | * @function: |
michael@0 | 54 | * FT_Stream_OpenGzip |
michael@0 | 55 | * |
michael@0 | 56 | * @description: |
michael@0 | 57 | * Open a new stream to parse gzip-compressed font files. This is |
michael@0 | 58 | * mainly used to support the compressed `*.pcf.gz' fonts that come |
michael@0 | 59 | * with XFree86. |
michael@0 | 60 | * |
michael@0 | 61 | * @input: |
michael@0 | 62 | * stream :: |
michael@0 | 63 | * The target embedding stream. |
michael@0 | 64 | * |
michael@0 | 65 | * source :: |
michael@0 | 66 | * The source stream. |
michael@0 | 67 | * |
michael@0 | 68 | * @return: |
michael@0 | 69 | * FreeType error code. 0~means success. |
michael@0 | 70 | * |
michael@0 | 71 | * @note: |
michael@0 | 72 | * The source stream must be opened _before_ calling this function. |
michael@0 | 73 | * |
michael@0 | 74 | * Calling the internal function `FT_Stream_Close' on the new stream will |
michael@0 | 75 | * *not* call `FT_Stream_Close' on the source stream. None of the stream |
michael@0 | 76 | * objects will be released to the heap. |
michael@0 | 77 | * |
michael@0 | 78 | * The stream implementation is very basic and resets the decompression |
michael@0 | 79 | * process each time seeking backwards is needed within the stream. |
michael@0 | 80 | * |
michael@0 | 81 | * In certain builds of the library, gzip compression recognition is |
michael@0 | 82 | * automatically handled when calling @FT_New_Face or @FT_Open_Face. |
michael@0 | 83 | * This means that if no font driver is capable of handling the raw |
michael@0 | 84 | * compressed file, the library will try to open a gzipped stream from |
michael@0 | 85 | * it and re-open the face with it. |
michael@0 | 86 | * |
michael@0 | 87 | * This function may return `FT_Err_Unimplemented_Feature' if your build |
michael@0 | 88 | * of FreeType was not compiled with zlib support. |
michael@0 | 89 | */ |
michael@0 | 90 | FT_EXPORT( FT_Error ) |
michael@0 | 91 | FT_Stream_OpenGzip( FT_Stream stream, |
michael@0 | 92 | FT_Stream source ); |
michael@0 | 93 | |
michael@0 | 94 | |
michael@0 | 95 | /************************************************************************ |
michael@0 | 96 | * |
michael@0 | 97 | * @function: |
michael@0 | 98 | * FT_Gzip_Uncompress |
michael@0 | 99 | * |
michael@0 | 100 | * @description: |
michael@0 | 101 | * Decompress a zipped input buffer into an output buffer. This function |
michael@0 | 102 | * is modeled after zlib's `uncompress' function. |
michael@0 | 103 | * |
michael@0 | 104 | * @input: |
michael@0 | 105 | * memory :: |
michael@0 | 106 | * A FreeType memory handle. |
michael@0 | 107 | * |
michael@0 | 108 | * input :: |
michael@0 | 109 | * The input buffer. |
michael@0 | 110 | * |
michael@0 | 111 | * input_len :: |
michael@0 | 112 | * The length of the input buffer. |
michael@0 | 113 | * |
michael@0 | 114 | * @output: |
michael@0 | 115 | * output:: |
michael@0 | 116 | * The output buffer. |
michael@0 | 117 | * |
michael@0 | 118 | * @inout: |
michael@0 | 119 | * output_len :: |
michael@0 | 120 | * Before calling the function, this is the the total size of the |
michael@0 | 121 | * output buffer, which must be large enough to hold the entire |
michael@0 | 122 | * uncompressed data (so the size of the uncompressed data must be |
michael@0 | 123 | * known in advance). After calling the function, `output_len' is the |
michael@0 | 124 | * size of the used data in `output'. |
michael@0 | 125 | * |
michael@0 | 126 | * @return: |
michael@0 | 127 | * FreeType error code. 0~means success. |
michael@0 | 128 | * |
michael@0 | 129 | * @note: |
michael@0 | 130 | * This function may return `FT_Err_Unimplemented_Feature' if your build |
michael@0 | 131 | * of FreeType was not compiled with zlib support. |
michael@0 | 132 | */ |
michael@0 | 133 | FT_EXPORT( FT_Error ) |
michael@0 | 134 | FT_Gzip_Uncompress( FT_Memory memory, |
michael@0 | 135 | FT_Byte* output, |
michael@0 | 136 | FT_ULong* output_len, |
michael@0 | 137 | const FT_Byte* input, |
michael@0 | 138 | FT_ULong input_len ); |
michael@0 | 139 | |
michael@0 | 140 | |
michael@0 | 141 | /* */ |
michael@0 | 142 | |
michael@0 | 143 | |
michael@0 | 144 | FT_END_HEADER |
michael@0 | 145 | |
michael@0 | 146 | #endif /* __FTGZIP_H__ */ |
michael@0 | 147 | |
michael@0 | 148 | |
michael@0 | 149 | /* END */ |