@@ -744,7 +744,7 @@ shape(CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_cells, hb
744744 group_state .last_gpu_cell = first_gpu_cell + (num_cells ? num_cells - 1 : 0 );
745745 load_hb_buffer (first_cpu_cell , first_gpu_cell , num_cells );
746746
747- if (disable_ligature || OPT ( disable_ligatures ) == DISABLE_LIGATURES_ALWAYS ) {
747+ if (disable_ligature ) {
748748 hb_shape (font , harfbuzz_buffer , & no_calt_feature , 1 );
749749 } else {
750750 hb_shape (font , harfbuzz_buffer , NULL , 0 );
@@ -1015,10 +1015,10 @@ test_shape(PyObject UNUSED *self, PyObject *args) {
10151015#undef G
10161016
10171017static inline void
1018- render_run (FontGroup * fg , CPUCell * first_cpu_cell , GPUCell * first_gpu_cell , index_type num_cells , ssize_t font_idx , bool pua_space_ligature , bool center_glyph , int cursor_offset ) {
1018+ render_run (FontGroup * fg , CPUCell * first_cpu_cell , GPUCell * first_gpu_cell , index_type num_cells , ssize_t font_idx , bool pua_space_ligature , bool center_glyph , int cursor_offset , DisableLigature disable_ligature_strategy ) {
10191019 switch (font_idx ) {
10201020 default :
1021- shape_run (first_cpu_cell , first_gpu_cell , num_cells , & fg -> fonts [font_idx ], false );
1021+ shape_run (first_cpu_cell , first_gpu_cell , num_cells , & fg -> fonts [font_idx ], disable_ligature_strategy == DISABLE_LIGATURES_ALWAYS );
10221022 if (pua_space_ligature ) merge_groups_for_pua_space_ligature ();
10231023 else if (cursor_offset > -1 ) {
10241024 index_type left , right ;
@@ -1052,21 +1052,18 @@ render_run(FontGroup *fg, CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, inde
10521052}
10531053
10541054void
1055- render_line (FONTS_DATA_HANDLE fg_ , Line * line , index_type lnum , Cursor * cursor ) {
1055+ render_line (FONTS_DATA_HANDLE fg_ , Line * line , index_type lnum , Cursor * cursor , DisableLigature disable_ligature_strategy ) {
10561056#define RENDER if (run_font_idx != NO_FONT && i > first_cell_in_run) { \
10571057 int cursor_offset = -1; \
1058- if (disable_ligature_in_line && first_cell_in_run <= cursor->x && cursor->x <= i) cursor_offset = cursor->x - first_cell_in_run; \
1059- render_run(fg, line->cpu_cells + first_cell_in_run, line->gpu_cells + first_cell_in_run, i - first_cell_in_run, run_font_idx, false, center_glyph, cursor_offset); \
1058+ if (disable_ligature_at_cursor && first_cell_in_run <= cursor->x && cursor->x <= i) cursor_offset = cursor->x - first_cell_in_run; \
1059+ render_run(fg, line->cpu_cells + first_cell_in_run, line->gpu_cells + first_cell_in_run, i - first_cell_in_run, run_font_idx, false, center_glyph, cursor_offset, disable_ligature_strategy ); \
10601060}
10611061 FontGroup * fg = (FontGroup * )fg_ ;
10621062 ssize_t run_font_idx = NO_FONT ;
10631063 bool center_glyph = false;
1064- bool disable_ligature_in_line = false ;
1064+ bool disable_ligature_at_cursor = cursor != NULL && disable_ligature_strategy == DISABLE_LIGATURES_CURSOR && lnum == cursor -> y ;
10651065 index_type first_cell_in_run , i ;
10661066 attrs_type prev_width = 0 ;
1067- if (cursor != NULL && OPT (disable_ligatures ) == DISABLE_LIGATURES_CURSOR ) {
1068- if (lnum == cursor -> y ) disable_ligature_in_line = true;
1069- }
10701067 for (i = 0 , first_cell_in_run = 0 ; i < line -> xnum ; i ++ ) {
10711068 if (prev_width == 2 ) { prev_width = 0 ; continue ; }
10721069 CPUCell * cpu_cell = line -> cpu_cells + i ;
@@ -1104,7 +1101,7 @@ render_line(FONTS_DATA_HANDLE fg_, Line *line, index_type lnum, Cursor *cursor)
11041101 center_glyph = true;
11051102 RENDER
11061103 center_glyph = false;
1107- render_run (fg , line -> cpu_cells + i , line -> gpu_cells + i , num_spaces + 1 , cell_font_idx , true, center_glyph , -1 );
1104+ render_run (fg , line -> cpu_cells + i , line -> gpu_cells + i , num_spaces + 1 , cell_font_idx , true, center_glyph , -1 , disable_ligature_strategy );
11081105 run_font_idx = NO_FONT ;
11091106 first_cell_in_run = i + num_spaces + 1 ;
11101107 prev_width = line -> gpu_cells [i + num_spaces ].attrs & WIDTH_MASK ;
@@ -1296,7 +1293,7 @@ test_render_line(PyObject UNUSED *self, PyObject *args) {
12961293 PyObject * line ;
12971294 if (!PyArg_ParseTuple (args , "O!" , & Line_Type , & line )) return NULL ;
12981295 if (!num_font_groups ) { PyErr_SetString (PyExc_RuntimeError , "must create font group first" ); return NULL ; }
1299- render_line ((FONTS_DATA_HANDLE )font_groups , (Line * )line , 0 , NULL );
1296+ render_line ((FONTS_DATA_HANDLE )font_groups , (Line * )line , 0 , NULL , DISABLE_LIGATURES_NEVER );
13001297 Py_RETURN_NONE ;
13011298}
13021299
0 commit comments