Revert "Glyphs now regenerate with the rest of the game's textures"
This reverts commit aa6174b3f2
.
This commit is contained in:
parent
add4e69374
commit
f354b84f6a
3 changed files with 36 additions and 70 deletions
|
@ -530,8 +530,6 @@ void RestoreSurfaces() // Guessed function name - this doesn't exist in the Linu
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
RestoreGlyphs(gFont);
|
||||
}
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
|
103
src/Font.cpp
103
src/Font.cpp
|
@ -955,51 +955,6 @@ static unsigned char GammaCorrect(unsigned char value)
|
|||
return lookup[value];
|
||||
}
|
||||
|
||||
static void SendGlyphToBackend(FontObject *font_object, Backend_Glyph *backend)
|
||||
{
|
||||
if (backend == NULL)
|
||||
return;
|
||||
|
||||
FT_Bitmap bitmap;
|
||||
FT_Bitmap_New(&bitmap);
|
||||
FT_Bitmap_Convert(font_object->library, &font_object->face->glyph->bitmap, &bitmap, 1);
|
||||
|
||||
switch (font_object->face->glyph->bitmap.pixel_mode)
|
||||
{
|
||||
case FT_PIXEL_MODE_LCD:
|
||||
for (unsigned int y = 0; y < bitmap.rows; ++y)
|
||||
{
|
||||
unsigned char *pixel_pointer = bitmap.buffer + y * bitmap.pitch;
|
||||
|
||||
for (unsigned int x = 0; x < bitmap.width; ++x)
|
||||
{
|
||||
*pixel_pointer = GammaCorrect(*pixel_pointer);
|
||||
++pixel_pointer;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FT_PIXEL_MODE_GRAY:
|
||||
for (unsigned int y = 0; y < bitmap.rows; ++y)
|
||||
{
|
||||
unsigned char *pixel_pointer = bitmap.buffer + y * bitmap.pitch;
|
||||
|
||||
for (unsigned int x = 0; x < bitmap.width; ++x)
|
||||
{
|
||||
*pixel_pointer = GammaCorrect((*pixel_pointer * 0xFF) / (bitmap.num_grays - 1));
|
||||
++pixel_pointer;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Backend_LoadGlyphPixels(backend, bitmap.buffer, bitmap.pitch);
|
||||
|
||||
FT_Bitmap_Done(font_object->library, &bitmap);
|
||||
}
|
||||
|
||||
static CachedGlyph* GetGlyphCached(FontObject *font_object, unsigned long unicode_value)
|
||||
{
|
||||
CachedGlyph *glyph;
|
||||
|
@ -1023,15 +978,48 @@ static CachedGlyph* GetGlyphCached(FontObject *font_object, unsigned long unicod
|
|||
FT_Load_Glyph(font_object->face, glyph_index, FT_LOAD_RENDER | FT_LOAD_MONOCHROME);
|
||||
#endif
|
||||
|
||||
glyph->unicode_value = unicode_value;
|
||||
glyph->x = font_object->face->glyph->bitmap_left;
|
||||
glyph->y = (FT_MulFix(font_object->face->ascender, font_object->face->size->metrics.y_scale) - font_object->face->glyph->metrics.horiBearingY + (64 / 2)) / 64;
|
||||
glyph->x_advance = font_object->face->glyph->advance.x / 64;
|
||||
|
||||
FT_Bitmap bitmap;
|
||||
FT_Bitmap_New(&bitmap);
|
||||
FT_Bitmap_Convert(font_object->library, &font_object->face->glyph->bitmap, &bitmap, 1);
|
||||
|
||||
unsigned char pixel_mode;
|
||||
switch (font_object->face->glyph->bitmap.pixel_mode)
|
||||
{
|
||||
case FT_PIXEL_MODE_LCD:
|
||||
pixel_mode = FONT_PIXEL_MODE_LCD;
|
||||
|
||||
for (unsigned int y = 0; y < bitmap.rows; ++y)
|
||||
{
|
||||
unsigned char *pixel_pointer = bitmap.buffer + y * bitmap.pitch;
|
||||
|
||||
for (unsigned int x = 0; x < bitmap.width; ++x)
|
||||
{
|
||||
*pixel_pointer = GammaCorrect(*pixel_pointer);
|
||||
++pixel_pointer;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FT_PIXEL_MODE_GRAY:
|
||||
pixel_mode = FONT_PIXEL_MODE_GRAY;
|
||||
|
||||
for (unsigned int y = 0; y < bitmap.rows; ++y)
|
||||
{
|
||||
unsigned char *pixel_pointer = bitmap.buffer + y * bitmap.pitch;
|
||||
|
||||
for (unsigned int x = 0; x < bitmap.width; ++x)
|
||||
{
|
||||
*pixel_pointer = GammaCorrect((*pixel_pointer * 0xFF) / (bitmap.num_grays - 1));
|
||||
++pixel_pointer;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FT_PIXEL_MODE_MONO:
|
||||
|
@ -1039,13 +1027,10 @@ static CachedGlyph* GetGlyphCached(FontObject *font_object, unsigned long unicod
|
|||
break;
|
||||
}
|
||||
|
||||
glyph->backend = Backend_CreateGlyph((pixel_mode == FONT_PIXEL_MODE_LCD ? font_object->face->glyph->bitmap.width / 3 : font_object->face->glyph->bitmap.width), font_object->face->glyph->bitmap.rows, pixel_mode);
|
||||
glyph->unicode_value = unicode_value;
|
||||
glyph->x = font_object->face->glyph->bitmap_left;
|
||||
glyph->y = (FT_MulFix(font_object->face->ascender, font_object->face->size->metrics.y_scale) - font_object->face->glyph->metrics.horiBearingY + (64 / 2)) / 64;
|
||||
glyph->x_advance = font_object->face->glyph->advance.x / 64;
|
||||
glyph->backend = Backend_CreateGlyph((pixel_mode == FT_PIXEL_MODE_LCD ? bitmap.width / 3 : bitmap.width), bitmap.rows, pixel_mode);
|
||||
Backend_LoadGlyphPixels(glyph->backend, bitmap.buffer, bitmap.pitch);
|
||||
|
||||
SendGlyphToBackend(font_object, glyph->backend);
|
||||
FT_Bitmap_Done(font_object->library, &bitmap);
|
||||
}
|
||||
|
||||
return glyph;
|
||||
|
@ -1190,19 +1175,3 @@ void UnloadFont(FontObject *font_object)
|
|||
free(font_object);
|
||||
}
|
||||
}
|
||||
|
||||
void RestoreGlyphs(FontObject *font_object)
|
||||
{
|
||||
for (CachedGlyph *glyph = font_object->glyph_list_head; glyph != NULL; glyph = glyph->next)
|
||||
{
|
||||
unsigned int glyph_index = FT_Get_Char_Index(font_object->face, glyph->unicode_value);
|
||||
|
||||
#ifndef DISABLE_FONT_ANTIALIASING
|
||||
FT_Load_Glyph(font_object->face, glyph_index, FT_LOAD_RENDER | (font_object->lcd_mode ? FT_LOAD_TARGET_LCD : 0));
|
||||
#else
|
||||
FT_Load_Glyph(font_object->face, glyph_index, FT_LOAD_RENDER | FT_LOAD_MONOCHROME);
|
||||
#endif
|
||||
|
||||
SendGlyphToBackend(font_object, glyph->backend);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,4 +10,3 @@ FontObject* LoadFontFromData(const unsigned char *data, size_t data_size, unsign
|
|||
FontObject* LoadFont(const char *font_filename, unsigned int cell_width, unsigned int cell_height);
|
||||
void DrawText(FontObject *font_object, Backend_Surface *surface, int x, int y, unsigned long colour, const char *string, size_t string_length);
|
||||
void UnloadFont(FontObject *font_object);
|
||||
void RestoreGlyphs(FontObject *font_object);
|
||||
|
|
Loading…
Add table
Reference in a new issue