diff options
Diffstat (limited to 'improve-font-rendering.patch')
-rw-r--r-- | improve-font-rendering.patch | 98 |
1 files changed, 52 insertions, 46 deletions
diff --git a/improve-font-rendering.patch b/improve-font-rendering.patch index 460aca6ca6da..daac7b6838d8 100644 --- a/improve-font-rendering.patch +++ b/improve-font-rendering.patch @@ -1,13 +1,16 @@ --- src/rxvtfont.C +++ src/rxvtfont.C -@@ -1226,92 +1226,63 @@ +@@ -1253,98 +1253,60 @@ return false; int ftheight = 0; - bool success = true; -- ++ p = FcPatternDuplicate (match); ++ f = XftFontOpenPattern (disp, p); + - for (;;) -- { ++ if (!f) + { - p = FcPatternDuplicate (match); - f = XftFontOpenPattern (disp, p); - @@ -17,88 +20,85 @@ - success = false; - break; - } - +- - FT_Face face = XftLockFace (f); -+ p = FcPatternDuplicate (match); -+ f = XftFontOpenPattern (disp, p); - +- +- // fuck me plenty: XftLockFace can actually return 0. try not to crash. +- // we also assume blindly that if the first lock succeeeds, then subsequent +- // locks will also succeed. +- if (!face) +- { +- XftFontClose (disp, f); +- success = false; +- break; +- } +- - ascent = (face->size->metrics.ascender + 63) >> 6; - descent = (-face->size->metrics.descender + 63) >> 6; - height = max (ascent + descent, (face->size->metrics.height + 63) >> 6); - width = 0; - - bool scalable = face->face_flags & FT_FACE_FLAG_SCALABLE; -+ if (!f) -+ { +- +- XftUnlockFace (f); +- +- int glheight = height; + FcPatternDestroy (p); + return false; + } -- XftUnlockFace (f); -+ FT_Face face = XftLockFace (f); - -- int glheight = height; -+ ascent = f->ascent; -+ descent = f->descent; -+ height = max (ascent + descent, f->height); -+ width = 0; - - for (uint16_t *t = extent_test_chars; t < extent_test_chars + ecb_array_length (extent_test_chars); t++) - { - FcChar16 ch = *t; -+ bool scalable = face->face_flags & FT_FACE_FLAG_SCALABLE; ++ FT_Face face = XftLockFace (f); - if (cs != CS_UNICODE - && ch > 0x100 - && FROM_UNICODE (cs, ch) == NOCHAR) - continue; -+ XftUnlockFace (f); ++ ascent = f->ascent; ++ descent = f->descent; ++ height = max (ascent + descent, f->height); ++ width = 0; - // ignore characters we wouldn't use anyways - bool careful; - if (!has_char (*t, &prop, careful)) - continue; ++ bool scalable = face->face_flags & FT_FACE_FLAG_SCALABLE; + +- XGlyphInfo g; +- XftTextExtents16 (disp, f, &ch, 1, &g); ++ XftUnlockFace (f); + +- g.width -= g.x; + for (uint16_t *t = extent_test_chars; t < extent_test_chars + ecb_array_length (extent_test_chars); t++) + { + FcChar16 ch = *t; -- XGlyphInfo g; -- XftTextExtents16 (disp, f, &ch, 1, &g); +- int wcw = WCWIDTH (ch); +- if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; + if (cs != CS_UNICODE + && ch > 0x100 + && FROM_UNICODE (cs, ch) == NOCHAR) + continue; - -- g.width -= g.x; ++ + // ignore characters we wouldn't use anyways + bool careful; + if (!has_char (*t, &prop, careful)) + continue; -- int wcw = WCWIDTH (ch); -- if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; -+ XGlyphInfo g; -+ XftTextExtents16 (disp, f, &ch, 1, &g); - - if (width < g.width ) width = g.width; - if (height < g.height ) height = g.height; - if (glheight < g.height - g.y) glheight = g.height - g.y; - } -+ g.width -= g.x; ++ XGlyphInfo g; ++ XftTextExtents16 (disp, f, &ch, 1, &g); - if (!width) - { -- rxvt_warn ("unable to calculate font width for '%s', ignoring.\n", name); -+ int wcw = WCWIDTH (ch); -+ if (wcw > 1) g.xOff = g.xOff / wcw; - -- XftFontClose (disp, f); -- f = 0; -+ if (width < g.xOff ) width = g.xOff; -+ if (height < g.height) height = g.height; -+ } - -- success = false; +- rxvt_warn ("unable to calculate font width for '%s', using max_advance_width.\n", name); +- width = f->max_advance_width; - break; - } - @@ -107,7 +107,7 @@ - || height <= 2 - || !scalable) - break; -+ bool success = true; ++ g.width -= g.x; - if (ftheight) - { @@ -115,7 +115,13 @@ - if (height > prop.height + 1) ftheight++; - if (height > prop.height + 2) ftheight++; - if (height > prop.height + 3) ftheight++; -- ++ int wcw = WCWIDTH (ch); ++ if (wcw > 1) g.xOff = g.xOff / wcw; ++ if (width < g.xOff ) width = g.xOff; ++ if (height < g.height) height = g.height; ++ } ++ bool success = true; + - ftheight -= height - prop.height; - } - else @@ -133,15 +139,15 @@ } FcPatternDestroy (match); -@@ -1404,7 +1375,7 @@ +@@ -1505,7 +1467,7 @@ /* Left-align to bounding box, do not overlap to the left. */ max_it(ep->x, x_); #endif - ep->y = y_ + ascent; + ep->y = y_ + term->fbase + (term->lineSpace >> 1); - if (extents.xOff == 0) - ep->x = x_ + cwidth; + // the xft font cell might differ from the terminal font cell, + // in which case we use the average between the two. --- src/screen.C +++ src/screen.C @@ -2538,8 +2538,8 @@ |