uobikiemukot / yaft

yet another framebuffer terminal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Add line spacing

xlucn opened this issue · comments

commented

There are two motivations for me to request line spacing (or something looks like it):

  1. Current I am using unifont and the multi-line CJK fonts are crowded together.
    It will be better if I can add e.g. 2 pixels between lines.
  2. My screen resolution is 1920x1080, font size of 8x16 (the only size available in unifont) will leave a 8 pixel empty border at bottom. It does not look good, and even worse, sometimes this area won't get cleared for example viewing an image with fbv when using tmux.
    If I can change the line spacing, maybe I can adjust the screen to contain exact integer number of lines.
commented

I messed with the code a little bit and came up with this solution. After applying this patch, each line will be 2 pixels higher with 1 pixel added to top and bottom each. I almost don't know anything about programming with fonts so there is no guarantee this solves the issue completely:

diff --git a/tools/bdf.h b/tools/bdf.h
index 82924cd..7a95b53 100644
--- a/tools/bdf.h
+++ b/tools/bdf.h
@@ -146,7 +146,7 @@ int read_bitmap(struct glyph_list_t **glist_head, struct glyph_t *default_glyph,
 
 		code   = convert_table[bdf_char->encoding];
 		width  = bdf_char->dwidth;
-		height = bdf_header->ascent + bdf_header->descent;
+		height = bdf_header->ascent + bdf_header->descent + 2;
 
 		//logging(DEBUG, "code:%d width:%d height:%d\n", code, width, height);
 
@@ -160,7 +160,7 @@ int read_bitmap(struct glyph_list_t **glist_head, struct glyph_t *default_glyph,
 			glyph->bitmap = (bitmap_width_t *) ecalloc(glyph->height, sizeof(bitmap_width_t));
 
 			for (int i = 0; i < glyph->height; i++)
-				glyph->bitmap[i] = bdf_char->bitmap[i];
+				glyph->bitmap[i + 1] = bdf_char->bitmap[i];
 
 			/* add new element to glyph list */
 			listp->code  = code;