w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ftglyph.h File Reference
#include <freetype/freetype.h>
Include dependency graph for ftglyph.h:

Go to the source code of this file.

Classes

struct  FT_GlyphRec_
 
struct  FT_BitmapGlyphRec_
 
struct  FT_OutlineGlyphRec_
 

Macros

#define ft_glyph_bbox_unscaled   FT_GLYPH_BBOX_UNSCALED
 
#define ft_glyph_bbox_subpixels   FT_GLYPH_BBOX_SUBPIXELS
 
#define ft_glyph_bbox_gridfit   FT_GLYPH_BBOX_GRIDFIT
 
#define ft_glyph_bbox_truncate   FT_GLYPH_BBOX_TRUNCATE
 
#define ft_glyph_bbox_pixels   FT_GLYPH_BBOX_PIXELS
 

Typedefs

typedef typedefFT_BEGIN_HEADER struct FT_Glyph_Class_ FT_Glyph_Class
 
typedef struct FT_GlyphRec_FT_Glyph
 
typedef struct FT_GlyphRec_ FT_GlyphRec
 
typedef struct FT_BitmapGlyphRec_FT_BitmapGlyph
 
typedef struct FT_BitmapGlyphRec_ FT_BitmapGlyphRec
 
typedef struct FT_OutlineGlyphRec_FT_OutlineGlyph
 
typedef struct FT_OutlineGlyphRec_ FT_OutlineGlyphRec
 
typedef enum FT_Glyph_BBox_Mode_ FT_Glyph_BBox_Mode
 

Enumerations

enum  FT_Glyph_BBox_Mode_ {
  FT_GLYPH_BBOX_UNSCALED = 0 , FT_GLYPH_BBOX_SUBPIXELS = 0 , FT_GLYPH_BBOX_GRIDFIT = 1 , FT_GLYPH_BBOX_TRUNCATE = 2 ,
  FT_GLYPH_BBOX_PIXELS = 3 , FT_GLYPH_BBOX_UNSCALED = 0 , FT_GLYPH_BBOX_SUBPIXELS = 0 , FT_GLYPH_BBOX_GRIDFIT = 1 ,
  FT_GLYPH_BBOX_TRUNCATE = 2 , FT_GLYPH_BBOX_PIXELS = 3
}
 

Functions

 FT_New_Glyph (FT_Library library, FT_Glyph_Format format, FT_Glyph *aglyph)
 
 FT_Get_Glyph (FT_GlyphSlot slot, FT_Glyph *aglyph)
 
 FT_Glyph_Copy (FT_Glyph source, FT_Glyph *target)
 
 FT_Glyph_Transform (FT_Glyph glyph, FT_Matrix *matrix, FT_Vector *delta)
 
 FT_Glyph_Get_CBox (FT_Glyph glyph, FT_UInt bbox_mode, FT_BBox *acbox)
 
 FT_Glyph_To_Bitmap (FT_Glyph *the_glyph, FT_Render_Mode render_mode, FT_Vector *origin, FT_Bool destroy)
 
 FT_Done_Glyph (FT_Glyph glyph)
 
 FT_Matrix_Multiply (const FT_Matrix *a, FT_Matrix *b)
 
 FT_Matrix_Invert (FT_Matrix *matrix)
 

Macro Definition Documentation

◆ ft_glyph_bbox_gridfit

#define ft_glyph_bbox_gridfit   FT_GLYPH_BBOX_GRIDFIT

Definition at line 384 of file ftglyph.h.

◆ ft_glyph_bbox_pixels

#define ft_glyph_bbox_pixels   FT_GLYPH_BBOX_PIXELS

Definition at line 386 of file ftglyph.h.

◆ ft_glyph_bbox_subpixels

#define ft_glyph_bbox_subpixels   FT_GLYPH_BBOX_SUBPIXELS

Definition at line 383 of file ftglyph.h.

◆ ft_glyph_bbox_truncate

#define ft_glyph_bbox_truncate   FT_GLYPH_BBOX_TRUNCATE

Definition at line 385 of file ftglyph.h.

◆ ft_glyph_bbox_unscaled

#define ft_glyph_bbox_unscaled   FT_GLYPH_BBOX_UNSCALED

Definition at line 382 of file ftglyph.h.

Typedef Documentation

◆ FT_BitmapGlyph

@type: FT_BitmapGlyph

@description: A handle to an object used to model a bitmap glyph image. This is a sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec.

