mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Use builtin NERD fonts
Prevents users from having to install their own NERD font. System fonts are still used preferentially on Linux but on macOS the builtin one is used preferentially. Cant find any CoreText API to change this. Still has to be implemented on macOS. And need to add code to the build system to bundle the font when building.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,6 +12,7 @@
|
|||||||
/dependencies
|
/dependencies
|
||||||
/tags
|
/tags
|
||||||
/build/
|
/build/
|
||||||
|
/fonts/
|
||||||
/linux-package/
|
/linux-package/
|
||||||
/kitty.app/
|
/kitty.app/
|
||||||
/glad/out/
|
/glad/out/
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- A new ``choose-fonts`` kitten that provides a UI with font previews to ease selection of fonts. Also has support for font features and variable fonts.
|
- A new ``choose-fonts`` kitten that provides a UI with font previews to ease selection of fonts. Also has support for font features and variable fonts.
|
||||||
|
|
||||||
|
- Add NERD fonts builtin so that users don't have to install them to use NERD symbols in kitty
|
||||||
|
|
||||||
- Wayland: Allow fractional scales less than one (:pull:`7549`)
|
- Wayland: Allow fractional scales less than one (:pull:`7549`)
|
||||||
|
|
||||||
- Wayland: Fix specifying the output name for the panel kitten not working (:iss:`7573`)
|
- Wayland: Fix specifying the output name for the panel kitten not working (:iss:`7573`)
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ terminfo_dir = os.path.join(kitty_base_dir, 'terminfo')
|
|||||||
logo_png_file = os.path.join(kitty_base_dir, 'logo', 'kitty.png')
|
logo_png_file = os.path.join(kitty_base_dir, 'logo', 'kitty.png')
|
||||||
beam_cursor_data_file = os.path.join(kitty_base_dir, 'logo', 'beam-cursor.png')
|
beam_cursor_data_file = os.path.join(kitty_base_dir, 'logo', 'beam-cursor.png')
|
||||||
shell_integration_dir = os.path.join(kitty_base_dir, 'shell-integration')
|
shell_integration_dir = os.path.join(kitty_base_dir, 'shell-integration')
|
||||||
|
fonts_dir = os.path.join(kitty_base_dir, 'fonts')
|
||||||
try:
|
try:
|
||||||
shell_path = pwd.getpwuid(os.geteuid()).pw_shell or '/bin/sh'
|
shell_path = pwd.getpwuid(os.geteuid()).pw_shell or '/bin/sh'
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
import ctypes
|
import ctypes
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from math import ceil, cos, floor, pi
|
from math import ceil, cos, floor, pi
|
||||||
from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, List, Literal, Optional, Tuple, Union, cast
|
from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, List, Literal, Optional, Tuple, Union, cast
|
||||||
|
|
||||||
from kitty.constants import is_macos
|
from kitty.constants import fonts_dir, is_macos
|
||||||
from kitty.fast_data_types import (
|
from kitty.fast_data_types import (
|
||||||
NUM_UNDERLINE_STYLES,
|
NUM_UNDERLINE_STYLES,
|
||||||
Screen,
|
Screen,
|
||||||
@@ -197,6 +198,14 @@ def set_font_family(opts: Optional[Options] = None, override_font_size: Optional
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def add_application_fonts() -> None:
|
||||||
|
for font in ('SymbolsNerdFontMono-Regular.ttf',):
|
||||||
|
path = os.path.join(fonts_dir, font)
|
||||||
|
if os.path.exists(path):
|
||||||
|
if not add_font_file(path):
|
||||||
|
log_error(f'Failed to add application font: {path}')
|
||||||
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
CBufType = ctypes.Array[ctypes.c_ubyte]
|
CBufType = ctypes.Array[ctypes.c_ubyte]
|
||||||
else:
|
else:
|
||||||
@@ -528,7 +537,6 @@ def test_fallback_font(qtext: Optional[str] = None, bold: bool = False, italic:
|
|||||||
|
|
||||||
|
|
||||||
def showcase() -> None:
|
def showcase() -> None:
|
||||||
add_font_file
|
|
||||||
f = 'monospace' if is_macos else 'Liberation Mono'
|
f = 'monospace' if is_macos else 'Liberation Mono'
|
||||||
test_render_string('He\u0347\u0305llo\u0337, w\u0302or\u0306l\u0354d!', family=f)
|
test_render_string('He\u0347\u0305llo\u0337, w\u0302or\u0306l\u0354d!', family=f)
|
||||||
test_render_string('你好,世界', family=f)
|
test_render_string('你好,世界', family=f)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ from .fast_data_types import (
|
|||||||
set_options,
|
set_options,
|
||||||
)
|
)
|
||||||
from .fonts.box_drawing import set_scale
|
from .fonts.box_drawing import set_scale
|
||||||
from .fonts.render import dump_font_debug, set_font_family
|
from .fonts.render import add_application_fonts, dump_font_debug, set_font_family
|
||||||
from .options.types import Options
|
from .options.types import Options
|
||||||
from .options.utils import DELETE_ENV_VAR
|
from .options.utils import DELETE_ENV_VAR
|
||||||
from .os_window_size import edge_spacing, initial_window_size_func
|
from .os_window_size import edge_spacing, initial_window_size_func
|
||||||
@@ -249,6 +249,7 @@ class AppRunner:
|
|||||||
set_options(opts, is_wayland(), args.debug_rendering, args.debug_font_fallback)
|
set_options(opts, is_wayland(), args.debug_rendering, args.debug_font_fallback)
|
||||||
try:
|
try:
|
||||||
set_font_family(opts)
|
set_font_family(opts)
|
||||||
|
add_application_fonts()
|
||||||
_run_app(opts, args, bad_lines, talk_fd)
|
_run_app(opts, args, bad_lines, talk_fd)
|
||||||
finally:
|
finally:
|
||||||
set_options(None)
|
set_options(None)
|
||||||
|
|||||||
Reference in New Issue
Block a user