Skip to content

Commit 6802f35

Browse files
Nicolas Pitregregkh
authored andcommitted
vt: make use of ucs_get_fallback() when glyph is unavailable
Attempt to display a fallback character when given character doesn't have an available glyph. The substitution may not be as good as the original character but still way more helpful than a squared question mark. Example substitutions: À -> A, ç -> c, ø -> o, ─ -> -, © -> C, etc. See gen_ucs_fallback_table.py for a comprehensive list. Signed-off-by: Nicolas Pitre <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fe26933 commit 6802f35

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/tty/vt/vt.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,6 +3007,19 @@ static int vc_get_glyph(struct vc_data *vc, int tc)
30073007
return tc;
30083008
}
30093009

3010+
/*
3011+
* The Unicode screen memory is allocated only when required.
3012+
* This is one such case: we're about to "cheat" with the displayed
3013+
* character meaning the simple screen buffer won't hold the original
3014+
* information, whereas the Unicode screen buffer always does.
3015+
*/
3016+
vc_uniscr_check(vc);
3017+
3018+
/* Try getting a simpler fallback character. */
3019+
tc = ucs_get_fallback(tc);
3020+
if (tc)
3021+
return vc_get_glyph(vc, tc);
3022+
30103023
/* Display U+FFFD (Unicode Replacement Character). */
30113024
return conv_uni_to_pc(vc, UCS_REPLACEMENT);
30123025
}

0 commit comments

Comments
 (0)