Definition at line 131 of file ftglyph.h.

◆ FT_BitmapGlyphRec

◆ FT_Glyph

typedef struct FT_GlyphRec_* FT_Glyph

@type: FT_Glyph

@description: Handle to an object used to model generic glyph images. It is a pointer to the @FT_GlyphRec structure and can contain a glyph bitmap or pointer.

Note
: Glyph objects are not owned by the library. You must thus release them manually (through @FT_Done_Glyph) before calling @FT_Done_FreeType.

Definition at line 87 of file ftglyph.h.

◆ FT_Glyph_BBox_Mode

◆ FT_Glyph_Class

typedef typedefFT_BEGIN_HEADER struct FT_Glyph_Class_ FT_Glyph_Class

ftglyph.h

FreeType convenience functions to handle glyphs (specification).

Copyright (C) 1996-2020 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 are 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.

Definition at line 45 of file ftglyph.h.

◆ FT_GlyphRec

typedef struct FT_GlyphRec_ FT_GlyphRec

◆ FT_OutlineGlyph

@type: FT_OutlineGlyph

@description: A handle to an object used to model an outline glyph image. This is a sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec.

Definition at line 186 of file ftglyph.h.

◆ FT_OutlineGlyphRec

Enumeration Type Documentation

◆ FT_Glyph_BBox_Mode_

Enumerator
FT_GLYPH_BBOX_UNSCALED 
FT_GLYPH_BBOX_SUBPIXELS 
FT_GLYPH_BBOX_GRIDFIT 
FT_GLYPH_BBOX_TRUNCATE 
FT_GLYPH_BBOX_PIXELS 
FT_GLYPH_BBOX_UNSCALED 
FT_GLYPH_BBOX_SUBPIXELS 
FT_GLYPH_BBOX_GRIDFIT 
FT_GLYPH_BBOX_TRUNCATE 
FT_GLYPH_BBOX_PIXELS 

Definition at line 369 of file ftglyph.h.

Function Documentation

◆ FT_Done_Glyph()

FT_Done_Glyph ( FT_Glyph  glyph)

@function: FT_Done_Glyph

@description: Destroy a given glyph.

@input: glyph :: A handle to the target glyph object.

Definition at line 641 of file ftglyph.c.

References FT_FREE.

Referenced by FT_Glyph_Stroke(), FT_Glyph_StrokeBorder(), ftc_inode_free(), XeTeXFontInst::getGlyphBounds(), and SplashFTFont::getGlyphPath().

◆ FT_Get_Glyph()

FT_Get_Glyph ( FT_GlyphSlot  slot,
FT_Glyph aglyph 
)

@function: FT_Get_Glyph

@description: A function used to extract a glyph image from a slot. Note that the created @FT_Glyph object must be released with @FT_Done_Glyph.

@input: slot :: A handle to the source glyph slot.

@output: aglyph :: A handle to the glyph object.

