OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ftadvanc.c */ | 3 /* ftadvanc.c */ |
4 /* */ | 4 /* */ |
5 /* Quick computation of advance widths (body). */ | 5 /* Quick computation of advance widths (body). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 2008, 2009, 2011, 2013 by */ | 7 /* Copyright 2008, 2009, 2011, 2013, 2014 by */ |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
9 /* */ | 9 /* */ |
10 /* This file is part of the FreeType project, and may only be used, */ | 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 */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
15 /* */ | 15 /* */ |
16 /***************************************************************************/ | 16 /***************************************************************************/ |
17 | 17 |
18 | 18 |
19 #include "../../include/ft2build.h" | 19 #include <ft2build.h> |
20 #include "../../include/freetype/internal/ftdebug.h" | 20 #include FT_INTERNAL_DEBUG_H |
21 | 21 |
22 #include "../../include/freetype/ftadvanc.h" | 22 #include FT_ADVANCES_H |
23 #include "../../include/freetype/internal/ftobjs.h" | 23 #include FT_INTERNAL_OBJECTS_H |
24 | 24 |
25 | 25 |
26 static FT_Error | 26 static FT_Error |
27 _ft_face_scale_advances( FT_Face face, | 27 _ft_face_scale_advances( FT_Face face, |
28 FT_Fixed* advances, | 28 FT_Fixed* advances, |
29 FT_UInt count, | 29 FT_UInt count, |
30 FT_Int32 flags ) | 30 FT_Int32 flags ) |
31 { | 31 { |
32 FT_Fixed scale; | 32 FT_Fixed scale; |
33 FT_UInt nn; | 33 FT_UInt nn; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 FT_UInt gindex, | 73 FT_UInt gindex, |
74 FT_Int32 flags, | 74 FT_Int32 flags, |
75 FT_Fixed *padvance ) | 75 FT_Fixed *padvance ) |
76 { | 76 { |
77 FT_Face_GetAdvancesFunc func; | 77 FT_Face_GetAdvancesFunc func; |
78 | 78 |
79 | 79 |
80 if ( !face ) | 80 if ( !face ) |
81 return FT_THROW( Invalid_Face_Handle ); | 81 return FT_THROW( Invalid_Face_Handle ); |
82 | 82 |
| 83 if ( !padvance ) |
| 84 return FT_THROW( Invalid_Argument ); |
| 85 |
83 if ( gindex >= (FT_UInt)face->num_glyphs ) | 86 if ( gindex >= (FT_UInt)face->num_glyphs ) |
84 return FT_THROW( Invalid_Glyph_Index ); | 87 return FT_THROW( Invalid_Glyph_Index ); |
85 | 88 |
86 func = face->driver->clazz->get_advances; | 89 func = face->driver->clazz->get_advances; |
87 if ( func && LOAD_ADVANCE_FAST_CHECK( flags ) ) | 90 if ( func && LOAD_ADVANCE_FAST_CHECK( flags ) ) |
88 { | 91 { |
89 FT_Error error; | 92 FT_Error error; |
90 | 93 |
91 | 94 |
92 error = func( face, gindex, 1, flags, padvance ); | 95 error = func( face, gindex, 1, flags, padvance ); |
(...skipping 18 matching lines...) Expand all Loading... |
111 FT_Fixed *padvances ) | 114 FT_Fixed *padvances ) |
112 { | 115 { |
113 FT_Face_GetAdvancesFunc func; | 116 FT_Face_GetAdvancesFunc func; |
114 FT_UInt num, end, nn; | 117 FT_UInt num, end, nn; |
115 FT_Error error = FT_Err_Ok; | 118 FT_Error error = FT_Err_Ok; |
116 | 119 |
117 | 120 |
118 if ( !face ) | 121 if ( !face ) |
119 return FT_THROW( Invalid_Face_Handle ); | 122 return FT_THROW( Invalid_Face_Handle ); |
120 | 123 |
| 124 if ( !padvances ) |
| 125 return FT_THROW( Invalid_Argument ); |
| 126 |
121 num = (FT_UInt)face->num_glyphs; | 127 num = (FT_UInt)face->num_glyphs; |
122 end = start + count; | 128 end = start + count; |
123 if ( start >= num || end < start || end > num ) | 129 if ( start >= num || end < start || end > num ) |
124 return FT_THROW( Invalid_Glyph_Index ); | 130 return FT_THROW( Invalid_Glyph_Index ); |
125 | 131 |
126 if ( count == 0 ) | 132 if ( count == 0 ) |
127 return FT_Err_Ok; | 133 return FT_Err_Ok; |
128 | 134 |
129 func = face->driver->clazz->get_advances; | 135 func = face->driver->clazz->get_advances; |
130 if ( func && LOAD_ADVANCE_FAST_CHECK( flags ) ) | 136 if ( func && LOAD_ADVANCE_FAST_CHECK( flags ) ) |
(...skipping 22 matching lines...) Expand all Loading... |
153 padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT ) | 159 padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT ) |
154 ? face->glyph->advance.y << 10 | 160 ? face->glyph->advance.y << 10 |
155 : face->glyph->advance.x << 10; | 161 : face->glyph->advance.x << 10; |
156 } | 162 } |
157 | 163 |
158 return error; | 164 return error; |
159 } | 165 } |
160 | 166 |
161 | 167 |
162 /* END */ | 168 /* END */ |
OLD | NEW |