managed to re-design entirely the API in <freetype/ftglyph.h>
It is now really the "glyph factory" that Stefan was probably dreaming about.. fixed some recent formatting errors from Werner ;-) cleaned up the demonstration programs from most of the rust that they had, though I'm sure someone is going to re-format them really soon !! "ftstring" now uses the new ftglyph.h API, and is now faster and smaller.. yep..
This commit is contained in:
parent
ac39ecdca8
commit
f9ca2bb58a
@ -152,83 +152,51 @@
|
||||
char bit_buffer[MAX_BUFFER];
|
||||
|
||||
|
||||
/* Render a single glyph with the "grays" component */
|
||||
/* Render a single glyph with the `grays' component */
|
||||
static
|
||||
FT_Error Render_Glyph( int x_offset,
|
||||
int y_offset )
|
||||
{
|
||||
FT_Bitmap bit2;
|
||||
grBitmap bit3;
|
||||
int width, height, pitch, size;
|
||||
int left, right, top, bottom;
|
||||
int x_top, y_top;
|
||||
|
||||
/* first, render the glyph into an intermediate buffer */
|
||||
|
||||
left = FLOOR( glyph->metrics.horiBearingX );
|
||||
right = CEIL( glyph->metrics.horiBearingX + glyph->metrics.width );
|
||||
width = TRUNC( right - left );
|
||||
|
||||
top = CEIL( glyph->metrics.horiBearingY );
|
||||
bottom = FLOOR( glyph->metrics.horiBearingY - glyph->metrics.height );
|
||||
height = TRUNC( top - bottom );
|
||||
|
||||
if ( glyph->format == ft_glyph_format_outline )
|
||||
grBitmap bit3;
|
||||
FT_Pos x_top, y_top;
|
||||
|
||||
/* first, render the glyph image into a bitmap */
|
||||
if (glyph->format != ft_glyph_format_bitmap)
|
||||
{
|
||||
pitch = antialias ? ( width + 3 ) & -4
|
||||
: ( width + 7 ) >> 3;
|
||||
size = pitch * height;
|
||||
|
||||
if ( size > MAX_BUFFER )
|
||||
return FT_Err_Out_Of_Memory;
|
||||
|
||||
bit2.width = width;
|
||||
bit2.rows = height;
|
||||
bit2.pitch = pitch;
|
||||
bit2.pixel_mode = antialias ? ft_pixel_mode_grays : ft_pixel_mode_mono;
|
||||
bit2.buffer = bit_buffer;
|
||||
|
||||
bit3.rows = bit2.rows;
|
||||
bit3.width = bit2.width;
|
||||
bit3.pitch = bit2.pitch;
|
||||
bit3.mode = antialias ? bit.mode : gr_pixel_mode_mono;
|
||||
bit3.buffer = bit_buffer;
|
||||
bit3.grays = 256;
|
||||
|
||||
FT_Outline_Translate( &glyph->outline, -left, -bottom );
|
||||
memset( bit_buffer, 0, size );
|
||||
|
||||
if ( low_prec )
|
||||
glyph->outline.flags &= ~ft_outline_high_precision;
|
||||
|
||||
error = FT_Outline_Get_Bitmap( library, &glyph->outline, &bit2 );
|
||||
error = FT_Render_Glyph( glyph, antialias ? ft_render_mode_normal : ft_render_mode_mono );
|
||||
if (error) return error;
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
/* now blit it to our display screen */
|
||||
bit3.rows = glyph->bitmap.rows;
|
||||
bit3.width = glyph->bitmap.width;
|
||||
bit3.pitch = glyph->bitmap.pitch;
|
||||
bit3.buffer = glyph->bitmap.buffer;
|
||||
|
||||
switch (glyph->bitmap.pixel_mode)
|
||||
{
|
||||
bit3.rows = glyph->bitmap.rows;
|
||||
bit3.width = glyph->bitmap.width;
|
||||
bit3.pitch = glyph->bitmap.pitch;
|
||||
bit3.mode = gr_pixel_mode_mono;
|
||||
bit3.buffer = glyph->bitmap.buffer;
|
||||
bit3.grays = 0;
|
||||
case ft_pixel_mode_mono:
|
||||
bit3.mode = gr_pixel_mode_mono;
|
||||
bit3.grays = 0;
|
||||
break;
|
||||
|
||||
case ft_pixel_mode_grays:
|
||||
bit3.mode = gr_pixel_mode_gray;
|
||||
bit3.grays = glyph->bitmap.num_grays;
|
||||
}
|
||||
|
||||
/* then, blit the image to the target surface */
|
||||
|
||||
x_top = x_offset + TRUNC( left );
|
||||
y_top = y_offset - TRUNC( top );
|
||||
|
||||
#if 0
|
||||
if ( bit.pitch < 0 )
|
||||
y_top = bit.rows - y_top;
|
||||
#endif
|
||||
/* Then, blit the image to the target surface */
|
||||
x_top = x_offset + glyph->bitmap_left;
|
||||
y_top = y_offset - glyph->bitmap_top;
|
||||
|
||||
grBlitGlyphToBitmap( &bit, &bit3, x_top, y_top, fore_color );
|
||||
|
||||
return FT_Err_Ok;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static
|
||||
FT_Error Reset_Scale( int pointSize )
|
||||
{
|
||||
@ -239,11 +207,6 @@
|
||||
pointSize << 6,
|
||||
res,
|
||||
res );
|
||||
if ( error )
|
||||
{
|
||||
/* to be written */
|
||||
}
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
@ -209,10 +209,12 @@
|
||||
|
||||
if (!glyph->image) continue;
|
||||
|
||||
x = glyph->pos.x >> 6;
|
||||
y = glyph->pos.y >> 6;
|
||||
x = glyph->pos.x;
|
||||
y = glyph->pos.y;
|
||||
|
||||
FT_Glyph_Get_Box( glyph->image, &cbox );
|
||||
FT_Glyph_Get_CBox( glyph->image,
|
||||
ft_glyph_bbox_gridfit,
|
||||
&cbox );
|
||||
|
||||
cbox.xMin += x;
|
||||
cbox.yMin += y;
|
||||
@ -230,7 +232,7 @@
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* Layout a string of glyphs
|
||||
* Layout a string of glyphs, the glyphs are untransformed..
|
||||
*
|
||||
*/
|
||||
static void layout_glyphs( void )
|
||||
@ -261,9 +263,9 @@
|
||||
{
|
||||
FT_Vector kern;
|
||||
|
||||
FT_Get_Kerning( face, prev_index, glyph->glyph_index, &kern );
|
||||
kern.x = FT_MulFix( kern.x, face->size->metrics.x_scale );
|
||||
if (hinted) kern.x = (kern.x+32) & -64;
|
||||
FT_Get_Kerning( face, prev_index, glyph->glyph_index,
|
||||
hinted ? ft_kerning_default : ft_kerning_unfitted,
|
||||
&kern );
|
||||
|
||||
origin_x += kern.x;
|
||||
}
|
||||
@ -273,28 +275,24 @@
|
||||
origin.x = origin_x;
|
||||
origin.y = 0;
|
||||
|
||||
if (transform)
|
||||
FT_Vector_Transform( &origin, &trans_matrix );
|
||||
|
||||
/* clear existing image if there is one */
|
||||
if (glyph->image)
|
||||
FT_Done_Glyph(glyph->image);
|
||||
|
||||
/* load the glyph image */
|
||||
/* for now, we take a monochrome glyph bitmap */
|
||||
error = FT_Get_Glyph_Bitmap( face, glyph->glyph_index,
|
||||
load_flags,
|
||||
num_grays,
|
||||
&origin,
|
||||
(FT_BitmapGlyph*)&glyph->image );
|
||||
/* load the glyph image (in its native format) */
|
||||
/* for now, we take a monochrome glyph bitmap */
|
||||
error = FT_Load_Glyph( face, glyph->glyph_index,
|
||||
hinted ? FT_LOAD_DEFAULT : FT_LOAD_NO_HINTING ) ||
|
||||
FT_Get_Glyph ( face->glyph, &glyph->image );
|
||||
if (error) continue;
|
||||
|
||||
glyph->pos = origin;
|
||||
|
||||
origin_x += glyph->image->advance;
|
||||
origin_x += face->glyph->advance.x;
|
||||
}
|
||||
string_center.x = origin_x / 2;
|
||||
string_center.y = 0;
|
||||
|
||||
if (transform)
|
||||
FT_Vector_Transform( &string_center, &trans_matrix );
|
||||
}
|
||||
@ -309,62 +307,81 @@
|
||||
PGlyph glyph = glyphs;
|
||||
grBitmap bit3;
|
||||
int n;
|
||||
FT_Vector delta;
|
||||
|
||||
/* first of all, we must compute the general delta for the glyph */
|
||||
/* set.. */
|
||||
delta.x = (x << 6) - string_center.x;
|
||||
delta.y = ((bit.rows-y) << 6) - string_center.y;
|
||||
|
||||
for ( n = 0; n < num_glyphs; n++, glyph++ )
|
||||
{
|
||||
FT_Glyph image;
|
||||
FT_Vector vec;
|
||||
|
||||
if (!glyph->image)
|
||||
continue;
|
||||
|
||||
switch (glyph->image->glyph_type)
|
||||
/* copy image */
|
||||
error = FT_Glyph_Copy( glyph->image, &image );
|
||||
if (error) continue;
|
||||
|
||||
/* transform it */
|
||||
vec = glyph->pos;
|
||||
FT_Vector_Transform( &vec, &trans_matrix );
|
||||
vec.x += delta.x;
|
||||
vec.y += delta.y;
|
||||
error = FT_Glyph_Transform( image, &trans_matrix, &vec );
|
||||
if (!error)
|
||||
{
|
||||
case ft_glyph_type_bitmap:
|
||||
FT_BBox bbox;
|
||||
|
||||
/* check bounding box, if it's not within the display surface, we */
|
||||
/* don't need to render it.. */
|
||||
|
||||
FT_Glyph_Get_CBox( image, ft_glyph_bbox_pixels, &bbox );
|
||||
|
||||
if ( bbox.xMax > 0 && bbox.yMax > 0 &&
|
||||
bbox.xMin < bit.width && bbox.yMin < bit.rows )
|
||||
{
|
||||
/* convert to a bitmap - destroy native image */
|
||||
error = FT_Glyph_To_Bitmap( &image,
|
||||
ft_render_mode_normal,
|
||||
0, 1 );
|
||||
if (!error)
|
||||
{
|
||||
/* this is a bitmap, we simply blit it to our target surface */
|
||||
FT_BitmapGlyph bitm = (FT_BitmapGlyph)glyph->image;
|
||||
FT_Bitmap* source = &bitm->bitmap;
|
||||
FT_BitmapGlyph bitmap = (FT_BitmapGlyph)image;
|
||||
FT_Bitmap* source = &bitmap->bitmap;
|
||||
FT_Pos x_top, y_top;
|
||||
|
||||
|
||||
bit3.rows = source->rows;
|
||||
bit3.width = source->width;
|
||||
bit3.pitch = source->pitch;
|
||||
bit3.buffer = source->buffer;
|
||||
|
||||
|
||||
switch (source->pixel_mode)
|
||||
{
|
||||
case ft_pixel_mode_mono:
|
||||
bit3.mode = gr_pixel_mode_mono;
|
||||
break;
|
||||
|
||||
|
||||
case ft_pixel_mode_grays:
|
||||
bit3.mode = gr_pixel_mode_gray;
|
||||
bit3.grays = source->num_grays;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* now render the bitmap into the display surface */
|
||||
x_top = x + (glyph->pos.x >> 6) + bitm->left;
|
||||
y_top = y - (glyph->pos.y >> 6) - bitm->top;
|
||||
x_top = bitmap->left;
|
||||
y_top = bit.rows - bitmap->top;
|
||||
grBlitGlyphToBitmap( &bit, &bit3, x_top, y_top, fore_color );
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
case ft_glyph_type_outline:
|
||||
{
|
||||
/* in the case of outlines, we directly render it into the */
|
||||
/* target surface with the smooth renderer.. */
|
||||
FT_OutlineGlyph out = (FT_OutlineGlyph)glyph->image;
|
||||
|
||||
FT_Outline_Translate( (x+pen_pos[n]) << 6, (y+
|
||||
error = FT_Outline_Render(
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
FT_Done_Glyph( image );
|
||||
}
|
||||
}
|
||||
|
||||
@ -407,8 +424,6 @@
|
||||
trans_matrix.xy = -sinus;
|
||||
trans_matrix.yx = sinus;
|
||||
trans_matrix.yy = cosinus;
|
||||
|
||||
FT_Set_Transform(face,&trans_matrix, 0);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
@ -723,8 +738,7 @@
|
||||
reset_transform();
|
||||
layout_glyphs();
|
||||
compute_bbox( &bbox );
|
||||
render_string( (bit.width-(string_center.x >> 5))/2,
|
||||
(bit.rows +(string_center.y >> 5))/2 );
|
||||
render_string( bit.width/2, bit.rows/2 );
|
||||
}
|
||||
|
||||
sprintf( Header, "%s %s (file %s)",
|
||||
|
@ -20,15 +20,13 @@
|
||||
/****************************************************************************/
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/ftrender.h>
|
||||
#include <freetype/ftglyph.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h> /* for clock() */
|
||||
|
||||
#include "graph.h"
|
||||
|
||||
/* SunOS 4.1.* does not define CLOCKS_PER_SEC, so include <sys/param.h> */
|
||||
/* to get the HZ macro which is the equivalent. */
|
||||
#if defined(__sun__) && !defined(SVR4) && !defined(__SVR4)
|
||||
@ -45,51 +43,28 @@
|
||||
FT_Library library;
|
||||
|
||||
FT_Face face;
|
||||
FT_Size size;
|
||||
FT_GlyphSlot glyph;
|
||||
|
||||
FT_Outline outline;
|
||||
|
||||
FT_Pos* cur_x;
|
||||
FT_Pos* cur_y;
|
||||
|
||||
unsigned short* cur_endContour;
|
||||
unsigned char* cur_touch;
|
||||
|
||||
FT_Outline outlines[MAX_GLYPHS];
|
||||
|
||||
int num_glyphs;
|
||||
FT_Glyph glyphs[MAX_GLYPHS];
|
||||
|
||||
int tab_glyphs;
|
||||
int cur_glyph;
|
||||
int cur_point;
|
||||
unsigned short cur_contour;
|
||||
|
||||
int pixel_size = CHARSIZE;
|
||||
int repeat_count = 1;
|
||||
int use_grays = 0;
|
||||
|
||||
FT_Bitmap Bit;
|
||||
grBitmap bit;
|
||||
|
||||
int Fail;
|
||||
int Num;
|
||||
|
||||
int vio_Height, vio_Width;
|
||||
|
||||
short visual; /* display glyphs while rendering */
|
||||
short antialias; /* smooth fonts with gray levels */
|
||||
short antialias = 1; /* smooth fonts with gray levels */
|
||||
short force_low;
|
||||
|
||||
|
||||
#define RASTER_BUFF_SIZE 128000
|
||||
char raster_buff[ RASTER_BUFF_SIZE ];
|
||||
|
||||
|
||||
static void Clear_Buffer();
|
||||
|
||||
static void Panic( const char* message )
|
||||
static
|
||||
void Panic( const char* message )
|
||||
{
|
||||
fprintf( stderr, "%s\n error code = 0x%04x\n", message, error );
|
||||
fprintf( stderr, "%s\n", message );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
@ -106,45 +81,10 @@
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* Init_Engine: */
|
||||
/* */
|
||||
/* Allocates bitmap, render pool and other structs... */
|
||||
/* */
|
||||
/*******************************************************************/
|
||||
|
||||
void Init_Engine( void )
|
||||
{
|
||||
Bit.rows = bit.rows;
|
||||
Bit.width = bit.width;
|
||||
Bit.pitch = bit.pitch;
|
||||
Bit.buffer = bit.buffer;
|
||||
Bit.pixel_mode = antialias ? ft_pixel_mode_grays : ft_pixel_mode_mono;
|
||||
Bit.num_grays = bit.grays;
|
||||
Clear_Buffer();
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* Clear_Buffer: */
|
||||
/* */
|
||||
/* Clears current bitmap. */
|
||||
/* */
|
||||
/*******************************************************************/
|
||||
|
||||
static void Clear_Buffer( void )
|
||||
{
|
||||
long size = Bit.rows * Bit.pitch;
|
||||
|
||||
memset( Bit.buffer, 0, size );
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* LoadTrueTypeChar: */
|
||||
/* LoadChar: */
|
||||
/* */
|
||||
/* Loads a glyph into memory. */
|
||||
/* */
|
||||
@ -152,60 +92,20 @@
|
||||
|
||||
FT_Error LoadChar( int idx )
|
||||
{
|
||||
error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT );
|
||||
if ( error )
|
||||
return error;
|
||||
|
||||
glyph->outline.flags |= ft_outline_single_pass |
|
||||
ft_outline_ignore_dropouts;
|
||||
|
||||
if (force_low)
|
||||
glyph->outline.flags &= ~ft_outline_high_precision;
|
||||
|
||||
/* debugging */
|
||||
#if 0
|
||||
if ( idx == 0 && !visual )
|
||||
FT_Glyph glyph;
|
||||
|
||||
/* loads the glyph in the glyph slot */
|
||||
error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) ||
|
||||
FT_Get_Glyph ( face->glyph, &glyph );
|
||||
if ( !error )
|
||||
{
|
||||
printf( "points = %d\n", outline.points );
|
||||
for ( j = 0; j < outline.points; j++ )
|
||||
printf( "%02x (%01hx,%01hx)\n",
|
||||
j, outline.xCoord[j], outline.yCoord[j] );
|
||||
printf( "\n" );
|
||||
glyphs[cur_glyph++] = glyph;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* create a new outline */
|
||||
FT_Outline_New( library,
|
||||
glyph->outline.n_points,
|
||||
glyph->outline.n_contours,
|
||||
&outlines[cur_glyph] );
|
||||
|
||||
/* copy the glyph outline into it */
|
||||
glyph->outline.flags |= ft_outline_single_pass;
|
||||
if (force_low)
|
||||
glyph->outline.flags &= ~ft_outline_high_precision;
|
||||
|
||||
FT_Outline_Copy( &glyph->outline, &outlines[cur_glyph] );
|
||||
|
||||
/* center outline around 0 */
|
||||
{
|
||||
FT_BBox bbox;
|
||||
|
||||
FT_Outline_Get_CBox( &glyph->outline, &bbox );
|
||||
FT_Outline_Translate( &outlines[cur_glyph],
|
||||
- ( bbox.xMax - bbox.xMin )/2,
|
||||
- ( bbox.yMax - bbox.yMin )/2 );
|
||||
}
|
||||
/* translate it */
|
||||
FT_Outline_Translate( &outlines[cur_glyph],
|
||||
Bit.width * 32 ,
|
||||
Bit.rows * 32 );
|
||||
cur_glyph++;
|
||||
|
||||
return FT_Err_Ok;
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/* */
|
||||
/* ConvertRaster: */
|
||||
@ -216,8 +116,19 @@
|
||||
|
||||
FT_Error ConvertRaster( int index )
|
||||
{
|
||||
outlines[index].flags |= ~ft_outline_single_pass;
|
||||
return FT_Outline_Get_Bitmap( library, &outlines[index], &Bit );
|
||||
FT_Glyph bitmap;
|
||||
FT_Error error;
|
||||
|
||||
bitmap = glyphs[index];
|
||||
error = FT_Glyph_To_Bitmap( &bitmap,
|
||||
antialias ? ft_render_mode_normal
|
||||
: ft_render_mode_mono,
|
||||
0,
|
||||
0 );
|
||||
if (!error)
|
||||
FT_Done_Glyph( bitmap );
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
@ -229,8 +140,7 @@
|
||||
fprintf( stderr, "options:\n");
|
||||
fprintf( stderr, " -r : repeat count to be used (default is 1)\n" );
|
||||
fprintf( stderr, " -s : character pixel size (default is 600)\n" );
|
||||
fprintf( stderr, " -v : display results..\n" );
|
||||
fprintf( stderr, " -g : render anti-aliased glyphs\n" );
|
||||
fprintf( stderr, " -m : render monochrome glyphs (default is anti-aliased)\n" );
|
||||
fprintf( stderr, " -a : use smooth anti-aliaser\n" );
|
||||
fprintf( stderr, " -l : force low quality even at small sizes\n" );
|
||||
exit(1);
|
||||
@ -243,37 +153,27 @@
|
||||
char filename[128 + 4];
|
||||
char alt_filename[128 + 4];
|
||||
char* execname;
|
||||
grSurface* surface = 0;
|
||||
|
||||
long t, t0, tz0;
|
||||
|
||||
|
||||
execname = argv[0];
|
||||
|
||||
antialias = 0;
|
||||
visual = 0;
|
||||
force_low = 0;
|
||||
antialias = 1;
|
||||
force_low = 0;
|
||||
|
||||
while ( argc > 1 && argv[1][0] == '-' )
|
||||
{
|
||||
switch ( argv[1][1] )
|
||||
{
|
||||
case 'g':
|
||||
antialias = 1;
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
use_grays = 1;
|
||||
case 'm':
|
||||
antialias = 0;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
force_low = 1;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
visual = 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
argc--;
|
||||
argv++;
|
||||
@ -328,17 +228,6 @@
|
||||
if ( (error = FT_Init_FreeType( &library )) )
|
||||
Panic( "Error while initializing engine" );
|
||||
|
||||
/* set-up smooth anti-aliaser */
|
||||
if (use_grays)
|
||||
{
|
||||
FT_Renderer smooth;
|
||||
|
||||
smooth = (FT_Renderer)FT_Get_Module( library, "smooth renderer" );
|
||||
if (!smooth) Panic( "Could not initialize smooth anti-aliasing renderer" );
|
||||
|
||||
FT_Set_Renderer( library, smooth, 0, 0 );
|
||||
}
|
||||
|
||||
/* Load face */
|
||||
|
||||
error = FT_New_Face( library, filename, 0, &face );
|
||||
@ -350,7 +239,6 @@
|
||||
/* get face properties and allocate preload arrays */
|
||||
|
||||
num_glyphs = face->num_glyphs;
|
||||
glyph = face->glyph;
|
||||
|
||||
tab_glyphs = MAX_GLYPHS;
|
||||
if ( tab_glyphs > num_glyphs )
|
||||
@ -361,32 +249,6 @@
|
||||
error = FT_Set_Pixel_Sizes( face, pixel_size, pixel_size );
|
||||
if ( error ) Panic( "Could not reset instance" );
|
||||
|
||||
bit.mode = antialias ? gr_pixel_mode_gray : gr_pixel_mode_mono;
|
||||
bit.width = 640;
|
||||
bit.rows = 480;
|
||||
bit.grays = 128;
|
||||
|
||||
if ( visual )
|
||||
{
|
||||
if ( !grInitDevices() )
|
||||
Panic( "Could not initialize graphics.\n" );
|
||||
|
||||
surface = grNewSurface( 0, &bit );
|
||||
if (!surface)
|
||||
Panic( "Could not open graphics window/screen.\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( grNewBitmap( bit.mode,
|
||||
bit.grays,
|
||||
bit.width,
|
||||
bit.rows,
|
||||
&bit ) )
|
||||
Panic( "Could not create rendering buffer.\n" );
|
||||
}
|
||||
|
||||
Init_Engine();
|
||||
|
||||
Num = 0;
|
||||
Fail = 0;
|
||||
|
||||
@ -405,8 +267,6 @@
|
||||
|
||||
/* First, preload 'tab_glyphs' in memory */
|
||||
cur_glyph = 0;
|
||||
cur_point = 0;
|
||||
cur_contour = 0;
|
||||
|
||||
printf( "loading %d glyphs", tab_glyphs );
|
||||
|
||||
@ -440,14 +300,6 @@
|
||||
else
|
||||
{
|
||||
rendered_glyphs ++;
|
||||
|
||||
if ( Num == 0 && visual )
|
||||
{
|
||||
sprintf( Header, "Glyph: %5d", Num );
|
||||
grSetTitle( surface, Header );
|
||||
grRefreshSurface( surface );
|
||||
Clear_Buffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -461,7 +313,7 @@
|
||||
|
||||
/* Now free all loaded outlines */
|
||||
for ( Num = 0; Num < cur_glyph; Num++ )
|
||||
FT_Outline_Done( library, &outlines[Num] );
|
||||
FT_Done_Glyph( glyphs[Num] );
|
||||
}
|
||||
|
||||
tz0 = Get_Time() - tz0;
|
||||
|
@ -158,7 +158,7 @@
|
||||
/* first, render the glyph image into a bitmap */
|
||||
if (glyph->format != ft_glyph_format_bitmap)
|
||||
{
|
||||
error = FT_Render_Glyph( glyph, antialias ? 1 : 0 );
|
||||
error = FT_Render_Glyph( glyph, antialias ? ft_render_mode_normal : ft_render_mode_mono );
|
||||
if (error) return error;
|
||||
|
||||
}
|
||||
|
@ -1,16 +1,15 @@
|
||||
/* memtest.c */
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include <freetype/ftmodule.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
FT_Error error;
|
||||
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
FT_Size size;
|
||||
FT_GlyphSlot slot;
|
||||
|
||||
unsigned int num_glyphs;
|
||||
int ptsize;
|
||||
@ -18,7 +17,6 @@
|
||||
int Fail;
|
||||
int Num;
|
||||
|
||||
extern void FT_Add_Default_Modules( FT_Library library );
|
||||
|
||||
|
||||
|
||||
|
@ -39,18 +39,7 @@
|
||||
#define FREETYPE_MINOR 0
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* To make freetype.h independent from configuration files we check */
|
||||
/* whether FT_EXPORT_DEF has been defined already. */
|
||||
/* */
|
||||
/* On some systems and compilers (Win32 mostly), an extra keyword is */
|
||||
/* necessary to compile the library as a DLL. */
|
||||
/* */
|
||||
#ifndef FT_EXPORT_DEF
|
||||
#define FT_EXPORT_DEF(x) extern x
|
||||
#endif
|
||||
|
||||
#include <freetype/config/ftconfig.h> /* read configuration information */
|
||||
#include <freetype/fterrors.h>
|
||||
#include <freetype/fttypes.h>
|
||||
|
||||
@ -335,7 +324,7 @@
|
||||
typedef enum FT_Encoding_
|
||||
{
|
||||
ft_encoding_none = 0,
|
||||
ft_encoding_symbol = 0,
|
||||
ft_encoding_symbol = FT_MAKE_TAG('s','y','m','b'),
|
||||
ft_encoding_unicode = FT_MAKE_TAG('u','n','i','c'),
|
||||
ft_encoding_latin_2 = FT_MAKE_TAG('l','a','t','2'),
|
||||
ft_encoding_sjis = FT_MAKE_TAG('s','j','i','s'),
|
||||
@ -344,9 +333,9 @@
|
||||
ft_encoding_wansung = FT_MAKE_TAG('w','a','n','s'),
|
||||
ft_encoding_johab = FT_MAKE_TAG('j','o','h','a'),
|
||||
|
||||
ft_encoding_adobe_standard = FT_MAKE_TAG('a','d','o','b'),
|
||||
ft_encoding_adobe_expert = FT_MAKE_TAG('a','d','b','e'),
|
||||
ft_encoding_adobe_custom = FT_MAKE_TAG('a','d','b','c'),
|
||||
ft_encoding_adobe_standard = FT_MAKE_TAG('A','D','O','B'),
|
||||
ft_encoding_adobe_expert = FT_MAKE_TAG('A','D','B','E'),
|
||||
ft_encoding_adobe_custom = FT_MAKE_TAG('A','D','B','C'),
|
||||
|
||||
ft_encoding_apple_roman = FT_MAKE_TAG('a','r','m','n')
|
||||
|
||||
@ -995,6 +984,9 @@
|
||||
/* vectorial or bitmap/graymaps.. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* library :: a handle to the FreeType library instance this slot */
|
||||
/* belongs to. */
|
||||
/* */
|
||||
/* face :: A handle to the parent face object. */
|
||||
/* */
|
||||
/* next :: In some cases (like some font tools), several glyph */
|
||||
@ -1111,6 +1103,7 @@
|
||||
|
||||
typedef struct FT_GlyphSlotRec_
|
||||
{
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
FT_GlyphSlot next;
|
||||
FT_UInt flags;
|
||||
@ -1813,8 +1806,23 @@
|
||||
/* glyph loader to use 'ft_render_mode_antialias' when calling */
|
||||
/* FT_Render_Glyph. */
|
||||
/* */
|
||||
/* THIS IS NOW 0, AS ANTI-ALIASED RENDERING IS NOW THE DEFAULT.. */
|
||||
/* */
|
||||
#define FT_LOAD_ANTI_ALIAS 4096
|
||||
#define FT_LOAD_ANTI_ALIAS 0 /* this is the default */
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Constant> */
|
||||
/* FT_LOAD_MONOCHROME */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Only used with FT_LOAD_RENDER set, indicates that the returned */
|
||||
/* glyph image should be 1-bit monochrome. This really tells the */
|
||||
/* glyph loader to use 'ft_render_mode_mono' when calling */
|
||||
/* FT_Render_Glyph. */
|
||||
/* */
|
||||
/* */
|
||||
#define FT_LOAD_MONOCHROME 0 /* this is the default */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
@ -1867,11 +1875,56 @@
|
||||
/* <Note> */
|
||||
/* The transformation is only applied to scalable image formats. */
|
||||
/* */
|
||||
/* The transformation is simply applied to the glyph after it is */
|
||||
/* loaded. It means that hinting is unaltered by the transform and */
|
||||
/* is performed on the character size given in the last call to */
|
||||
/* FT_Set_Char_Sizes or FT_Set_Pixel_Sizes */
|
||||
/* */
|
||||
FT_EXPORT_DEF( void ) FT_Set_Transform( FT_Face face,
|
||||
FT_Matrix* matrix,
|
||||
FT_Vector* delta );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* <Enum>
|
||||
* FT_Render_Mode
|
||||
*
|
||||
* <Description>
|
||||
* An enumeration type that lists the render modes supported by the
|
||||
* FreeType 2 renderer(s). A renderer is in charge of converting a
|
||||
* glyph image into a bitmap..
|
||||
*
|
||||
* <Fields>
|
||||
* ft_render_mode_normal :: this is the default render mode,
|
||||
* it corresponds to 8-bit anti-aliased
|
||||
* bitmaps, using 256 levels of gray.
|
||||
*
|
||||
* ft_render_mode_mono :: this render mode is used to produce
|
||||
* 1-bit monochrome bitmaps
|
||||
*
|
||||
* <Note>
|
||||
* There is no render mode to produce 8-bit "monochrome" bitmaps,
|
||||
* you'll have to make the conversion yourself if you need such
|
||||
* things (besides, FreeType is not a graphics library..)
|
||||
*
|
||||
* More modes might appear later for specific display modes (e.g.
|
||||
* TV, LCDs, etc..). They will be supported through the simple
|
||||
* addition of a renderer module, with no changes to the rest of
|
||||
* the engine..
|
||||
*
|
||||
*
|
||||
*************************************************************************/
|
||||
|
||||
typedef enum FT_Render_Mode_
|
||||
{
|
||||
ft_render_mode_normal = 0,
|
||||
ft_render_mode_mono = 1
|
||||
|
||||
} FT_Render_Mode;
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* <Function>
|
||||
@ -1885,29 +1938,46 @@
|
||||
* slot :: handle to the glyph slot containing the image to
|
||||
* convert
|
||||
*
|
||||
* render_mode :: a set of bit flags indicating which kind of bitmap
|
||||
* to render. For now, only 'ft_render_mode_anti_alias'
|
||||
* is supported by the available renderers, but others
|
||||
* could appear later (e.g. LCD or TV optimised)
|
||||
* render_mode :: this is the render mode used to render the glyph image
|
||||
* into a bitmap. See FT_Render_Mode for possible values.
|
||||
*
|
||||
* <Return>
|
||||
* Error code. 0 means success.
|
||||
*
|
||||
* <Note>
|
||||
* in case of success, the renderer will be used to convert glyph
|
||||
* images in the renderer's known format into bitmaps.
|
||||
*
|
||||
* This doesn't change the current renderer for other formats..
|
||||
*
|
||||
* The slot's native image should be considered lost after the
|
||||
* conversion..
|
||||
*
|
||||
*************************************************************************/
|
||||
|
||||
FT_EXPORT_DEF(FT_Error) FT_Render_Glyph( FT_GlyphSlot slot,
|
||||
FT_UInt render_mode );
|
||||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* <Enum>
|
||||
* FT_Kerning_Mode
|
||||
*
|
||||
* <Description>
|
||||
* A list of enumerations used to specify which kerning values to
|
||||
* return in FT_Get_Kerning
|
||||
*
|
||||
* <Field>
|
||||
* ft_kerning_default :: used to returned scaled and grid-fitted kerning
|
||||
* distances. (value is 0)
|
||||
*
|
||||
* ft_kerning_unfitted :: used to returned scaled by un-grid-fitted
|
||||
* kerning distances.
|
||||
*
|
||||
* ft_kerning_unscaled :: used to return the kerning vector in original
|
||||
* font units..
|
||||
*
|
||||
**************************************************************************/
|
||||
typedef enum FT_Kerning_Mode_
|
||||
{
|
||||
ft_kerning_default = 0,
|
||||
ft_kerning_unfitted,
|
||||
ft_kerning_unscaled
|
||||
|
||||
} FT_Kerning_Mode;
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
@ -1923,6 +1993,9 @@
|
||||
/* */
|
||||
/* right_glyph :: The index of the right glyph in the kern pair. */
|
||||
/* */
|
||||
/* kern_mode :: see FT_Kerning_Mode for more info. Determines the */
|
||||
/* scale/dimension of the returned kerning vector */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* kerning :: The kerning vector. This is in font units for */
|
||||
/* scalable formats, and in pixels for fixed-sizes */
|
||||
@ -1940,6 +2013,7 @@
|
||||
FT_EXPORT_DEF(FT_Error) FT_Get_Kerning( FT_Face face,
|
||||
FT_UInt left_glyph,
|
||||
FT_UInt right_glyph,
|
||||
FT_UInt kern_mode,
|
||||
FT_Vector* kerning );
|
||||
|
||||
|
||||
@ -2120,468 +2194,6 @@
|
||||
FT_Matrix* matrix );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Get_Bitmap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Renders an outline within a bitmap. The outline's image is simply */
|
||||
/* or-ed to the target bitmap. */
|
||||
/* */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a FreeType library object. */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* map :: A pointer to the target bitmap descriptor. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* YES. Rendering is synchronized, so that concurrent calls to the */
|
||||
/* scan-line converter will be serialized. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function does NOT CREATE the bitmap, it only renders an */
|
||||
/* outline image within the one you pass to it! */
|
||||
/* */
|
||||
/* It will use the raster correponding to the default glyph format. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(FT_Error) FT_Outline_Get_Bitmap( FT_Library library,
|
||||
FT_Outline* outline,
|
||||
FT_Bitmap* bitmap );
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Render */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Renders an outline within a bitmap using the current scan-convert */
|
||||
/* This functions uses a FT_Raster_Params as argument, allowing */
|
||||
/* advanced features like direct composition/translucency, etc.. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a FreeType library object. */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* params :: A pointer to a FT_Raster_Params used to describe */
|
||||
/* the rendering operation */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* YES. Rendering is synchronized, so that concurrent calls to the */
|
||||
/* scan-line converter will be serialized. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You should know what you're doing and the role of FT_Raster_Params */
|
||||
/* to use this function. */
|
||||
/* */
|
||||
/* the field "params.source" will be set to "outline" before the */
|
||||
/* scan converter is called, which means that the value you give it */
|
||||
/* is actually ignored.. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(FT_Error) FT_Outline_Render( FT_Library library,
|
||||
FT_Outline* outline,
|
||||
FT_Raster_Params* params );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Decompose */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Walks over an outline's structure to decompose it into individual */
|
||||
/* segments and Bezier arcs. This function is also able to emit */
|
||||
/* `move to' and `close to' operations to indicate the start and end */
|
||||
/* of new contours in the outline. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the source target. */
|
||||
/* */
|
||||
/* funcs :: A table of `emitters', i.e,. function pointers called */
|
||||
/* during decomposition to indicate path operations. */
|
||||
/* */
|
||||
/* user :: A typeless pointer which is passed to each emitter */
|
||||
/* during the decomposition. It can be used to store */
|
||||
/* the state during the decomposition. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means sucess. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(FT_Error) FT_Outline_Decompose( FT_Outline* outline,
|
||||
FT_Outline_Funcs* funcs,
|
||||
void* user );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_New */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Creates a new outline of a given size. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the library object from where the */
|
||||
/* outline is allocated. Note however that the new */
|
||||
/* outline will NOT necessarily be FREED when */
|
||||
/* destroying the library, by FT_Done_FreeType(). */
|
||||
/* */
|
||||
/* numPoints :: The maximal number of points within the outline. */
|
||||
/* */
|
||||
/* numContours :: The maximal number of contours within the outline. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* outline :: A handle to the new outline. NULL in case of */
|
||||
/* error. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* No. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The reason why this function takes a `library' parameter is simply */
|
||||
/* to use the library's memory allocator. You can copy the source */
|
||||
/* code of this function, replacing allocations with `malloc()' if */
|
||||
/* you want to control where the objects go. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(FT_Error) FT_Outline_New( FT_Library library,
|
||||
FT_UInt numPoints,
|
||||
FT_Int numContours,
|
||||
FT_Outline* outline );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Done */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Destroys an outline created with FT_Outline_New(). */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle of the library object used to allocate the */
|
||||
/* outline. */
|
||||
/* */
|
||||
/* outline :: A pointer to the outline object to be discarded. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* No. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* If the outline's `owner' field is not set, only the outline */
|
||||
/* descriptor will be released. */
|
||||
/* */
|
||||
/* The reason why this function takes an `outline' parameter is */
|
||||
/* simply to use FT_Alloc()/FT_Free(). You can copy the source code */
|
||||
/* of this function, replacing allocations with `malloc()' in your */
|
||||
/* application if you want something simpler. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(FT_Error) FT_Outline_Done( FT_Library library,
|
||||
FT_Outline* outline );
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Get_CBox */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Returns an outline's `control box'. The control box encloses all */
|
||||
/* the outline's points, including Bezier control points. Though it */
|
||||
/* coincides with the exact bounding box for most glyphs, it can be */
|
||||
/* slightly larger in some situations (like when rotating an outline */
|
||||
/* which contains Bezier outside arcs). */
|
||||
/* */
|
||||
/* Computing the control box is very fast, while getting the bounding */
|
||||
/* box can take much more time as it needs to walk over all segments */
|
||||
/* and arcs in the outline. To get the latter, you can use the */
|
||||
/* `ftbbox' component which is dedicated to this single task. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* cbox :: The outline's control box. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(void) FT_Outline_Get_CBox( FT_Outline* outline,
|
||||
FT_BBox* cbox );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Translate */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Applies a simple translation to the points of an outline. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* xOffset :: The horizontal offset. */
|
||||
/* yOffset :: The vertical offset. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(void) FT_Outline_Translate( FT_Outline* outline,
|
||||
FT_Pos xOffset,
|
||||
FT_Pos yOffset );
|
||||
|
||||
|
||||
#if 0
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Raster */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Register a given raster to the library. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a target library object. */
|
||||
/* raster_funcs :: pointer to the raster's interface */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function will do the following: */
|
||||
/* */
|
||||
/* - a new raster object is created through raster_func.raster_new */
|
||||
/* if this fails, then the function returns */
|
||||
/* */
|
||||
/* - if a raster is already registered for the glyph format */
|
||||
/* specified in raster_funcs, it will be destroyed */
|
||||
/* */
|
||||
/* - the new raster is registered for the glyph format */
|
||||
/* */
|
||||
FT_EXPORT_DEF(FT_Error) FT_Set_Raster( FT_Library library,
|
||||
FT_Raster_Funcs* raster_funcs );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Unset_Raster */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Removes a given raster from the library. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a target library object. */
|
||||
/* raster_funcs :: pointer to the raster's interface */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function should never be used by a normal client application */
|
||||
/* as FT_Set_Raster unregisters the previous raster for a given */
|
||||
/* glyph format.. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(FT_Error) FT_Unset_Raster( FT_Library library,
|
||||
FT_Raster_Funcs* raster_funcs );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* <Function>
|
||||
* FT_Get_Raster
|
||||
*
|
||||
* <Description>
|
||||
* Return a pointer to the raster corresponding to a given glyph
|
||||
* format tag.
|
||||
*
|
||||
* <Input>
|
||||
* library :: handle to source library object
|
||||
* glyph_format :: glyph format tag
|
||||
*
|
||||
* <Output>
|
||||
* raster_funcs :: if this field is not 0, returns a pointer to the
|
||||
* raster's interface/descriptor..
|
||||
*
|
||||
* <Return>
|
||||
* a pointer to the corresponding raster object.
|
||||
*
|
||||
*************************************************************************/
|
||||
|
||||
FT_EXPORT_DEF(FT_Raster) FT_Get_Raster( FT_Library library,
|
||||
FT_Glyph_Format glyph_format,
|
||||
FT_Raster_Funcs *raster_funcs );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Raster_Mode */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Set a raster-specific mode. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a target library object. */
|
||||
/* format :: the glyph format used to select the raster */
|
||||
/* mode :: the raster-specific mode descriptor */
|
||||
/* args :: the mode arguments */
|
||||
/* <Return> */
|
||||
/* Error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(FT_Error) FT_Set_Raster_Mode( FT_Library library,
|
||||
FT_Glyph_Format format,
|
||||
unsigned long mode,
|
||||
void* args );
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***** *****/
|
||||
/***** C O N V E N I E N C E F U N C T I O N S *****/
|
||||
/***** *****/
|
||||
/***** *****/
|
||||
/***** The following functions are provided as a convenience *****/
|
||||
/***** to client applications. However, their compilation might *****/
|
||||
/***** be discarded if FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS *****/
|
||||
/***** is defined in "config/ftoption.h". *****/
|
||||
/***** *****/
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Copy */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Copies an outline into another one. Both objects must have the */
|
||||
/* same sizes (number of points & number of contours) when this */
|
||||
/* function is called. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* source :: A handle to the source outline. */
|
||||
/* target :: A handle to the target outline. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(FT_Error) FT_Outline_Copy( FT_Outline* source,
|
||||
FT_Outline* target );
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Transform */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Applies a simple 2x2 matrix to all of an outline's points. Useful */
|
||||
/* for applying rotations, slanting, flipping, etc. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* matrix :: A pointer to the transformation matrix. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You can use FT_Outline_Translate() if you need to translate the */
|
||||
/* outline's points. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(void) FT_Outline_Transform( FT_Outline* outline,
|
||||
FT_Matrix* matrix );
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Reverse */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Reverse the drawing direction of an outline. This is used to */
|
||||
/* ensure consistent fill conventions for mirrored glyphs.. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This functions toggles the bit flag ft_outline_reverse_fill in */
|
||||
/* the outline's "flags" field.. */
|
||||
/* */
|
||||
/* It shouldn't be used by a normal client application, unless it */
|
||||
/* knows what it's doing.. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(void) FT_Outline_Reverse( FT_Outline* outline );
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Matrix_Multiply */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Performs the matrix operation `b = a*b'. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: A pointer to matrix `a'. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* b :: A pointer to matrix `b'. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(void) FT_Matrix_Multiply( FT_Matrix* a,
|
||||
FT_Matrix* b );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Matrix_Invert */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Inverts a 2x2 matrix. Returns an error if it can't be inverted. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* matrix :: A pointer to the target matrix. Remains untouched in */
|
||||
/* case of error. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(FT_Error) FT_Matrix_Invert( FT_Matrix* matrix );
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Default_Drivers */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Adds the set of default drivers to a given library object. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to a new library object. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(void) FT_Default_Drivers( FT_Library library );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ FT_ERROR_START_LIST
|
||||
FT_ERRORDEF( FT_Err_Invalid_Character_Code, 0x0013, "invalid character code" )
|
||||
|
||||
FT_ERRORDEF( FT_Err_Unimplemented_Feature, 0x0020, "unimplemented feature" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Glyph_Format, 0x0021, "invalid glyph image format" )
|
||||
FT_ERRORDEF( FT_Err_Invalid_Glyph_Format, 0x0021, "unsupported glyph image format" )
|
||||
FT_ERRORDEF( FT_Err_Cannot_Render_Glyph, 0x0022, "cannot render this glyph format" )
|
||||
|
||||
FT_ERRORDEF( FT_Err_Invalid_Library_Handle, 0x0030, "invalid library handle" )
|
||||
|
@ -32,13 +32,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
|
||||
ft_glyph_type_none = 0,
|
||||
ft_glyph_type_bitmap = 1,
|
||||
ft_glyph_type_outline = 2
|
||||
|
||||
} FT_GlyphType;
|
||||
/* forward declaration to a private type */
|
||||
typedef struct FT_Glyph_Class_ FT_Glyph_Class;
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
@ -46,45 +41,23 @@
|
||||
* FT_GlyphRec
|
||||
*
|
||||
* <Description>
|
||||
* The root glyph structure contains a given glyph image's metrics.
|
||||
* Note that the FT_Glyph type is a pointer to FT_GlyphRec
|
||||
* The root glyph structure contains a given glyph image plus its
|
||||
* advance width in 16.16 fixed float format..
|
||||
*
|
||||
* <Field>
|
||||
* memory :: a handle to the memory allocator that is used to
|
||||
* create/clone/destroy this glyph..
|
||||
*
|
||||
* glyph_type :: the glyph type..
|
||||
*
|
||||
* height :: height of glyph image
|
||||
* width :: width of glyph image
|
||||
*
|
||||
* bearingX :: horizontal bearing, this is the distance from the
|
||||
* the current pen position to the left of the glyph
|
||||
*
|
||||
* bearingY :: vertical bearing, this is the distance from the
|
||||
* current pen position to the top of the glyph
|
||||
*
|
||||
* advance :: this is the horizontal or vertical advance for the
|
||||
* glyph
|
||||
*
|
||||
* <Note>
|
||||
* the distances expressed in the metrics are expressed in 26.6 fixed
|
||||
* float sub-pixels (i.e. 1/64th of pixels).
|
||||
*
|
||||
* the vertical bearing has a positive value when the glyph top is
|
||||
* above the baseline, and negative when it is under..
|
||||
* library :: a handle to the FreeType library object.
|
||||
* clazz :: a pointer to the glyph's class. Private.
|
||||
* format :: the format of the glyph's image
|
||||
* advance :: a 16.16 vector that gives the glyph's advance width
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
typedef struct FT_GlyphRec_
|
||||
{
|
||||
FT_Memory memory;
|
||||
FT_GlyphType glyph_type;
|
||||
FT_Int height;
|
||||
FT_Int width;
|
||||
FT_Int bearingX;
|
||||
FT_Int bearingY;
|
||||
FT_Int advance;
|
||||
FT_Library library;
|
||||
const FT_Glyph_Class* clazz;
|
||||
FT_Glyph_Format format;
|
||||
FT_Vector advance;
|
||||
|
||||
} FT_GlyphRec, *FT_Glyph;
|
||||
|
||||
@ -95,41 +68,37 @@
|
||||
* FT_BitmapGlyphRec
|
||||
*
|
||||
* <Description>
|
||||
* A structure used to describe a bitmap glyph image..
|
||||
* Note that the FT_BitmapGlyph type is a pointer to FT_BitmapGlyphRec
|
||||
* A structure used for bitmap glyph images.. This really is
|
||||
* a "sub-class" of "FT_GlyphRec".
|
||||
*
|
||||
* <Field>
|
||||
* metrics :: the corresponding glyph metrics
|
||||
* bitmap :: a descriptor for the bitmap.
|
||||
* root :: the root FT_Glyph fields
|
||||
* left :: left-side bearing, i.e. the horizontal distance from
|
||||
* the current pen position to the left border of the glyph
|
||||
* bitmap.
|
||||
* top :: top-side bearing, i.e. the vertical distance from the
|
||||
* current pen position to the top border of the glyph bitmap
|
||||
* this distance is positive for upwards-y !!
|
||||
* bitmap :: a descriptor for the bitmap.
|
||||
*
|
||||
* <Note>
|
||||
* the "width" and "height" fields of the metrics are expressed in
|
||||
* 26.6 sub-pixels. However, the width and height in pixels can be
|
||||
* read directly from "bitmap.width" and "bitmap.height"
|
||||
*
|
||||
* this structure is used for both monochrome and anti-aliased
|
||||
* bitmaps (the bitmap descriptor contains field describing the
|
||||
* format of the pixel buffer)
|
||||
* You can typecast a FT_Glyph to FT_BitmapGlyph when you have
|
||||
* glyph->format == ft_glyph_format_bitmap. This lets you access
|
||||
* the bitmap's content easily..
|
||||
*
|
||||
* the corresponding pixel buffer is always owned by the BitmapGlyph
|
||||
* and is thus creatde and destroyed with it..
|
||||
* and is thus created and destroyed with it..
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
typedef struct FT_BitmapGlyphRec_
|
||||
{
|
||||
FT_GlyphRec metrics;
|
||||
FT_GlyphRec root;
|
||||
FT_Int left;
|
||||
FT_Int top;
|
||||
FT_Bitmap bitmap;
|
||||
|
||||
} FT_BitmapGlyphRec_, *FT_BitmapGlyph;
|
||||
} FT_BitmapGlyphRec, *FT_BitmapGlyph;
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
@ -138,147 +107,238 @@
|
||||
* FT_OutlineGlyphRec
|
||||
*
|
||||
* <Description>
|
||||
* A structure used to describe a vectorial outline glyph image..
|
||||
* Note that the FT_OutlineGlyph type is a pointer to FT_OutlineGlyphRec
|
||||
* A structure used for outline (vectorial) glyph images..
|
||||
* This really is a "sub-class" of FT_GlyphRec.
|
||||
*
|
||||
* <Field>
|
||||
* metrics :: the corresponding glyph metrics
|
||||
* root :: the root FT_Glyph fields.
|
||||
* outline :: a descriptor for the outline
|
||||
*
|
||||
* <Note>
|
||||
* the "width" and "height" fields of the metrics are expressed in
|
||||
* 26.6 sub-pixels. However, the width and height in pixels can be
|
||||
* read directly from "bitmap.width" and "bitmap.rows"
|
||||
* You can typecast a FT_Glyph to FT_OutlineGlyph when you have
|
||||
* glyph->format == ft_glyph_format_outline. This lets you access
|
||||
* the outline's content easily..
|
||||
*
|
||||
* the corresponding outline points tables is always owned by the
|
||||
* object and are destroyed with it..
|
||||
* As the outline is extracted from a glyph slot, its coordinates
|
||||
* are expressed normally in 26.6 pixels, unless the flag
|
||||
* FT_LOAD_NO_SCALE was used in FT_Load_Glyph / FT_Load_Char..
|
||||
*
|
||||
* an OutlineGlyph can be used to generate a BitmapGlyph with the
|
||||
* function FT_OutlineGlyph_Render()
|
||||
* the outline's tables are always owned by the object and are
|
||||
* destroyed with it..
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
typedef struct FT_OutlineGlyphRec_
|
||||
{
|
||||
FT_GlyphRec metrics;
|
||||
FT_GlyphRec root;
|
||||
FT_Outline outline;
|
||||
|
||||
} FT_OutlineGlyphRec_, *FT_OutlineGlyph;
|
||||
} FT_OutlineGlyphRec, *FT_OutlineGlyph;
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* <Function>
|
||||
* FT_Get_Glyph_Bitmap
|
||||
* FT_Get_Glyph
|
||||
*
|
||||
* <Description>
|
||||
* A function used to directly return a bitmap glyph image
|
||||
* from a face.
|
||||
* A function used to extract one glyph image from a slot..
|
||||
*
|
||||
* <Input>
|
||||
* face :: handle to source face object
|
||||
* glyph_index :: glyph index in face
|
||||
* load_flags :: load flags, see FT_LOAD_FLAG_XXXX constants..
|
||||
* grays :: number of gray levels for anti-aliased bitmaps,
|
||||
* set to 0 if you want to render a monochrome bitmap
|
||||
* origin :: a pointer to the origin's position. Set to 0
|
||||
* if the current transform is the identity..
|
||||
* slot :: handle to source glyph slot.
|
||||
*
|
||||
* <Output>
|
||||
* bitglyph :: pointer to the new bitmap glyph
|
||||
* aglyph :: handle to the glyph object.
|
||||
*
|
||||
* <Return>
|
||||
* Error code. 0 means success.
|
||||
*
|
||||
* <Note>
|
||||
* If the font contains glyph outlines, these will be automatically
|
||||
* converted to a bitmap according to the value of "grays"
|
||||
*
|
||||
* If "grays" is set to 0, the result is a 1-bit monochrome bitmap
|
||||
* otherwise, it is an 8-bit gray-level bitmap
|
||||
*
|
||||
* The number of gray levels in the result anti-aliased bitmap might
|
||||
* not be "grays", depending on the current scan-converter implementation
|
||||
*
|
||||
* Note that it is not possible to generate 8-bit monochrome bitmaps
|
||||
* with this function. Rather, use FT_Get_Glyph_Outline, then
|
||||
* FT_Glyph_Render_Outline and provide your own span callbacks..
|
||||
*
|
||||
* When the face doesn't contain scalable outlines, this function will
|
||||
* fail if the current transform is not the identity, or if the glyph
|
||||
* origin's phase to the pixel grid is not 0 in both directions !!
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
FT_EXPORT_DEF(FT_Error) FT_Get_Glyph_Bitmap( FT_Face face,
|
||||
FT_UInt glyph_index,
|
||||
FT_UInt load_flags,
|
||||
FT_Int grays,
|
||||
FT_Vector* origin,
|
||||
FT_BitmapGlyph *abitglyph );
|
||||
|
||||
FT_EXPORT_DEF(FT_Error) FT_Get_Glyph( FT_GlyphSlot slot,
|
||||
FT_Glyph *aglyph );
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* <Function>
|
||||
* FT_Get_Glyph_Outline
|
||||
* FT_Glyph_Copy
|
||||
*
|
||||
* <Description>
|
||||
* A function used to directly return an outline glyph image from a
|
||||
* face. This is faster than calling FT_Load_Glyph+FT_Get_Outline_Bitmap..
|
||||
* A function used to copy one glyph image.
|
||||
*
|
||||
* <Input>
|
||||
* face :: handle to source face object
|
||||
* glyph_index :: glyph index in face
|
||||
* load_flags :: load flags, see FT_LOAD_FLAG_XXXX constants..
|
||||
* source :: handle to source glyph object
|
||||
*
|
||||
* <Output>
|
||||
* vecglyph :: pointer to the new outline glyph
|
||||
* target :: handle to target glyph object. 0 in case of error
|
||||
*
|
||||
* <Return>
|
||||
* Error code. 0 means success.
|
||||
*
|
||||
* <Note>
|
||||
* If the glyph is not an outline in the face, this function will
|
||||
* fail..
|
||||
*
|
||||
* This function will fail if the load flags FT_LOAD_NO_OUTLINE and
|
||||
* FT_LOAD_NO_RECURSE are set..
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
FT_EXPORT_DEF(FT_Error) FT_Get_Glyph_Outline( FT_Face face,
|
||||
FT_UInt glyph_index,
|
||||
FT_UInt load_flags,
|
||||
FT_OutlineGlyph *vecglyph );
|
||||
FT_EXPORT_DEF(FT_Error) FT_Glyph_Copy( FT_Glyph source,
|
||||
FT_Glyph *target );
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* <Function>
|
||||
* FT_Set_Transform
|
||||
* FT_Glyph_Transform
|
||||
*
|
||||
* <Description>
|
||||
* A function used to set the transform that is applied to glyph images
|
||||
* just after they're loaded in the face's glyph slot, and before they're
|
||||
* returned by either FT_Get_Glyph_Bitmap or FT_Get_Glyph_Outline
|
||||
* Transforms a glyph image, when it's format is scalable
|
||||
*
|
||||
* <Input>
|
||||
* face :: handle to source face object
|
||||
* matrix :: pointer to the transform's 2x2 matrix. 0 for identity
|
||||
* delta :: pointer to the transform's translation. 0 for null vector
|
||||
* glyph :: handle to target glyph object
|
||||
*
|
||||
* matrix :: pointer to 2x2 matrix to apply
|
||||
*
|
||||
* delta :: pointer to a 2d vector to apply. coordinates are
|
||||
* expressed in 1/64th of a pixel..
|
||||
*
|
||||
* <Return>
|
||||
* error code (is not 0, the glyph format is not scalable).
|
||||
*
|
||||
* <Note>
|
||||
* The transform is only applied to glyph outlines when they are found
|
||||
* in a font face. It is unable to transform embedded glyph bitmaps
|
||||
* the 2x2 transform matrix is also applied to the glyph's
|
||||
* advance vector
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
FT_EXPORT_DEF(void) FT_Set_Transform( FT_Face face,
|
||||
FT_Matrix* matrix,
|
||||
FT_Vector* delta );
|
||||
FT_EXPORT_DEF(FT_Error) FT_Glyph_Transform( FT_Glyph glyph,
|
||||
FT_Matrix* matrix,
|
||||
FT_Vector* delta );
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* <Function>
|
||||
* FT_Glyph_Get_CBox
|
||||
*
|
||||
* <Description>
|
||||
* Returns the glyph image's bounding box.
|
||||
*
|
||||
* <Input>
|
||||
* glyph :: handle to source glyph object
|
||||
* mode :: a set of bit flags that indicate how to interpret
|
||||
* the meaning of the box's coordinates
|
||||
*
|
||||
* <Output>
|
||||
* box :: the glyph bounding box. Coordinates are expressed in
|
||||
* 1/64th of pixels, it is grid-fitted..
|
||||
*
|
||||
* <Note>
|
||||
* Coordinates are relative to the glyph origin, using the Y-upwards
|
||||
* convention..
|
||||
*
|
||||
* if 'ft_glyph_bbox_subpixels' is set in "mode", the bbox coordinates
|
||||
* are returned in 26.6 pixels (i.e. 1/64th of pixels).
|
||||
*
|
||||
* otherwise, coordinates are in integer pixels.
|
||||
*
|
||||
* note that the maximum coordinates are exclusive, which means that
|
||||
* once can compute the width and height of the glyph image (be it
|
||||
* in integer or 26.6 pixels) as:
|
||||
*
|
||||
* width = bbox.xMax - bbox.xMin;
|
||||
* height = bbox.yMax - bbox.yMin;
|
||||
*
|
||||
* Note also that for 26.6 coordinates, if the 'ft_glyph_bbox_gridfit'
|
||||
* flag is set in "mode", the coordinates will also be grid-fitted,
|
||||
* which corresponds to:
|
||||
*
|
||||
* bbox.xMin = FLOOR(bbox.xMin);
|
||||
* bbox.yMin = FLOOR(bbox.yMin);
|
||||
* bbox.xMax = CEILING(bbox.xMax);
|
||||
* bbox.yMax = CEILING(bbox.yMax);
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
enum
|
||||
{
|
||||
ft_glyph_bbox_pixels = 0,
|
||||
ft_glyph_bbox_subpixels = 1,
|
||||
ft_glyph_bbox_gridfit = 2
|
||||
};
|
||||
|
||||
FT_EXPORT_DEF(void) FT_Glyph_Get_CBox( FT_Glyph glyph,
|
||||
FT_UInt bbox_mode,
|
||||
FT_BBox *cbox );
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* <Function>
|
||||
* FT_Glyph_To_Bitmap
|
||||
*
|
||||
* <Description>
|
||||
* converts a given glyph object to a bitmap glyph object
|
||||
*
|
||||
* <InOut>
|
||||
* glyph :: pointer to a handle to the target glyph
|
||||
*
|
||||
* <Input>
|
||||
* render_mode :: a set of bit flags that describe how
|
||||
*
|
||||
* origin :: pointer to a vector used to translate the glyph image
|
||||
* before rendering. Can be 0 (for no translation). The
|
||||
* origin is expressed in 26.6 pixels..
|
||||
*
|
||||
* destroy :: a boolean that indicates that the original glyph image
|
||||
* should be destroyed by this function. The glyph is
|
||||
* never destroyed in case of error..
|
||||
*
|
||||
* <Return>
|
||||
* Error code. 0 means success
|
||||
*
|
||||
* <Note>
|
||||
* the glyph image is translated with the "origin" vector before
|
||||
* rendering.. In case of error, it it translated back to its original
|
||||
* position and the glyph is untouched..
|
||||
*
|
||||
* The first parameter is a pointer to a FT_Glyph handle, that
|
||||
* will be replaced by this function. Typically, you would use:
|
||||
*
|
||||
* {
|
||||
* FT_Glyph glyph;
|
||||
* FT_BitmapGlyph glyph_bitmap;
|
||||
*
|
||||
* // load glyph
|
||||
* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT );
|
||||
*
|
||||
* // extract glyph image
|
||||
* error = FT_Get_Glyph( face->glyph, &glyph );
|
||||
*
|
||||
* // convert to a bitmap (default render mode + destroy old)
|
||||
* if (glyph->format != ft_glyph_format_bitmap)
|
||||
* {
|
||||
* error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_default, 0, 1 );
|
||||
* if (error) // glyph unchanged..
|
||||
* }
|
||||
*
|
||||
* // access bitmap content by typecasting
|
||||
* glyph_bitmap = (FT_BitmapGlyph)glyph;
|
||||
*
|
||||
* // do funny stuff with it, like blitting/drawing
|
||||
* ....
|
||||
*
|
||||
* // discard glyph image (bitmap or not)
|
||||
* FT_Done_Glyph( glyph );
|
||||
*
|
||||
*
|
||||
* This function will always fail if the glyph's format isn't scalable
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
FT_EXPORT_DEF(FT_Error) FT_Glyph_To_Bitmap( FT_Glyph *the_glyph,
|
||||
FT_ULong render_mode,
|
||||
FT_Vector* origin,
|
||||
FT_Bool destroy );
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* <Function>
|
||||
@ -295,32 +355,49 @@
|
||||
FT_EXPORT_DEF(void) FT_Done_Glyph( FT_Glyph glyph );
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* <Function>
|
||||
* FT_Glyph_Get_Box
|
||||
*
|
||||
* <Description>
|
||||
* Returns the glyph image's bounding box in pixels.
|
||||
*
|
||||
* <Input>
|
||||
* glyph :: handle to target glyph object
|
||||
*
|
||||
* <Output>
|
||||
* box :: the glyph bounding box. Coordinates are expressed in
|
||||
* _integer_ pixels, with exclusive max bounds
|
||||
*
|
||||
* <Note>
|
||||
* Coordinates are relative to the glyph origin, using the Y-upwards
|
||||
* convention..
|
||||
*
|
||||
* The width of the box in pixels is box.xMax-box.xMin
|
||||
* The height is box.yMax - box.yMin
|
||||
*
|
||||
***********************************************************************/
|
||||
/* other helpful functions */
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Matrix_Multiply */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Performs the matrix operation `b = a*b'. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: A pointer to matrix `a'. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* b :: A pointer to matrix `b'. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(void) FT_Matrix_Multiply( FT_Matrix* a,
|
||||
FT_Matrix* b );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Matrix_Invert */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Inverts a 2x2 matrix. Returns an error if it can't be inverted. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* matrix :: A pointer to the target matrix. Remains untouched in */
|
||||
/* case of error. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(FT_Error) FT_Matrix_Invert( FT_Matrix* matrix );
|
||||
|
||||
FT_EXPORT_DEF(void) FT_Glyph_Get_Box( FT_Glyph glyph,
|
||||
FT_BBox *box );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -192,6 +192,93 @@
|
||||
FT_Module module );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* <Function>
|
||||
* FT_New_Library
|
||||
*
|
||||
* <Description>
|
||||
* Creates a new "virgin" library that uses a custom memory manager.
|
||||
* The library has no registered driver, those can be added with a
|
||||
* call to FT_Add_Default_Modules
|
||||
*
|
||||
* <Input>
|
||||
* memory :: handle to custom memory manager
|
||||
*
|
||||
* <Output>
|
||||
* library :: handle to fresh new library object
|
||||
*
|
||||
* <Return>
|
||||
* Error code (module not listed)
|
||||
*
|
||||
*************************************************************************/
|
||||
|
||||
FT_EXPORT_DEF(FT_Error) FT_New_Library( FT_Memory memory,
|
||||
FT_Library* library );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* <Function>
|
||||
* FT_Done_Library
|
||||
*
|
||||
* <Description>
|
||||
* Destroys a given library, and all child objects, except the
|
||||
* memory manager.
|
||||
*
|
||||
* <Input>
|
||||
* library :: handle to target library object
|
||||
*
|
||||
* <Return>
|
||||
* Error code (module not listed)
|
||||
*
|
||||
*************************************************************************/
|
||||
|
||||
FT_EXPORT_DEF(FT_Error) FT_Done_Library( FT_Library library );
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* <Function>
|
||||
* FT_Set_Debug_Hook
|
||||
*
|
||||
* <Description>
|
||||
* Used only by the TrueType debugger. This function is private and
|
||||
* should never be called by normal applications..
|
||||
*
|
||||
* <Input>
|
||||
* library :: handle to target library object
|
||||
* hook_index :: hook index
|
||||
* debug_hook :: debug hook functions
|
||||
*
|
||||
*************************************************************************/
|
||||
|
||||
typedef void (*FT_DebugHook_Func)( void* arg );
|
||||
|
||||
FT_EXPORT_DEF(void) FT_Set_Debug_Hook( FT_Library library,
|
||||
FT_UInt hook_index,
|
||||
FT_DebugHook_Func debug_hook );
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Add_Default_Modules */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Adds the set of default modules to a given library object. */
|
||||
/* This is only useful when you create a library object with */
|
||||
/* FT_New_Library (usually to plug a custom memory manager) */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a new library object. */
|
||||
/* */
|
||||
FT_EXPORT_DEF(void) FT_Add_Default_Modules( FT_Library library );
|
||||
|
||||
|
||||
|
||||
#endif /* FTMODULE_H */
|
||||
|
||||
|
||||
|
@ -19,6 +19,41 @@
|
||||
#define FTRENDER_H
|
||||
|
||||
#include <freetype/ftmodule.h>
|
||||
#include <freetype/ftglyph.h>
|
||||
|
||||
/* create a new glyph object */
|
||||
typedef FT_Error (*FT_Glyph_Init_Func)( FT_Glyph glyph,
|
||||
FT_GlyphSlot slot );
|
||||
|
||||
/* destroys a given glyph object */
|
||||
typedef void (*FT_Glyph_Done_Func)( FT_Glyph glyph );
|
||||
|
||||
typedef void (*FT_Glyph_Transform_Func)( FT_Glyph glyph,
|
||||
FT_Matrix* matrix,
|
||||
FT_Vector* delta );
|
||||
|
||||
typedef void (*FT_Glyph_BBox_Func)( FT_Glyph glyph,
|
||||
FT_BBox *abbox );
|
||||
|
||||
typedef FT_Error (*FT_Glyph_Copy_Func)( FT_Glyph source,
|
||||
FT_Glyph target );
|
||||
|
||||
typedef FT_Error (*FT_Glyph_Prepare_Func)( FT_Glyph glyph,
|
||||
FT_GlyphSlot slot );
|
||||
|
||||
struct FT_Glyph_Class_
|
||||
{
|
||||
FT_UInt glyph_size;
|
||||
FT_Glyph_Format glyph_format;
|
||||
FT_Glyph_Init_Func glyph_init;
|
||||
FT_Glyph_Done_Func glyph_done;
|
||||
FT_Glyph_Copy_Func glyph_copy;
|
||||
FT_Glyph_Transform_Func glyph_transform;
|
||||
FT_Glyph_BBox_Func glyph_bbox;
|
||||
FT_Glyph_Prepare_Func glyph_prepare;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
@ -81,11 +116,6 @@
|
||||
} FT_Renderer_Class;
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
ft_render_mode_antialias = 1
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* <Function>
|
||||
|
@ -257,13 +257,17 @@
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
#define FT_RENDERER(x) ((FT_Renderer)(x))
|
||||
#define FT_RENDERER(x) ((FT_Renderer)(x))
|
||||
#define FT_GLYPH(x) ((FT_Glyph)(x))
|
||||
#define FT_BITMAP_GLYPH(x) ((FT_BitmapGlyph)(x))
|
||||
#define FT_OUTLINE_GLYPH(x) ((FT_OutlineGlyph)(x))
|
||||
|
||||
typedef struct FT_RendererRec_
|
||||
{
|
||||
FT_ModuleRec root;
|
||||
FT_Renderer_Class* clazz;
|
||||
FT_Glyph_Format glyph_format;
|
||||
const FT_Glyph_Class glyph_class;
|
||||
|
||||
FT_Raster raster;
|
||||
FT_Raster_Render_Func raster_render;
|
||||
@ -384,7 +388,6 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
typedef void (*FT_DebugHook_Func)( void* arg );
|
||||
|
||||
|
||||
typedef struct FT_LibraryRec_
|
||||
@ -408,19 +411,6 @@
|
||||
} FT_LibraryRec;
|
||||
|
||||
|
||||
FT_EXPORT_DEF(FT_Error) FT_New_Library( FT_Memory memory,
|
||||
FT_Library* library );
|
||||
|
||||
|
||||
FT_EXPORT_DEF(FT_Error) FT_Done_Library( FT_Library library );
|
||||
|
||||
|
||||
|
||||
FT_EXPORT_DEF(void) FT_Set_Debug_Hook( FT_Library library,
|
||||
FT_UInt hook_index,
|
||||
FT_DebugHook_Func debug_hook );
|
||||
|
||||
|
||||
BASE_DEF(FT_Renderer) FT_Lookup_Renderer( FT_Library library,
|
||||
FT_Glyph_Format format,
|
||||
FT_ListNode *node );
|
||||
@ -430,7 +420,6 @@
|
||||
FT_UInt render_mode );
|
||||
|
||||
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
|
||||
|
||||
FT_EXPORT_DEF(FT_Error) FT_New_Stream( const char* filepathname,
|
||||
|
1113
src/base/ftglyph.c
1113
src/base/ftglyph.c
File diff suppressed because it is too large
Load Diff
@ -664,7 +664,8 @@
|
||||
FT_Memory memory = driver->root.memory;
|
||||
FT_Error error = FT_Err_Ok;
|
||||
|
||||
|
||||
slot->library = driver->root.library;
|
||||
|
||||
if ( FT_DRIVER_USES_OUTLINES( driver ) )
|
||||
error = FT_GlyphLoader_New( memory, &slot->loader );
|
||||
|
||||
@ -1023,10 +1024,10 @@
|
||||
load_flags & FT_LOAD_RENDER )
|
||||
{
|
||||
error = FT_Render_Glyph( slot,
|
||||
( load_flags & FT_LOAD_ANTI_ALIAS )
|
||||
? ft_render_mode_antialias
|
||||
: 0 );
|
||||
}
|
||||
( load_flags & FT_LOAD_MONOCHROME )
|
||||
? ft_render_mode_mono
|
||||
: ft_render_mode_normal );
|
||||
}
|
||||
|
||||
Exit:
|
||||
return error;
|
||||
@ -2039,6 +2040,9 @@
|
||||
/* */
|
||||
/* right_glyph :: The index of the right glyph in the kern pair. */
|
||||
/* */
|
||||
/* kern_mode :: see FT_Kerning_Mode for more info. Determines the */
|
||||
/* scale/dimension of the returned kerning vector */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* kerning :: The kerning vector. This is in font units for */
|
||||
/* scalable formats, and in pixels for fixed-sizes */
|
||||
@ -2053,16 +2057,16 @@
|
||||
/* kernings, are out of the scope of this API function -- they can be */
|
||||
/* implemented through format-specific interfaces. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Get_Kerning( FT_Face face,
|
||||
FT_UInt left_glyph,
|
||||
FT_UInt right_glyph,
|
||||
FT_Vector* kerning )
|
||||
FT_EXPORT_FUNC(FT_Error) FT_Get_Kerning( FT_Face face,
|
||||
FT_UInt left_glyph,
|
||||
FT_UInt right_glyph,
|
||||
FT_UInt kern_mode,
|
||||
FT_Vector* kerning )
|
||||
{
|
||||
FT_Error error = FT_Err_Ok;
|
||||
FT_Driver driver;
|
||||
FT_Memory memory;
|
||||
|
||||
|
||||
if ( !face )
|
||||
return FT_Err_Invalid_Face_Handle;
|
||||
|
||||
@ -2079,6 +2083,20 @@
|
||||
right_glyph,
|
||||
kerning );
|
||||
}
|
||||
if (!error)
|
||||
{
|
||||
if (kern_mode != ft_kerning_unscaled)
|
||||
{
|
||||
kerning->x = FT_MulFix( kerning->x, face->size->metrics.x_scale );
|
||||
kerning->y = FT_MulFix( kerning->y, face->size->metrics.y_scale );
|
||||
|
||||
if (kern_mode != ft_kerning_unfitted)
|
||||
{
|
||||
kerning->x = (kerning->x+32) & -64;
|
||||
kerning->y = (kerning->y+32) & -64;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
kerning->x = 0;
|
||||
@ -2599,24 +2617,13 @@
|
||||
/* slot :: A handle to the glyph slot containing the image to */
|
||||
/* convert. */
|
||||
/* */
|
||||
/* render_mode :: A set of bit flags indicating which kind of bitmap */
|
||||
/* to render. For now, only */
|
||||
/* `ft_render_mode_anti_alias' is supported by the */
|
||||
/* available renderers, but others could appear later */
|
||||
/* (e.g. optimized for TV or LCD). */
|
||||
/* render_mode :: this is the render mode used to render the glyph */
|
||||
/* image into a bitmap. See FT_Render_Mode for a list */
|
||||
/* of possible values. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* In case of success, the renderer will be used to convert glyph */
|
||||
/* images in the renderer's known format into bitmaps. */
|
||||
/* */
|
||||
/* This doesn't change the current renderer for other formats. */
|
||||
/* */
|
||||
/* The slot's native image should be considered lost after the */
|
||||
/* conversion. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Render_Glyph( FT_GlyphSlot slot,
|
||||
FT_UInt render_mode )
|
||||
{
|
||||
|
@ -23,8 +23,7 @@
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#include <freetype/freetype.h>
|
||||
#include <freetype/config/ftconfig.h>
|
||||
#include <freetype/ftoutln.h>
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
|
||||
|
||||
@ -337,6 +336,57 @@
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Copy */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Copies an outline into another one. Both objects must have the */
|
||||
/* same sizes (number of points & number of contours) when this */
|
||||
/* function is called. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* source :: A handle to the source outline. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* target :: A handle to the target outline. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Outline_Copy( FT_Outline* source,
|
||||
FT_Outline* target )
|
||||
{
|
||||
FT_Int is_owner;
|
||||
|
||||
|
||||
if ( !source || !target ||
|
||||
source->n_points != target->n_points ||
|
||||
source->n_contours != target->n_contours )
|
||||
return FT_Err_Invalid_Argument;
|
||||
|
||||
MEM_Copy( target->points, source->points,
|
||||
source->n_points * sizeof ( FT_Vector ) );
|
||||
|
||||
MEM_Copy( target->tags, source->tags,
|
||||
source->n_points * sizeof ( FT_Byte ) );
|
||||
|
||||
MEM_Copy( target->contours, source->contours,
|
||||
source->n_contours * sizeof ( FT_Short ) );
|
||||
|
||||
/* copy all flags, except the `ft_outline_owner' one */
|
||||
is_owner = target->flags & ft_outline_owner;
|
||||
target->flags = source->flags;
|
||||
|
||||
target->flags &= ~ft_outline_owner;
|
||||
target->flags |= is_owner;
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
@ -759,163 +809,14 @@
|
||||
/* You can use FT_Outline_Translate() if you need to translate the */
|
||||
/* outline's points. */
|
||||
/* */
|
||||
BASE_FUNC( void ) FT_Outline_Transform( FT_Outline* outline,
|
||||
FT_Matrix* matrix )
|
||||
FT_EXPORT_FUNC( void ) FT_Outline_Transform( FT_Outline* outline,
|
||||
FT_Matrix* matrix )
|
||||
{
|
||||
FT_Vector* vec = outline->points;
|
||||
FT_Vector* limit = vec + outline->n_points;
|
||||
|
||||
|
||||
for ( ; vec < limit; vec++ )
|
||||
FT_Vector_Transform( vec, matrix );
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** The following functions are not used by the font drivers ****/
|
||||
/**** but they are provided as a convenience for client ****/
|
||||
/**** applications. ****/
|
||||
/**** ****/
|
||||
/**** Note that they will not be compiled if the configuration ****/
|
||||
/**** macro FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS is defined. ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Copy */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Copies an outline into another one. Both objects must have the */
|
||||
/* same sizes (number of points & number of contours) when this */
|
||||
/* function is called. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* source :: A handle to the source outline. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* target :: A handle to the target outline. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Outline_Copy( FT_Outline* source,
|
||||
FT_Outline* target )
|
||||
{
|
||||
FT_Int is_owner;
|
||||
|
||||
|
||||
if ( !source || !target ||
|
||||
source->n_points != target->n_points ||
|
||||
source->n_contours != target->n_contours )
|
||||
return FT_Err_Invalid_Argument;
|
||||
|
||||
MEM_Copy( target->points, source->points,
|
||||
source->n_points * 2 * sizeof ( FT_Pos ) );
|
||||
|
||||
MEM_Copy( target->tags, source->tags,
|
||||
source->n_points * sizeof ( FT_Byte ) );
|
||||
|
||||
MEM_Copy( target->contours, source->contours,
|
||||
source->n_contours * sizeof ( FT_Short ) );
|
||||
|
||||
/* copy all flags, except the `ft_outline_owner' one */
|
||||
is_owner = target->flags & ft_outline_owner;
|
||||
target->flags = source->flags;
|
||||
|
||||
target->flags &= ~ft_outline_owner;
|
||||
target->flags |= is_owner;
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Matrix_Multiply */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Performs the matrix operation `b = a*b'. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: A pointer to matrix `a'. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* b :: A pointer to matrix `b'. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( void ) FT_Matrix_Multiply( FT_Matrix* a,
|
||||
FT_Matrix* b )
|
||||
{
|
||||
FT_Fixed xx, xy, yx, yy;
|
||||
|
||||
|
||||
xx = FT_MulFix( a->xx, b->xx ) + FT_MulFix( a->xy, b->yx );
|
||||
xy = FT_MulFix( a->xx, b->xy ) + FT_MulFix( a->xy, b->yy );
|
||||
yx = FT_MulFix( a->yx, b->xx ) + FT_MulFix( a->yy, b->yx );
|
||||
yy = FT_MulFix( a->yx, b->xy ) + FT_MulFix( a->yy, b->yy );
|
||||
|
||||
b->xx = xx; b->xy = xy;
|
||||
b->yx = yx; b->yy = yy;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Matrix_Invert */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Inverts a 2x2 matrix. Returns an error if it can't be inverted. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* matrix :: A pointer to the target matrix. Remains untouched in */
|
||||
/* case of error. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <MT-Note> */
|
||||
/* Yes. */
|
||||
/* */
|
||||
FT_EXPORT_FUNC( FT_Error ) FT_Matrix_Invert( FT_Matrix* matrix )
|
||||
{
|
||||
FT_Pos delta, xx, yy;
|
||||
|
||||
|
||||
/* compute discriminant */
|
||||
delta = FT_MulFix( matrix->xx, matrix->yy ) -
|
||||
FT_MulFix( matrix->xy, matrix->yx );
|
||||
|
||||
if ( !delta )
|
||||
return FT_Err_Invalid_Argument; /* matrix can't be inverted */
|
||||
|
||||
matrix->xy = - FT_DivFix( matrix->xy, delta );
|
||||
matrix->yx = - FT_DivFix( matrix->yx, delta );
|
||||
|
||||
xx = matrix->xx;
|
||||
yy = matrix->yy;
|
||||
|
||||
matrix->xx = FT_DivFix( yy, delta );
|
||||
matrix->yy = FT_DivFix( xx, delta );
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_NO_CONVENIENCE_FUNCS */
|
||||
|
||||
|
||||
/* END */
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <freetype/internal/ftcalc.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/sfnt.h>
|
||||
#include <freetype/ftoutln.h>
|
||||
#include <freetype/tttags.h>
|
||||
|
||||
#include <t2load.h>
|
||||
|
@ -583,7 +583,6 @@
|
||||
*(FT_Int*)q = (FT_Int)val;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
*(FT_Long*)q = val;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <cidgload.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
|
||||
#include <freetype/ftoutln.h>
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
@ -459,7 +459,7 @@
|
||||
|
||||
if ( bchar_index < 0 || achar_index < 0 )
|
||||
{
|
||||
FT_ERROR(( "t1operator_seac: ));
|
||||
FT_ERROR(( "t1operator_seac:" ));
|
||||
FT_ERROR(( " invalid seac character code arguments\n" ));
|
||||
return T1_Err_Syntax_Error;
|
||||
}
|
||||
@ -862,7 +862,7 @@
|
||||
if ( ip[0] != 12 || ip[1] != 17 )
|
||||
{
|
||||
FT_ERROR(( "CID_Parse_CharStrings:" ));
|
||||
FT_ERROR(( " `pop' expected, found (%d %d)\n",
|
||||
FT_ERROR(( " 'pop' expected, found (%d %d)\n",
|
||||
ip[0], ip[1] ));
|
||||
goto Syntax_Error;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include <freetype/ftoutln.h>
|
||||
#include <raster1.h>
|
||||
#include <ftraster.h>
|
||||
|
||||
@ -84,7 +85,7 @@
|
||||
}
|
||||
|
||||
/* check rendering mode */
|
||||
if ( mode & ft_render_mode_antialias )
|
||||
if ( mode != ft_render_mode_mono )
|
||||
{
|
||||
/* raster1 is only capable of producing monochrome bitmaps */
|
||||
if (render->clazz == &ft_raster1_renderer_class)
|
||||
@ -124,7 +125,7 @@
|
||||
}
|
||||
|
||||
/* allocate new one, depends on pixel format */
|
||||
if ( mode & ft_render_mode_antialias )
|
||||
if (!(mode & ft_render_mode_mono))
|
||||
{
|
||||
/* we pad to 32 bits, only for backwards compatibility with FT 1.x */
|
||||
pitch = (width+3) & -4;
|
||||
|
@ -126,7 +126,7 @@
|
||||
#include "ftgrays.h"
|
||||
#include <freetype/internal/ftobjs.h> /* for UNUSED() */
|
||||
#include <freetype/internal/ftdebug.h> /* for FT_TRACE() and FT_ERROR() */
|
||||
#include <freetype/freetype.h> /* for FT_Outline_Decompose() */
|
||||
#include <freetype/ftoutln.h> /* for FT_Outline_Decompose() */
|
||||
|
||||
#define ErrRaster_Invalid_Mode FT_Err_Cannot_Render_Glyph
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <freetype/internal/ftobjs.h>
|
||||
#include <freetype/ftoutln.h>
|
||||
#include <ftsmooth.h>
|
||||
#include <ftgrays.h>
|
||||
|
||||
@ -51,8 +52,8 @@
|
||||
|
||||
/* return the glyph's control box */
|
||||
static void ft_smooth_get_cbox( FT_Renderer render,
|
||||
FT_GlyphSlot slot,
|
||||
FT_BBox *cbox )
|
||||
FT_GlyphSlot slot,
|
||||
FT_BBox *cbox )
|
||||
{
|
||||
MEM_Set( cbox, 0, sizeof(*cbox) );
|
||||
|
||||
@ -84,7 +85,7 @@
|
||||
}
|
||||
|
||||
/* check mode */
|
||||
if ( mode != ft_render_mode_antialias )
|
||||
if ( mode != ft_render_mode_normal )
|
||||
return FT_Err_Cannot_Render_Glyph;
|
||||
|
||||
outline = &slot->outline;
|
||||
@ -104,7 +105,7 @@
|
||||
width = (cbox.xMax - cbox.xMin) >> 6;
|
||||
height = (cbox.yMax - cbox.yMin) >> 6;
|
||||
bitmap = &slot->bitmap;
|
||||
memory = slot->face->memory;
|
||||
memory = render->root.memory;
|
||||
|
||||
/* release old bitmap buffer */
|
||||
if ((slot->flags & ft_glyph_own_bitmap))
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/internal/sfnt.h>
|
||||
#include <freetype/tttags.h>
|
||||
#include <freetype/ftoutln.h>
|
||||
|
||||
|
||||
#include <ttgload.h>
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <t1gload.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/ftoutln.h>
|
||||
|
||||
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
|
||||
#include <t1hinter.h>
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <z1gload.h>
|
||||
#include <freetype/internal/ftdebug.h>
|
||||
#include <freetype/internal/ftstream.h>
|
||||
#include <freetype/ftoutln.h>
|
||||
|
||||
#undef FT_COMPONENT
|
||||
#define FT_COMPONENT trace_t1gload
|
||||
|
Loading…
Reference in New Issue
Block a user