Returns
: FreeType error code. 0~means success.
Note
: Because *aglyph->advance.x and *aglyph->advance.y are 16.16 fixed-point numbers, slot->advance.x and slot->advance.y (which are in 26.6 fixed-point format) must be in the range ]-32768;32768[.

Definition at line 401 of file ftglyph.c.

References error, Exit(), FT_Done_Glyph(), FT_ERROR, FT_New_Glyph(), FT_THROW, glyph, slot, glyph::x, and glyph::y.

Referenced by ftc_basic_family_load_glyph(), XeTeXFontInst::getGlyphBounds(), and SplashFTFont::getGlyphPath().

◆ FT_Glyph_Copy()

FT_Glyph_Copy ( FT_Glyph  source,
FT_Glyph target 
)

@function: FT_Glyph_Copy

@description: A function used to copy a glyph image. Note that the created @FT_Glyph object must be released with @FT_Done_Glyph.

@input: source :: A handle to the source glyph object.

@output: target :: A handle to the target glyph object. 0~in case of error.

Returns
: FreeType error code. 0~means success.

Definition at line 316 of file ftglyph.c.

References copy(), error, Exit(), FT_Done_Glyph(), FT_THROW, NULL, and target.

Referenced by FT_Glyph_Stroke(), and FT_Glyph_StrokeBorder().

◆ FT_Glyph_Get_CBox()

FT_Glyph_Get_CBox ( FT_Glyph  glyph,
FT_UInt  bbox_mode,
FT_BBox acbox 
)

@function: FT_Glyph_Get_CBox

@description: Return a glyph's 'control box'. The control box encloses all the outline's points, including Bezier control points. Though it coincides with the exact bounding box for most glyphs, it can be slightly larger in some situations (like when rotating an outline that contains Bezier outside arcs).

Computing the control box is very fast, while getting the bounding box can take much more time as it needs to walk over all segments and arcs in the outline. To get the latter, you can use the 'ftbbox' component, which is dedicated to this single task.

@input: glyph :: A handle to the source glyph object.

mode :: The mode that indicates how to interpret the returned bounding box values.

@output: acbox :: The glyph coordinate bounding box. Coordinates are expressed in 1/64th of pixels if it is grid-fitted.

Note
: Coordinates are relative to the glyph origin, using the y~upwards convention.

If the glyph has been loaded with @FT_LOAD_NO_SCALE, bbox_mode must be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font units in 26.6 pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS is another name for this constant.

If the font is tricky and the glyph has been loaded with @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get reasonable values for the CBox it is necessary to load the glyph at a large ppem value (so that the hinting instructions can properly shift and scale the subglyphs), then extracting the CBox, which can be eventually converted back to font units.

Note that the maximum coordinates are exclusive, which means that one can compute the width and height of the glyph image (be it in integer or 26.6 pixels) as:

width = bbox.xMax - bbox.xMin;
height = bbox.yMax - bbox.yMin;
#define width(a)
Definition: aptex-macros.h:198
#define height(a)
Definition: aptex-macros.h:200
Definition: nsfix.c:44

Note also that for 26.6 coordinates, if bbox_mode is set to @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, which corresponds to:

bbox.xMin = FLOOR(bbox.xMin);
bbox.yMin = FLOOR(bbox.yMin);
bbox.xMax = CEILING(bbox.xMax);
bbox.yMax = CEILING(bbox.yMax);
#define FLOOR(x)
Definition: ftraster.c:449
#define CEILING(x)
Definition: ftraster.c:450

To get the bbox in pixel coordinates, set bbox_mode to @FT_GLYPH_BBOX_TRUNCATE.

To get the bbox in grid-fitted pixel coordinates, set bbox_mode to @FT_GLYPH_BBOX_PIXELS.

Definition at line 489 of file ftglyph.c.

References FT_GLYPH_BBOX_GRIDFIT, FT_GLYPH_BBOX_PIXELS, FT_GLYPH_BBOX_TRUNCATE, FT_PIX_CEIL_LONG, FT_PIX_FLOOR, and glyph::xMin.

Referenced by XeTeXFontInst::getGlyphBounds().

◆ FT_Glyph_To_Bitmap()

FT_Glyph_To_Bitmap ( FT_Glyph the_glyph,
FT_Render_Mode  render_mode,
FT_Vector origin,
FT_Bool  destroy 
)

@function: FT_Glyph_To_Bitmap

@description: Convert a given glyph object to a bitmap glyph object.

@inout: the_glyph :: A pointer to a handle to the target glyph.

@input: render_mode :: An enumeration that describes how the data is rendered.

origin :: A pointer to a vector used to translate the glyph image before rendering. Can be~0 (if no translation). The origin is expressed in 26.6 pixels.

destroy :: A boolean that indicates that the original glyph image should be destroyed by this function. It is never destroyed in case of error.

Returns
: FreeType error code. 0~means success.
Note
: This function does nothing if the glyph format isn't scalable.

The glyph image is translated with the origin vector before rendering.

The first parameter is a pointer to an @FT_Glyph handle, that will be replaced by this function (with newly allocated data). Typically, you would use (omitting error handling):

FT_BitmapGlyph glyph_bitmap;
// load glyph
// extract glyph image
// convert to a bitmap (default render mode + destroying old)
if ( glyph->format != FT_GLYPH_FORMAT_BITMAP )
{
0, 1 );
if ( error ) // `glyph' unchanged
...
}
// access bitmap content by typecasting
glyph_bitmap = (FT_BitmapGlyph)glyph;
// do funny stuff with it, like blitting/drawing
...
// discard glyph image (bitmap or not)
FT_Done_Glyph( glyph );
#define error(a)
Definition: dviinfo.c:48
#define FT_LOAD_DEFAULT
Definition: freetype.h:3021
@ FT_RENDER_MODE_NORMAL
Definition: freetype.h:3249
FT_Load_Char(FT_Face face, FT_ULong char_code, FT_Int32 load_flags)
Definition: ftobjs.c:1099
FT_Glyph_To_Bitmap(FT_Glyph *the_glyph, FT_Render_Mode render_mode, FT_Vector *origin, FT_Bool destroy)
Definition: ftglyph.c:536
FT_Get_Glyph(FT_GlyphSlot slot, FT_Glyph *aglyph)
Definition: ftglyph.c:401
struct FT_BitmapGlyphRec_ * FT_BitmapGlyph
Definition: ftglyph.h:131
@ FT_GLYPH_FORMAT_BITMAP
Definition: ftimage.h:748
FT_Face face
Definition: cffdrivr.c:659
#define glyph_index()
FT_GlyphSlot glyph
Definition: freetype.h:1065
Definition: pbmfont.h:4
TT_Glyph glyph
Definition: ttf2pfb.c:162

