1999-12-17 00:11:37 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ftobjs.c */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* The FreeType private base classes (base). */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* Copyright 1996-2000 by */
|
1999-12-17 00:11:37 +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-05-31 08:55:12 +02:00
|
|
|
|
2000-05-11 20:23:52 +02:00
|
|
|
#include <freetype/internal/ftobjs.h>
|
|
|
|
#include <freetype/internal/ftlist.h>
|
|
|
|
#include <freetype/internal/ftdebug.h>
|
|
|
|
#include <freetype/internal/ftstream.h>
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-05-11 20:23:52 +02:00
|
|
|
#include <freetype/tttables.h>
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/**** ****/
|
|
|
|
/**** ****/
|
|
|
|
/**** M E M O R Y ****/
|
|
|
|
/**** ****/
|
|
|
|
/**** ****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* messages during execution. */
|
|
|
|
/* */
|
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_memory
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Alloc */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Allocates a new block of memory. The returned area is always */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* zero-filled; this is a strong convention in many FreeType parts. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* memory :: A handle to a given `memory object' which handles */
|
|
|
|
/* allocation. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* size :: The size in bytes of the block to allocate. */
|
|
|
|
/* */
|
|
|
|
/* <Output> */
|
|
|
|
/* P :: A pointer to the fresh new block. It should be set to */
|
|
|
|
/* NULL if `size' is 0, or in case of error. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* FreeType error code. 0 means success. */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
BASE_FUNC( FT_Error ) FT_Alloc( FT_Memory memory,
|
|
|
|
FT_Long size,
|
|
|
|
void** P )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Assert( P != 0 );
|
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
if ( size > 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
*P = memory->alloc( memory, size );
|
2000-01-10 18:19:45 +01:00
|
|
|
if ( !*P )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_ERROR(( "FT_Alloc:" ));
|
2000-01-10 18:19:45 +01:00
|
|
|
FT_ERROR(( " Out of memory? (%ld requested)\n",
|
1999-12-17 00:11:37 +01:00
|
|
|
size ));
|
|
|
|
|
|
|
|
return FT_Err_Out_Of_Memory;
|
|
|
|
}
|
|
|
|
MEM_Set( *P, 0, size );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*P = NULL;
|
|
|
|
|
|
|
|
FT_TRACE2(( "FT_Alloc:" ));
|
2000-05-18 18:18:05 +02:00
|
|
|
FT_TRACE2(( " size = %ld, block = 0x%08p, ref = 0x%08p\n",
|
|
|
|
size, *P, P ));
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Realloc */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Reallocates a block of memory pointed to by `*P' to `Size' bytes */
|
|
|
|
/* from the heap, possibly changing `*P'. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* memory :: A handle to a given `memory object' which handles */
|
|
|
|
/* reallocation. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* current :: The current block size in bytes. */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* size :: The new block size in bytes. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* P :: A pointer to the fresh new block. It should be set to */
|
|
|
|
/* NULL if `size' is 0, or in case of error. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* FreeType error code. 0 means success. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* All callers of FT_Realloc() _must_ provide the current block size */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* as well as the new one. */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
BASE_FUNC( FT_Error ) FT_Realloc( FT_Memory memory,
|
|
|
|
FT_Long current,
|
|
|
|
FT_Long size,
|
|
|
|
void** P )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
void* Q;
|
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
FT_Assert( P != 0 );
|
|
|
|
|
|
|
|
/* if the original pointer is NULL, call FT_Alloc() */
|
|
|
|
if ( !*P )
|
|
|
|
return FT_Alloc( memory, size, P );
|
|
|
|
|
|
|
|
/* if the new block if zero-sized, clear the current one */
|
|
|
|
if ( size <= 0 )
|
|
|
|
{
|
|
|
|
FT_Free( memory, P );
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
Q = memory->realloc( memory, current, size, *P );
|
2000-01-10 18:19:45 +01:00
|
|
|
if ( !Q )
|
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
*P = Q;
|
|
|
|
return FT_Err_Ok;
|
|
|
|
|
|
|
|
Fail:
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_ERROR(( "FT_Realloc:" ));
|
2000-01-10 18:19:45 +01:00
|
|
|
FT_ERROR(( " Failed (current %ld, requested %ld)\n",
|
1999-12-17 00:11:37 +01:00
|
|
|
current, size ));
|
|
|
|
return FT_Err_Out_Of_Memory;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Free */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Releases a given block of memory allocated through FT_Alloc(). */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* memory :: A handle to a given `memory object' which handles */
|
|
|
|
/* memory deallocation */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* P :: This is the _address_ of a _pointer_ which points to the */
|
|
|
|
/* allocated block. It is always set to NULL on exit. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* FreeType error code. 0 means success. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* If P or *P are NULL, this function should return successfully. */
|
|
|
|
/* This is a strong convention within all of FreeType and its */
|
|
|
|
/* drivers. */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
BASE_FUNC( void ) FT_Free( FT_Memory memory,
|
|
|
|
void** P )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_TRACE2(( "FT_Free:" ));
|
2000-05-18 18:18:05 +02:00
|
|
|
FT_TRACE2(( " Freeing block 0x%08p, ref 0x%08p\n",
|
2000-05-31 08:55:12 +02:00
|
|
|
P, P ? *P : (void*)0 ));
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
FT_Assert( P != 0 );
|
2000-01-10 18:19:45 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( *P )
|
|
|
|
{
|
|
|
|
memory->free( memory, *P );
|
|
|
|
*P = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* ft_new_input_stream */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Creates a new input stream object from an FT_Open_Args structure. */
|
|
|
|
/* */
|
2000-06-02 02:01:14 +02:00
|
|
|
/* <Note> */
|
|
|
|
/* The function expects a valid `astream' parameter. */
|
2000-02-13 14:37:38 +01:00
|
|
|
static
|
2000-02-16 09:23:58 +01:00
|
|
|
FT_Error ft_new_input_stream( FT_Library library,
|
|
|
|
FT_Open_Args* args,
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_Stream* astream )
|
2000-02-13 14:37:38 +01:00
|
|
|
{
|
2000-02-16 09:23:58 +01:00
|
|
|
FT_Error error;
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_Stream stream;
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !library )
|
|
|
|
return FT_Err_Invalid_Library_Handle;
|
|
|
|
|
|
|
|
if ( !args )
|
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
*astream = 0;
|
|
|
|
memory = library->memory;
|
2000-02-16 09:23:58 +01:00
|
|
|
if ( ALLOC( stream, sizeof ( *stream ) ) )
|
2000-03-28 13:22:31 +02:00
|
|
|
goto Exit;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
stream->memory = memory;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-05-12 12:19:41 +02:00
|
|
|
/* now, look at the stream flags */
|
|
|
|
if ( args->flags & ft_open_memory )
|
2000-02-13 14:37:38 +01:00
|
|
|
{
|
2000-05-12 12:19:41 +02:00
|
|
|
error = 0;
|
|
|
|
FT_New_Memory_Stream( library,
|
|
|
|
args->memory_base,
|
|
|
|
args->memory_size,
|
|
|
|
stream );
|
|
|
|
}
|
2000-05-31 08:55:12 +02:00
|
|
|
else if ( args->flags & ft_open_pathname )
|
2000-05-12 12:19:41 +02:00
|
|
|
{
|
|
|
|
error = FT_New_Stream( args->pathname, stream );
|
|
|
|
stream->pathname.pointer = args->pathname;
|
|
|
|
}
|
2000-05-31 08:55:12 +02:00
|
|
|
else if ( args->flags & ft_open_stream && args->stream )
|
2000-05-12 12:19:41 +02:00
|
|
|
{
|
|
|
|
*stream = *(args->stream);
|
|
|
|
stream->memory = memory;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
error = FT_Err_Invalid_Argument;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
if ( error )
|
|
|
|
FREE( stream );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
*astream = stream;
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
Exit:
|
2000-02-13 14:37:38 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
2000-05-02 12:51:41 +02:00
|
|
|
/* FT_Done_Stream */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Closes and destroys a stream object. */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* <Input> */
|
|
|
|
/* stream :: The stream to be closed and destroyed. */
|
|
|
|
/* */
|
|
|
|
FT_EXPORT_FUNC( void ) FT_Done_Stream( FT_Stream stream )
|
2000-05-02 12:51:41 +02:00
|
|
|
{
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( stream && stream->close )
|
2000-05-02 12:51:41 +02:00
|
|
|
stream->close( stream );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
static
|
2000-02-16 09:23:58 +01:00
|
|
|
void ft_done_stream( FT_Stream* astream )
|
2000-02-13 14:37:38 +01:00
|
|
|
{
|
|
|
|
FT_Stream stream = *astream;
|
|
|
|
FT_Memory memory = stream->memory;
|
2000-02-16 09:23:58 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
if ( stream->close )
|
2000-02-13 14:37:38 +01:00
|
|
|
stream->close( stream );
|
2000-03-05 17:07:58 +01:00
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
FREE( stream );
|
|
|
|
*astream = 0;
|
|
|
|
}
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/**** ****/
|
|
|
|
/**** ****/
|
2000-02-16 09:23:58 +01:00
|
|
|
/**** O B J E C T M A N A G E M E N T ****/
|
1999-12-17 00:11:37 +01:00
|
|
|
/**** ****/
|
|
|
|
/**** ****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2000-06-03 08:03:11 +02:00
|
|
|
|
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_objs
|
|
|
|
|
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
/* destructor for sizes list */
|
|
|
|
static
|
|
|
|
void destroy_size( FT_Memory memory,
|
|
|
|
FT_Size size,
|
|
|
|
FT_Driver driver )
|
|
|
|
{
|
|
|
|
/* finalize format-specific stuff */
|
|
|
|
driver->interface.done_size( size );
|
|
|
|
FREE( size );
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
/* destructor for faces list */
|
|
|
|
static
|
|
|
|
void destroy_face( FT_Memory memory,
|
|
|
|
FT_Face face,
|
|
|
|
FT_Driver driver )
|
|
|
|
{
|
|
|
|
/* Discard glyph slots for this face */
|
|
|
|
/* XXX: Beware! FT_Done_GlyphSlot() changes the field `face->slot' */
|
|
|
|
while ( face->glyph )
|
|
|
|
FT_Done_GlyphSlot( face->glyph );
|
|
|
|
|
|
|
|
/* Discard all sizes for this face */
|
|
|
|
FT_List_Finalize( &face->sizes_list,
|
|
|
|
(FT_List_Destructor)destroy_size,
|
|
|
|
memory,
|
|
|
|
driver );
|
|
|
|
face->size = 0;
|
|
|
|
|
|
|
|
/* finalize format-specific stuff */
|
|
|
|
driver->interface.done_face( face );
|
|
|
|
|
|
|
|
/* Now discard client data */
|
|
|
|
if ( face->generic.finalizer )
|
|
|
|
face->generic.finalizer( face );
|
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
/* close the stream for this face */
|
2000-05-17 01:44:38 +02:00
|
|
|
ft_done_stream( &face->stream );
|
2000-02-13 14:37:38 +01:00
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
/* get rid of it */
|
|
|
|
FREE( face );
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* Destroy_Driver */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Destroys a given driver object. This also destroys all child */
|
|
|
|
/* faces. */
|
|
|
|
/* */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* <InOut> */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* driver :: A handle to the target driver object. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* The driver _must_ be LOCKED! */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
static
|
2000-01-10 18:19:45 +01:00
|
|
|
void Destroy_Driver( FT_Driver driver )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-01-10 18:19:45 +01:00
|
|
|
FT_Memory memory = driver->memory;
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* now, finalize all faces in the driver list */
|
|
|
|
FT_List_Finalize( &driver->faces_list,
|
|
|
|
(FT_List_Destructor)destroy_face,
|
|
|
|
memory,
|
|
|
|
driver );
|
|
|
|
|
|
|
|
/* finalize the driver object */
|
2000-01-10 18:19:45 +01:00
|
|
|
if ( driver->interface.done_driver )
|
|
|
|
driver->interface.done_driver( driver );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* finalize client-data */
|
2000-01-10 18:19:45 +01:00
|
|
|
if ( driver->generic.finalizer )
|
|
|
|
driver->generic.finalizer( driver );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* discard it */
|
|
|
|
FREE( driver );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Get_Raster */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Returns the raster interface corresponding to a given glyph format */
|
|
|
|
/* tag. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* library :: A handle to the source library object. */
|
|
|
|
/* */
|
|
|
|
/* glyph_format :: The glyph format tag. */
|
|
|
|
/* */
|
|
|
|
/* <Output> */
|
|
|
|
/* raster_funcs :: If this field is not 0, the raster's interface */
|
|
|
|
/* functions are returned. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* A pointer to the corresponding raster object. */
|
|
|
|
/* */
|
|
|
|
FT_EXPORT_FUNC( FT_Raster ) FT_Get_Raster(
|
|
|
|
FT_Library library,
|
|
|
|
FT_Glyph_Format glyph_format,
|
|
|
|
FT_Raster_Funcs* raster_funcs )
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
|
|
|
FT_Int n;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !library )
|
|
|
|
return 0;
|
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
for ( n = 0; n < FT_MAX_GLYPH_FORMATS; n++ )
|
|
|
|
{
|
|
|
|
FT_Raster_Funcs* funcs = &library->raster_funcs[n];
|
2000-05-31 08:55:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
if ( funcs->glyph_format == glyph_format )
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( raster_funcs )
|
2000-03-28 13:22:31 +02:00
|
|
|
*raster_funcs = *funcs;
|
|
|
|
return library->rasters[n];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* FT_Set_Raster */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* Registers a given raster to the library. */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* library :: A handle to a target library object. */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* */
|
|
|
|
/* raster_funcs :: A pointer to the raster's interface functions. */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* <Note> */
|
|
|
|
/* This function will do the following: */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* - A new raster object is created through `raster_func.raster_new'. */
|
|
|
|
/* If this fails, the function returns. */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* - If a raster is already registered for the glyph format */
|
|
|
|
/* specified in raster_funcs, it will be destroyed. */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* - The new raster is registered for the glyph format. */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Set_Raster( FT_Library library,
|
|
|
|
FT_Raster_Funcs* raster_funcs )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-02 02:01:14 +02:00
|
|
|
FT_Glyph_Format glyph_format;
|
2000-03-28 13:22:31 +02:00
|
|
|
FT_Raster_Funcs* funcs;
|
|
|
|
FT_Raster raster;
|
|
|
|
FT_Error error;
|
|
|
|
FT_Int n, index;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !library )
|
|
|
|
return FT_Err_Invalid_Library_Handle;
|
|
|
|
|
|
|
|
if ( !raster_funcs )
|
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
|
|
|
|
glyph_format = raster_funcs->glyph_format;
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( glyph_format == ft_glyph_format_none )
|
2000-03-28 13:22:31 +02:00
|
|
|
return FT_Err_Invalid_Argument;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
/* create a new raster object */
|
|
|
|
error = raster_funcs->raster_new( library->memory, &raster );
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
raster_funcs->raster_reset( raster,
|
|
|
|
library->raster_pool,
|
|
|
|
library->raster_pool_size );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
index = -1;
|
2000-05-31 08:55:12 +02:00
|
|
|
for ( n = 0; n < FT_MAX_GLYPH_FORMATS; n++ )
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
|
|
|
FT_Raster_Funcs* funcs = library->raster_funcs + n;
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
|
|
|
/* record the first vacant entry in `index' */
|
|
|
|
if ( index < 0 && funcs->glyph_format == ft_glyph_format_none )
|
2000-03-28 13:22:31 +02:00
|
|
|
index = n;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
/* compare this entry's glyph format with the one we need */
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( funcs->glyph_format == glyph_format )
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
2000-05-31 08:55:12 +02:00
|
|
|
/* A raster already exists for this glyph format. We will */
|
|
|
|
/* destroy it before updating its entry in the table. */
|
2000-03-28 13:22:31 +02:00
|
|
|
funcs->raster_done( library->rasters[n] );
|
|
|
|
index = n;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( index < 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-03-28 13:22:31 +02:00
|
|
|
/* the table is full and has no vacant entries */
|
|
|
|
error = FT_Err_Too_Many_Glyph_Formats;
|
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
funcs = library->raster_funcs + index;
|
|
|
|
*funcs = *raster_funcs;
|
|
|
|
library->rasters[index] = raster;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
Fail:
|
|
|
|
raster_funcs->raster_done( raster );
|
|
|
|
goto Exit;
|
2000-05-17 01:44:38 +02:00
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* FT_Unset_Raster */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* Removes a given raster from the library. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* library :: A handle to a target library object. */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* */
|
|
|
|
/* raster_funcs :: A pointer to the raster's interface functions. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error ) FT_Unset_Raster(
|
|
|
|
FT_Library library,
|
|
|
|
FT_Raster_Funcs* raster_funcs )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-02 02:01:14 +02:00
|
|
|
FT_Glyph_Format glyph_format;
|
2000-03-28 13:22:31 +02:00
|
|
|
FT_Error error;
|
|
|
|
FT_Int n;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !library )
|
|
|
|
return FT_Err_Invalid_Library_Handle;
|
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
error = FT_Err_Invalid_Argument;
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !raster_funcs )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
glyph_format = raster_funcs->glyph_format;
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( glyph_format == ft_glyph_format_none )
|
1999-12-17 00:11:37 +01:00
|
|
|
goto Exit;
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
for ( n = 0; n < FT_MAX_GLYPH_FORMATS; n++ )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-03-28 13:22:31 +02:00
|
|
|
FT_Raster_Funcs* funcs = library->raster_funcs + n;
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
|
|
|
if ( funcs->glyph_format == glyph_format )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-03-28 13:22:31 +02:00
|
|
|
funcs->raster_done( library->rasters[n] );
|
|
|
|
library->rasters[n] = 0;
|
|
|
|
library->raster_funcs[n].glyph_format = ft_glyph_format_none;
|
|
|
|
error = FT_Err_Ok;
|
|
|
|
break;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Set_Raster_Mode */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* Sets a raster-specific mode. */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* <InOut> */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* library :: A handle to a target library object. */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* format :: The glyph format used to select the raster. */
|
|
|
|
/* */
|
|
|
|
/* mode :: The raster-specific mode descriptor. */
|
|
|
|
/* */
|
|
|
|
/* args :: The mode arguments. */
|
|
|
|
/* */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* <Return> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
2000-03-28 13:22:31 +02:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Set_Raster_Mode( FT_Library library,
|
|
|
|
FT_Glyph_Format format,
|
|
|
|
unsigned long mode,
|
|
|
|
void* args )
|
2000-03-28 13:22:31 +02:00
|
|
|
{
|
|
|
|
FT_Raster_Funcs funcs;
|
|
|
|
FT_Raster raster;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !library )
|
|
|
|
return FT_Err_Invalid_Library_Handle;
|
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
raster = FT_Get_Raster( library, format, &funcs );
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( raster && args && funcs.raster_set_mode )
|
2000-03-28 13:22:31 +02:00
|
|
|
return funcs.raster_set_mode( raster, mode, args );
|
|
|
|
else
|
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
}
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Set_Debug_Hook */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Sets a debug hook function for debugging the interpreter of a */
|
|
|
|
/* font format. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* library :: A handle to the library object. */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* hook_index :: The index of the debug hook. You should use the */
|
|
|
|
/* values defined in ftobjs.h, e.g. */
|
|
|
|
/* FT_DEBUG_HOOK_TRUETYPE */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* debug_hook :: The function used to debug the interpreter. */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* Currently, four debug hook slots are available, but only two (for */
|
|
|
|
/* the TrueType and the Type 1 interpreter) are defined. */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( void ) FT_Set_Debug_Hook( FT_Library library,
|
|
|
|
FT_UInt hook_index,
|
|
|
|
FT_DebugHook_Func debug_hook )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( library && debug_hook &&
|
|
|
|
hook_index <
|
2000-05-31 08:55:12 +02:00
|
|
|
( sizeof ( library->debug_hooks ) / sizeof ( void* ) ) )
|
1999-12-17 00:11:37 +01:00
|
|
|
library->debug_hooks[hook_index] = debug_hook;
|
|
|
|
}
|
2000-01-10 18:19:45 +01:00
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_New_Library */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* This function is used to create a new FreeType library instance */
|
|
|
|
/* from a given memory object. It is thus possible to use libraries */
|
|
|
|
/* with distinct memory allocators within the same program. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* memory :: A handle to the original memory object. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Output> */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* alibrary :: A pointer to handle of a new library object. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_New_Library( FT_Memory memory,
|
|
|
|
FT_Library* alibrary )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-02 02:01:14 +02:00
|
|
|
FT_Library library = 0;
|
|
|
|
FT_Error error;
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !memory )
|
|
|
|
return FT_Err_Invalid_Argument;
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
/* first of all, allocate the library object */
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( ALLOC( library, sizeof ( *library ) ) )
|
|
|
|
return error;
|
|
|
|
|
|
|
|
library->memory = memory;
|
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
/* allocate the render pool */
|
|
|
|
library->raster_pool_size = FT_RENDER_POOL_SIZE;
|
|
|
|
if ( ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) )
|
|
|
|
goto Fail;
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
/* now register the default raster for the `outline' glyph image */
|
|
|
|
/* format for now, ignore the error... */
|
2000-03-28 13:22:31 +02:00
|
|
|
error = FT_Set_Raster( library, &ft_default_raster );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/* That's ok now */
|
|
|
|
*alibrary = library;
|
|
|
|
|
|
|
|
return FT_Err_Ok;
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
Fail:
|
|
|
|
FREE( library );
|
|
|
|
return error;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Done_Library */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Discards a given library object. This closes all drivers and */
|
|
|
|
/* discards all resource objects. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* library :: A handle to the target library. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Done_Library( FT_Library library )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_Int n;
|
|
|
|
|
|
|
|
|
|
|
|
if ( !library )
|
|
|
|
return FT_Err_Invalid_Library_Handle;
|
|
|
|
|
|
|
|
memory = library->memory;
|
|
|
|
|
|
|
|
/* Discard client-data */
|
2000-01-10 18:19:45 +01:00
|
|
|
if ( library->generic.finalizer )
|
1999-12-17 00:11:37 +01:00
|
|
|
library->generic.finalizer( library );
|
|
|
|
|
|
|
|
/* Close all drivers in the library */
|
|
|
|
for ( n = 0; n < library->num_drivers; n++ )
|
|
|
|
{
|
|
|
|
FT_Driver driver = library->drivers[n];
|
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( driver )
|
|
|
|
{
|
|
|
|
Destroy_Driver( driver );
|
|
|
|
library->drivers[n] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
/* Destroy raster objects */
|
2000-02-16 09:23:58 +01:00
|
|
|
FREE( library->raster_pool );
|
2000-03-28 13:22:31 +02:00
|
|
|
library->raster_pool_size = 0;
|
2000-01-10 18:19:45 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_Raster_Funcs* cur = library->raster_funcs;
|
|
|
|
FT_Raster_Funcs* limit = cur + FT_MAX_GLYPH_FORMATS;
|
2000-03-28 13:22:31 +02:00
|
|
|
FT_Raster* raster = library->rasters;
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
for ( ; cur < limit; cur++, raster++ )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-03-28 13:22:31 +02:00
|
|
|
if ( cur->glyph_format != ft_glyph_format_none )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-03-28 13:22:31 +02:00
|
|
|
cur->raster_done( *raster );
|
|
|
|
*raster = 0;
|
|
|
|
cur->glyph_format = ft_glyph_format_none;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FREE( library );
|
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Add_Driver */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Registers a new driver in a given library object. This function */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* takes only a pointer to a driver interface; it uses it to create */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* the new driver, then sets up some important fields. */
|
|
|
|
/* */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* <InOut> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* library :: A handle to the target library object. */
|
|
|
|
/* */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* <Input> */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* driver_interface :: A pointer to a driver interface table. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* This function doesn't check whether the driver is already */
|
|
|
|
/* installed! */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Add_Driver(
|
|
|
|
FT_Library library,
|
|
|
|
const FT_DriverInterface* driver_interface )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Driver driver;
|
|
|
|
FT_Memory memory;
|
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !library )
|
1999-12-17 00:11:37 +01:00
|
|
|
return FT_Err_Invalid_Library_Handle;
|
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !driver_interface )
|
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
memory = library->memory;
|
|
|
|
error = FT_Err_Ok;
|
|
|
|
|
|
|
|
if ( library->num_drivers >= FT_MAX_DRIVERS )
|
|
|
|
error = FT_Err_Too_Many_Drivers;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( ALLOC( driver, driver_interface->driver_object_size ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
driver->library = library;
|
|
|
|
driver->memory = memory;
|
|
|
|
driver->interface = *driver_interface;
|
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
if ( driver_interface->init_driver )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
error = driver_interface->init_driver( driver );
|
2000-01-10 18:19:45 +01:00
|
|
|
if ( error )
|
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
library->drivers[library->num_drivers++] = driver;
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
Fail:
|
|
|
|
FREE( driver );
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Remove_Driver */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* Unregisters a given driver. This closes the driver, which in turn */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* destroys all faces, sizes, slots, etc. associated with it. */
|
|
|
|
/* */
|
|
|
|
/* This function also DESTROYS the driver object. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* driver :: A handle to target driver object. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Remove_Driver( FT_Driver driver )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Library library;
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_Driver *cur, *last;
|
|
|
|
FT_Error error;
|
|
|
|
|
|
|
|
|
|
|
|
if ( !driver )
|
|
|
|
return FT_Err_Invalid_Driver_Handle;
|
|
|
|
|
|
|
|
library = driver->library;
|
|
|
|
memory = driver->memory;
|
|
|
|
|
|
|
|
if ( !library || !memory )
|
|
|
|
return FT_Err_Invalid_Driver_Handle;
|
|
|
|
|
|
|
|
/* look-up driver entry in library table */
|
|
|
|
error = FT_Err_Invalid_Driver_Handle;
|
|
|
|
cur = library->drivers;
|
|
|
|
last = cur + library->num_drivers - 1;
|
|
|
|
|
|
|
|
for ( ; cur <= last; cur++ )
|
|
|
|
{
|
|
|
|
if ( *cur == driver )
|
|
|
|
{
|
2000-02-16 09:23:58 +01:00
|
|
|
/* destroy the driver object */
|
1999-12-17 00:11:37 +01:00
|
|
|
Destroy_Driver( driver );
|
|
|
|
|
|
|
|
/* now move the last driver in the table to the vacant slot */
|
2000-01-10 18:19:45 +01:00
|
|
|
if ( cur < last )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
*cur = *last;
|
|
|
|
*last = 0;
|
|
|
|
}
|
|
|
|
library->num_drivers--;
|
|
|
|
|
|
|
|
/* exit loop */
|
|
|
|
error = FT_Err_Ok;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Get_Driver */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* Returns the handle of the driver responsible for a given format */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* (or service) according to its `name'. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* library :: A handle to the library object. */
|
|
|
|
/* driver_name :: The name of the driver to look up. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* A handle to the driver object, 0 otherwise. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Driver ) FT_Get_Driver( FT_Library library,
|
|
|
|
char* driver_name )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Driver *cur, *limit;
|
2000-01-10 18:19:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
if ( !library || !driver_name )
|
1999-12-17 00:11:37 +01:00
|
|
|
return 0;
|
2000-01-10 18:19:45 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
cur = library->drivers;
|
|
|
|
limit = cur + library->num_drivers;
|
|
|
|
for ( ; cur < limit; cur++ )
|
|
|
|
{
|
|
|
|
if ( strcmp( (*cur)->interface.driver_name, driver_name ) == 0 )
|
|
|
|
return *cur;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* open_face */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* This function does some work for FT_Open_Face(). */
|
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
static
|
2000-05-12 12:19:41 +02:00
|
|
|
FT_Error open_face( FT_Driver driver,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_Long face_index,
|
|
|
|
FT_Int num_params,
|
|
|
|
FT_Parameter* params,
|
|
|
|
FT_Face* aface )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_DriverInterface* interface;
|
|
|
|
FT_Face face = 0;
|
|
|
|
FT_Error error;
|
|
|
|
|
|
|
|
|
|
|
|
interface = &driver->interface;
|
|
|
|
memory = driver->memory;
|
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
/* allocate the face object, and perform basic initialization */
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( ALLOC( face, interface->face_object_size ) )
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
face->driver = driver;
|
|
|
|
face->memory = memory;
|
|
|
|
face->stream = stream;
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
error = interface->init_face( stream,
|
|
|
|
face,
|
|
|
|
face_index,
|
|
|
|
num_params,
|
|
|
|
params );
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( error )
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
*aface = face;
|
|
|
|
|
|
|
|
Fail:
|
|
|
|
if ( error )
|
|
|
|
{
|
|
|
|
interface->done_face( face );
|
|
|
|
FREE( face );
|
|
|
|
*aface = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_New_Face */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* Creates a new face object from a given resource and typeface index */
|
|
|
|
/* using a pathname to the font file. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* <InOut> */
|
|
|
|
/* library :: A handle to the library resource. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* <Input> */
|
|
|
|
/* pathname :: A path to the font file. */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* face_index :: The index of the face within the resource. The */
|
|
|
|
/* first face has index 0. */
|
|
|
|
/* <Output> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* aface :: A handle to a new face object. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* Unlike FreeType 1.x, this function automatically creates a glyph */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* slot for the face object which can be accessed directly through */
|
|
|
|
/* `face->glyph'. */
|
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* Note that additional slots can be added to each face with the */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* FT_New_GlyphSlot() API function. Slots are linked in a single */
|
|
|
|
/* list through their `next' field. */
|
|
|
|
/* */
|
|
|
|
/* FT_New_Face() can be used to determine and/or check the font */
|
|
|
|
/* format of a given font resource. If the `face_index' field is */
|
|
|
|
/* negative, the function will _not_ return any face handle in */
|
|
|
|
/* `*face'. Its return value should be 0 if the resource is */
|
|
|
|
/* recognized, or non-zero if not. */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_New_Face( FT_Library library,
|
|
|
|
const char* pathname,
|
|
|
|
FT_Long face_index,
|
|
|
|
FT_Face* aface )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-03-28 13:22:31 +02:00
|
|
|
FT_Open_Args args;
|
2000-02-16 09:23:58 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
/* test for valid `library' and `aface' delayed to FT_Open_Face() */
|
|
|
|
|
|
|
|
if ( !pathname )
|
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
|
2000-05-12 12:19:41 +02:00
|
|
|
args.flags = ft_open_pathname;
|
|
|
|
args.pathname = (char*)pathname;
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-02-10 17:14:35 +01:00
|
|
|
return FT_Open_Face( library, &args, face_index, aface );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_New_Memory_Face */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Creates a new face object from a given resource and typeface index */
|
|
|
|
/* using a font file already loaded into memory. */
|
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* library :: A handle to the library resource. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* file_base :: A pointer to the beginning of the font data. */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* file_size :: The size of the memory chunk used by the font data. */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* face_index :: The index of the face within the resource. The */
|
|
|
|
/* first face has index 0. */
|
|
|
|
/* <Output> */
|
|
|
|
/* face :: A handle to a new face object. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* FreeType error code. 0 means success. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* Unlike FreeType 1.x, this function automatically creates a glyph */
|
|
|
|
/* slot for the face object which can be accessed directly through */
|
|
|
|
/* `face->glyph'. */
|
|
|
|
/* */
|
|
|
|
/* Note that additional slots can be added to each face with the */
|
|
|
|
/* FT_New_GlyphSlot() API function. Slots are linked in a single */
|
|
|
|
/* list through their `next' field. */
|
|
|
|
/* */
|
|
|
|
/* FT_New_Memory_Face() can be used to determine and/or check the */
|
|
|
|
/* font format of a given font resource. If the `face_index' field */
|
|
|
|
/* is negative, the function will _not_ return any face handle in */
|
|
|
|
/* `*face'. Its return value should be 0 if the resource is */
|
|
|
|
/* recognized, or non-zero if not. */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_New_Memory_Face( FT_Library library,
|
|
|
|
void* file_base,
|
|
|
|
FT_Long file_size,
|
|
|
|
FT_Long face_index,
|
|
|
|
FT_Face* face )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-03-28 13:22:31 +02:00
|
|
|
FT_Open_Args args;
|
2000-02-16 09:23:58 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
/* test for valid `library' and `face' delayed to FT_Open_Face() */
|
|
|
|
|
|
|
|
if ( !file_base )
|
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
|
2000-05-12 12:19:41 +02:00
|
|
|
args.flags = ft_open_memory;
|
2000-02-10 17:14:35 +01:00
|
|
|
args.memory_base = file_base;
|
|
|
|
args.memory_size = file_size;
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-02-10 17:14:35 +01:00
|
|
|
return FT_Open_Face( library, &args, face_index, face );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Open_Face */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Opens a face object from a given resource and typeface index using */
|
|
|
|
/* an `FT_Open_Args' structure. If the face object doesn't exist, it */
|
|
|
|
/* will be created. */
|
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* library :: A handle to the library resource. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* args :: A pointer to an `FT_Open_Args' structure which must */
|
|
|
|
/* be filled by the caller. */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* face_index :: The index of the face within the resource. The */
|
|
|
|
/* first face has index 0. */
|
|
|
|
/* <Output> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* aface :: A handle to a new face object. */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* FreeType error code. 0 means success. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* Unlike FreeType 1.x, this function automatically creates a glyph */
|
|
|
|
/* slot for the face object which can be accessed directly through */
|
|
|
|
/* `face->glyph'. */
|
|
|
|
/* */
|
|
|
|
/* Note that additional slots can be added to each face with the */
|
|
|
|
/* FT_New_GlyphSlot() API function. Slots are linked in a single */
|
|
|
|
/* list through their `next' field. */
|
|
|
|
/* */
|
|
|
|
/* FT_Open_Face() can be used to determine and/or check the font */
|
|
|
|
/* format of a given font resource. If the `face_index' field is */
|
|
|
|
/* negative, the function will _not_ return any face handle in */
|
|
|
|
/* `*face'. Its return value should be 0 if the resource is */
|
|
|
|
/* recognized, or non-zero if not. */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Open_Face( FT_Library library,
|
|
|
|
FT_Open_Args* args,
|
|
|
|
FT_Long face_index,
|
|
|
|
FT_Face* aface )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Driver driver;
|
|
|
|
FT_Memory memory;
|
2000-02-10 17:14:35 +01:00
|
|
|
FT_Stream stream;
|
1999-12-17 00:11:37 +01:00
|
|
|
FT_Face face = 0;
|
|
|
|
FT_ListNode node = 0;
|
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
/* test for valid `library' and `args' delayed to */
|
|
|
|
/* ft_new_input_stream() */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !aface )
|
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
|
|
|
|
*aface = 0;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-02-10 17:14:35 +01:00
|
|
|
/* create input stream */
|
|
|
|
error = ft_new_input_stream( library, args, &stream );
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2000-02-10 17:14:35 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
memory = library->memory;
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
/* If the font driver is specified in the `args' structure, use */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* it. Otherwise, we'll scan the list of registered drivers. */
|
2000-05-12 12:19:41 +02:00
|
|
|
if ( args->flags & ft_open_driver && args->driver )
|
2000-02-13 14:37:38 +01:00
|
|
|
{
|
|
|
|
driver = args->driver;
|
2000-02-16 09:23:58 +01:00
|
|
|
/* not all drivers directly support face objects, so check... */
|
|
|
|
if ( driver->interface.face_object_size )
|
2000-02-13 14:37:38 +01:00
|
|
|
{
|
2000-05-12 12:19:41 +02:00
|
|
|
FT_Int num_params = 0;
|
|
|
|
FT_Parameter* params = 0;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-05-12 12:19:41 +02:00
|
|
|
if ( args->flags & ft_open_params )
|
|
|
|
{
|
|
|
|
num_params = args->num_params;
|
|
|
|
params = args->params;
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-05-12 12:19:41 +02:00
|
|
|
error = open_face( driver, stream, face_index,
|
|
|
|
num_params, params, &face );
|
2000-02-16 09:23:58 +01:00
|
|
|
if ( !error )
|
|
|
|
goto Success;
|
2000-02-13 14:37:38 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
error = FT_Err_Invalid_Handle;
|
|
|
|
|
|
|
|
goto Fail;
|
|
|
|
}
|
2000-03-02 11:52:57 +01:00
|
|
|
else
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
/* check each font driver for an appropriate format */
|
2000-01-10 18:19:45 +01:00
|
|
|
FT_Driver* cur = library->drivers;
|
|
|
|
FT_Driver* limit = cur + library->num_drivers;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
for ( ; cur < limit; cur++ )
|
|
|
|
{
|
|
|
|
driver = *cur;
|
2000-02-16 09:23:58 +01:00
|
|
|
/* not all drivers directly support face objects, so check... */
|
|
|
|
if ( driver->interface.face_object_size )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-05-12 12:19:41 +02:00
|
|
|
FT_Int num_params = 0;
|
|
|
|
FT_Parameter* params = 0;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-05-12 12:19:41 +02:00
|
|
|
if ( args->flags & ft_open_params )
|
|
|
|
{
|
|
|
|
num_params = args->num_params;
|
|
|
|
params = args->params;
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-05-12 12:19:41 +02:00
|
|
|
error = open_face( driver, stream, face_index,
|
|
|
|
num_params, params, &face );
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( !error )
|
|
|
|
goto Success;
|
|
|
|
|
|
|
|
if ( error != FT_Err_Unknown_File_Format )
|
2000-02-10 17:14:35 +01:00
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no driver is able to handle this format */
|
|
|
|
error = FT_Err_Unknown_File_Format;
|
2000-02-10 17:14:35 +01:00
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Success:
|
|
|
|
FT_TRACE4(( "FT_New_Face: New face object, adding to list\n" ));
|
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
/* add the face object to its driver's list */
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( ALLOC( node, sizeof ( *node ) ) )
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
node->data = face;
|
2000-05-31 08:55:12 +02:00
|
|
|
/* don't assume driver is the same as face->driver, so use */
|
|
|
|
/* face->driver instead. */
|
2000-03-05 17:07:58 +01:00
|
|
|
FT_List_Add( &face->driver->faces_list, node );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
/* now allocate a glyph slot object for the face */
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_GlyphSlot slot;
|
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" ));
|
|
|
|
error = FT_New_GlyphSlot( face, &slot );
|
2000-02-16 09:23:58 +01:00
|
|
|
if ( error )
|
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
/* finally, allocate a size object for the face */
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Size size;
|
|
|
|
|
2000-02-16 09:23:58 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
FT_TRACE4(( "FT_Open_Face: Creating size object\n" ));
|
|
|
|
error = FT_New_Size( face, &size );
|
2000-02-16 09:23:58 +01:00
|
|
|
if ( error )
|
|
|
|
goto Fail;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
/* initialize transformation for convenience functions */
|
2000-03-28 13:22:31 +02:00
|
|
|
face->transform_matrix.xx = 0x10000L;
|
|
|
|
face->transform_matrix.xy = 0;
|
|
|
|
face->transform_matrix.yx = 0;
|
|
|
|
face->transform_matrix.yy = 0x10000L;
|
|
|
|
|
|
|
|
face->transform_delta.x = 0;
|
|
|
|
face->transform_delta.y = 0;
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
*aface = face;
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
Fail:
|
|
|
|
FT_Done_Face( face );
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
FT_TRACE4(( "FT_Open_Face: Return %d\n", error ));
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Attach_File */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* `Attaches' a given font file to an existing face. This is usually */
|
|
|
|
/* to read additional information for a single face object. For */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* example, it is used to read the AFM files that come with Type 1 */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* fonts in order to add kerning data and other metrics. */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* <InOut> */
|
|
|
|
/* face :: The target face object. */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* <Input> */
|
|
|
|
/* filepathname :: An 8-bit pathname naming the `metrics' file. */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* FreeType error code. 0 means success. */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* If your font file is in memory, or if you want to provide your */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* own input stream object, use FT_Attach_Stream(). */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* The meaning of the `attach' action (i.e., what really happens when */
|
|
|
|
/* the new file is read) is not fixed by FreeType itself. It really */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* depends on the font format (and thus the font driver). */
|
|
|
|
/* */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* Client applications are expected to know what they are doing */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* when invoking this function. Most drivers simply do not implement */
|
2000-02-16 09:23:58 +01:00
|
|
|
/* file attachments. */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Attach_File( FT_Face face,
|
|
|
|
const char* filepathname )
|
2000-02-13 14:37:38 +01:00
|
|
|
{
|
2000-03-28 13:22:31 +02:00
|
|
|
FT_Open_Args open;
|
2000-02-13 14:37:38 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
/* test for valid `face' delayed to FT_Attach_Stream() */
|
|
|
|
|
|
|
|
if ( !filepathname )
|
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
|
2000-05-12 12:19:41 +02:00
|
|
|
open.flags = ft_open_pathname;
|
|
|
|
open.pathname = (char*)filepathname;
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
return FT_Attach_Stream( face, &open );
|
|
|
|
}
|
2000-02-16 09:23:58 +01:00
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Attach_Stream */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* This function is similar to FT_Attach_File() with the exception */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* that it reads the attachment from an arbitrary stream. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* face :: The target face object. */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* parameters :: A pointer to an FT_Open_Args structure used to */
|
|
|
|
/* describe the input stream to FreeType. */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* <Return> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* <Note> */
|
|
|
|
/* The meaning of the `attach' (i.e. what really happens when the */
|
|
|
|
/* new file is read) is not fixed by FreeType itself. It really */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* depends on the font format (and thus the font driver). */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* Client applications are expected to know what they are doing */
|
|
|
|
/* when invoking this function. Most drivers simply do not implement */
|
|
|
|
/* file attachments. */
|
2000-02-13 14:37:38 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Attach_Stream( FT_Face face,
|
|
|
|
FT_Open_Args* parameters )
|
2000-02-13 14:37:38 +01:00
|
|
|
{
|
|
|
|
FT_Stream stream;
|
|
|
|
FT_Error error;
|
|
|
|
FT_Driver driver;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
FTDriver_getInterface get_interface;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
/* test for valid `parameters' delayed to ft_new_input_stream() */
|
|
|
|
|
|
|
|
if ( !face )
|
|
|
|
return FT_Err_Invalid_Face_Handle;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
driver = face->driver;
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !driver )
|
|
|
|
return FT_Err_Invalid_Driver_Handle;
|
|
|
|
|
|
|
|
error = ft_new_input_stream( driver->library, parameters, &stream );
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
/* we implement FT_Attach_Stream in each driver through the */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* `attach_file' interface */
|
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
error = FT_Err_Unimplemented_Feature;
|
|
|
|
|
|
|
|
get_interface = driver->interface.get_interface;
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( get_interface )
|
2000-02-13 14:37:38 +01:00
|
|
|
{
|
|
|
|
FT_Attach_Reader reader;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-02-15 13:54:06 +01:00
|
|
|
reader = (FT_Attach_Reader)(get_interface( driver, "attach_file" ));
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( reader )
|
2000-02-13 14:37:38 +01:00
|
|
|
error = reader( face, stream );
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
/* close the attached stream */
|
|
|
|
ft_done_stream( &stream );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-02-13 14:37:38 +01:00
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Done_Face */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Discards a given face object, as well as all of its child slots */
|
|
|
|
/* and sizes. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* face :: A handle to a target face object. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Done_Face( FT_Face face )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Driver driver;
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_DriverInterface* interface;
|
|
|
|
FT_ListNode node;
|
|
|
|
|
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !face )
|
1999-12-17 00:11:37 +01:00
|
|
|
return FT_Err_Invalid_Face_Handle;
|
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
driver = face->driver;
|
|
|
|
if ( !driver )
|
|
|
|
return FT_Err_Invalid_Driver_Handle;
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
interface = &driver->interface;
|
|
|
|
memory = driver->memory;
|
|
|
|
|
|
|
|
/* find face in driver's list */
|
|
|
|
node = FT_List_Find( &driver->faces_list, face );
|
|
|
|
if ( node )
|
|
|
|
{
|
|
|
|
/* remove face object from the driver's list */
|
|
|
|
FT_List_Remove( &driver->faces_list, node );
|
|
|
|
FREE( node );
|
|
|
|
|
|
|
|
/* now destroy the object proper */
|
|
|
|
destroy_face( memory, face, driver );
|
|
|
|
error = FT_Err_Ok;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
error = FT_Err_Invalid_Face_Handle;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_New_Size */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Creates a new size object from a given face object. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* face :: A handle to a parent face object. */
|
|
|
|
/* */
|
|
|
|
/* <Output> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* asize :: A handle to a new size object. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_New_Size( FT_Face face,
|
|
|
|
FT_Size* asize )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_Driver driver;
|
|
|
|
FT_DriverInterface* interface;
|
|
|
|
|
|
|
|
FT_Size size = 0;
|
|
|
|
FT_ListNode node = 0;
|
|
|
|
|
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !face )
|
1999-12-17 00:11:37 +01:00
|
|
|
return FT_Err_Invalid_Face_Handle;
|
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !asize )
|
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
|
|
|
|
*asize = 0;
|
|
|
|
|
|
|
|
driver = face->driver;
|
|
|
|
if ( !driver )
|
|
|
|
return FT_Err_Invalid_Driver_Handle;
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
interface = &driver->interface;
|
|
|
|
memory = face->memory;
|
|
|
|
|
|
|
|
/* Allocate new size object and perform basic initialisation */
|
|
|
|
if ( ALLOC( size, interface->size_object_size ) ||
|
|
|
|
ALLOC( node, sizeof ( FT_ListNodeRec ) ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
size->face = face;
|
|
|
|
|
|
|
|
error = interface->init_size( size );
|
|
|
|
|
|
|
|
/* in case of success, add to the face's list */
|
|
|
|
if ( !error )
|
|
|
|
{
|
|
|
|
*asize = size;
|
|
|
|
node->data = size;
|
|
|
|
FT_List_Add( &face->sizes_list, node );
|
2000-01-10 18:19:45 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/* record as current size for the face */
|
|
|
|
face->size = size;
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
if ( error )
|
|
|
|
{
|
|
|
|
FREE( node );
|
|
|
|
FREE( size );
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Done_Size */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Discards a given size object. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* size :: A handle to a target size object. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Done_Size( FT_Size size )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Driver driver;
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_Face face;
|
|
|
|
FT_ListNode node;
|
|
|
|
|
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !size )
|
1999-12-17 00:11:37 +01:00
|
|
|
return FT_Err_Invalid_Size_Handle;
|
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
face = size->face;
|
|
|
|
if ( !face )
|
|
|
|
return FT_Err_Invalid_Face_Handle;
|
|
|
|
|
|
|
|
driver = face->driver;
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( !driver )
|
|
|
|
return FT_Err_Invalid_Driver_Handle;
|
|
|
|
|
|
|
|
memory = driver->memory;
|
|
|
|
|
|
|
|
error = FT_Err_Ok;
|
|
|
|
node = FT_List_Find( &face->sizes_list, size );
|
|
|
|
if ( node )
|
|
|
|
{
|
|
|
|
FT_List_Remove( &face->sizes_list, node );
|
|
|
|
FREE( node );
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( face->size == size )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
face->size = 0;
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( face->sizes_list.head )
|
1999-12-17 00:11:37 +01:00
|
|
|
face->size = (FT_Size)(face->sizes_list.head->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
destroy_size( memory, size, driver );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
error = FT_Err_Invalid_Size_Handle;
|
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Set_Char_Size */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* Sets the character dimensions of a given face object. The */
|
|
|
|
/* `char_width' and `char_height' values are used for the width and */
|
|
|
|
/* height, respectively, expressed in 26.6 fractional points. */
|
|
|
|
/* */
|
|
|
|
/* If the horizontal or vertical resolution values are zero, a */
|
|
|
|
/* default value of 72dpi is used. Similarly, if one of the */
|
|
|
|
/* character dimensions is zero, its value is set equal to the other. */
|
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* size :: A handle to a target size object. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* char_width :: The character width, in 26.6 fractional points. */
|
|
|
|
/* */
|
|
|
|
/* char_height :: The character height, in 26.6 fractional */
|
|
|
|
/* points. */
|
|
|
|
/* */
|
|
|
|
/* horz_resolution :: The horizontal resolution. */
|
|
|
|
/* */
|
|
|
|
/* vert_resolution :: The vertical resolution. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* When dealing with fixed-size faces (i.e., non-scalable formats), */
|
|
|
|
/* use the function FT_Set_Pixel_Sizes(). */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Set_Char_Size( FT_Face face,
|
|
|
|
FT_F26Dot6 char_width,
|
|
|
|
FT_F26Dot6 char_height,
|
|
|
|
FT_UInt horz_resolution,
|
|
|
|
FT_UInt vert_resolution )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Driver driver;
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_DriverInterface* interface;
|
2000-06-02 02:01:14 +02:00
|
|
|
FT_Size_Metrics* metrics;
|
2000-01-27 14:56:02 +01:00
|
|
|
FT_Long dim_x, dim_y;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !face )
|
1999-12-17 00:11:37 +01:00
|
|
|
return FT_Err_Invalid_Face_Handle;
|
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !face->size )
|
|
|
|
return FT_Err_Invalid_Size_Handle;
|
|
|
|
|
|
|
|
driver = face->driver;
|
|
|
|
if ( !driver )
|
|
|
|
return FT_Err_Invalid_Driver_Handle;
|
|
|
|
|
|
|
|
metrics = &face->size->metrics;
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( !char_width )
|
1999-12-17 00:11:37 +01:00
|
|
|
char_width = char_height;
|
2000-05-31 08:55:12 +02:00
|
|
|
else if ( !char_height )
|
1999-12-17 00:11:37 +01:00
|
|
|
char_height = char_width;
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( !horz_resolution )
|
1999-12-17 00:11:37 +01:00
|
|
|
horz_resolution = 72;
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( !vert_resolution )
|
1999-12-17 00:11:37 +01:00
|
|
|
vert_resolution = 72;
|
|
|
|
|
|
|
|
driver = face->driver;
|
|
|
|
interface = &driver->interface;
|
|
|
|
memory = driver->memory;
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
/* default processing -- this can be overridden by the driver */
|
|
|
|
if ( char_width < 1 * 64 ) char_width = 1 * 64;
|
|
|
|
if ( char_height < 1 * 64 ) char_height = 1 * 64;
|
2000-01-27 14:56:02 +01:00
|
|
|
|
|
|
|
/* Compute pixel sizes in 26.6 units */
|
2000-05-31 08:55:12 +02:00
|
|
|
dim_x = ( ( ( char_width * horz_resolution ) / 72 ) + 32 ) & -64;
|
|
|
|
dim_y = ( ( ( char_height * vert_resolution ) / 72 ) + 32 ) & -64;
|
2000-01-27 14:56:02 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
metrics->x_ppem = (FT_UShort)(dim_x >> 6);
|
|
|
|
metrics->y_ppem = (FT_UShort)(dim_y >> 6);
|
2000-01-27 14:56:02 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
metrics->x_scale = 0x10000L;
|
|
|
|
metrics->y_scale = 0x10000L;
|
|
|
|
|
|
|
|
if ( face->face_flags & FT_FACE_FLAG_SCALABLE )
|
2000-01-27 14:56:02 +01:00
|
|
|
{
|
|
|
|
metrics->x_scale = FT_DivFix( dim_x, face->units_per_EM );
|
|
|
|
metrics->y_scale = FT_DivFix( dim_y, face->units_per_EM );
|
|
|
|
}
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
error = interface->set_char_sizes( face->size,
|
|
|
|
char_width,
|
|
|
|
char_height,
|
|
|
|
horz_resolution,
|
|
|
|
vert_resolution );
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Set_Pixel_Sizes */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* Sets the character dimensions of a given face object. The width */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* and height are expressed in integer pixels. */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* If one of the character dimensions is zero, its value is set equal */
|
|
|
|
/* to the other. */
|
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* face :: A handle to the target face object. */
|
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* <Input> */
|
|
|
|
/* pixel_width :: The character width, in integer pixels. */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* pixel_height :: The character height, in integer pixels. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Set_Pixel_Sizes( FT_Face face,
|
|
|
|
FT_UInt pixel_width,
|
|
|
|
FT_UInt pixel_height )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Driver driver;
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_DriverInterface* interface;
|
2000-01-27 14:56:02 +01:00
|
|
|
FT_Size_Metrics* metrics = &face->size->metrics;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !face )
|
1999-12-17 00:11:37 +01:00
|
|
|
return FT_Err_Invalid_Face_Handle;
|
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !face->size )
|
|
|
|
return FT_Err_Invalid_Size_Handle;
|
|
|
|
|
|
|
|
driver = face->driver;
|
|
|
|
if ( !driver )
|
|
|
|
return FT_Err_Invalid_Driver_Handle;
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
interface = &driver->interface;
|
|
|
|
memory = driver->memory;
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
/* default processing -- this can be overridden by the driver */
|
|
|
|
if ( pixel_width == 0 )
|
2000-05-26 19:13:23 +02:00
|
|
|
pixel_width = pixel_height;
|
2000-05-31 08:55:12 +02:00
|
|
|
else if ( pixel_height == 0 )
|
2000-05-26 19:13:23 +02:00
|
|
|
pixel_height = pixel_width;
|
2000-06-03 08:03:11 +02:00
|
|
|
|
2000-01-27 14:56:02 +01:00
|
|
|
if ( pixel_width < 1 ) pixel_width = 1;
|
|
|
|
if ( pixel_height < 1 ) pixel_height = 1;
|
|
|
|
|
|
|
|
metrics->x_ppem = pixel_width;
|
|
|
|
metrics->y_ppem = pixel_height;
|
|
|
|
|
|
|
|
if ( face->face_flags & FT_FACE_FLAG_SCALABLE )
|
|
|
|
{
|
|
|
|
metrics->x_scale = FT_DivFix( metrics->x_ppem << 6,
|
|
|
|
face->units_per_EM );
|
|
|
|
|
|
|
|
metrics->y_scale = FT_DivFix( metrics->y_ppem << 6,
|
|
|
|
face->units_per_EM );
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
error = interface->set_pixel_sizes( face->size,
|
2000-01-27 14:56:02 +01:00
|
|
|
pixel_width,
|
|
|
|
pixel_height );
|
1999-12-17 00:11:37 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_New_GlyphSlot */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* It is sometimes useful to have more than one glyph slot for a */
|
|
|
|
/* given face object. This function is used to create additional */
|
|
|
|
/* slots. All of them are automatically discarded when the face is */
|
|
|
|
/* destroyed. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* face :: A handle to a parent face object. */
|
|
|
|
/* */
|
|
|
|
/* <Output> */
|
|
|
|
/* aslot :: A handle to a new glyph slot object. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_New_GlyphSlot( FT_Face face,
|
|
|
|
FT_GlyphSlot* aslot )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Driver driver;
|
|
|
|
FT_DriverInterface* interface;
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_GlyphSlot slot;
|
|
|
|
|
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !face )
|
|
|
|
return FT_Err_Invalid_Face_Handle;
|
|
|
|
|
|
|
|
if ( !aslot )
|
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
*aslot = 0;
|
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
driver = face->driver;
|
|
|
|
if ( !driver )
|
|
|
|
return FT_Err_Invalid_Driver_Handle;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
interface = &driver->interface;
|
|
|
|
memory = driver->memory;
|
|
|
|
|
|
|
|
FT_TRACE4(( "FT_New_GlyphSlot: Creating new slot object\n" ));
|
|
|
|
if ( ALLOC( slot, interface->slot_object_size ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
slot->face = face;
|
2000-01-10 18:19:45 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
slot->max_subglyphs = 0;
|
|
|
|
slot->num_subglyphs = 0;
|
|
|
|
slot->subglyphs = 0;
|
|
|
|
|
|
|
|
error = interface->init_glyph_slot( slot );
|
|
|
|
if ( !error )
|
|
|
|
{
|
|
|
|
/* in case of success, add slot to the face's list */
|
|
|
|
slot->next = face->glyph;
|
|
|
|
face->glyph = slot;
|
|
|
|
*aslot = slot;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( error )
|
|
|
|
FREE( slot );
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
FT_TRACE4(( "FT_New_GlyphSlot: Return %d\n", error ));
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Done_GlyphSlot */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Destroys a given glyph slot. Remember however that all slots are */
|
|
|
|
/* automatically destroyed with its parent. Using this function is */
|
|
|
|
/* not always mandatory. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* slot :: A handle to a target glyph slot. */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( void ) FT_Done_GlyphSlot( FT_GlyphSlot slot )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( slot )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Driver driver = slot->face->driver;
|
|
|
|
FT_Memory memory = driver->memory;
|
|
|
|
FT_GlyphSlot* parent;
|
|
|
|
FT_GlyphSlot cur;
|
|
|
|
|
|
|
|
|
|
|
|
/* Remove slot from its parent face's list */
|
|
|
|
parent = &slot->face->glyph;
|
|
|
|
cur = *parent;
|
|
|
|
while ( cur )
|
|
|
|
{
|
|
|
|
if ( cur == slot )
|
|
|
|
{
|
|
|
|
*parent = cur->next;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cur = cur->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
driver->interface.done_glyph_slot( slot );
|
|
|
|
FREE( slot );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Load_Glyph */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* A function used to load a single glyph within a given face. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* face :: A handle to a target face object where the glyph */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* will be loaded. */
|
|
|
|
/* */
|
|
|
|
/* glyph_index :: The index of the glyph in the font file. */
|
|
|
|
/* */
|
|
|
|
/* load_flags :: A flag indicating what to load for this glyph. The */
|
|
|
|
/* FT_LOAD_XXX constants can be used to control the */
|
|
|
|
/* glyph loading process (e.g., whether the outline */
|
|
|
|
/* should be scaled, whether to load bitmaps or not, */
|
|
|
|
/* whether to hint the outline, etc). */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* FreeType error code. 0 means success. */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Load_Glyph( FT_Face face,
|
|
|
|
FT_UInt glyph_index,
|
|
|
|
FT_Int load_flags )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Driver driver;
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !face )
|
1999-12-17 00:11:37 +01:00
|
|
|
return FT_Err_Invalid_Face_Handle;
|
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !face->size )
|
|
|
|
return FT_Err_Invalid_Size_Handle;
|
|
|
|
|
|
|
|
if ( !face->glyph )
|
|
|
|
return FT_Err_Invalid_Slot_Handle;
|
|
|
|
|
2000-05-26 08:40:49 +02:00
|
|
|
if ( glyph_index >= face->num_glyphs )
|
|
|
|
return FT_Err_Invalid_Argument;
|
2000-06-03 08:03:11 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
driver = face->driver;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-03-28 13:22:31 +02:00
|
|
|
/* when the flag NO_RECURSE is set, we disable hinting and scaling */
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( load_flags & FT_LOAD_NO_RECURSE )
|
2000-03-28 13:22:31 +02:00
|
|
|
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
error = driver->interface.load_glyph( face->glyph,
|
|
|
|
face->size,
|
|
|
|
glyph_index,
|
|
|
|
load_flags );
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Load_Char */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* A function used to load a single character within a given face */
|
|
|
|
/* and the selected charmap (to be done with the FT_Select_Charmap() */
|
|
|
|
/* function). */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* face :: A handle to a target face object where the */
|
|
|
|
/* character will be loaded. */
|
|
|
|
/* */
|
|
|
|
/* char_code :: The character code of the glyph in the font file. */
|
|
|
|
/* */
|
|
|
|
/* load_flags :: A flag indicating what to load for this glyph. The */
|
|
|
|
/* FT_LOAD_XXX constants can be used to control the */
|
|
|
|
/* glyph loading process (e.g., whether the outline */
|
|
|
|
/* should be scaled, whether to load bitmaps or not, */
|
|
|
|
/* whether to hint the outline, etc). */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* FreeType error code. 0 means success. */
|
|
|
|
/* */
|
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Load_Char( FT_Face face,
|
|
|
|
FT_ULong char_code,
|
|
|
|
FT_Int load_flags )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Driver driver;
|
|
|
|
FT_UInt glyph_index;
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !face )
|
1999-12-17 00:11:37 +01:00
|
|
|
return FT_Err_Invalid_Face_Handle;
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !face->size )
|
|
|
|
return FT_Err_Invalid_Size_Handle;
|
|
|
|
|
|
|
|
if ( !face->glyph )
|
|
|
|
return FT_Err_Invalid_Slot_Handle;
|
|
|
|
|
|
|
|
if ( !face->charmap )
|
|
|
|
return FT_Err_Invalid_CharMap_Handle;
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
driver = face->driver;
|
|
|
|
glyph_index = FT_Get_Char_Index( face, char_code );
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
if ( glyph_index == 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
error = FT_Err_Invalid_Character_Code;
|
|
|
|
else
|
|
|
|
error = driver->interface.load_glyph( face->glyph,
|
|
|
|
face->size,
|
|
|
|
glyph_index,
|
|
|
|
load_flags );
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Get_Kerning */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Returns the kerning vector between two glyphs of a same face. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* face :: A handle to a source face object. */
|
|
|
|
/* */
|
|
|
|
/* left_glyph :: The index of the left glyph in the kern pair. */
|
|
|
|
/* */
|
|
|
|
/* right_glyph :: The index of the right glyph in the kern pair. */
|
|
|
|
/* */
|
|
|
|
/* <Output> */
|
|
|
|
/* kerning :: The kerning vector. This is in font units for */
|
|
|
|
/* scalable formats, and in pixels for fixed-sizes */
|
|
|
|
/* formats. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* FreeType error code. 0 means success. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* Only horizontal layouts (left-to-right & right-to-left) are */
|
|
|
|
/* supported by this method. Other layouts, or more sophisticated */
|
|
|
|
/* kernings, are out of the scope of this API function -- they can be */
|
|
|
|
/* implemented through format-specific interfaces. */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Get_Kerning( FT_Face face,
|
|
|
|
FT_UInt left_glyph,
|
|
|
|
FT_UInt right_glyph,
|
|
|
|
FT_Vector* kerning )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-02 02:01:14 +02:00
|
|
|
FT_Error error = FT_Err_Ok;
|
1999-12-17 00:11:37 +01:00
|
|
|
FT_Driver driver;
|
|
|
|
FT_Memory memory;
|
|
|
|
|
|
|
|
|
|
|
|
if ( !face )
|
2000-06-02 02:01:14 +02:00
|
|
|
return FT_Err_Invalid_Face_Handle;
|
|
|
|
|
|
|
|
if ( !kerning )
|
|
|
|
return FT_Err_Invalid_Argument;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
driver = face->driver;
|
|
|
|
memory = driver->memory;
|
|
|
|
|
|
|
|
if ( driver->interface.get_kerning )
|
|
|
|
{
|
2000-05-31 08:55:12 +02:00
|
|
|
error = driver->interface.get_kerning( face,
|
|
|
|
left_glyph,
|
|
|
|
right_glyph,
|
|
|
|
kerning );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
kerning->x = 0;
|
|
|
|
kerning->y = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-05-12 19:09:38 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Select_Charmap */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* Selects a given charmap by its encoding tag (as listed in */
|
|
|
|
/* `freetype.h'). */
|
2000-05-12 19:09:38 +02:00
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* face :: A handle to the source face object. */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* */
|
|
|
|
/* encoding :: A handle to the selected charmap. */
|
2000-05-12 19:09:38 +02:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
2000-05-12 19:09:38 +02:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* This function will return an error if no charmap in the face */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* corresponds to the encoding queried here. */
|
2000-05-12 19:09:38 +02:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Select_Charmap( FT_Face face,
|
|
|
|
FT_Encoding encoding )
|
2000-05-12 19:09:38 +02:00
|
|
|
{
|
2000-06-02 02:01:14 +02:00
|
|
|
FT_CharMap* cur;
|
|
|
|
FT_CharMap* limit;
|
|
|
|
|
|
|
|
|
|
|
|
if ( !face )
|
|
|
|
return FT_Err_Invalid_Face_Handle;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
cur = face->charmaps;
|
|
|
|
if ( !cur )
|
|
|
|
return FT_Err_Invalid_CharMap_Handle;
|
|
|
|
|
|
|
|
limit = cur + face->num_charmaps;
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-05-12 19:09:38 +02:00
|
|
|
for ( ; cur < limit; cur++ )
|
|
|
|
{
|
|
|
|
if ( cur[0]->encoding == encoding )
|
|
|
|
{
|
|
|
|
face->charmap = cur[0];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Set_Charmap */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Selects a given charmap for character code to glyph index */
|
|
|
|
/* decoding. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* face :: A handle to the source face object. */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* charmap :: A handle to the selected charmap. */
|
2000-05-12 19:09:38 +02:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
2000-05-12 19:09:38 +02:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* This function will return an error when the charmap is not part */
|
|
|
|
/* of the face (i.e., if it is not listed in the face->charmaps[] */
|
2000-05-12 19:09:38 +02:00
|
|
|
/* table). */
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Set_Charmap( FT_Face face,
|
|
|
|
FT_CharMap charmap )
|
2000-05-12 19:09:38 +02:00
|
|
|
{
|
2000-06-02 02:01:14 +02:00
|
|
|
FT_CharMap* cur;
|
|
|
|
FT_CharMap* limit;
|
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-06-02 02:01:14 +02:00
|
|
|
if ( !face )
|
|
|
|
return FT_Err_Invalid_Face_Handle;
|
|
|
|
|
|
|
|
cur = face->charmaps;
|
|
|
|
if ( !cur )
|
|
|
|
return FT_Err_Invalid_CharMap_Handle;
|
|
|
|
|
|
|
|
limit = cur + face->num_charmaps;
|
2000-05-31 08:55:12 +02:00
|
|
|
|
2000-05-12 19:09:38 +02:00
|
|
|
for ( ; cur < limit; cur++ )
|
|
|
|
{
|
|
|
|
if ( cur[0] == charmap )
|
|
|
|
{
|
|
|
|
face->charmap = cur[0];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FT_Err_Invalid_Argument;
|
|
|
|
}
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Get_Char_Index */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Returns the glyph index of a given character code. This function */
|
|
|
|
/* uses a charmap object to do the translation. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* face :: A handle to the source face object. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* charcode :: The character code. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* The glyph index. 0 means `undefined character code'. */
|
|
|
|
/* */
|
2000-06-02 02:01:14 +02:00
|
|
|
FT_EXPORT_FUNC( FT_UInt ) FT_Get_Char_Index( FT_Face face,
|
|
|
|
FT_ULong charcode )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_UInt result;
|
|
|
|
FT_Driver driver;
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
result = 0;
|
|
|
|
if ( face && face->charmap )
|
|
|
|
{
|
|
|
|
driver = face->driver;
|
|
|
|
result = driver->interface.get_char_index( face->charmap, charcode );
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Get_Sfnt_Table */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Returns a pointer to a given SFNT table within a face. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* face :: A handle to the source face object. */
|
|
|
|
/* tag :: An index of an SFNT table. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* A type-less pointer to the table. This will be 0 in case of */
|
|
|
|
/* error, or if the corresponding table was not found *OR* loaded */
|
|
|
|
/* from the file. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* The table is owned by the face object, and disappears with it. */
|
|
|
|
/* */
|
|
|
|
/* This function is only useful to access SFNT tables that are loaded */
|
|
|
|
/* by the sfnt/truetype/opentype drivers. See the FT_Sfnt_Tag */
|
|
|
|
/* enumeration in `tttables.h' for a list. */
|
|
|
|
/* */
|
|
|
|
/* You can load any table with a different function.. XXX */
|
|
|
|
/* */
|
|
|
|
FT_EXPORT_FUNC( void* ) FT_Get_Sfnt_Table( FT_Face face,
|
|
|
|
FT_Sfnt_Tag tag )
|
2000-04-25 18:10:50 +02:00
|
|
|
{
|
|
|
|
void* table = 0;
|
|
|
|
FT_Get_Sfnt_Table_Func func;
|
|
|
|
FT_Driver driver;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
|
|
|
if ( !face || !FT_IS_SFNT( face ) )
|
2000-04-25 18:10:50 +02:00
|
|
|
goto Exit;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-04-25 18:10:50 +02:00
|
|
|
driver = face->driver;
|
2000-05-24 02:31:14 +02:00
|
|
|
func = (FT_Get_Sfnt_Table_Func)driver->interface.get_interface(
|
2000-05-31 08:55:12 +02:00
|
|
|
driver, "get_sfnt" );
|
|
|
|
if ( func )
|
|
|
|
table = func( face, tag );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-04-25 18:10:50 +02:00
|
|
|
Exit:
|
|
|
|
return table;
|
2000-05-17 01:44:38 +02:00
|
|
|
}
|
2000-04-25 18:10:50 +02:00
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Done_FreeType */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Destroys a given FreeType library object and all of its childs, */
|
|
|
|
/* including resources, drivers, faces, sizes, etc. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* library :: A handle to the target library object. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FreeType error code. 0 means success. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
FT_EXPORT_FUNC( FT_Error ) FT_Done_FreeType( FT_Library library )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-02 02:01:14 +02:00
|
|
|
/* test for valid `library' delayed to FT_Done_Library() */
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/* Discard the library object */
|
|
|
|
FT_Done_Library( library );
|
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/* END */
|