freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft] How to fast get the metrics value of one character


From: xujian
Subject: [ft] How to fast get the metrics value of one character
Date: Wed, 1 Apr 2009 20:06:51 +0800

 

HI,

Now, I use freetype font engine on our embedded system. It works fine .but there is a question:

 

For displaying several characters for one time.  Firstly  I call:

/******************************/

    while(*string)

    {

        error = FT_Load_Char(pFTFace,*string, FT_LOAD_DEFAULT);

        string++;

        if(error){

            break;

        }

        pFtrect->right += slot->advance.x>>6;

        baseline_offset = (metrics->height-metrics->horiBearingY)>>6>baseline_offset?(metrics->height-metrics->horiBearingY)>>6:baseline_offset;

        pFtrect->top = (metrics->horiBearingY>>6)>pFtrect->top ?metrics->horiBearingY>>6:pFtrect->top;

 

    }

/****************/

To get the total w and h  of the whole strings. then  malloc  (w*h )  memory to store the bitmaps which will be rendered to.

 

Secondly:

Call :

        while(*str_temp)

        {

            error = FT_Load_Char(pFTFace,*str_temp, FT_LOAD_RENDER);

            str_temp++;

            align_top = h-rect.baseline-slot->bitmap_top;

            align_left = slot->bitmap_left;

            for(int i=0;i <slot->bitmap.rows;i++)

            {

                buf_temp =buf+x_offset+ (align_top+i)*w+align_left; 

                for(int j=0;j<slot->bitmap.width;j++)

                {

                    *buf_temp++ = slot->bitmap.buffer[i*slot->bitmap.width+j];

                   

                }

            }

            x_offset += slot->advance.x>>6;

 

      }

 I get the idea that the two  FT_Load_Char waste a lot of time.

How can I get the total w and h  of the whole strings  fast ?< metrics value>

 

Thanks


reply via email to

[Prev in Thread] Current Thread [Next in Thread]