Skip to content

Commit

Permalink
Fix clipped letters when followed by some capital letters.
Browse files Browse the repository at this point in the history
Fixes ticket:4569.
  • Loading branch information
Cyp committed Apr 5, 2017
1 parent 0bfd217 commit 9c04d4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion data/base/shaders/text.frag
Expand Up @@ -10,6 +10,6 @@ out vec4 FragColor1;
void main()
{
vec4 texColour = texture2D(texture, uv) * color.a;
FragColor = vec4(texColour.rgb * color.rgb, texColour.rgb * vec3(0.299, 0.587, 0.114));
FragColor = texColour * color;
FragColor1 = texColour;
}
15 changes: 9 additions & 6 deletions lib/ivis_opengl/textdraw.cpp
Expand Up @@ -297,8 +297,8 @@ struct TextShaper
: buffer(std::move(b)), pixelPosition(p), size(s), pitch(_pitch) {}
};

std::vector<glyphRaster> glyphes;
std::transform(shapingResult.begin(), shapingResult.end(), std::back_inserter(glyphes),
std::vector<glyphRaster> glyphs;
std::transform(shapingResult.begin(), shapingResult.end(), std::back_inserter(glyphs),
[&] (const HarfbuzzPosition &g) {
RasterizedGlyph glyph = face.get(g.codepoint, g.penPosition % 64);
int32_t x0 = g.penPosition.x / 64 + glyph.bearing_x;
Expand All @@ -316,7 +316,7 @@ struct TextShaper
std::unique_ptr<unsigned char[]> stringTexture(new unsigned char[4 * width * height]);
memset(stringTexture.get(), 0, 4 * width * height);

std::for_each(glyphes.begin(), glyphes.end(),
std::for_each(glyphs.begin(), glyphs.end(),
[&](const glyphRaster &g)
{
for (int i = 0; i < g.size.y; ++i)
Expand All @@ -325,9 +325,12 @@ struct TextShaper
for (int j = 0; j < g.size.x; ++j)
{
uint32_t j0 = g.pixelPosition.x - min_x;
stringTexture[4 * ((i0 + i) * width + j + j0)] = g.buffer[i * g.pitch + 3 * j];
stringTexture[4 * ((i0 + i) * width + j + j0) + 1] = g.buffer[i * g.pitch + 3 * j + 1];
stringTexture[4 * ((i0 + i) * width + j + j0) + 2] = g.buffer[i * g.pitch + 3 * j + 2];
uint8_t const *src = &g.buffer[i * g.pitch + 3 * j];
uint8_t *dst = &stringTexture[4 * ((i0 + i) * width + j + j0)];
dst[0] = std::min(dst[0] + src[0], 255);
dst[1] = std::min(dst[1] + src[1], 255);
dst[2] = std::min(dst[2] + src[2], 255);
dst[3] = std::min(dst[3] + ((src[0] * 77 + src[1] * 150 + src[2] * 29) >> 8), 255);
}
}
});
Expand Down

0 comments on commit 9c04d4a

Please sign in to comment.