2000-10-31 23:13:54 +01:00
|
|
|
|
/***************************************************************************/
|
|
|
|
|
/* */
|
|
|
|
|
/* ftcsbits.c */
|
|
|
|
|
/* */
|
|
|
|
|
/* FreeType sbits manager (body). */
|
|
|
|
|
/* */
|
2003-04-23 08:47:12 +02:00
|
|
|
|
/* Copyright 2000-2001, 2002, 2003 by */
|
2000-10-31 23:13:54 +01:00
|
|
|
|
/* 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-12-08 17:17:16 +01:00
|
|
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
|
#include FT_CACHE_H
|
2003-12-19 22:23:58 +01:00
|
|
|
|
#include FT_CACHE_INTERNAL_SBITS_H
|
2000-12-08 17:17:16 +01:00
|
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
|
#include FT_ERRORS_H
|
2000-10-29 01:34:45 +02:00
|
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
|
#include "ftcerror.h"
|
|
|
|
|
|
2000-10-31 23:13:54 +01:00
|
|
|
|
|
2001-12-05 16:59:33 +01:00
|
|
|
|
/*************************************************************************/
|
|
|
|
|
/*************************************************************************/
|
|
|
|
|
/***** *****/
|
|
|
|
|
/***** SBIT CACHE NODES *****/
|
|
|
|
|
/***** *****/
|
|
|
|
|
/*************************************************************************/
|
|
|
|
|
/*************************************************************************/
|
2000-10-28 15:17:11 +02:00
|
|
|
|
|
|
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
|
static FT_Error
|
2001-12-05 16:59:33 +01:00
|
|
|
|
ftc_sbit_copy_bitmap( FTC_SBit sbit,
|
|
|
|
|
FT_Bitmap* bitmap,
|
|
|
|
|
FT_Memory memory )
|
2000-10-28 15:17:11 +02:00
|
|
|
|
{
|
|
|
|
|
FT_Error error;
|
2001-10-26 18:58:27 +02:00
|
|
|
|
FT_Int pitch = bitmap->pitch;
|
2000-10-28 15:17:11 +02:00
|
|
|
|
FT_ULong size;
|
|
|
|
|
|
2000-10-31 23:13:54 +01:00
|
|
|
|
|
2000-10-28 15:17:11 +02:00
|
|
|
|
if ( pitch < 0 )
|
|
|
|
|
pitch = -pitch;
|
|
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
|
size = (FT_ULong)( pitch * bitmap->rows );
|
2000-10-28 15:17:11 +02:00
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
|
if ( !FT_ALLOC( sbit->buffer, size ) )
|
|
|
|
|
FT_MEM_COPY( sbit->buffer, bitmap->buffer, size );
|
2000-10-28 15:17:11 +02:00
|
|
|
|
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
|
FTC_SNode_Free( FTC_SNode snode,
|
|
|
|
|
FTC_Cache cache )
|
2001-12-05 16:59:33 +01:00
|
|
|
|
{
|
2002-09-08 23:29:11 +02:00
|
|
|
|
FTC_SBit sbit = snode->sbits;
|
2003-12-19 22:23:58 +01:00
|
|
|
|
FT_UInt count = snode->count;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
FT_Memory memory = cache->memory;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( ; count > 0; sbit++, count-- )
|
2002-03-22 14:52:37 +01:00
|
|
|
|
FT_FREE( sbit->buffer );
|
2001-12-05 16:59:33 +01:00
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
|
FTC_GNode_Done( FTC_GNODE( snode ), cache );
|
|
|
|
|
|
|
|
|
|
FT_FREE( snode );
|
2001-12-05 16:59:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-10-26 18:58:27 +02:00
|
|
|
|
static FT_Error
|
2003-12-26 08:26:08 +01:00
|
|
|
|
ftc_snode_load( FTC_SNode snode,
|
|
|
|
|
FTC_Manager manager,
|
|
|
|
|
FT_UInt gindex,
|
|
|
|
|
FT_ULong *asize )
|
2000-10-28 15:17:11 +02:00
|
|
|
|
{
|
2003-12-26 08:26:08 +01:00
|
|
|
|
FT_Error error;
|
|
|
|
|
FTC_GNode gnode = FTC_GNODE( snode );
|
|
|
|
|
FTC_Family family = gnode->family;
|
|
|
|
|
FT_Memory memory = manager->memory;
|
|
|
|
|
FT_Face face;
|
|
|
|
|
FTC_SBit sbit;
|
|
|
|
|
FTC_SFamilyClass clazz;
|
2001-12-20 18:49:10 +01:00
|
|
|
|
|
2000-10-28 15:17:11 +02:00
|
|
|
|
|
2003-12-21 02:41:32 +01:00
|
|
|
|
if ( (FT_UInt)(gindex - gnode->gindex) >= snode->count )
|
2001-10-26 18:58:27 +02:00
|
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
|
FT_ERROR(( "ftc_snode_load: invalid glyph index" ));
|
2001-10-26 18:58:27 +02:00
|
|
|
|
return FTC_Err_Invalid_Argument;
|
|
|
|
|
}
|
2000-10-28 15:17:11 +02:00
|
|
|
|
|
2003-12-26 08:26:08 +01:00
|
|
|
|
sbit = snode->sbits + ( gindex - gnode->gindex );
|
|
|
|
|
clazz = (FTC_SFamilyClass)family->clazz;
|
2000-10-28 15:17:11 +02:00
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
|
sbit->buffer = 0;
|
|
|
|
|
|
|
|
|
|
error = clazz->family_load_glyph( family, gindex, manager, &face );
|
|
|
|
|
if ( error )
|
|
|
|
|
goto BadGlyph;
|
2001-12-05 16:59:33 +01:00
|
|
|
|
|
2000-10-28 15:17:11 +02:00
|
|
|
|
{
|
2003-12-19 22:23:58 +01:00
|
|
|
|
FT_Int temp;
|
|
|
|
|
FT_GlyphSlot slot = face->glyph;
|
|
|
|
|
FT_Bitmap* bitmap = &slot->bitmap;
|
|
|
|
|
FT_Int xadvance, yadvance;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
|
2003-12-26 08:26:08 +01:00
|
|
|
|
|
2003-12-19 22:23:58 +01:00
|
|
|
|
if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
|
2001-10-26 18:58:27 +02:00
|
|
|
|
{
|
2003-12-26 08:26:08 +01:00
|
|
|
|
FT_ERROR(( "%s: glyph loaded didn't return a bitmap!\n",
|
2003-12-19 22:23:58 +01:00
|
|
|
|
"ftc_snode_load" ));
|
|
|
|
|
goto BadGlyph;
|
|
|
|
|
}
|
2000-10-31 21:42:18 +01:00
|
|
|
|
|
2003-12-26 08:26:08 +01:00
|
|
|
|
/* |