[dev] [st] crash on font resize (patch inside)

2015-02-14 Thread Nils Reuße

hi folks,

i found a bug in st (latest git):

if you keep downsizing your fontsize until either xw.ch or xw.cw gets 0, 
st crashes, because there is an unchecked division in cresize. my patch 
fixes the problem, but i haven't checked for a better solution.


nils


diff --git a/st.c b/st.c
index 1deb7bc..5403d29 100644
--- a/st.c
+++ b/st.c
@@ -3815,8 +3815,8 @@ cresize(int width, int height) {
if(height != 0)
xw.h = height;

-   col = (xw.w - 2 * borderpx) / xw.cw;
-   row = (xw.h - 2 * borderpx) / xw.ch;
+   col = (xw.w - 2 * borderpx) / (xw.cw ? xw.cw : 1);
+   row = (xw.h - 2 * borderpx) / (xw.ch ? xw.ch : 1);

tresize(col, row);
xresize(col, row);



Re: [dev] [st] crash on font resize (patch inside)

2015-02-15 Thread Nils Reuße

On 14.02.2015 22:55, Nils Reuße wrote:

hi folks,

i found a bug in st (latest git):

if you keep downsizing your fontsize until either xw.ch or xw.cw gets 0,
st crashes, because there is an unchecked division in cresize. my patch
fixes the problem, but i haven't checked for a better solution.

nils


diff --git a/st.c b/st.c
index 1deb7bc..5403d29 100644
--- a/st.c
+++ b/st.c
@@ -3815,8 +3815,8 @@ cresize(int width, int height) {
 if(height != 0)
 xw.h = height;

-   col = (xw.w - 2 * borderpx) / xw.cw;
-   row = (xw.h - 2 * borderpx) / xw.ch;
+   col = (xw.w - 2 * borderpx) / (xw.cw ? xw.cw : 1);
+   row = (xw.h - 2 * borderpx) / (xw.ch ? xw.ch : 1);

 tresize(col, row);
 xresize(col, row);


This patch also does the job, and also prevents (gohufont, at least) to 
disappear completely.


diff --git a/st.c b/st.c
index 1deb7bc..547ddc9 100644
--- a/st.c
+++ b/st.c
@@ -2992,7 +2992,7 @@ xloadfonts(char *fontstr, double fontsize) {
if(!pattern)
die("st: can't open font %s\n", fontstr);

-   if(fontsize > 0) {
+   if(fontsize > 1) {
FcPatternDel(pattern, FC_PIXEL_SIZE);
FcPatternDel(pattern, FC_SIZE);
FcPatternAddDouble(pattern, FC_PIXEL_SIZE, 
(double)fontsize);




Re: [dev] [st] crash on font resize (patch inside)

2015-02-15 Thread Nils Reuße

On 15.02.2015 11:01, k...@shike2.com wrote:



diff --git a/st.c b/st.c
index 1deb7bc..547ddc9 100644
--- a/st.c
+++ b/st.c
@@ -2992,7 +2992,7 @@ xloadfonts(char *fontstr, double fontsize) {
  if(!pattern)
  die("st: can't open font %s\n", fontstr);

-   if(fontsize > 0) {
+   if(fontsize > 1) {
  FcPatternDel(pattern, FC_PIXEL_SIZE);
  FcPatternDel(pattern, FC_SIZE);
  FcPatternAddDouble(pattern, FC_PIXEL_SIZE,
(double)fontsize);


I like more this patch, and it is the version I am going to apply.

Regards,



Thanks! While you're at it, you could bump the copyright note as well.

Best,
Nils


diff --git a/st.c b/st.c
index 1deb7bc..b9d30a7 100644
--- a/st.c
+++ b/st.c
@@ -3938,7 +3938,7 @@ run(void) {

 void
 usage(void) {
-   die("%s " VERSION " (c) 2010-2014 st engineers\n" \
+   die("%s " VERSION " (c) 2010-2015 st engineers\n" \
"usage: st [-a] [-v] [-c class] [-f font] [-g geometry] [-o 
file]\n"
"  [-i] [-t title] [-w windowid] [-e command ...]\n", 
argv0);

 }




Re: [dev] [st] can't use Xterm font

2015-02-23 Thread Nils Reuße

On 23.02.2015 17:48, Greg Reagle wrote:

On Sat, Feb 21, 2015, at 10:24 AM, Vampyrah Broadcasting wrote:

I want to use Xterms font in st. The Arch Wiki page about Xterm (
https://wiki.archlinux.org/index.php/Xterm ) says that xterm uses the
font
-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-?
also abbrevated to 6x13. I have verified that with xfontsel. My
problem is that I cant select this font in the config.h file of st,
nor can I use anything else that looks like XTerms font in xfontsel.
Instead, it looks like what's in the attachment. What must I do to
make the font right?


I have a similar problem, possibly the same problem.  I am running
Xubuntu 14.04.  I really like the font from xterm that I've used for
many years before switching over to st recently, but it shows up
distorted like in your screen shot.  A lot of the fonts I try show up
distorted like that.

What I am doing now is I've made config.h in st:
 static char font[] = "Liberation
 Mono:pixelsize=15:antialias=false:autohint=false";
This looks pretty good for me.  I'd prefer to be able to use the xterm
font, but Liberation Mono is good enough for me to work with.  Also,
FYI, in case you don't already know, you can use keys to increase and
decrease the font size.  I submitted a patch to update the man page but
it hasn't been included yet.

I have a hunch that the problem has something to do with the type of the
font, trutype versus bitmapped versus type 1, but I am no expert in font
technology.



If you're using an ubuntu flavor, bitmap fonts are disabled by default. 
To enable them, do


  $ cd /etc/fonts/conf.d/
  $ sudo rm 70-no-bitmaps.conf
  $ sudo ln -s ../conf.avail/70-yes-bitmaps.conf

then run

  $ fc-cache -f

and search for fixed:

  $ fc-list | grep -i fixed


nils



[dev] [st] keep some glyph modes for the cursor

2017-02-06 Thread Nils Reuße
st currently does not keep any mode for the cursor that was active in the 
underlying glyph (e.g. italic text), the mode is always ATTR_NULL [1].  At [2] 
you can find a screenshot that shows the implications.  Other terminals (at 
least vte-based, such as XFCE-terminal) keep some modes for the cursor.  I find 
the current behaviour very disruptive, so here is a patch that keeps a few 
(arbitrarily chosen) modes for the cursor.

Any comments?

Thanks and king regards
Nils

[1] http://git.suckless.org/st/tree/st.c#n3963
[2] http://i.imgur.com/R2yCEaC.png


diff --git a/st.c b/st.c
index 708e7ae..f91545b 100644
--- a/st.c
+++ b/st.c
@@ -3998,6 +3998,8 @@ xdrawcursor(void)
xdrawglyph(og, oldx, oldy);
 
g.u = term.line[term.c.y][term.c.x].u;
+   ushort keep_mode = (ATTR_BOLD | ATTR_ITALIC | ATTR_UNDERLINE | 
ATTR_STRUCK);
+   g.mode |= (term.line[term.c.y][term.c.x].mode & keep_mode);
 
/*
 * Select the right color for the right mode.



[dev] [st] parse relative font size instead of pixelsize

2013-12-17 Thread Nils Reuße

Hi suckless@,

i tried to set a font and fontsize in config.h with the xft notation 
FONT-SIZE:


static char font[] = "Source Code Pro Medium-18:style=Regular";

The font was recognized, but not the font size, defaulting to 12.  The 
same was true when i used the size attribute:


static char font[] = "Source Code Pro Medium:style=Regular:size=18";

After figuring out that only the attribute 'pixelsize' works, i changed 
all occurrences of FC_PIXEL_SIZE to FC_SIZE in st.c (latest git, patch 
below), and now it works with size (but obviously breaks with pixelsize).


I prefer size over pixelsize because size scales to the current display 
resolution, while pixelsize has to be increased (either in config.h or 
on starting st), e.g. if you switch between a non-hd (home) and hd 
screen (work).


What do you think?

Best,
Nils


diff --git a/st.c b/st.c
index f883ac1..e888f32 100644
--- a/st.c
+++ b/st.c
@@ -2841,11 +2841,11 @@ xloadfonts(char *fontstr, int fontsize) {
die("st: can't open font %s\n", fontstr);

if(fontsize > 0) {
-   FcPatternDel(pattern, FC_PIXEL_SIZE);
-   FcPatternAddDouble(pattern, FC_PIXEL_SIZE, (double)fontsize);
+   FcPatternDel(pattern, FC_SIZE);
+   FcPatternAddDouble(pattern, FC_SIZE, (double)fontsize);
usedfontsize = fontsize;
} else {
-   result = FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, 
&fontval);
+   result = FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval);
if(result == FcResultMatch) {
usedfontsize = (int)fontval;
} else {
@@ -2853,7 +2853,7 @@ xloadfonts(char *fontstr, int fontsize) {
 * Default font size is 12, if none given. This is to
 * have a known usedfontsize value.
 */
-   FcPatternAddDouble(pattern, FC_PIXEL_SIZE, 12);
+   FcPatternAddDouble(pattern, FC_SIZE, 12);
usedfontsize = 12;
}
}



Re: [dev] [st] parse relative font size instead of pixelsize

2013-12-17 Thread Nils Reuße

On 12/17/2013 10:06 AM, Nils Reuße wrote:

Hi suckless@,

i tried to set a font and fontsize in config.h with the xft notation
FONT-SIZE:

 static char font[] = "Source Code Pro Medium-18:style=Regular";

The font was recognized, but not the font size, defaulting to 12.  The
same was true when i used the size attribute:

 static char font[] = "Source Code Pro Medium:style=Regular:size=18";

After figuring out that only the attribute 'pixelsize' works, i changed
all occurrences of FC_PIXEL_SIZE to FC_SIZE in st.c (latest git, patch
below), and now it works with size (but obviously breaks with pixelsize).

I prefer size over pixelsize because size scales to the current display
resolution, while pixelsize has to be increased (either in config.h or
on starting st), e.g. if you switch between a non-hd (home) and hd
screen (work).

What do you think?

Best,
Nils


diff --git a/st.c b/st.c
index f883ac1..e888f32 100644
--- a/st.c
+++ b/st.c
@@ -2841,11 +2841,11 @@ xloadfonts(char *fontstr, int fontsize) {
  die("st: can't open font %s\n", fontstr);

  if(fontsize > 0) {
-FcPatternDel(pattern, FC_PIXEL_SIZE);
-FcPatternAddDouble(pattern, FC_PIXEL_SIZE, (double)fontsize);
+FcPatternDel(pattern, FC_SIZE);
+FcPatternAddDouble(pattern, FC_SIZE, (double)fontsize);
  usedfontsize = fontsize;
  } else {
-result = FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval);
+result = FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval);
  if(result == FcResultMatch) {
  usedfontsize = (int)fontval;
  } else {
@@ -2853,7 +2853,7 @@ xloadfonts(char *fontstr, int fontsize) {
   * Default font size is 12, if none given. This is to
   * have a known usedfontsize value.
   */
-FcPatternAddDouble(pattern, FC_PIXEL_SIZE, 12);
+FcPatternAddDouble(pattern, FC_SIZE, 12);
  usedfontsize = 12;
  }
  }


Sorry for double posting, but i figured out that 'pixelsize' still works 
when my patch is applied.  Didn't test bitmap fonts so far, though.


Nils