Skip to content

Commit

Permalink
Avoid clipping glyphs on fonts with broken metrics
Browse files Browse the repository at this point in the history
As @shermp pointed out (#20 (comment))
Thanks!
  • Loading branch information
NiLuJe committed Nov 3, 2018
1 parent 03e0c42 commit b75e7cf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions fbink.c
Original file line number Diff line number Diff line change
Expand Up @@ -3467,7 +3467,7 @@ int
// If we're painting in B&W, use the mask as-is, it's already B&W ;).
// We just need to invert it ;).
uint8_t ainv = invert ^ 0xFF;
for (unsigned int j = 0U; j < font_size_px; j++) {
for (int j = 0; j < max_line_height; j++) {
for (unsigned int k = 0U; k < lw; k++) {
color.r = color.g = color.b = lnPtr[k] ^ ainv;
put_pixel(&paint_point, &color);
Expand All @@ -3478,7 +3478,7 @@ int
paint_point.y++;
}
} else {
for (unsigned int j = 0U; j < font_size_px; j++) {
for (int j = 0; j < max_line_height; j++) {
for (unsigned int k = 0U; k < lw; k++) {
if (lnPtr[k] == 0U) {
// No coverage (transparent) -> background
Expand All @@ -3504,7 +3504,7 @@ int
// NOTE: One more branch needed because 4bpp fbs are terrible...
if (vInfo.bits_per_pixel > 4U) {
// 8, 16, 24 & 32bpp
for (unsigned int j = 0U; j < font_size_px; j++) {
for (int j = 0; j < max_line_height; j++) {
for (unsigned int k = 0U; k < lw; k++) {
if (lnPtr[k] == 0U) {
// No coverage (transparent) -> background
Expand All @@ -3529,7 +3529,7 @@ int
}
} else {
// 4bpp... We'll have to alpha-blend *everything* to avoid clobbering pixels...
for (unsigned int j = 0U; j < font_size_px; j++) {
for (int j = 0; j < max_line_height; j++) {
for (unsigned int k = 0U; k < lw; k++) {
// AA, blend it using the coverage mask as alpha, and the underlying pixel as fg
get_pixel(&paint_point, &fb_color);
Expand All @@ -3550,7 +3550,7 @@ int
FBInkColor fb_color = { 0 };
if (vInfo.bits_per_pixel > 4U) {
// 8, 16, 24 & 32bpp
for (unsigned int j = 0U; j < font_size_px; j++) {
for (int j = 0; j < max_line_height; j++) {
for (unsigned int k = 0U; k < lw; k++) {
if (lnPtr[k] == 0xFF) {
// Full coverage (opaque) -> foreground
Expand All @@ -3575,7 +3575,7 @@ int
}
} else {
// 4bpp...
for (unsigned int j = 0U; j < font_size_px; j++) {
for (int j = 0; j < max_line_height; j++) {
for (unsigned int k = 0U; k < lw; k++) {
// AA, blend it using the coverage mask as alpha, and the underlying pixel as bg
get_pixel(&paint_point, &fb_color);
Expand All @@ -3596,7 +3596,7 @@ int
FBInkColor fb_color = { 0 };
if (vInfo.bits_per_pixel > 4U) {
// 8, 16, 24 & 32bpp
for (unsigned int j = 0U; j < font_size_px; j++) {
for (int j = 0; j < max_line_height; j++) {
for (unsigned int k = 0U; k < lw; k++) {
if (lnPtr[k] == 0xFF) {
// Full coverage (opaque) -> foreground
Expand Down Expand Up @@ -3629,7 +3629,7 @@ int
}
} else {
// 4bpp...
for (unsigned int j = 0U; j < font_size_px; j++) {
for (int j = 0; j < max_line_height; j++) {
for (unsigned int k = 0U; k < lw; k++) {
// AA, blend it using the coverage mask as alpha, and the underlying pixel as bg
// Without forgetting our foreground color trickery...
Expand Down

0 comments on commit b75e7cf

Please sign in to comment.