freetype-devel
[Top][All Lists]
Advanced

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

[ft-devel] glyph metrics don't match bitmap size (2.8.1)


From: Nicolas Jinchereau
Subject: [ft-devel] glyph metrics don't match bitmap size (2.8.1)
Date: Mon, 18 Sep 2017 18:52:16 -0400

When using FT_LOAD_TARGET_LCD, the size of the rendered bitmap doesn't seem to match the size in the metrics. It's usually off by 1~2 units - is this normal?

Example:

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

int main()
{
    FT_Library _library;
    FT_Init_FreeType(&_library);
    FT_Library_SetLcdFilter(_library, FT_LCD_FILTER_DEFAULT);

    FT_Face face;
    FT_New_Face(_library, "arial.ttf", 0, &face);
    FT_Set_Pixel_Sizes(face, 0, 14);
    
    FT_Int32 flags = 0;
    flags |= FT_LOAD_TARGET_LCD;
    flags |= FT_LOAD_RENDER;

    string sample = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

    for(char c : sample)
    {
        FT_Load_Char(face, (int)c, flags);
        cout << (face->glyph->bitmap.width / 3) << " ==? ";
        cout << (face->glyph->metrics.width >> 6) << endl;
    }

    FT_Done_Face(face);
    return 0;
}

Any help with this would be appreciated

   Nick


reply via email to

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