Add option adjust_baseline to adjust the baseline position on macOS
This commit is contained in:
parent
51f8b22dfa
commit
bb26b3d549
@ -366,7 +366,7 @@ cell_metrics(PyObject *s, unsigned int* cell_width, unsigned int* cell_height, u
|
|||||||
CGRect bounds_without_leading = CTLineGetBoundsWithOptions(line, kCTLineBoundsExcludeTypographicLeading);
|
CGRect bounds_without_leading = CTLineGetBoundsWithOptions(line, kCTLineBoundsExcludeTypographicLeading);
|
||||||
CGFloat typographic_ascent, typographic_descent, typographic_leading;
|
CGFloat typographic_ascent, typographic_descent, typographic_leading;
|
||||||
CTLineGetTypographicBounds(line, &typographic_ascent, &typographic_descent, &typographic_leading);
|
CTLineGetTypographicBounds(line, &typographic_ascent, &typographic_descent, &typographic_leading);
|
||||||
CGFloat bounds_ascent = bounds_without_leading.size.height + bounds_without_leading.origin.y;
|
CGFloat bounds_ascent = bounds_without_leading.size.height + bounds_without_leading.origin.y - OPT(adjust_baseline);
|
||||||
*baseline = (unsigned int)floor(bounds_ascent + 0.5);
|
*baseline = (unsigned int)floor(bounds_ascent + 0.5);
|
||||||
*cell_height = MAX(4u, (unsigned int)ceilf(line_height));
|
*cell_height = MAX(4u, (unsigned int)ceilf(line_height));
|
||||||
// Not sure if we should add this to bounds ascent and then round it or add
|
// Not sure if we should add this to bounds ascent and then round it or add
|
||||||
|
|||||||
@ -94,6 +94,15 @@ opt('adjust_column_width', '0',
|
|||||||
option_type='adjust_line_height', ctype='!adjust_column_width',
|
option_type='adjust_line_height', ctype='!adjust_column_width',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
opt('adjust_baseline', '0',
|
||||||
|
option_type='int', ctype='int',
|
||||||
|
add_to_default=False,
|
||||||
|
long_text='''
|
||||||
|
Adjust the baseline position of each character (in pixels) on macOS. A positive
|
||||||
|
number moves all characters up, and a negative number moves them down.
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
|
||||||
opt('+symbol_map', 'U+E0A0-U+E0A3,U+E0C0-U+E0C7 PowerlineSymbols',
|
opt('+symbol_map', 'U+E0A0-U+E0A3,U+E0C0-U+E0C7 PowerlineSymbols',
|
||||||
option_type='symbol_map',
|
option_type='symbol_map',
|
||||||
add_to_default=False,
|
add_to_default=False,
|
||||||
|
|||||||
3
kitty/options/parse.py
generated
3
kitty/options/parse.py
generated
@ -37,6 +37,9 @@ class Parser:
|
|||||||
def active_tab_title_template(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
def active_tab_title_template(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||||
ans['active_tab_title_template'] = active_tab_title_template(val)
|
ans['active_tab_title_template'] = active_tab_title_template(val)
|
||||||
|
|
||||||
|
def adjust_baseline(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||||
|
ans['adjust_baseline'] = int(val)
|
||||||
|
|
||||||
def adjust_column_width(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
def adjust_column_width(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||||
ans['adjust_column_width'] = adjust_line_height(val)
|
ans['adjust_column_width'] = adjust_line_height(val)
|
||||||
|
|
||||||
|
|||||||
15
kitty/options/to-c-generated.h
generated
15
kitty/options/to-c-generated.h
generated
@ -57,6 +57,19 @@ convert_from_opts_adjust_column_width(PyObject *py_opts, Options *opts) {
|
|||||||
Py_DECREF(ret);
|
Py_DECREF(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
convert_from_python_adjust_baseline(PyObject *val, Options *opts) {
|
||||||
|
opts->adjust_baseline = PyLong_AsLong(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
convert_from_opts_adjust_baseline(PyObject *py_opts, Options *opts) {
|
||||||
|
PyObject *ret = PyObject_GetAttrString(py_opts, "adjust_baseline");
|
||||||
|
if (ret == NULL) return;
|
||||||
|
convert_from_python_adjust_baseline(ret, opts);
|
||||||
|
Py_DECREF(ret);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
convert_from_python_disable_ligatures(PyObject *val, Options *opts) {
|
convert_from_python_disable_ligatures(PyObject *val, Options *opts) {
|
||||||
opts->disable_ligatures = PyLong_AsLong(val);
|
opts->disable_ligatures = PyLong_AsLong(val);
|
||||||
@ -886,6 +899,8 @@ convert_opts_from_python_opts(PyObject *py_opts, Options *opts) {
|
|||||||
if (PyErr_Occurred()) return false;
|
if (PyErr_Occurred()) return false;
|
||||||
convert_from_opts_adjust_column_width(py_opts, opts);
|
convert_from_opts_adjust_column_width(py_opts, opts);
|
||||||
if (PyErr_Occurred()) return false;
|
if (PyErr_Occurred()) return false;
|
||||||
|
convert_from_opts_adjust_baseline(py_opts, opts);
|
||||||
|
if (PyErr_Occurred()) return false;
|
||||||
convert_from_opts_disable_ligatures(py_opts, opts);
|
convert_from_opts_disable_ligatures(py_opts, opts);
|
||||||
if (PyErr_Occurred()) return false;
|
if (PyErr_Occurred()) return false;
|
||||||
convert_from_opts_cursor_shape(py_opts, opts);
|
convert_from_opts_cursor_shape(py_opts, opts);
|
||||||
|
|||||||
2
kitty/options/types.py
generated
2
kitty/options/types.py
generated
@ -45,6 +45,7 @@ option_names = ( # {{{
|
|||||||
'active_tab_font_style',
|
'active_tab_font_style',
|
||||||
'active_tab_foreground',
|
'active_tab_foreground',
|
||||||
'active_tab_title_template',
|
'active_tab_title_template',
|
||||||
|
'adjust_baseline',
|
||||||
'adjust_column_width',
|
'adjust_column_width',
|
||||||
'adjust_line_height',
|
'adjust_line_height',
|
||||||
'allow_hyperlinks',
|
'allow_hyperlinks',
|
||||||
@ -435,6 +436,7 @@ class Options:
|
|||||||
active_tab_font_style: typing.Tuple[bool, bool] = (True, True)
|
active_tab_font_style: typing.Tuple[bool, bool] = (True, True)
|
||||||
active_tab_foreground: Color = Color(red=0, green=0, blue=0)
|
active_tab_foreground: Color = Color(red=0, green=0, blue=0)
|
||||||
active_tab_title_template: typing.Optional[str] = None
|
active_tab_title_template: typing.Optional[str] = None
|
||||||
|
adjust_baseline: int = 0
|
||||||
adjust_column_width: typing.Union[int, float] = 0
|
adjust_column_width: typing.Union[int, float] = 0
|
||||||
adjust_line_height: typing.Union[int, float] = 0
|
adjust_line_height: typing.Union[int, float] = 0
|
||||||
allow_hyperlinks: int = 1
|
allow_hyperlinks: int = 1
|
||||||
|
|||||||
@ -42,6 +42,7 @@ typedef struct {
|
|||||||
WindowTitleIn macos_show_window_title_in;
|
WindowTitleIn macos_show_window_title_in;
|
||||||
int adjust_line_height_px, adjust_column_width_px;
|
int adjust_line_height_px, adjust_column_width_px;
|
||||||
float adjust_line_height_frac, adjust_column_width_frac;
|
float adjust_line_height_frac, adjust_column_width_frac;
|
||||||
|
int adjust_baseline;
|
||||||
float background_opacity, dim_opacity;
|
float background_opacity, dim_opacity;
|
||||||
|
|
||||||
char* background_image;
|
char* background_image;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user