Skip to content

Commit

Permalink
feat: undercurl thickness control, fix: win.cyo
Browse files Browse the repository at this point in the history
  • Loading branch information
RaafatTurki authored and neeasade committed Dec 7, 2021
1 parent 62bad7a commit 38cf9f3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .Xresources
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ st.disable_alpha_correction: 0
! / \ / \ / \
! \_/ \_/
st.undercurl_shape: 1
! adds 1 pixel of thickness to the undercurl for every undercurl_thickness_threshold pixels of font size
st.undercurl_thickness_threshold: 28

! colors -- this is the base16-twilight colorscheme.
st.foreground: #a7a7a7
Expand Down
1 change: 1 addition & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,3 +537,4 @@ static char ascii_printable[] =
* render method of undercurls
*/
static unsigned int undercurl_shape = 1;
static unsigned int undercurl_thickness_threshold = 28;
8 changes: 4 additions & 4 deletions x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ drawundercurlcurly(GC ugc, int winx, int winy, int wlw, int width, int widthThre
int ww = win.cw;//width;
int wh = dc.font.descent - wlw/2 - 1;//r.height/7;
int wx = winx;
int wy = winy + win.cyo + win.ch - dc.font.descent;
int wy = winy + win.ch - dc.font.descent + win.cyo;
// Draw waves
int narcs = charlen * 2 + 1;
XArc *arcs = xmalloc(sizeof(XArc) * narcs);
Expand Down Expand Up @@ -1641,7 +1641,7 @@ drawundercurlspiky(GC ugc, int winx, int winy, int wlw, int width, int widthThre
int ww = win.cw;//width;
int wh = dc.font.descent - wlw/2 - 1;//r.height/7;
int wx = winx;
int wy = winy + win.ch - dc.font.descent;
int wy = winy + win.ch - dc.font.descent + win.cyo;
// Make the underline corridor larger
/*
wy -= wh;
Expand Down Expand Up @@ -1750,7 +1750,7 @@ drawundercurlcapped(GC ugc, int winx, int winy, int wlw, int width, int widthThr
int ww = win.cw;//width;
int wh = dc.font.descent - wlw/2 - 1;//r.height/7;
int wx = winx;
int wy = winy + win.cyo + win.ch - dc.font.descent;
int wy = winy + win.cyo + win.ch - dc.font.descent + win.cyo;

// Cap is half of wave width
float capRatio = 0.5f;
Expand Down Expand Up @@ -2071,7 +2071,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
XftDrawRect(xw.draw, fg, winx, winy + win.cyo + dc.font.ascent + 1, width, 1);
// Undercurl
} else if (base.ustyle == 3) {
const int widthThreshold = 28; // +1 width every widthThreshold px of font
const int widthThreshold = undercurl_thickness_threshold; // +1 width every widthThreshold px of font
int wlw = (win.ch / widthThreshold) + 1; // Wave Line Width
XGCValues ugcv = {
.foreground = selectlinecolor(base, fg),
Expand Down
1 change: 1 addition & 0 deletions xst.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ xrdb_load(void)

XRESOURCE_LOAD_INTEGER("depth", opt_depth);
XRESOURCE_LOAD_INTEGER("undercurl_shape", undercurl_shape);
XRESOURCE_LOAD_INTEGER("undercurl_thickness_threshold", undercurl_thickness_threshold);
}
XFlush(dpy);
}
Expand Down

0 comments on commit 38cf9f3

Please sign in to comment.