[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Freetype] Transforming glyph : use of API
From: |
SOULLARD Clement |
Subject: |
[Freetype] Transforming glyph : use of API |
Date: |
Thu, 05 Feb 2004 10:08:50 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.6) Gecko/20040113 |
Hi,
I want to transform some glyph but I'm not sure that I do a correct use
of the APIs for doing that. I may write a tutorial on this if someone
explain it to me... This would probably be a good Part III in the
tutorial...
So, to perform this I use the method :
- FT_Load_Glyph (face, nglyph, FT_LOAD_DEFAULT);
- FT_Get_Glyph( face->glyph, &glyph );
- FT_Glyph_Transform(glyph,&trans,&vect);
At that point no error is raised at that point...
Then calling :
- FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, 0, 1 ); return me
an error code -1...
Why ? Is this a bad use of the api ?
For details I give you the code I use hereafter. The transformation I
perform is
[2 0]
[1 1]
and the vector is [0,0]
Thanks for your help.
---------------------------------------
/**
Transform the glyph
**/
FT_Glyph
FTFont::transformGlyph(int nglyph,double x00,double x01,double
x10,double x11){
FT_Matrix trans;
trans.xx=x00;trans.xy=x01;trans.yx=x10;trans.yy=x11;
FT_Vector vect;vect.x=0;error=0;
vect.y=0;
FT_Glyph glyph;
FT_Load_Glyph (face, nglyph, FT_LOAD_DEFAULT);
FT_Get_Glyph( face->glyph, &glyph );
error=FT_Glyph_Transform(glyph,&trans,&vect);
if(error){
Tracer::printErr("FTFont::transformGlyph erreur dans
error=FT_Glyph_Transform"+QString::number(error));
}
return glyph;
}
-------------------------------------------------------------------------
-----
/**
Compute the bitmap of a glyph
\param glyph a glyph
**/
uchar*
FTFont::getUmap (FT_Glyph glyph){
FT_BitmapGlyph glyph_bitmap;
// 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_NORMAL, 0, 1 );
}
if(error){
Tracer::printErr("FTFont::getUmap Error dans FT_Glyph_To_Bitmap
error="+QString::number(error)+",glyph="+QString::number((long)glyph,16))
;
}
// access bitmap content by typecasting
glyph_bitmap = (FT_BitmapGlyph)glyph;
FT_Bitmap bitmap=glyph_bitmap->bitmap;
// discard glyph image (bitmap or not)
return face->glyph->bitmap.buffer;
}
--------------------------------------------------
Ce message ainsi que les éventuelles pièces jointes constituent une
correspondance privée et confidentielle à l’attention exclusive du
destinataire désigné ci-dessus. Si vous n’êtes pas le destinataire
du présent message ou une personne susceptible de pouvoir le lui
délivrer, il vous est signifié que toute divulgation, distribution ou
copie de cette transmission est strictement interdite. Si vous avez
reçu ce message par erreur, nous vous remercions d’en informer
l’expéditeur par téléphone ou de lui retourner le présent message,
puis d’effacer immédiatement ce message de votre système.
This e-mail and any attachments is a confidential correspondence
intended only for use of the individual or entity named above. If you
are not the intended recipient or the agent responsible for delivering
the message to the intended recipient, you are hereby notified that any
disclosure, distribution or copying of this communication is strictly
prohibited. If you have received this communication in error, please
notify the sender by phone or by replying this message, and then delete
this message from your system.