Skip to content

Commit

Permalink
Merge pull request #6 from cherniid/monochrome-bitmap
Browse files Browse the repository at this point in the history
fix monochrome bitmap data in FT_Load_Char result
  • Loading branch information
vladimirgamalyan authored Mar 4, 2020
2 parents 9f92ff7 + 5503f7a commit 2900db4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/freeType/FtFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,16 @@ class Font
for (std::uint32_t row = 0; row < glyphMetrics.height; ++row)
{
std::uint32_t *dst = buffer + (y + row) * surfaceW + x;
std::uint8_t *src = slot->bitmap.buffer + slot->bitmap.pitch * row;
std::uint8_t const *src = slot->bitmap.buffer + slot->bitmap.pitch * row;

std::vector<std::uint8_t> unpacked;
if (slot->bitmap.pixel_mode == FT_PIXEL_MODE_MONO) {
unpacked.reserve(slot->bitmap.width);
for (int byte = 0; byte < slot->bitmap.pitch; ++byte)
for (std::uint8_t mask = 0x80; mask; mask = mask >> 1)
unpacked.push_back(src[byte] & mask ? 0xff : 0x00);
src = unpacked.data();
}

for (auto col = glyphMetrics.width; col > 0 && dst < dst_check; --col) {
const std::uint32_t alpha = *src++;
Expand Down

0 comments on commit 2900db4

Please sign in to comment.