@@ -2925,6 +2925,7 @@ static void vc_con_rewind(struct vc_data *vc)
2925
2925
2926
2926
#define UCS_ZWS 0x200b /* Zero Width Space */
2927
2927
#define UCS_VS16 0xfe0f /* Variation Selector 16 */
2928
+ #define UCS_REPLACEMENT 0xfffd /* Replacement Character */
2928
2929
2929
2930
static int vc_process_ucs (struct vc_data * vc , int * c , int * tc )
2930
2931
{
@@ -2984,12 +2985,38 @@ static int vc_process_ucs(struct vc_data *vc, int *c, int *tc)
2984
2985
return 0 ;
2985
2986
}
2986
2987
2988
+ static int vc_get_glyph (struct vc_data * vc , int tc )
2989
+ {
2990
+ int glyph = conv_uni_to_pc (vc , tc );
2991
+ u16 charmask = vc -> vc_hi_font_mask ? 0x1ff : 0xff ;
2992
+
2993
+ if (!(glyph & ~charmask ))
2994
+ return glyph ;
2995
+
2996
+ if (glyph == -1 )
2997
+ return -1 ; /* nothing to display */
2998
+
2999
+ /* Glyph not found */
3000
+ if ((!vc -> vc_utf || vc -> vc_disp_ctrl || tc < 128 ) && !(tc & ~charmask )) {
3001
+ /*
3002
+ * In legacy mode use the glyph we get by a 1:1 mapping.
3003
+ * This would make absolutely no sense with Unicode in mind, but do this for
3004
+ * ASCII characters since a font may lack Unicode mapping info and we don't
3005
+ * want to end up with having question marks only.
3006
+ */
3007
+ return tc ;
3008
+ }
3009
+
3010
+ /* Display U+FFFD (Unicode Replacement Character). */
3011
+ return conv_uni_to_pc (vc , UCS_REPLACEMENT );
3012
+ }
3013
+
2987
3014
static int vc_con_write_normal (struct vc_data * vc , int tc , int c ,
2988
3015
struct vc_draw_region * draw )
2989
3016
{
2990
3017
int next_c ;
2991
3018
unsigned char vc_attr = vc -> vc_attr ;
2992
- u16 himask = vc -> vc_hi_font_mask , charmask = himask ? 0x1ff : 0xff ;
3019
+ u16 himask = vc -> vc_hi_font_mask ;
2993
3020
u8 width = 1 ;
2994
3021
bool inverse = false;
2995
3022
@@ -3000,39 +3027,17 @@ static int vc_con_write_normal(struct vc_data *vc, int tc, int c,
3000
3027
}
3001
3028
3002
3029
/* Now try to find out how to display it */
3003
- tc = conv_uni_to_pc (vc , tc );
3004
- if (tc & ~charmask ) {
3005
- if (tc == -1 )
3006
- return -1 ; /* nothing to display */
3030
+ tc = vc_get_glyph (vc , tc );
3031
+ if (tc == -1 )
3032
+ return -1 ; /* nothing to display */
3033
+ if (tc < 0 ) {
3034
+ inverse = true;
3035
+ tc = conv_uni_to_pc (vc , '?' );
3036
+ if (tc < 0 )
3037
+ tc = '?' ;
3007
3038
3008
- /* Glyph not found */
3009
- if ((!vc -> vc_utf || vc -> vc_disp_ctrl || c < 128 ) &&
3010
- !(c & ~charmask )) {
3011
- /*
3012
- * In legacy mode use the glyph we get by a 1:1
3013
- * mapping.
3014
- * This would make absolutely no sense with Unicode in
3015
- * mind, but do this for ASCII characters since a font
3016
- * may lack Unicode mapping info and we don't want to
3017
- * end up with having question marks only.
3018
- */
3019
- tc = c ;
3020
- } else {
3021
- /*
3022
- * Display U+FFFD. If it's not found, display an inverse
3023
- * question mark.
3024
- */
3025
- tc = conv_uni_to_pc (vc , 0xfffd );
3026
- if (tc < 0 ) {
3027
- inverse = true;
3028
- tc = conv_uni_to_pc (vc , '?' );
3029
- if (tc < 0 )
3030
- tc = '?' ;
3031
-
3032
- vc_attr = vc_invert_attr (vc );
3033
- con_flush (vc , draw );
3034
- }
3035
- }
3039
+ vc_attr = vc_invert_attr (vc );
3040
+ con_flush (vc , draw );
3036
3041
}
3037
3042
3038
3043
next_c = c ;
0 commit comments