ooops. Add missing files
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
diff --git a/include/freetype/ftadvanc.h b/include/freetype/ftadvanc.h
new file mode 100644
index 0000000..02befa1
--- /dev/null
+++ b/include/freetype/ftadvanc.h
@@ -0,0 +1,131 @@
+/***************************************************************************/
+/* */
+/* ftadvanc.h */
+/* */
+/* FreeType access the glyph advances (specification only). */
+/* */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+#ifndef __FREETYPE_ADVANCE_H__
+#define __FREETYPE_ADVANCE_H__
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+ /*************************************************************************/
+ /* */
+ /* <Const> */
+ /* FT_ADVANCE_FLAG_FAST_ONLY */
+ /* */
+ /* <Description> */
+ /* a bit-flag to be or-ed to the 'flags' parameter of the */
+ /* @FT_Get_Advance and @FT_Get_Advances. */
+ /* */
+ /* when set, it indicates that you want these functions to fail */
+ /* if the corresponding hinting mode or font driver doesn't */
+ /* allow for very quick advance computation. */
+ /* */
+ /* typically, unscaled, unhinted, bitmapped and light-hinted glyphs */
+ /* can have their advance width(s) computed very quickly. */
+ /* */
+ /* not so for normal and bytecode hinted modes, which require */
+ /* loading/scaling/hinting the glyph outline instead, which is */
+ /* extremely slow by comparison */
+ /* */
+#define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000U
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Advance */
+ /* */
+ /* <Description> */
+ /* Retrieve the advance of a given glyph outline in a @FT_Face. */
+ /* by default, the unhinted advance is returned in font units */
+ /* */
+ /* <Input> */
+ /* face :: source @FT_Face handle */
+ /* gindex :: glyph index */
+ /* load_flags :: a set of bit-flags similar to those used */
+ /* when calling @FT_Load_Glyph, used to determine */
+ /* what kind of advances you need. */
+ /* <Output> */
+ /* padvance :: the advance value, in either font units or 16.16 */
+ /* format. */
+ /* */
+ /* if @FT_LOAD_VERTICAL_LAYOUT is set, this is the */
+ /* vertical advance corresponding to a vertical layout. */
+ /* otherwise, it's the horizontal advance in an */
+ /* horizontal layout. */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */
+ /* if the corresponding's font backend doesn't have a quick way to */
+ /* retrieve the advances. */
+ /* */
+ /* A scaled advance is returned in 16.16 format, but isn't */
+ /* transformed by the affine transform specified by @FT_Set_Transform */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Get_Advance( FT_Face face,
+ FT_UInt gindex,
+ FT_UInt load_flags,
+ FT_Fixed *padvance );
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Advances */
+ /* */
+ /* <Description> */
+ /* Retrieve the advance of several glyph outlines in a @FT_Face. */
+ /* by default, the unhinted advances are returned in font units */
+ /* */
+ /* <Input> */
+ /* face :: source @FT_Face handle */
+ /* start :: first glyph index */
+ /* count :: number of advances you want to retrieve */
+ /* load_flags :: a set of bit-flags similar to those used when */
+ /* calling @FT_Load_Glyph. */
+ /* */
+ /* <Output> */
+ /* padvance :: the advances, in either font units or 16.16 format. */
+ /* this array must contain at least 'count' elements */
+ /* */
+ /* if @FT_LOAD_VERTICAL_LAYOUT is set, these are the */
+ /* vertical advances corresponding to a vertical layout. */
+ /* otherwise, they are the horizontal advances in an */
+ /* horizontal layout. */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */
+ /* if the corresponding's font backend doesn't have a quick way to */
+ /* retrieve the advances. */
+ /* */
+ /* Scaled advances are returned in 16.16 format, but aren't */
+ /* transformed by the affine transform specified by @FT_Set_Transform */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Get_Advances( FT_Face face,
+ FT_UInt start,
+ FT_UInt count,
+ FT_UInt load_flags,
+ FT_Fixed *padvances );
+
+/* */
+
+#endif /* __FREETYPE_ADVANCE_H__ */
diff --git a/src/base/ftadvanc.c b/src/base/ftadvanc.c
new file mode 100644
index 0000000..626a0cf
--- /dev/null
+++ b/src/base/ftadvanc.c
@@ -0,0 +1,127 @@
+#include <ft2build.h>
+#include FT_ADVANCES_H
+#include FT_INTERNAL_OBJECTS_H
+
+ static FT_Error
+ _ft_face_scale_advances( FT_Face face,
+ FT_Fixed* advances,
+ FT_UInt count,
+ FT_UInt flags )
+ {
+ FT_Fixed scale;
+ FT_UInt nn;
+
+ if ( (flags & FT_LOAD_NO_SCALE) )
+ return FT_Err_Ok;
+
+ if ( face->size == NULL )
+ return FT_Err_Invalid_Size_Handle;
+
+ if ( !(flags & FT_LOAD_VERTICAL_LAYOUT) )
+ scale = face->size->metrics.x_scale;
+ else
+ scale = face->size->metrics.y_scale;
+
+ /* this must be the same computation than to get linearHori/VertAdvance
+ * (see FT_Load_Glyph() implementation in src/base/ftobjs.c */
+ for (nn = 0; nn < count; nn++)
+ advances[nn] = FT_MulDiv( advances[nn], scale, 64 );
+
+ return 0;
+ }
+
+
+/* at the moment, we can perform fast advance retrieval only in
+ the following cases:
+
+ - unscaled load
+ - unhinted load
+ - light-hinted load
+ */
+#define LOAD_ADVANCE_FAST_CHECK(flags) \
+ (((flags & (FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING)) != 0) || \
+ FT_LOAD_TARGET_MODE(flags) == FT_RENDER_MODE_LIGHT)
+
+ FT_EXPORT_DEF(FT_Error)
+ FT_Get_Advance( FT_Face face,
+ FT_UInt gindex,
+ FT_UInt flags,
+ FT_Fixed *padvance )
+ {
+ FT_Face_GetAdvancesFunc func;
+
+ if ( !face )
+ return FT_Err_Invalid_Face_Handle;
+
+ if (gindex >= (FT_UInt) face->num_glyphs )
+ return FT_Err_Invalid_Glyph_Index;
+
+ func = face->driver->clazz->get_advances;
+ if (func != NULL && LOAD_ADVANCE_FAST_CHECK(flags))
+ {
+ FT_Error error;
+
+ error = func( face, gindex, 1, flags, padvance );
+ if (!error)
+ return _ft_face_scale_advances( face, padvance, 1, flags );
+
+ if (error != FT_Err_Unimplemented_Feature)
+ return error;
+ }
+
+ return FT_Get_Advances( face, gindex, 1, flags, padvance );
+ }
+
+
+ FT_EXPORT_DEF(FT_Error)
+ FT_Get_Advances( FT_Face face,
+ FT_UInt start,
+ FT_UInt count,
+ FT_UInt flags,
+ FT_Fixed *padvances )
+ {
+ FT_Face_GetAdvancesFunc func;
+ FT_UInt num, end, nn;
+ FT_Error error = 0;
+
+ if ( !face )
+ return FT_Err_Invalid_Face_Handle;
+
+ num = (FT_UInt) face->num_glyphs;
+ end = start + count;
+ if (start >= num || end < start || end > num)
+ return FT_Err_Invalid_Glyph_Index;
+
+ if (count == 0)
+ return FT_Err_Ok;
+
+ func = face->driver->clazz->get_advances;
+ if (func != NULL && LOAD_ADVANCE_FAST_CHECK(flags))
+ {
+ error = func( face, start, count, flags, padvances );
+ if (!error) goto Exit;
+
+ if (error != FT_Err_Unimplemented_Feature)
+ return error;
+ }
+
+ error = 0;
+
+ if ((flags & FT_ADVANCE_FLAG_FAST_ONLY) != 0)
+ return FT_Err_Unimplemented_Feature;
+
+ flags |= FT_LOAD_ADVANCE_ONLY;
+ for (nn = 0; nn < count; nn++)
+ {
+ error = FT_Load_Glyph( face, start+nn, flags );
+ if (error) break;
+
+ padvances[nn] = (flags & FT_LOAD_VERTICAL_LAYOUT)
+ ? face->glyph->advance.x
+ : face->glyph->advance.y;
+ }
+ if (error) return error;
+
+ Exit:
+ return _ft_face_scale_advances( face, padvances, count, flags );
+ }