Remove box drawing python code

This commit is contained in:
Kovid Goyal
2024-12-23 14:50:53 +05:30
parent 6a18db45f0
commit c67475271f
7 changed files with 766 additions and 1603 deletions

View File

@@ -2678,7 +2678,6 @@ class Boss:
window.refresh()
def apply_new_options(self, opts: Options) -> None:
from .fonts.box_drawing import set_scale
bg_colors_before = {w.id: w.screen.color_profile.default_bg for w in self.all_windows}
# Update options storage
set_options(opts, is_wayland(), self.args.debug_rendering, self.args.debug_font_fallback)
@@ -2686,7 +2685,6 @@ class Boss:
set_layout_options(opts)
set_default_env(opts.env.copy())
# Update font data
set_scale(opts.box_drawing_scale)
from .fonts.render import set_font_family
set_font_family(opts)
for os_window_id, tm in self.os_window_map.items():

View File

@@ -1,5 +1,4 @@
import termios
from ctypes import Array, c_ubyte
from typing import Any, Callable, Dict, Iterator, List, Literal, NewType, Optional, Tuple, TypedDict, Union, overload
from kitty.boss import Boss
@@ -1131,7 +1130,6 @@ def set_send_sprite_to_gpu(
def set_font_data(
box_drawing_func: Callable[[int, int, int, float], Tuple[int, Union[bytearray, bytes, Array[c_ubyte]]]],
descriptor_for_idx: Callable[[int], Tuple[Union[FontObject|str], bool, bool]],
bold: int, italic: int, bold_italic: int, num_symbol_fonts: int,
symbol_maps: Tuple[Tuple[int, int, int], ...], font_sz_in_pts: float,

View File

@@ -769,7 +769,7 @@ START_ALLOW_CASE_RANGE
END_ALLOW_CASE_RANGE
}
static PyObject* box_drawing_function = NULL, *descriptor_for_idx = NULL;
static PyObject *descriptor_for_idx = NULL;
void
render_alpha_mask(const uint8_t *alpha_mask, pixel* dest, const Region *src_rect, const Region *dest_rect, size_t src_stride, size_t dest_stride, pixel color_rgb) {
@@ -1912,12 +1912,12 @@ set_symbol_maps(SymbolMap **maps, size_t *num, const PyObject *sm) {
static PyObject*
set_font_data(PyObject UNUSED *m, PyObject *args) {
PyObject *sm, *ns;
Py_CLEAR(box_drawing_function); Py_CLEAR(descriptor_for_idx);
if (!PyArg_ParseTuple(args, "OOIIIIO!dO!",
&box_drawing_function, &descriptor_for_idx,
Py_CLEAR(descriptor_for_idx);
if (!PyArg_ParseTuple(args, "OIIIIO!dO!",
&descriptor_for_idx,
&descriptor_indices.bold, &descriptor_indices.italic, &descriptor_indices.bi, &descriptor_indices.num_symbol_fonts,
&PyTuple_Type, &sm, &OPT(font_size), &PyTuple_Type, &ns)) return NULL;
Py_INCREF(box_drawing_function); Py_INCREF(descriptor_for_idx);
Py_INCREF(descriptor_for_idx);
free_font_groups();
clear_symbol_maps();
set_symbol_maps(&symbol_maps, &num_symbol_maps, sm);
@@ -2030,7 +2030,6 @@ static void
finalize(void) {
Py_CLEAR(python_send_to_gpu_impl);
clear_symbol_maps();
Py_CLEAR(box_drawing_function);
Py_CLEAR(descriptor_for_idx);
free_font_groups();
free(ligature_types);

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@ import ctypes
import os
import sys
from collections.abc import Generator
from typing import TYPE_CHECKING, Any, Callable, Literal, Optional, Union, cast
from typing import TYPE_CHECKING, Any, Callable, Literal, Optional, Union
from kitty.constants import fonts_dir, is_macos
from kitty.fast_data_types import (
@@ -22,7 +22,6 @@ from kitty.fast_data_types import (
test_render_line,
test_shape,
)
from kitty.fonts.box_drawing import BufType, render_box_char
from kitty.options.types import Options, defaults
from kitty.options.utils import parse_font_spec
from kitty.types import _T
@@ -205,7 +204,7 @@ def set_font_family(opts: Optional[Options] = None, override_font_size: Optional
ns = create_narrow_symbols(opts)
num_symbol_fonts = len(current_faces) - before
set_font_data(
render_box_drawing, descriptor_for_idx,
descriptor_for_idx,
indices['bold'], indices['italic'], indices['bi'], num_symbol_fonts,
sm, sz, ns
)
@@ -218,15 +217,6 @@ else:
UnderlineCallback = Callable[[CBufType, int, int, int, int], None]
def render_box_drawing(codepoint: int, cell_width: int, cell_height: int, dpi: float) -> tuple[int, CBufType]:
CharTexture = ctypes.c_ubyte * (cell_width * cell_height)
buf = CharTexture()
render_box_char(
chr(codepoint), cast(BufType, buf), cell_width, cell_height, dpi
)
return ctypes.addressof(buf), buf
class setup_for_testing:
xnum = 100000

View File

@@ -45,7 +45,6 @@ from .fast_data_types import (
set_default_window_icon,
set_options,
)
from .fonts.box_drawing import set_scale
from .fonts.render import dump_font_debug, set_font_family
from .options.types import Options
from .options.utils import DELETE_ENV_VAR
@@ -253,7 +252,6 @@ class AppRunner:
self.initial_window_size_func = initial_window_size_func
def __call__(self, opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = (), talk_fd: int = -1) -> None:
set_scale(opts.box_drawing_scale)
set_options(opts, is_wayland(), args.debug_rendering, args.debug_font_fallback)
if theme_colors.refresh():
theme_colors.patch_opts(opts, args.debug_rendering)