patch by Anthony Lee:

* fixed bitmap fonts for real (applied the wrong patch last time)

* some cleanup for coding style by myself (in other places)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23269 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-01-06 18:01:47 +00:00
parent d2df03947e
commit 1c05a4100f
+30 -28
View File
@@ -332,12 +332,25 @@ decompose_ft_bitmap_gray8(const FT_Bitmap& bitmap, int x, int y,
} }
for (i = 0; i < bitmap.rows; i++) { for (i = 0; i < bitmap.rows; i++) {
sl.reset_spans(); sl.reset_spans();
if (bitmap.pixel_mode == FT_PIXEL_MODE_MONO) {
// font has built-in mono bitmap
agg::bitset_iterator bits(buf, 0);
int j;
for (j = 0; j < bitmap.width; j++) {
if (bits.bit())
sl.add_cell(x + j, agg::cover_full);
++bits;
}
} else {
const uint8* p = buf; const uint8* p = buf;
for (j = 0; j < bitmap.width; j++) { for (j = 0; j < bitmap.width; j++) {
if (*p) if (*p)
sl.add_cell(x + j, *p); sl.add_cell(x + j, *p);
++p; ++p;
} }
}
buf += pitch; buf += pitch;
if (sl.num_spans()) { if (sl.num_spans()) {
sl.finalize(y - i - 1); sl.finalize(y - i - 1);
@@ -422,17 +435,11 @@ FontEngine::PrepareGlyph(unsigned glyphCode)
switch(fGlyphRendering) { switch(fGlyphRendering) {
case glyph_ren_native_mono: case glyph_ren_native_mono:
case glyph_ren_native_gray8: fLastError = FT_Render_Glyph(fFace->glyph, FT_RENDER_MODE_MONO);
fLastError = FT_Render_Glyph(fFace->glyph,
fGlyphRendering == glyph_ren_native_mono ?
FT_RENDER_MODE_MONO : FT_RENDER_MODE_NORMAL);
if (fLastError == 0) { if (fLastError == 0) {
switch (fFace->glyph->bitmap.pixel_mode) {
case FT_PIXEL_MODE_MONO:
decompose_ft_bitmap_mono(fFace->glyph->bitmap, decompose_ft_bitmap_mono(fFace->glyph->bitmap,
fFace->glyph->bitmap_left, fFace->glyph->bitmap_left, kFlipY ?
kFlipY ? -fFace->glyph->bitmap_top -fFace->glyph->bitmap_top : fFace->glyph->bitmap_top,
: fFace->glyph->bitmap_top,
kFlipY, fScanlineBin, fScanlineStorageBin); kFlipY, fScanlineBin, fScanlineStorageBin);
fBounds.x1 = fScanlineStorageBin.min_x(); fBounds.x1 = fScanlineStorageBin.min_x();
fBounds.y1 = fScanlineStorageBin.min_y(); fBounds.y1 = fScanlineStorageBin.min_y();
@@ -441,12 +448,16 @@ FontEngine::PrepareGlyph(unsigned glyphCode)
fDataSize = fScanlineStorageBin.byte_size(); fDataSize = fScanlineStorageBin.byte_size();
fDataType = glyph_data_mono; fDataType = glyph_data_mono;
return true; return true;
}
break;
case FT_PIXEL_MODE_GRAY:
case glyph_ren_native_gray8:
fLastError = FT_Render_Glyph(fFace->glyph, FT_RENDER_MODE_NORMAL);
if (fLastError == 0) {
decompose_ft_bitmap_gray8(fFace->glyph->bitmap, decompose_ft_bitmap_gray8(fFace->glyph->bitmap,
fFace->glyph->bitmap_left, fFace->glyph->bitmap_left, kFlipY ?
kFlipY ? -fFace->glyph->bitmap_top -fFace->glyph->bitmap_top : fFace->glyph->bitmap_top,
: fFace->glyph->bitmap_top,
kFlipY, fScanlineAA, fScanlineStorageAA); kFlipY, fScanlineAA, fScanlineStorageAA);
fBounds.x1 = fScanlineStorageAA.min_x(); fBounds.x1 = fScanlineStorageAA.min_x();
fBounds.y1 = fScanlineStorageAA.min_y(); fBounds.y1 = fScanlineStorageAA.min_y();
@@ -455,12 +466,9 @@ FontEngine::PrepareGlyph(unsigned glyphCode)
fDataSize = fScanlineStorageAA.byte_size(); fDataSize = fScanlineStorageAA.byte_size();
fDataType = glyph_data_gray8; fDataType = glyph_data_gray8;
return true; return true;
}
break;
default:
break;
}
}
break;
case glyph_ren_outline: case glyph_ren_outline:
fPath.remove_all(); fPath.remove_all();
@@ -513,8 +521,7 @@ FontEngine::GetKerning(unsigned first, unsigned second,
{ {
if (fFace && first && second && FT_HAS_KERNING(fFace)) { if (fFace && first && second && FT_HAS_KERNING(fFace)) {
FT_Vector delta; FT_Vector delta;
FT_Get_Kerning(fFace, first, second, FT_Get_Kerning(fFace, first, second, FT_KERNING_DEFAULT, &delta);
FT_KERNING_DEFAULT, &delta);
double dx = int26p6_to_dbl(delta.x); double dx = int26p6_to_dbl(delta.x);
double dy = int26p6_to_dbl(delta.y); double dy = int26p6_to_dbl(delta.y);
@@ -546,15 +553,10 @@ FontEngine::Init(const char* fontFilePath, unsigned faceIndex, double size,
FT_Done_Face(fFace); FT_Done_Face(fFace);
if (fontFileBuffer && fontFileBufferSize) { if (fontFileBuffer && fontFileBufferSize) {
fLastError = FT_New_Memory_Face(fLibrary, fLastError = FT_New_Memory_Face(fLibrary,
(const FT_Byte*)fontFileBuffer, (const FT_Byte*)fontFileBuffer, fontFileBufferSize,
fontFileBufferSize, faceIndex, &fFace);
faceIndex,
&fFace);
} else { } else {
fLastError = FT_New_Face(fLibrary, fLastError = FT_New_Face(fLibrary, fontFilePath, faceIndex, &fFace);
fontFilePath,
faceIndex,
&fFace);
} }
if (fLastError != 0) if (fLastError != 0)