freetype
[Top][All Lists]
Advanced

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

Re: [ft] FT_Set_Char_Size vs. FT_Set_Pixel_Sizes


From: Olumide
Subject: Re: [ft] FT_Set_Char_Size vs. FT_Set_Pixel_Sizes
Date: Tue, 22 Nov 2016 13:04:12 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 19/11/2016 17:42, Werner LEMBERG wrote:

Then I loaded the character 'f'(shorter than the pipe symbol)
expecting to get a bitmap with fewer rows, instead I got a bitmap
with a larger number of rows.

It's not clear to me whether you simply get a larger bitmap (i.e.,
more rows), or whether the glyph itself (this is, the rendered black
pixels) is larger...

I'm getting more rows (see sample code).

In case you haven't solved the problem yet please provide a
standalone, *small* demo program for the terminal that exhibits the
issue.

Here is a sample program; and here's the output that I'm getting:

Output:
    Num rows (char |): 32
    Num rows (char f): 38

------------------------------------------------------------------

#include <iostream>
#include <ft2build.h>
#include FT_FREETYPE_H

#define CHECK_STATUS( err , msg )            \
    if( err )                                \
    {                                        \
        LOG_ERROR << msg << " failed ...";   \
        exit( EXIT_FAILURE );                \
    }                                        \


// Omitting cleanup for brevity
int main(int argc, char* argv[] )
{
    FT_Face face;
    FT_Error error;
    FT_GlyphSlot slot;
    FT_Library library;

    const char* filename = "C:\\Windows\\Fonts\\frank.ttf";

    error = FT_Init_FreeType( &library );
    CHECK_STATUS( error , "Initialize library" )

    error = FT_New_Face( library , filename, 0 , &face );
    CHECK_STATUS( error , "Create face" )

    error = FT_Set_Pixel_Sizes( face , 55 , 55 );
    CHECK_STATUS( error , "Set pixel size" )

error = FT_Load_Char( face, '|' , FT_LOAD_RENDER | FT_LOAD_MONOCHROME );
    CHECK_STATUS( error , "Load char" )

    slot = face->glyph;
    std::cout << "Num rows: " << slot->bitmap.rows << std::endl;

error = FT_Load_Char( face, 'f' , FT_LOAD_RENDER | FT_LOAD_MONOCHROME );
    CHECK_STATUS( error , "Load char" )
    std::cout << "Num rows: " << slot->bitmap.rows << std::endl;

    return 0;
}

------------------------------------------------------------------

Regards,

- Olumide





reply via email to

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