It seems like there is a problem with Xft2 extents calculation.  The
test code is attached.

The command I use to compile is
    gcc -o test0 test0.c -Wall `pkg-config --cflags xft` `pkg-config --libs xft`

I am testing it on a brand new RH Limbo.  The result (in UTF-8) is also
attached.  For a string in Chinese, its extents are all 0.

I tried fcpackage.02-06-27.17-59.tar.gz and the result is the same.

Regards,

Yao Zhang
#include <stdio.h>

#include <X11/Xft/Xft.h>

static void test_extents(Display *display, XftFont *font, char *buffer)
{
    XGlyphInfo extents;

    XftTextExtentsUtf8(display, font,
                       buffer, strlen(buffer), &extents);
    printf("String: %s\n", buffer);
    printf("\twidth: %d\n", extents.width);
    printf("\theight: %d\n", extents.height);
    printf("\tx: %d\n", extents.x);
    printf("\ty: %d\n", extents.y);
    printf("\txOff: %d\n", extents.xOff);
    printf("\tyOff: %d\n", extents.yOff);
}

int main(int argc, char *argv[])
{
    Display *display;
    int screen;
    XftFont *font;
    char *name;

    display = XOpenDisplay(NULL);
    if (display == NULL) {
        return 1;
    }
    screen = DefaultScreen(display);

    printf("DISPLAY: %s\n", XDisplayString(display));
    printf("Font opening..\n");
    font = XftFontOpenName(display, screen, "AR PL SungtiL GB-16");
    name = FcNameUnparse(font->pattern);
    if (name != NULL) {
        printf("Font opened: %s\n", name);
        free(name);
    }

    test_extents(display, font, "a");
    test_extents(display, font, "b");
    test_extents(display, font, "c");
    test_extents(display, font, "d");
    test_extents(display, font, "abcd");
    test_extents(display, font, "一");
    test_extents(display, font, "中");
    test_extents(display, font, "一中");

    XftFontClose(display, font);

    XCloseDisplay(display);

    return 0;
}

Attachment: result.UTF-8
Description: Binary data

Reply via email to