Here is another example, again without error handling:

...
for ( idx = 0; i < MAX_GLYPHS; i++ )
...
for ( idx = 0; i < MAX_GLYPHS; i++ )
{
...
// after this call, `bitmap' no longer points into
// the `glyphs' array (and the old value isn't destroyed)
...
}
...
for ( idx = 0; i < MAX_GLYPHS; i++ )
void glyphs(int opcode)
Definition: disdvi.c:775
FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: ftobjs.c:796
@ FT_RENDER_MODE_MONO
Definition: freetype.h:3251
FT_Done_Glyph(FT_Glyph glyph)
Definition: ftglyph.c:641
small capitals from c petite p scientific i
Definition: afcover.h:80
FT_UInt idx
Definition: cffcmap.c:135
#define MAX_GLYPHS
Definition: gf2pbm.c:137

Definition at line 536 of file ftglyph.c.

References b, dummy, error, Exit(), ft_bitmap_glyph_init(), FT_Done_Glyph(), FT_Err_Ok, FT_GLYPH, FT_Glyph_Transform(), FT_Render_Glyph_Internal(), FT_THROW, FT_UNUSED, FT_ZERO, glyph, library, NULL, and v.

◆ FT_Glyph_Transform()

FT_Glyph_Transform ( FT_Glyph  glyph,
FT_Matrix matrix,
FT_Vector delta 
)

@function: FT_Glyph_Transform

@description: Transform a glyph image if its format is scalable.

@inout: glyph :: A handle to the target glyph object.

@input: matrix :: A pointer to a 2x2 matrix to apply.

delta :: A pointer to a 2d vector to apply. Coordinates are expressed in 1/64th of a pixel.

Returns
: FreeType error code (if not 0, the glyph format is not scalable).
Note
: The 2x2 transformation matrix is also applied to the glyph's advance vector.

Definition at line 456 of file ftglyph.c.

References delta, error, FT_Err_Ok, FT_THROW, FT_Vector_Transform(), and matrix().

◆ FT_Matrix_Invert()

FT_Matrix_Invert ( FT_Matrix matrix)

@function: FT_Matrix_Invert

@description: Invert a 2x2 matrix. Return an error if it can't be inverted.

@inout: matrix :: A pointer to the target matrix. Remains untouched in case of error.

Returns
: FreeType error code. 0~means success.

Definition at line 688 of file ftcalc.c.

References delta, FT_DivFix(), FT_Err_Ok, FT_MulFix(), FT_Pos, FT_THROW, matrix(), xx, and yy.

Referenced by af_loader_load_glyph().

◆ FT_Matrix_Multiply()

FT_Matrix_Multiply ( const FT_Matrix a,
FT_Matrix b 
)

Definition at line 660 of file ftcalc.c.

References a, ADD_LONG, b, FT_MulFix(), xx, and yy.

◆ FT_New_Glyph()

FT_New_Glyph ( FT_Library  library,
FT_Glyph_Format  format,
FT_Glyph aglyph 
)

@function: FT_New_Glyph

@description: A function used to create a new empty glyph image. Note that the created @FT_Glyph object must be released with @FT_Done_Glyph.

@input: library :: A handle to the FreeType library object.

format :: The format of the glyph's image.

@output: aglyph :: A handle to the glyph object.

Returns
: FreeType error code. 0~means success.
Since
: 2.10

Definition at line 363 of file ftglyph.c.

References format, FT_GLYPH_FORMAT_BITMAP, FT_GLYPH_FORMAT_OUTLINE, FT_Lookup_Renderer(), ft_outline_glyph_class, FT_THROW, library, NULL, and render.