Hash :
37379e21
Author :
Date :
2000-03-28T11:22:31
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 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
/***************************************************************************/
/* */
/* ftglyph.h */
/* */
/* FreeType convenience functions to handle glyphs.. */
/* */
/* Copyright 1996-1999 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. */
/* */
/* This file contains the definition of several convenience functions */
/* that can be used by client applications to easily retrieve glyph */
/* bitmaps and outlines from a given face. */
/* */
/* These functions should be optional if you're writing a font server */
/* or text layout engine on top of FreeType. However, they are pretty */
/* handy for many other simple uses of the library.. */
/* */
/***************************************************************************/
#ifndef FTGLYPH_H
#define FTGLYPH_H
#include <freetype.h>
typedef enum {
ft_glyph_type_none = 0,
ft_glyph_type_bitmap = 1,
ft_glyph_type_outline = 2
} FT_GlyphType;
/***********************************************************************
*
* <Struct>
* FT_GlyphRec
*
* <Description>
* The root glyph structure contains a given glyph image's metrics.
* Note that the FT_Glyph type is a pointer to FT_GlyphRec
*
* <Field>
* memory :: a handle to the memory allocator that is used to
* create/clone/destroy this glyph..
*
* glyph_type :: the glyph type..
*
* height :: height of glyph image
* width :: width of glyph image
*
* bearingX :: horizontal bearing, this is the distance from the
* the current pen position to the left of the glyph
*
* bearingY :: vertical bearing, this is the distance from the
* current pen position to the top of the glyph
*
* advance :: this is the horizontal or vertical advance for the
* glyph
*
* <Note>
* the distances expressed in the metrics are expressed in 26.6 fixed
* float sub-pixels (i.e. 1/64th of pixels).
*
* the vertical bearing has a positive value when the glyph top is
* above the baseline, and negative when it is under..
*
***********************************************************************/
typedef struct FT_GlyphRec_
{
FT_Memory memory;
FT_GlyphType glyph_type;
FT_Int height;
FT_Int width;
FT_Int bearingX;
FT_Int bearingY;
FT_Int advance;
} FT_GlyphRec, *FT_Glyph;
/***********************************************************************
*
* <Struct>
* FT_BitmapGlyphRec
*
* <Description>
* A structure used to describe a bitmap glyph image..
* Note that the FT_BitmapGlyph type is a pointer to FT_BitmapGlyphRec
*
* <Field>
* metrics :: the corresponding glyph metrics
* bitmap :: a descriptor for the bitmap.
*
* <Note>
* the "width" and "height" fields of the metrics are expressed in
* 26.6 sub-pixels. However, the width and height in pixels can be
* read directly from "bitmap.width" and "bitmap.height"
*
* this structure is used for both monochrome and anti-aliased
* bitmaps (the bitmap descriptor contains field describing the
* format of the pixel buffer)
*
* the corresponding pixel buffer is always owned by the BitmapGlyph
* and is thus creatde and destroyed with it..
*
***********************************************************************/
typedef struct FT_BitmapGlyphRec_
{
FT_GlyphRec metrics;
FT_Int left;
FT_Int top;
FT_Bitmap bitmap;
} FT_BitmapGlyphRec_, *FT_BitmapGlyph;
/***********************************************************************
*
* <Struct>
* FT_OutlineGlyphRec
*
* <Description>
* A structure used to describe a vectorial outline glyph image..
* Note that the FT_OutlineGlyph type is a pointer to FT_OutlineGlyphRec
*
* <Field>
* metrics :: the corresponding glyph metrics
* outline :: a descriptor for the outline
*
* <Note>
* the "width" and "height" fields of the metrics are expressed in
* 26.6 sub-pixels. However, the width and height in pixels can be
* read directly from "bitmap.width" and "bitmap.rows"
*
* the corresponding outline points tables is always owned by the
* object and are destroyed with it..
*
* an OutlineGlyph can be used to generate a BitmapGlyph with the
* function FT_OutlineGlyph_Render()
*
***********************************************************************/
typedef struct FT_OutlineGlyphRec_
{
FT_GlyphRec metrics;
FT_Outline outline;
} FT_OutlineGlyphRec_, *FT_OutlineGlyph;
/***********************************************************************
*
* <Function>
* FT_Get_Glyph_Bitmap
*
* <Description>
* A function used to directly return a monochrome bitmap glyph image
* from a face.
*
* <Input>
* face :: handle to source face object
* glyph_index :: glyph index in face
* load_flags :: load flags, see FT_LOAD_FLAG_XXXX constants..
* grays :: number of gray levels for anti-aliased bitmaps,
* set to 0 if you want to render a monochrome bitmap
* origin :: a pointer to the origin's position. Set to 0
* if the current transform is the identity..
*
* <Output>
* bitglyph :: pointer to the new bitmap glyph
*
* <Return>
* Error code. 0 means success.
*
* <Note>
* If the font contains glyph outlines, these will be automatically
* converted to a bitmap according to the value of "grays"
*
* If "grays" is set to 0, the result is a 1-bit monochrome bitmap
* otherwise, it is an 8-bit gray-level bitmap
*
* The number of gray levels in the result anti-aliased bitmap might
* not be "grays", depending on the current scan-converter implementation
*
* Note that it is not possible to generate 8-bit monochrome bitmaps
* with this function. Rather, use FT_Get_Glyph_Outline, then
* FT_Glyph_Render_Outline and provide your own span callbacks..
*
* When the face doesn't contain scalable outlines, this function will
* fail if the current transform is not the identity, or if the glyph
* origin's phase to the pixel grid is not 0 in both directions !!
*
***********************************************************************/
EXPORT_DEF
FT_Error FT_Get_Glyph_Bitmap( FT_Face face,
FT_UInt glyph_index,
FT_UInt load_flags,
FT_Int grays,
FT_Vector* origin,
FT_BitmapGlyph *abitglyph );
/***********************************************************************
*
* <Function>
* FT_Get_Glyph_Outline
*
* <Description>
* A function used to directly return a bitmap glyph image from a
* face. This is faster than calling FT_Load_Glyph+FT_Get_Outline_Bitmap..
*
* <Input>
* face :: handle to source face object
* glyph_index :: glyph index in face
* load_flags :: load flags, see FT_LOAD_FLAG_XXXX constants..
*
* <Output>
* vecglyph :: pointer to the new outline glyph
*
* <Return>
* Error code. 0 means success.
*
* <Note>
* If the glyph is not an outline in the face, this function will
* fail..
*
* This function will fail if the load flags FT_LOAD_NO_OUTLINE and
* FT_LOAD_NO_RECURSE are set..
*
***********************************************************************/
EXPORT_DEF
FT_Error FT_Get_Glyph_Outline( FT_Face face,
FT_UInt glyph_index,
FT_UInt load_flags,
FT_OutlineGlyph *vecglyph );
/***********************************************************************
*
* <Function>
* FT_Set_Transform
*
* <Description>
* A function used to set the transform that is applied to glyph images
* just after they're loaded in the face's glyph slot, and before they're
* returned by either FT_Get_Glyph_Bitmap or FT_Get_Glyph_Outline
*
* <Input>
* face :: handle to source face object
* matrix :: pointer to the transform's 2x2 matrix. 0 for identity
* delta :: pointer to the transform's translation. 0 for null vector
*
* <Note>
* The transform is only applied to glyph outlines when they are found
* in a font face. It is unable to transform embedded glyph bitmaps
*
***********************************************************************/
EXPORT_DEF
void FT_Set_Transform( FT_Face face,
FT_Matrix* matrix,
FT_Vector* delta );
/***********************************************************************
*
* <Function>
* FT_Done_Glyph
*
* <Description>
* Destroys a given glyph..
*
* <Input>
* glyph :: handle to target glyph object
*
***********************************************************************/
EXPORT_DEF
void FT_Done_Glyph( FT_Glyph glyph );
/***********************************************************************
*
* <Function>
* FT_Glyph_Get_Box
*
* <Description>
* Returns the glyph image's bounding box in pixels.
*
* <Input>
* glyph :: handle to target glyph object
*
* <Output>
* box :: the glyph bounding box. Coordinates are expressed in
* _integer_ pixels, with exclusive max bounds
*
* <Note>
* Coordinates are relative to the glyph origin, using the Y-upwards
* convention..
*
* The width of the box in pixels is box.xMax-box.xMin
* The height is box.yMax - box.yMin
*
***********************************************************************/
EXPORT_DEF
void FT_Glyph_Get_Box( FT_Glyph glyph,
FT_BBox *box );
#endif /* FTGLYPH_H */