[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ft-devel] Error Invalid_Argument in FT_Load_Char()
From: |
Stefan Koch |
Subject: |
[ft-devel] Error Invalid_Argument in FT_Load_Char() |
Date: |
Tue, 26 Sep 2006 18:42:19 +0200 |
User-agent: |
Mozilla Thunderbird 0.6 (Windows/20040502) |
Hello,
when upgrading to libfreetype-2.2.1 I noticed, that the font "Lucida
Sans Regular" is not rendered completely anymore as it was with version
2.1.10:
libfreetype-2.1.10
% ./example2 LucidaSansRegular.ttf
+++ +++
+++++++++++ ##+ +##+
###########+ +#+ +##+
++++###+++++ +#+ +++ +#+
+## +##
+## ++##++ +####+ +#####+ ++###++ +####+
+## +######+ +#####+ +#####+ +#######+ +#####+
+## +#+ +#+ ##+ +## +## +#+ ##+
+## ##+ +## +##+ +## ##+ +## +##+
+## ######## +###++ +## ## ##+ +###++
+## +#######+ +####+ +## +## ##+ +####+
+## ##+ +### +## ##+ ## +###
+## ##+ +## +## ##+ +## +##
+## +##+++++ ++++### +##++ +##+++##+ ++++###
+## +###### +#####+ +### +#####+ +#####+
++++ ++++ +++ +++ ++++
8< - - -
libfreetype-2.2.1
% ./example LucidaSansRegular.ttf
ft error 6
ft error 6
+++++++++++
###########+
++++###+++++ +++
+## +##
+## +####+ +#####+ +####+
+## +#####+ +#####+ +#####+
+## ##+ +## ##+
+## +##+ +## +##+
+## +###++ +## +###++
+## +####+ +## +####+
+## +### +## +###
+## +## +## +##
+## ++++### +##++ ++++###
+## +#####+ +### +#####+
++++ +++ ++++
8< - - -
Test-Program:
/* gcc -O0 -g -W -Wall -std=gnu99 -pedantic -I /usr/include/freetype2 -o
example example.c -lfreetype -lm -lz */
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#define PANE_WIDTH 79
#define PANE_HEIGHT 30
unsigned char image[PANE_HEIGHT][PANE_WIDTH];
const FT_UInt GLYPH_INDEX[6] = {
84, 233, 115, 116, 242, 115 /* Téstòs */
};
void
draw_bitmap( FT_Bitmap* bitmap,
FT_Int x,
FT_Int y)
{
FT_Int i, j, p, q;
FT_Int x_max = x + bitmap->width;
FT_Int y_max = y + bitmap->rows;
for ( i = x, p = 0; i < x_max; i++, p++ )
{
for ( j = y, q = 0; j < y_max; j++, q++ )
{
if ( i >= PANE_WIDTH || j >= PANE_HEIGHT )
continue;
image[j][i] |= bitmap->buffer[q * bitmap->width + p];
}
}
}
void
show_image( void )
{
int i, j;
for ( i = 0; i < PANE_HEIGHT; i++ )
{
for ( j = 0; j < PANE_WIDTH; j++ )
putchar( image[i][j] == 0 ? ' '
: image[i][j] < 128 ? '+'
: '#' );
putchar( '\n' );
}
}
int
main( int argc,
char** argv )
{
FT_Library library;
FT_Face face;
FT_GlyphSlot slot;
FT_Matrix matrix; /* transformation matrix */
FT_Vector pen; /* untransformed origin */
FT_Error error;
char* filename;
double angle;
int target_height;
int n;
filename = argv[1]; /* first argument */
angle = ( 0.0 / 360 ) * 3.14159 * 2; /* use 0 degrees */
target_height = PANE_HEIGHT;
if (argc < 2) {
fprintf(stderr, "Usage: example <font path>\n");
return 0;
}
error = FT_Init_FreeType( &library ); /* initialize library */
/* error handling omitted */
error = FT_New_Face( library, argv[1], 0, &face ); /* create face
object */
/* error handling omitted */
error = FT_Set_Char_Size( face, 18 * 64, 0,
72, 0 ); /* set character size */
/* error handling omitted */
slot = face->glyph;
/* set up matrix */
matrix.xx = (FT_Fixed)( cos( angle ) * 0x10000L );
matrix.xy = (FT_Fixed)(-sin( angle ) * 0x10000L );
matrix.yx = (FT_Fixed)( sin( angle ) * 0x10000L );
matrix.yy = (FT_Fixed)( cos( angle ) * 0x10000L );
pen.x = 0 * 64;
pen.y = ( target_height - 20 ) * 64;
for (n = 0; n < 6; n++)
{
/* set transformation */
FT_Set_Transform( face, &matrix, &pen );
/* load glyph image into the slot (erase previous one) */
error = FT_Load_Char( face, GLYPH_INDEX[n], FT_LOAD_RENDER );
if ( error ) {
fprintf(stderr, "ft error %d\n", error);
continue; /* ignore errors */
}
/* now, draw to our target surface (convert position) */
draw_bitmap( &slot->bitmap,
slot->bitmap_left,
target_height - slot->bitmap_top );
/* increment pen position */
pen.x += slot->advance.x;
pen.y += slot->advance.y;
}
show_image();
FT_Done_Face ( face );
FT_Done_FreeType( library );
return 0;
}
8< - - -
I could provide the font for testing if needed.
Regards,
Stefan
Debian GNU Linux / i386