[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Freetype] Buggy metrics with FreeType 2 and BDF or PCF fonts?
From: |
Juliusz Chroboczek |
Subject: |
[Freetype] Buggy metrics with FreeType 2 and BDF or PCF fonts? |
Date: |
Sat, 17 Aug 2002 17:01:23 +0200 (CEST) |
Hi,
I'm attaching a little test program that you should run on 8x13.bdf
and 8x13.pcf. Please notice the (x, y) couple printed for every
glyph, which are, respectively,
face->glyph->metrics.horiBearingX and
face->glyph->metrics.horiBearingY.
The 8x13 font has a bounding box of (0, -2) through (8, 11). Thus, I
believe that the correct values should be (0, 704). However, I'm
getting
(0, -128) for the BDF version; and
(512, 704) for PCF version.
Can anyone confirm this bug, or tell me what I'm doing wrong?
Thanks,
Juliusz
----------------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include "freetype/freetype.h"
FT_Library ft_library;
int
main(int argc, char **argv)
{
int rc, index, code, x, y;
FT_Face face;
if(argc != 2)
exit(1);
rc = FT_Init_FreeType(&ft_library);
if(rc != 0) {
fprintf(stderr, "Couldn't init library: %d.\n", rc);
return 1;
}
rc = FT_New_Face(ft_library, argv[1], 0, &face);
if(rc != 0) {
fprintf(stderr, "Couldn't make new face: %d.\n", rc);
return 1;
}
rc = FT_Set_Pixel_Sizes(face, 13, 13);
if(rc != 0) {
fprintf(stderr, "Couldn't select size: %d.\n", rc);
return 1;
}
rc = FT_Select_Charmap(face, ft_encoding_unicode);
if(rc != 0) {
fprintf(stderr, "Couldn't select charmap: %d.\n", rc);
return 1;
}
for(code = 0; code < 0xFFFF; code++) {
index = FT_Get_Char_Index(face, code);
if(code != 0 && index <= 0)
continue;
rc = FT_Load_Glyph(face, index,
FT_LOAD_RENDER | FT_LOAD_MONOCHROME);
if(rc != 0) {
printf("Couldn't load glyph %d(%d): %d.\n\n",
code, index, rc);
continue;
}
printf("%d(%d): %d x %d (%d, %d)\n",
code, index,
face->glyph->bitmap.width, face->glyph->bitmap.rows,
face->glyph->metrics.horiBearingX,
face->glyph->metrics.horiBearingY);
for(y = 0; y < face->glyph->bitmap.rows; y++) {
for(x = 0; x < face->glyph->bitmap.width; x++) {
if((face->glyph->bitmap.buffer[y * face->glyph->bitmap.pitch +
x / 8] &
1 << (7 - x % 8)) != 0)
printf("*");
else
printf(" ");
}
printf("\n");
}
printf("\n");
}
return 0;
}
- [Freetype] Buggy metrics with FreeType 2 and BDF or PCF fonts?,
Juliusz Chroboczek <=