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