2000-03-28 13:22:31 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ftglyph.c */
|
|
|
|
/* */
|
2000-05-30 18:49:14 +02:00
|
|
|
/* FreeType convenience functions to handle glyphs (body). */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* */
|
2004-01-22 10:07:12 +01:00
|
|
|
/* Copyright 1996-2001, 2002, 2003, 2004 by */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
2000-06-05 07:26:15 +02:00
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* 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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2000-05-30 18:49:14 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_GLYPH_H
|
|
|
|
#include FT_OUTLINE_H
|
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
2000-03-28 13:22:31 +02:00
|
|
|
|
2000-05-30 18:49:14 +02:00
|
|
|
|
2000-06-03 08:03:11 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
|
|
|
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
|
|
|
/* messages during execution. */
|
|
|
|
/* */
|
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_glyph
|
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/**** ****/
|
|
|
|
/**** Convenience functions ****/
|
|
|
|
/**** ****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2000-06-03 08:03:11 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in ftglyph.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
2003-01-14 16:53:33 +01:00
|
|
|
FT_Matrix_Multiply( const FT_Matrix* a,
|
2003-04-23 07:38:13 +02:00
|
|
|
FT_Matrix *b )
|
2000-05-24 02:31:14 +02:00
|
|
|
{
|
2000-07-01 01:12:55 +02:00
|
|
|
FT_Fixed xx, xy, yx, yy;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( !a || !b )
|
|
|
|
return;
|
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
xx = FT_MulFix( a->xx, b->xx ) + FT_MulFix( a->xy, b->yx );
|
|
|
|
xy = FT_MulFix( a->xx, b->xy ) + FT_MulFix( a->xy, b->yy );
|
|
|
|
yx = FT_MulFix( a->yx, b->xx ) + FT_MulFix( a->yy, b->yx );
|
|
|
|
yy = FT_MulFix( a->yx, b->xy ) + FT_MulFix( a->yy, b->yy );
|
2000-05-30 18:49:14 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
b->xx = xx; b->xy = xy;
|
|
|
|
b->yx = yx; b->yy = yy;
|
2000-03-28 13:22:31 +02:00
|
|
|
}
|
|
|
|
|
2000-05-30 18:49:14 +02:00
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in ftglyph.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Matrix_Invert( FT_Matrix* matrix )
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
2000-07-01 01:12:55 +02:00
|
|
|
FT_Pos delta, xx, yy;
|
2000-05-30 18:49:14 +02:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( !matrix )
|
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/* compute discriminant */
|
|
|
|
delta = FT_MulFix( matrix->xx, matrix->yy ) -
|
|
|
|
FT_MulFix( matrix->xy, matrix->yx );
|
2000-05-30 18:49:14 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
if ( !delta )
|
|
|
|
return FT_Err_Invalid_Argument; /* matrix can't be inverted */
|
2000-06-02 02:01:14 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
matrix->xy = - FT_DivFix( matrix->xy, delta );
|
|
|
|
matrix->yx = - FT_DivFix( matrix->yx, delta );
|
2000-06-02 02:01:14 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
xx = matrix->xx;
|
|
|
|
yy = matrix->yy;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
matrix->xx = FT_DivFix( yy, delta );
|
|
|
|
matrix->yy = FT_DivFix( xx, delta );
|
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/**** ****/
|
|
|
|
/**** FT_BitmapGlyph support ****/
|
|
|
|
/**** ****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static FT_Error
|
|
|
|
ft_bitmap_copy( FT_Memory memory,
|
|
|
|
FT_Bitmap* source,
|
|
|
|
FT_Bitmap* target )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Int pitch = source->pitch;
|
|
|
|
FT_ULong size;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
*target = *source;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
if ( pitch < 0 )
|
|
|
|
pitch = -pitch;
|
|
|
|
|
|
|
|
size = (FT_ULong)( pitch * source->rows );
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( !FT_ALLOC( target->buffer, size ) )
|
|
|
|
FT_MEM_COPY( target->buffer, source->buffer, size );
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
return error;
|
2000-07-01 16:06:46 +02:00
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static FT_Error
|
|
|
|
ft_bitmap_glyph_init( FT_BitmapGlyph glyph,
|
|
|
|
FT_GlyphSlot slot )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
2000-07-01 16:06:46 +02:00
|
|
|
FT_Error error = FT_Err_Ok;
|
|
|
|
FT_Library library = FT_GLYPH(glyph)->library;
|
|
|
|
FT_Memory memory = library->memory;
|
|
|
|
|
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
2000-07-01 01:12:55 +02:00
|
|
|
error = FT_Err_Invalid_Glyph_Format;
|
2000-03-28 13:22:31 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/* grab the bitmap in the slot - do lazy copying whenever possible */
|
|
|
|
glyph->bitmap = slot->bitmap;
|
|
|
|
glyph->left = slot->bitmap_left;
|
|
|
|
glyph->top = slot->bitmap_top;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2003-06-18 08:59:57 +02:00
|
|
|
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
|
|
|
|
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
|
2000-07-01 01:12:55 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* copy the bitmap into a new buffer */
|
|
|
|
error = ft_bitmap_copy( memory, &slot->bitmap, &glyph->bitmap );
|
|
|
|
}
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
Exit:
|
|
|
|
return error;
|
2000-07-01 16:06:46 +02:00
|
|
|
}
|
2000-03-28 13:22:31 +02:00
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static FT_Error
|
|
|
|
ft_bitmap_glyph_copy( FT_BitmapGlyph source,
|
|
|
|
FT_BitmapGlyph target )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
FT_Memory memory = source->root.library->memory;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
target->left = source->left;
|
|
|
|
target->top = source->top;
|
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
return ft_bitmap_copy( memory, &source->bitmap, &target->bitmap );
|
2000-07-01 16:06:46 +02:00
|
|
|
}
|
2000-06-29 05:14:25 +02:00
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static void
|
|
|
|
ft_bitmap_glyph_done( FT_BitmapGlyph glyph )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
FT_Memory memory = FT_GLYPH(glyph)->library->memory;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( glyph->bitmap.buffer );
|
2000-07-01 01:12:55 +02:00
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static void
|
|
|
|
ft_bitmap_glyph_bbox( FT_BitmapGlyph glyph,
|
|
|
|
FT_BBox* cbox )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
cbox->xMin = glyph->left << 6;
|
2000-07-01 16:06:46 +02:00
|
|
|
cbox->xMax = cbox->xMin + ( glyph->bitmap.width << 6 );
|
2000-07-01 01:12:55 +02:00
|
|
|
cbox->yMax = glyph->top << 6;
|
2000-10-17 16:29:48 +02:00
|
|
|
cbox->yMin = cbox->yMax - ( glyph->bitmap.rows << 6 );
|
2000-07-01 16:06:46 +02:00
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
const FT_Glyph_Class ft_bitmap_glyph_class =
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
sizeof( FT_BitmapGlyphRec ),
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
FT_GLYPH_FORMAT_BITMAP,
|
|
|
|
|
|
|
|
(FT_Glyph_InitFunc) ft_bitmap_glyph_init,
|
|
|
|
(FT_Glyph_DoneFunc) ft_bitmap_glyph_done,
|
|
|
|
(FT_Glyph_CopyFunc) ft_bitmap_glyph_copy,
|
|
|
|
(FT_Glyph_TransformFunc)0,
|
2002-09-05 17:10:54 +02:00
|
|
|
(FT_Glyph_GetBBoxFunc) ft_bitmap_glyph_bbox,
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
(FT_Glyph_PrepareFunc) 0
|
2000-07-01 01:12:55 +02:00
|
|
|
};
|
2000-03-28 13:22:31 +02:00
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/**** ****/
|
|
|
|
/**** FT_OutlineGlyph support ****/
|
|
|
|
/**** ****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2000-05-30 18:49:14 +02:00
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static FT_Error
|
|
|
|
ft_outline_glyph_init( FT_OutlineGlyph glyph,
|
|
|
|
FT_GlyphSlot slot )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
2000-07-01 16:06:46 +02:00
|
|
|
FT_Error error = FT_Err_Ok;
|
|
|
|
FT_Library library = FT_GLYPH(glyph)->library;
|
|
|
|
FT_Outline* source = &slot->outline;
|
|
|
|
FT_Outline* target = &glyph->outline;
|
|
|
|
|
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/* check format in glyph slot */
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
error = FT_Err_Invalid_Glyph_Format;
|
2000-05-30 18:49:14 +02:00
|
|
|
goto Exit;
|
2000-03-28 13:22:31 +02:00
|
|
|
}
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/* allocate new outline */
|
|
|
|
error = FT_Outline_New( library, source->n_points, source->n_contours,
|
|
|
|
&glyph->outline );
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2000-07-01 01:12:55 +02:00
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
/* copy it */
|
2004-01-16 09:46:51 +01:00
|
|
|
FT_ARRAY_COPY( target->points, source->points, source->n_points );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2004-01-16 09:46:51 +01:00
|
|
|
FT_ARRAY_COPY( target->tags, source->tags, source->n_points );
|
2000-07-01 01:12:55 +02:00
|
|
|
|
2004-01-16 09:46:51 +01:00
|
|
|
FT_ARRAY_COPY( target->contours, source->contours, source->n_contours );
|
2000-07-01 01:12:55 +02:00
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
/* copy all flags, except the `FT_OUTLINE_OWNER' one */
|
|
|
|
target->flags = source->flags | FT_OUTLINE_OWNER;
|
2000-05-30 18:49:14 +02:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
Exit:
|
|
|
|
return error;
|
2000-07-01 16:06:46 +02:00
|
|
|
}
|
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static void
|
|
|
|
ft_outline_glyph_done( FT_OutlineGlyph glyph )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
2000-07-01 16:06:46 +02:00
|
|
|
FT_Outline_Done( FT_GLYPH( glyph )->library, &glyph->outline );
|
2000-03-28 13:22:31 +02:00
|
|
|
}
|
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static FT_Error
|
|
|
|
ft_outline_glyph_copy( FT_OutlineGlyph source,
|
|
|
|
FT_OutlineGlyph target )
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
2000-07-01 01:12:55 +02:00
|
|
|
FT_Error error;
|
2000-07-01 16:06:46 +02:00
|
|
|
FT_Library library = FT_GLYPH( source )->library;
|
|
|
|
|
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
error = FT_Outline_New( library, source->outline.n_points,
|
|
|
|
source->outline.n_contours, &target->outline );
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( !error )
|
2000-07-01 01:12:55 +02:00
|
|
|
FT_Outline_Copy( &source->outline, &target->outline );
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
return error;
|
|
|
|
}
|
2000-03-28 13:22:31 +02:00
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static void
|
|
|
|
ft_outline_glyph_transform( FT_OutlineGlyph glyph,
|
|
|
|
FT_Matrix* matrix,
|
|
|
|
FT_Vector* delta )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( matrix )
|
2000-07-01 01:12:55 +02:00
|
|
|
FT_Outline_Transform( &glyph->outline, matrix );
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
if ( delta )
|
2000-07-01 01:12:55 +02:00
|
|
|
FT_Outline_Translate( &glyph->outline, delta->x, delta->y );
|
|
|
|
}
|
2000-05-30 18:49:14 +02:00
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static void
|
|
|
|
ft_outline_glyph_bbox( FT_OutlineGlyph glyph,
|
|
|
|
FT_BBox* bbox )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
FT_Outline_Get_CBox( &glyph->outline, bbox );
|
2000-07-01 16:06:46 +02:00
|
|
|
}
|
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static FT_Error
|
|
|
|
ft_outline_glyph_prepare( FT_OutlineGlyph glyph,
|
|
|
|
FT_GlyphSlot slot )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
slot->format = FT_GLYPH_FORMAT_OUTLINE;
|
2000-07-01 01:12:55 +02:00
|
|
|
slot->outline = glyph->outline;
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
slot->outline.flags &= ~FT_OUTLINE_OWNER;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
return FT_Err_Ok;
|
2000-07-01 16:06:46 +02:00
|
|
|
}
|
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
const FT_Glyph_Class ft_outline_glyph_class =
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
sizeof( FT_OutlineGlyphRec ),
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
FT_GLYPH_FORMAT_OUTLINE,
|
|
|
|
|
|
|
|
(FT_Glyph_InitFunc) ft_outline_glyph_init,
|
|
|
|
(FT_Glyph_DoneFunc) ft_outline_glyph_done,
|
|
|
|
(FT_Glyph_CopyFunc) ft_outline_glyph_copy,
|
|
|
|
(FT_Glyph_TransformFunc)ft_outline_glyph_transform,
|
2002-09-05 17:10:54 +02:00
|
|
|
(FT_Glyph_GetBBoxFunc) ft_outline_glyph_bbox,
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
(FT_Glyph_PrepareFunc) ft_outline_glyph_prepare
|
2000-07-01 01:12:55 +02:00
|
|
|
};
|
2000-06-02 02:01:14 +02:00
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/**** ****/
|
|
|
|
/**** FT_Glyph class and API ****/
|
|
|
|
/**** ****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static FT_Error
|
|
|
|
ft_new_glyph( FT_Library library,
|
|
|
|
const FT_Glyph_Class* clazz,
|
|
|
|
FT_Glyph* aglyph )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
FT_Memory memory = library->memory;
|
|
|
|
FT_Error error;
|
|
|
|
FT_Glyph glyph;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
*aglyph = 0;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( !FT_ALLOC( glyph, clazz->glyph_size ) )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
glyph->library = library;
|
|
|
|
glyph->clazz = clazz;
|
|
|
|
glyph->format = clazz->glyph_format;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
*aglyph = glyph;
|
|
|
|
}
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
return error;
|
2000-07-01 16:06:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in ftglyph.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Glyph_Copy( FT_Glyph source,
|
|
|
|
FT_Glyph *target )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
FT_Glyph copy;
|
|
|
|
FT_Error error;
|
|
|
|
const FT_Glyph_Class* clazz;
|
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/* check arguments */
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( !target || !source || !source->clazz )
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
|
|
|
error = FT_Err_Invalid_Argument;
|
|
|
|
goto Exit;
|
|
|
|
}
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
*target = 0;
|
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
clazz = source->clazz;
|
|
|
|
error = ft_new_glyph( source->library, clazz, © );
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2000-07-01 01:12:55 +02:00
|
|
|
|
2001-02-16 17:27:35 +01:00
|
|
|
copy->advance = source->advance;
|
|
|
|
copy->format = source->format;
|
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( clazz->glyph_copy )
|
2000-07-01 01:12:55 +02:00
|
|
|
error = clazz->glyph_copy( source, copy );
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
if ( error )
|
2000-07-01 01:12:55 +02:00
|
|
|
FT_Done_Glyph( copy );
|
|
|
|
else
|
|
|
|
*target = copy;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
Exit:
|
|
|
|
return error;
|
2000-07-01 16:06:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in ftglyph.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Get_Glyph( FT_GlyphSlot slot,
|
|
|
|
FT_Glyph *aglyph )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
2003-09-29 22:35:34 +02:00
|
|
|
FT_Library library;
|
2000-07-01 01:12:55 +02:00
|
|
|
FT_Error error;
|
|
|
|
FT_Glyph glyph;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
const FT_Glyph_Class* clazz = 0;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
if ( !slot )
|
|
|
|
return FT_Err_Invalid_Slot_Handle;
|
|
|
|
|
2003-09-29 22:35:34 +02:00
|
|
|
library = slot->library;
|
|
|
|
|
2000-07-04 05:37:18 +02:00
|
|
|
if ( !aglyph )
|
2000-07-01 16:06:46 +02:00
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
|
|
|
|
/* if it is a bitmap, that's easy :-) */
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
|
2000-07-01 01:12:55 +02:00
|
|
|
clazz = &ft_bitmap_glyph_class;
|
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
/* it it is an outline too */
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
|
2000-07-01 01:12:55 +02:00
|
|
|
clazz = &ft_outline_glyph_class;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
else
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
2000-07-01 01:12:55 +02:00
|
|
|
/* try to find a renderer that supports the glyph image format */
|
|
|
|
FT_Renderer render = FT_Lookup_Renderer( library, slot->format, 0 );
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
if ( render )
|
2000-07-01 01:12:55 +02:00
|
|
|
clazz = &render->glyph_class;
|
2000-03-28 13:22:31 +02:00
|
|
|
}
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
if ( !clazz )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
error = FT_Err_Invalid_Glyph_Format;
|
2000-03-28 13:22:31 +02:00
|
|
|
goto Exit;
|
2000-07-01 01:12:55 +02:00
|
|
|
}
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/* create FT_Glyph object */
|
|
|
|
error = ft_new_glyph( library, clazz, &glyph );
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
/* copy advance while converting it to 16.16 format */
|
2000-07-01 01:12:55 +02:00
|
|
|
glyph->advance.x = slot->advance.x << 10;
|
|
|
|
glyph->advance.y = slot->advance.y << 10;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/* now import the image from the glyph slot */
|
|
|
|
error = clazz->glyph_init( glyph, slot );
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
/* if an error occurred, destroy the glyph */
|
|
|
|
if ( error )
|
2000-07-01 01:12:55 +02:00
|
|
|
FT_Done_Glyph( glyph );
|
|
|
|
else
|
|
|
|
*aglyph = glyph;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
Exit:
|
|
|
|
return error;
|
2000-07-01 16:06:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in ftglyph.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Glyph_Transform( FT_Glyph glyph,
|
|
|
|
FT_Matrix* matrix,
|
|
|
|
FT_Vector* delta )
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
2000-07-01 01:12:55 +02:00
|
|
|
const FT_Glyph_Class* clazz;
|
|
|
|
FT_Error error = FT_Err_Ok;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
if ( !glyph || !glyph->clazz )
|
2000-07-01 01:12:55 +02:00
|
|
|
error = FT_Err_Invalid_Argument;
|
|
|
|
else
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
2000-07-01 01:12:55 +02:00
|
|
|
clazz = glyph->clazz;
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( clazz->glyph_transform )
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
2000-07-01 01:12:55 +02:00
|
|
|
/* transform glyph image */
|
|
|
|
clazz->glyph_transform( glyph, matrix, delta );
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/* transform advance vector */
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( matrix )
|
2000-07-01 01:12:55 +02:00
|
|
|
FT_Vector_Transform( &glyph->advance, matrix );
|
2000-03-28 13:22:31 +02:00
|
|
|
}
|
2000-07-01 01:12:55 +02:00
|
|
|
else
|
|
|
|
error = FT_Err_Invalid_Glyph_Format;
|
|
|
|
}
|
|
|
|
return error;
|
2000-07-01 16:06:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in ftglyph.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
FT_Glyph_Get_CBox( FT_Glyph glyph,
|
|
|
|
FT_UInt bbox_mode,
|
|
|
|
FT_BBox *acbox )
|
2000-07-01 16:06:46 +02:00
|
|
|
{
|
2000-07-01 01:12:55 +02:00
|
|
|
const FT_Glyph_Class* clazz;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
|
2001-06-18 16:23:45 +02:00
|
|
|
if ( !acbox )
|
|
|
|
return;
|
|
|
|
|
|
|
|
acbox->xMin = acbox->yMin = acbox->xMax = acbox->yMax = 0;
|
|
|
|
|
|
|
|
if ( !glyph || !glyph->clazz )
|
|
|
|
return;
|
2000-07-01 01:12:55 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
clazz = glyph->clazz;
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( !clazz->glyph_bbox )
|
2001-06-18 16:23:45 +02:00
|
|
|
return;
|
2000-07-01 01:12:55 +02:00
|
|
|
else
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
2000-07-01 01:12:55 +02:00
|
|
|
/* retrieve bbox in 26.6 coordinates */
|
2000-11-07 07:30:29 +01:00
|
|
|
clazz->glyph_bbox( glyph, acbox );
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/* perform grid fitting if needed */
|
* include/freetype/ftglyph.h (ft_glyph_bbox_unscaled,
ft_glyph_bbox_subpixels, ft_glyph_bbox_gridfit,
ft_glyph_bbox_truncate, ft_glyph_bbox_pixels): Replaced with
FT_GLYPH_BBOX_UNSCALED, FT_GLYPH_BBOX_SUBPIXELS,
FT_GLYPH_BBIX_GRIDFIT, FT_GLYPH_BBOX_TRUNCATE, FT_GLYPH_BBOX_PIXELS.
The lowercase variants are now (deprecated aliases) to the uppercase
versions.
Updated all other files.
* include/freetype/ftmodule.h (ft_module_font_driver,
ft_module_renderer, ft_module_hinter, ft_module_styler,
ft_module_driver_scalable, ft_module_driver_no_outlines,
ft_module_driver_has_hinter): Replaced with FT_MODULE_FONT_DRIVER,
FT_MODULE_RENDERER, FT_MODULE_HINTER, FT_MODULE_STYLER,
FT_MODULE_DRIVER_SCALABLE, FT_MODULE_DRIVER_NO_OUTLINES,
FT_MODULE_DRIVER_HAS_HINTER.
The lowercase variants are now (deprecated aliases) to the uppercase
versions.
Updated all other files.
* src/base/ftglyph.c (FT_Glyph_Get_CBox): Handle bbox_mode better
as enumeration.
* src/pcf/pcfdrivr.c (pcf_driver_class), src/winfonts/winfnt.c
(winfnt_driver_class), src/bdf/bdfdrivr.c (bdf_driver_class): Add
the FT_MODULE_DRIVER_NO_OUTLINES flag.
2003-06-17 12:42:27 +02:00
|
|
|
if ( bbox_mode == FT_GLYPH_BBOX_GRIDFIT ||
|
|
|
|
bbox_mode == FT_GLYPH_BBOX_PIXELS )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
2003-12-24 02:10:46 +01:00
|
|
|
acbox->xMin = FT_PIX_FLOOR( acbox->xMin );
|
|
|
|
acbox->yMin = FT_PIX_FLOOR( acbox->yMin );
|
|
|
|
acbox->xMax = FT_PIX_CEIL( acbox->xMax );
|
|
|
|
acbox->yMax = FT_PIX_CEIL( acbox->yMax );
|
2000-07-01 01:12:55 +02:00
|
|
|
}
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/* convert to integer pixels if needed */
|
* include/freetype/ftglyph.h (ft_glyph_bbox_unscaled,
ft_glyph_bbox_subpixels, ft_glyph_bbox_gridfit,
ft_glyph_bbox_truncate, ft_glyph_bbox_pixels): Replaced with
FT_GLYPH_BBOX_UNSCALED, FT_GLYPH_BBOX_SUBPIXELS,
FT_GLYPH_BBIX_GRIDFIT, FT_GLYPH_BBOX_TRUNCATE, FT_GLYPH_BBOX_PIXELS.
The lowercase variants are now (deprecated aliases) to the uppercase
versions.
Updated all other files.
* include/freetype/ftmodule.h (ft_module_font_driver,
ft_module_renderer, ft_module_hinter, ft_module_styler,
ft_module_driver_scalable, ft_module_driver_no_outlines,
ft_module_driver_has_hinter): Replaced with FT_MODULE_FONT_DRIVER,
FT_MODULE_RENDERER, FT_MODULE_HINTER, FT_MODULE_STYLER,
FT_MODULE_DRIVER_SCALABLE, FT_MODULE_DRIVER_NO_OUTLINES,
FT_MODULE_DRIVER_HAS_HINTER.
The lowercase variants are now (deprecated aliases) to the uppercase
versions.
Updated all other files.
* src/base/ftglyph.c (FT_Glyph_Get_CBox): Handle bbox_mode better
as enumeration.
* src/pcf/pcfdrivr.c (pcf_driver_class), src/winfonts/winfnt.c
(winfnt_driver_class), src/bdf/bdfdrivr.c (bdf_driver_class): Add
the FT_MODULE_DRIVER_NO_OUTLINES flag.
2003-06-17 12:42:27 +02:00
|
|
|
if ( bbox_mode == FT_GLYPH_BBOX_TRUNCATE ||
|
|
|
|
bbox_mode == FT_GLYPH_BBOX_PIXELS )
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
2000-11-07 07:30:29 +01:00
|
|
|
acbox->xMin >>= 6;
|
|
|
|
acbox->yMin >>= 6;
|
|
|
|
acbox->xMax >>= 6;
|
|
|
|
acbox->yMax >>= 6;
|
2000-03-28 13:22:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-07-01 01:12:55 +02:00
|
|
|
return;
|
2000-03-28 13:22:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in ftglyph.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
* src/sfnt/ttpost.c (load_post_names, tt_face_free_ps_names,
tt_face_get_ps_name): Replace switch statement with if clauses to
make it more portable.
* src/cff/cffobjs.c (cff_face_init): Ditto.
* include/freetype/ftmodule.h (FT_Module_Class): Use `FT_Long' for
`module_size'.
* include/freetype/ftrender.h (FT_Glyph_Class_): Use `FT_Long' for
`glyph_size'.
* src/base/ftobjs.c (FT_Render_Glyph): Change second parameter to
`FT_Render_Mode'.
(FT_Render_Glyph_Internal): Change third parameter to
`FT_Render_Mode'.
* src/base/ftglyph.c (FT_Glyph_To_Bitmap): Change second parameter
to `FT_Render_Mode'.
* src/raster/ftrend1.c (ft_raster1_render): Change third parameter
to `FT_Render_Mode'.
* src/smooth/ftsmooth.c (ft_smooth_render, ft_smooth_render_lcd,
ft_smooth_render_lcd_v): Ditto.
(ft_smooth_render_generic): Change third and fifth parameter to
`FT_Render_Mode'.
* include/freetype/freetype.h, include/freetype/internal/ftobjs.h,
include/freetype/ftglyph.h: Updated.
* src/cff/cffdrivr.c (Load_Glyph), src/pcf/pcfdriver.c
(PCF_Glyph_Load), src/pfr/pfrobjs.c (pfr_slot_load),
src/winfonts/winfnt.c (FNT_Load_Glyph), src/t42/t42objs.c
(T42_GlyphSlot_Load), src/bdf/bdfdrivr.c (BDF_Glyph_Load): Change
fourth parameter to `FT_Int32'.
* src/pfr/pfrobjs.c (pfr_face_init): Add two missing parameters
and declare them as unused.
* src/cid/cidparse.h (CID_Parser): Use FT_Long for `postscript_len'.
* src/psnames/psnames.h (PS_Unicode_Value_Func): Change return
value to FT_UInt32.
* src/psnames/psmodule.c (ps_unicode_value, ps_build_unicode_table):
Updated accordingly.
* src/cff/cffdrivr.c (Get_Kerning): Use FT_Long for `middle'.
(cff_get_glyph_name): Use cast for result of ft_strlen.
* src/cff/cffparse.c (cff_parse_real): User cast for assigning
`exp'.
* src/cff/cffload.c (cff_index_get_pointers): Use FT_ULong for
some local variables.
(cff_charset_load, cff_encoding_load): Use casts to FT_UInt for some
switch statements.
(cff_font_load): Use cast in call to CFF_Load_FD_Select.
* src/cff/cffobjs.c (cff_size_init): Use more casts.
(cff_face_init): Use FT_Int32 for `flags'.
* src/cff/cffgload.c (cff_operator_seac): Use cast for assigning
`adx' and `ady'.
(cff_decoder_parse_charstrings): Use FT_ULong for third parameter.
Use more casts.
* src/cff/cffcmap.c (cff_cmap_unicode_init): Use cast for `count'.
* src/cid/cidload.c (cid_read_subrs): Use FT_ULong for `len'.
* src/cid/cidgload.c (cid_load_glyph): Add missing cast for
`cid_get_offset'.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings) <18>: Use
cast for `num_points'.
(t1_decoder_init): Use cast for assigning `decoder->num_glyphs'.
* src/base/ftdebug.c (ft_debug_init): Use FT_Int.
* include/freetype/internal/ftdriver.h (FT_Slot_LoadFunc): Use
`FT_Int32' for fourth parameter.
* src/base/ftobjs.c (open_face): Use cast for calling
clazz->init_face.
* src/raster/ftraster.c (Set_High_Precision): Use `1' instead of
`1L'.
(Finalize_Profile_Table, Line_Up, ft_black_init): Use casts.
* src/raster/ftrend1.c (ft_raster1_render): Ditto.
* src/sfnt/sfnt_dir_check: Compare `magic' with unsigned long
constant.
* builds/amiga/include/freetype/config/ftmodule.h: Updated.
2002-09-27 13:09:23 +02:00
|
|
|
FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
|
|
|
|
FT_Render_Mode render_mode,
|
|
|
|
FT_Vector* origin,
|
|
|
|
FT_Bool destroy )
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
2003-06-18 08:59:57 +02:00
|
|
|
FT_GlyphSlotRec dummy;
|
|
|
|
FT_GlyphSlot_InternalRec dummy_internal;
|
|
|
|
FT_Error error = FT_Err_Ok;
|
|
|
|
FT_Glyph glyph;
|
|
|
|
FT_BitmapGlyph bitmap = NULL;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2003-06-18 08:59:57 +02:00
|
|
|
const FT_Glyph_Class* clazz;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* check argument */
|
|
|
|
if ( !the_glyph )
|
2000-07-01 01:12:55 +02:00
|
|
|
goto Bad;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
/* we render the glyph into a glyph bitmap using a `dummy' glyph slot */
|
|
|
|
/* then calling FT_Render_Glyph_Internal() */
|
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
glyph = *the_glyph;
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( !glyph )
|
2000-07-01 01:12:55 +02:00
|
|
|
goto Bad;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
clazz = glyph->clazz;
|
2002-07-09 01:05:14 +02:00
|
|
|
|
2003-05-28 08:10:57 +02:00
|
|
|
/* when called with a bitmap glyph, do nothing and return successfully */
|
2002-07-09 01:05:14 +02:00
|
|
|
if ( clazz == &ft_bitmap_glyph_class )
|
|
|
|
goto Exit;
|
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( !clazz || !clazz->glyph_prepare )
|
2000-07-01 01:12:55 +02:00
|
|
|
goto Bad;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2002-07-28 07:05:24 +02:00
|
|
|
FT_MEM_ZERO( &dummy, sizeof ( dummy ) );
|
2003-06-18 08:59:57 +02:00
|
|
|
FT_MEM_ZERO( &dummy_internal, sizeof ( dummy_internal ) );
|
|
|
|
dummy.internal = &dummy_internal;
|
|
|
|
dummy.library = glyph->library;
|
|
|
|
dummy.format = clazz->glyph_format;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
/* create result bitmap glyph */
|
2000-07-01 01:12:55 +02:00
|
|
|
error = ft_new_glyph( glyph->library, &ft_bitmap_glyph_class,
|
|
|
|
(FT_Glyph*)&bitmap );
|
2001-12-07 22:56:32 +01:00
|
|
|
if ( error )
|
2000-07-01 16:06:46 +02:00
|
|
|
goto Exit;
|
|
|
|
|
2003-05-28 08:10:57 +02:00
|
|
|
#if 1
|
2001-12-05 18:24:34 +01:00
|
|
|
/* if `origin' is set, translate the glyph image */
|
|
|
|
if ( origin )
|
|
|
|
FT_Glyph_Transform( glyph, 0, origin );
|
2001-12-16 09:17:33 +01:00
|
|
|
#else
|
|
|
|
FT_UNUSED( origin );
|
2001-12-05 18:24:34 +01:00
|
|
|
#endif
|
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
/* prepare dummy slot for rendering */
|
2000-08-21 06:43:01 +02:00
|
|
|
error = clazz->glyph_prepare( glyph, &dummy );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( !error )
|
2000-08-21 06:43:01 +02:00
|
|
|
error = FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode );
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2003-05-28 08:10:57 +02:00
|
|
|
#if 1
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( !destroy && origin )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
FT_Vector v;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
v.x = -origin->x;
|
|
|
|
v.y = -origin->y;
|
|
|
|
FT_Glyph_Transform( glyph, 0, &v );
|
|
|
|
}
|
2001-12-05 18:24:34 +01:00
|
|
|
#endif
|
|
|
|
|
2001-12-07 22:56:32 +01:00
|
|
|
if ( error )
|
2001-12-05 18:24:34 +01:00
|
|
|
goto Exit;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-11-03 08:57:51 +01:00
|
|
|
/* in case of success, copy the bitmap to the glyph bitmap */
|
2001-12-05 18:24:34 +01:00
|
|
|
error = ft_bitmap_glyph_init( bitmap, &dummy );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2001-12-05 18:24:34 +01:00
|
|
|
/* copy advance */
|
|
|
|
bitmap->root.advance = glyph->advance;
|
2000-11-03 08:57:51 +01:00
|
|
|
|
2001-12-05 18:24:34 +01:00
|
|
|
if ( destroy )
|
|
|
|
FT_Done_Glyph( glyph );
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2001-12-05 18:24:34 +01:00
|
|
|
*the_glyph = FT_GLYPH( bitmap );
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
Exit:
|
2001-12-07 22:56:32 +01:00
|
|
|
if ( error && bitmap )
|
|
|
|
FT_Done_Glyph( FT_GLYPH( bitmap ) );
|
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
return error;
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2000-07-01 01:12:55 +02:00
|
|
|
Bad:
|
|
|
|
error = FT_Err_Invalid_Argument;
|
|
|
|
goto Exit;
|
2000-07-01 16:06:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in ftglyph.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
FT_Done_Glyph( FT_Glyph glyph )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
2000-07-01 16:06:46 +02:00
|
|
|
if ( glyph )
|
2000-07-01 01:12:55 +02:00
|
|
|
{
|
|
|
|
FT_Memory memory = glyph->library->memory;
|
|
|
|
const FT_Glyph_Class* clazz = glyph->clazz;
|
|
|
|
|
2000-07-01 16:06:46 +02:00
|
|
|
|
|
|
|
if ( clazz->glyph_done )
|
2000-07-01 01:12:55 +02:00
|
|
|
clazz->glyph_done( glyph );
|
2000-07-01 16:06:46 +02:00
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( glyph );
|
2000-07-01 01:12:55 +02:00
|
|
|
}
|
2000-03-28 13:22:31 +02:00
|
|
|
}
|
2000-05-05 15:11:36 +02:00
|
|
|
|
|
|
|
|
2000-05-30 18:49:14 +02:00
|
|
|
/* END */
|