linux console: reprogram font only after grabbing the framebuffer #2046

pull/2053/head
nick black 3 years ago committed by nick black
parent 1ad7f70fac
commit d920ca5636

@ -573,8 +573,7 @@ reprogram_linux_font(int fd, struct console_font_op* cfo,
return 0;
}
static int
reprogram_console_font(int fd, unsigned no_font_changes, bool* quadrants){
int reprogram_console_font(int fd, unsigned no_font_changes, bool* quadrants){
struct console_font_op cfo = {
.op = KD_FONT_OP_GET,
.charcount = 512,
@ -605,7 +604,7 @@ reprogram_console_font(int fd, unsigned no_font_changes, bool* quadrants){
// is the provided fd a Linux console? if so, returns true. if it is indeed
// a Linux console, and the console font has the quadrant glyphs (either
// because they were already present, or we added them), quadrants is set high.
bool is_linux_console(int fd, unsigned no_font_changes, bool* quadrants){
bool is_linux_console(int fd){
if(fd < 0){
return false;
}
@ -615,7 +614,6 @@ bool is_linux_console(int fd, unsigned no_font_changes, bool* quadrants){
return false;
}
loginfo("Verified Linux console, mode %d\n", mode);
reprogram_console_font(fd, no_font_changes, quadrants);
return true;
}

@ -9,7 +9,13 @@ extern "C" {
struct tinfo;
bool is_linux_console(int fd, unsigned no_font_changes, bool* quadrants);
// is this a linux virtual console?
bool is_linux_console(int fd);
// attempt to reprogram the console font, if necessary, to include all the
// quadrant glyphs. |quadrants| will be true if the quadrants are available,
// whether that required a reprogramming or not.
int reprogram_console_font(int fd, unsigned no_font_changes, bool* quadrants);
// if is_linux_console() returned true, call this to determine whether it is
// a drawable framebuffer console. do not call if not a verified console!

@ -464,7 +464,8 @@ add_pushcolors_escapes(tinfo* ti, size_t* tablelen, size_t* tableused){
// needs be correct, even though we identify the terminal. le sigh.
static int
apply_term_heuristics(tinfo* ti, const char* termname, queried_terminals_e qterm,
size_t* tablelen, size_t* tableused, bool* invertsixel){
size_t* tablelen, size_t* tableused, bool* invertsixel,
unsigned nonewfonts){
if(!termname){
// setupterm interprets a missing/empty TERM variable as the special value “unknown”.
termname = "unknown";
@ -478,6 +479,7 @@ apply_term_heuristics(tinfo* ti, const char* termname, queried_terminals_e qterm
ti->termversion = NULL;
}
}
// FIXME clean this shit up; use a table for chrissakes
// st had neither caps.sextants nor caps.quadrants last i checked (0.8.4)
ti->caps.braille = true; // most everyone has working caps.braille, even from fonts
if(qterm == TERMINAL_KITTY){ // kitty (https://sw.kovidgoyal.net/kitty/)
@ -562,11 +564,11 @@ apply_term_heuristics(tinfo* ti, const char* termname, queried_terminals_e qterm
ti->caps.quadrants = true;
ti->caps.rgb = true;
}else if(qterm == TERMINAL_ITERM){
termname = "iTerm2";
// iTerm implements DCS ASU, but has no detection for it
if(add_appsync_escapes_dcs(ti, tablelen, tableused)){
return -1;
}
termname = "iTerm2";
ti->caps.quadrants = true;
ti->caps.rgb = true;
setup_iterm_bitmaps(ti, ti->ttyfd);
@ -579,13 +581,16 @@ apply_term_heuristics(tinfo* ti, const char* termname, queried_terminals_e qterm
if(uname(&un) == 0){
ti->termversion = strdup(un.release);
}
if(ti->linux_fb_fd >= 0){
if(is_linux_framebuffer(ti)){
termname = "Linux framebuffer";
setup_fbcon_bitmaps(ti, ti->linux_fb_fd);
}else{
termname = "Linux console";
}
reprogram_console_font(ti->linux_fb_fd, nonewfonts, &ti->caps.quadrants);
ti->caps.braille = false; // no caps.braille, no caps.sextants in linux console
#else
(void)nonewfonts;
#endif
}else if(qterm == TERMINAL_TERMINOLOGY){
termname = "Terminology";
@ -681,26 +686,19 @@ int interrogate_terminfo(tinfo* ti, const char* termtype, FILE* out, unsigned ut
const char* tname = NULL;
#ifdef __APPLE__
qterm = macos_early_matches();
(void)nonewfonts;
#elif defined(__MINGW64__)
if(prepare_windows_terminal(ti, &tablelen, &tableused)){
return -1;
}
qterm = TERMINAL_MSTERMINAL;
(void)nonewfonts;
(void)termtype;
#elif defined(__linux__)
ti->linux_fb_fd = -1;
ti->linux_fbuffer = MAP_FAILED;
// we might or might not program quadrants into the console font
if(is_linux_console(ti->ttyfd, nonewfonts, &ti->caps.quadrants)){
if(is_linux_console(ti->ttyfd)){
qterm = TERMINAL_LINUX;
if(is_linux_framebuffer(ti)){
// FIXME set up pixel-drawing API for framebuffer #1369
}
}
#else
(void)nonewfonts;
#endif
#ifndef __MINGW64__
if(ti->ttyfd >= 0){
@ -874,7 +872,8 @@ int interrogate_terminfo(tinfo* ti, const char* termtype, FILE* out, unsigned ut
}
}
bool invertsixel = false;
if(apply_term_heuristics(ti, tname, qterm, &tablelen, &tableused, &invertsixel)){
if(apply_term_heuristics(ti, tname, qterm, &tablelen, &tableused,
&invertsixel, nonewfonts)){
ncinputlayer_stop(&ti->input);
goto err;
}

Loading…
Cancel
Save