mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-10 05:44:16 +00:00
add new domain --load-font <path>
which makes a font from a custom path available
This commit is contained in:
parent
97743969fe
commit
b5c2c65447
4 changed files with 25 additions and 0 deletions
19
src/font.c
19
src/font.c
|
@ -2,6 +2,25 @@
|
|||
#include "animation.h"
|
||||
#include "bar_manager.h"
|
||||
|
||||
void font_register(char* font_path) {
|
||||
CFStringRef url_string = CFStringCreateWithCString(kCFAllocatorDefault,
|
||||
font_path,
|
||||
kCFStringEncodingUTF8);
|
||||
if (url_string) {
|
||||
CFURLRef url_ref = CFURLCreateWithString(kCFAllocatorDefault,
|
||||
url_string,
|
||||
NULL );
|
||||
if (url_ref) {
|
||||
CTFontManagerRegisterFontsForURL(url_ref,
|
||||
kCTFontManagerScopeProcess,
|
||||
NULL );
|
||||
CFRelease(url_ref);
|
||||
}
|
||||
CFRelease(url_string);
|
||||
}
|
||||
free(font_path);
|
||||
}
|
||||
|
||||
void font_create_ctfont(struct font* font) {
|
||||
|
||||
CFStringRef family_ref = CFStringCreateWithCString(NULL,
|
||||
|
|
|
@ -11,6 +11,8 @@ struct font {
|
|||
char* style;
|
||||
};
|
||||
|
||||
void font_register(char* font_path);
|
||||
|
||||
void font_init(struct font* font);
|
||||
void font_destroy(struct font* font);
|
||||
bool font_set(struct font* font, char* font_string, bool forced);
|
||||
|
|
|
@ -713,6 +713,9 @@ void handle_message_mach(struct mach_buffer* buffer) {
|
|||
} else if (token_equals(command, DOMAIN_HOTLOAD)) {
|
||||
struct token token = get_token(&message);
|
||||
hotload_set_state(evaluate_boolean_state(token, hotload_get_state()));
|
||||
} else if (token_equals(command, DOMAIN_ADD_FONT)) {
|
||||
struct token token = get_token(&message);
|
||||
font_register(token_to_string(token));
|
||||
} else if (token_equals(command, DOMAIN_RELOAD)) {
|
||||
char* rbr_msg = get_batch_line(&message);
|
||||
char* cur = rbr_msg;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#define DOMAIN_HOTLOAD "--hotload"
|
||||
#define DOMAIN_RELOAD "--reload"
|
||||
#define DOMAIN_ADD_FONT "--load-font"
|
||||
|
||||
#define SUB_DOMAIN_ICON "icon"
|
||||
#define SUB_DOMAIN_LABEL "label"
|
||||
|
|
Loading…
Reference in a new issue