2000-08-23 19:32:42 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ftcimage.c */
|
|
|
|
/* */
|
|
|
|
/* XXX */
|
|
|
|
/* */
|
|
|
|
/* Copyright 2000 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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
#include <cache/ftcimage.h>
|
|
|
|
|
|
|
|
static
|
2000-08-23 19:32:42 +02:00
|
|
|
void ftc_done_glyph_image( FTC_Image_Queue queue,
|
|
|
|
FTC_ImageNode node )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_UNUSED( queue );
|
|
|
|
|
|
|
|
FT_Done_Glyph( FTC_IMAGENODE_GET_GLYPH( node ) );
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
static
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_ULong ftc_size_bitmap_image( FTC_Image_Queue queue,
|
|
|
|
FTC_ImageNode node )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
|
|
|
FT_Long pitch;
|
|
|
|
FT_BitmapGlyph glyph;
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_UNUSED( queue );
|
|
|
|
|
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
glyph = (FT_BitmapGlyph)FTC_IMAGENODE_GET_GLYPH(node);
|
|
|
|
pitch = glyph->bitmap.pitch;
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( pitch < 0 )
|
2000-08-23 13:22:30 +02:00
|
|
|
pitch = -pitch;
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
return (FT_ULong)(pitch * glyph->bitmap->rows + sizeof ( *glyph ) );
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2000-08-23 13:22:30 +02:00
|
|
|
static
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_ULong ftc_size_outline_image( FTC_Image_Queue queue,
|
|
|
|
FTC_ImageNode node )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
|
|
|
FT_Long pitch;
|
|
|
|
FT_OutlineGlyph glyph;
|
|
|
|
FT_Outline* outline;
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_UNUSED( queue );
|
|
|
|
|
|
|
|
|
|
|
|
glyph = (FT_OutlineGlyph)FTC_IMAGENODE_GET_GLYPH( node );
|
2000-08-23 13:22:30 +02:00
|
|
|
outline = &glyph->outline;
|
|
|
|
|
|
|
|
return (FT_ULong)(
|
2000-08-23 19:32:42 +02:00
|
|
|
outline->n_points * ( sizeof ( FT_Vector ) + sizeof ( FT_Byte ) ) +
|
|
|
|
outline->n_contours * sizeof ( FT_Short ) +
|
|
|
|
sizeof( *glyph ) );
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** MONOCHROME BITMAP CALLBACKS *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2000-08-23 13:22:30 +02:00
|
|
|
|
|
|
|
static
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_Error ftc_init_mono_image( FTC_Image_Queue queue,
|
|
|
|
FTC_ImageNode node )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_Face face;
|
|
|
|
FT_Size size;
|
|
|
|
FT_Error error;
|
2000-08-23 13:22:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
error = FTC_Manager_Lookup_Size( queue->manager,
|
|
|
|
&queue->size_rec,
|
|
|
|
&face, &size );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( !error )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_UInt glyph_index = FTC_IMAGENODE_GINDEX( node );
|
2000-08-23 13:22:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
error = FT_Load_Glyph( face, glyph_index,
|
|
|
|
FT_LOAD_RENDER | FT_LOAD_MONOCHROME );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( !error )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
|
|
|
if ( face->glyph->format != ft_image_format_bitmap ||
|
2000-08-23 19:32:42 +02:00
|
|
|
face->glyph->bitmap.pixel_mode != ft_pixel_mode_mono )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2000-08-23 19:32:42 +02:00
|
|
|
/* there is no monochrome glyph for this font! */
|
2000-08-23 13:22:30 +02:00
|
|
|
error = FT_Err_Invalid_Glyph_Index;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* ok, copy it */
|
|
|
|
FT_Glyph glyph;
|
|
|
|
|
|
|
|
|
|
|
|
error = FT_Get_Glyph( face->glyph, &glyph );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( !error )
|
|
|
|
FTC_IMAGENODE_SET_GLYPH( node, glyph );
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_Error ftc_init_gray_image( FTC_Image_Queue queue,
|
|
|
|
FTC_ImageNode node )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_Face face;
|
|
|
|
FT_Size size;
|
|
|
|
FT_Error error;
|
2000-08-23 13:22:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
error = FTC_Manager_Lookup_Size( queue->manager,
|
|
|
|
&queue->size_rec,
|
|
|
|
&face, &size );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( !error )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_UInt glyph_index = FTC_IMAGENODE_GINDEX( node );
|
2000-08-23 13:22:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
error = FT_Load_Glyph( face, glyph_index,
|
|
|
|
FT_LOAD_RENDER );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( !error )
|
2000-08-23 13:22:30 +02:00
|
|
|
{
|
|
|
|
if ( face->glyph->format != ft_image_format_bitmap ||
|
|
|
|
face->glyph->bitmap.pixel_mode != ft_pixel_mode_grays )
|
|
|
|
{
|
2000-08-23 19:32:42 +02:00
|
|
|
/* there is no monochrome glyph for this font! */
|
2000-08-23 13:22:30 +02:00
|
|
|
error = FT_Err_Invalid_Glyph_Index;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* ok, copy it */
|
|
|
|
FT_Glyph glyph;
|
|
|
|
|
|
|
|
|
|
|
|
error = FT_Get_Glyph( face->glyph, &glyph );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( !error )
|
|
|
|
FTC_IMAGENODE_SET_GLYPH( node, glyph );
|
2000-08-23 13:22:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
/* END */
|