Merge branch 'master' of https://github.com/isaz/kitty
This commit is contained in:
commit
af4b072b29
@ -16,6 +16,9 @@ Changelog
|
||||
- Linux: Ensure that the python embedded in the kitty binary build always uses
|
||||
UTF-8 mode (:iss:`924`)
|
||||
|
||||
- Linux: Handle fonts that contain monochrome bitmaps (such as the Terminus TTF
|
||||
font) (:pull:`934`)
|
||||
|
||||
|
||||
0.12.1 [2018-09-08]
|
||||
------------------------------
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#endif
|
||||
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_BITMAP_H
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
|
||||
@ -231,6 +232,30 @@ load_glyph(Face *self, int glyph_index, int load_type) {
|
||||
int flags = get_load_flags(self->hinting, self->hintstyle, load_type);
|
||||
int error = FT_Load_Glyph(self->face, glyph_index, flags);
|
||||
if (error) { set_freetype_error("Failed to load glyph, with error:", error); return false; }
|
||||
|
||||
// Embedded bitmap glyph?
|
||||
if(self->face->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) {
|
||||
FT_Bitmap bitmap;
|
||||
FT_Bitmap_New(&bitmap);
|
||||
|
||||
// This also sets pixel_mode to FT_PIXEL_MODE_GRAY so we don't have to
|
||||
error = FT_Bitmap_Convert(library, &self->face->glyph->bitmap, &bitmap, 1);
|
||||
if (error) { set_freetype_error("Failed to convert bitmap, with error:", error); return false; }
|
||||
|
||||
// Normalize gray levels to the range [0..255]
|
||||
bitmap.num_grays = 256;
|
||||
for (uint i = 0; i < bitmap.rows; ++i) {
|
||||
for (uint j = 0; j < bitmap.width; ++j)
|
||||
{
|
||||
unsigned char *p = &bitmap.buffer[i*bitmap.width+j];
|
||||
// We only have 2 levels
|
||||
*p = *p ? 255 : 0;
|
||||
}
|
||||
}
|
||||
error = FT_Bitmap_Copy(library, &bitmap, &self->face->glyph->bitmap);
|
||||
if (error) { set_freetype_error("Failed to copy bitmap, with error:", error); return false; }
|
||||
FT_Bitmap_Done(library, &bitmap);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user