mirror of
https://github.com/alrayyes/st
synced 2023-11-14 15:56:30 +00:00
feat: added second emoji font
This commit is contained in:
parent
372e01a0f3
commit
469556ba48
8
PKGBUILD
8
PKGBUILD
@ -6,7 +6,7 @@ pkgrel=1
|
||||
pkgdesc='A simple virtual terminal emulator for X.'
|
||||
arch=('i686' 'x86_64')
|
||||
license=('MIT')
|
||||
depends=('libxft' 'libxext' 'otf-nerd-fonts-fira-code')
|
||||
depends=('libxft' 'nerd-fonts-hack')
|
||||
makedepends=('ncurses')
|
||||
conflicts=('st')
|
||||
url="http://st.suckless.org"
|
||||
@ -18,6 +18,7 @@ _patches=("st-clipboard-0.8.3.diff"
|
||||
"st-vertcenter-20180320-6ac8c8a.diff"
|
||||
"st-alpha-0.8.2.diff"
|
||||
"st-ligatures-alpha-scrollback-20200430-0.8.3.diff"
|
||||
"st-font2-20190416-ba72400.diff"
|
||||
)
|
||||
|
||||
source=("http://dl.suckless.org/st/st-$pkgver.tar.gz"
|
||||
@ -25,14 +26,15 @@ source=("http://dl.suckless.org/st/st-$pkgver.tar.gz"
|
||||
"${_patches[@]}")
|
||||
|
||||
sha256sums=('d42d3ceceb4d6a65e32e90a5336e3d446db612c3fbd9ebc1780bc6c9a03346a6'
|
||||
'7dad11c04d2c869bc14f70ee23dd27cbb1b88934f12ae59a39b59ecbbf1b2291'
|
||||
'0bd28ddbfe0a036fc1b4736ad4ba1435d98b14a8cda2f3558175a9aee48ccf14'
|
||||
'0f5ce33953abce74a9da3088ea35bf067a9a4cfeb9fe6ea9800268ce69e436c0'
|
||||
'1e41fe17a5ef5a8194eea07422b49d815e2c2bb4d58d84771f793be423005310'
|
||||
'319458d980195d18fa0f81a6898d58f8d046c5ff982ab872d741f54bb60e267d'
|
||||
'cb87eb654985da46ff63663407184402393ad3d3013c8795570552fe56a15b9d'
|
||||
'04e6a4696293f668260b2f54a7240e379dbfabbc209de07bd5d4d57e9f513360'
|
||||
'9c5b4b4f23de80de78ca5ec3739dc6ce5e7f72666186cf4a9c6b614ac90fb285'
|
||||
'a7b3681d849fd8cca75cd38022a14fef2e26dc085bed1ebd8dcf0a65baa14898')
|
||||
'a7b3681d849fd8cca75cd38022a14fef2e26dc085bed1ebd8dcf0a65baa14898'
|
||||
'7279c787dba23d72a8a0a4613c0917e03d0087f0254f56a530cd9c521857d20b')
|
||||
|
||||
prepare() {
|
||||
cd $srcdir/st-$pkgver
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
- [[https://st.suckless.org/patches/alpha/][alpha]]
|
||||
- [[https://st.suckless.org/patches/clipboard/][clipboard]]
|
||||
- [[https://st.suckless.org/patches/font2/][font2]]
|
||||
- [[https://st.suckless.org/patches/ligatures/][ligatures]]
|
||||
- [[https://st.suckless.org/patches/scrollback/][scrollback]]
|
||||
- [[https://st.suckless.org/patches/scrollback/][scrollback-mouse]]
|
||||
|
7
config.h
7
config.h
@ -6,8 +6,11 @@
|
||||
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
||||
*/
|
||||
static char *font =
|
||||
"FuraCode Nerd Font "
|
||||
"Mono:style=Regular:pixelsize=18:antialias=true:autohint=true";
|
||||
"Hack Nerd Font Mono:pixelsize=18:antialias=true:autohint=true";
|
||||
|
||||
static char *font2[] = {
|
||||
"JoyPixels:pixelsize=18:antialias=true:autohint=true",
|
||||
};
|
||||
static int borderpx = 2;
|
||||
|
||||
/*
|
||||
|
@ -6,8 +6,11 @@
|
||||
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
||||
*/
|
||||
static char *font =
|
||||
"FuraCode Nerd Font "
|
||||
"Mono:style=Regular:pixelsize=12:antialias=true:autohint=true";
|
||||
"Hack Nerd Font Mono:pixelsize=14:antialias=true:autohint=true";
|
||||
|
||||
static char *font2[] = {
|
||||
"JoyPixels:pixelsize=14:antialias=true:autohint=true",
|
||||
};
|
||||
static int borderpx = 2;
|
||||
|
||||
/*
|
||||
|
167
st-font2-20190416-ba72400.diff
Normal file
167
st-font2-20190416-ba72400.diff
Normal file
@ -0,0 +1,167 @@
|
||||
From ba724004c6a368e452114f7dc147a9978fe0f3b4 Mon Sep 17 00:00:00 2001
|
||||
From: Kirill Bugaev <kirill.bugaev87@gmail.com>
|
||||
Date: Tue, 16 Apr 2019 04:31:30 +0800
|
||||
Subject: [PATCH] This patch allows to add spare font besides default. Some
|
||||
glyphs can be not present in default font. For this glyphs st uses
|
||||
font-config and try to find them in font cache first. This patch append fonts
|
||||
defined in font2 variable to the beginning of font cache. So they will be
|
||||
used first for glyphs that absent in default font.
|
||||
|
||||
---
|
||||
config.def.h | 6 +++
|
||||
x.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 107 insertions(+)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 482901e..676719e 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -6,6 +6,12 @@
|
||||
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
||||
*/
|
||||
static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
|
||||
+/* Spare fonts */
|
||||
+static char *font2[] = {
|
||||
+/* "Inconsolata for Powerline:pixelsize=12:antialias=true:autohint=true", */
|
||||
+/* "Hack Nerd Font Mono:pixelsize=11:antialias=true:autohint=true", */
|
||||
+};
|
||||
+
|
||||
static int borderpx = 2;
|
||||
|
||||
/*
|
||||
diff --git a/x.c b/x.c
|
||||
index 5828a3b..d37e59d 100644
|
||||
--- a/x.c
|
||||
+++ b/x.c
|
||||
@@ -149,6 +149,8 @@ static void xhints(void);
|
||||
static int xloadcolor(int, const char *, Color *);
|
||||
static int xloadfont(Font *, FcPattern *);
|
||||
static void xloadfonts(char *, double);
|
||||
+static int xloadsparefont(FcPattern *, int);
|
||||
+static void xloadsparefonts(void);
|
||||
static void xunloadfont(Font *);
|
||||
static void xunloadfonts(void);
|
||||
static void xsetenv(void);
|
||||
@@ -296,6 +298,7 @@ zoomabs(const Arg *arg)
|
||||
{
|
||||
xunloadfonts();
|
||||
xloadfonts(usedfont, arg->f);
|
||||
+ xloadsparefonts();
|
||||
cresize(0, 0);
|
||||
redraw();
|
||||
xhints();
|
||||
@@ -977,6 +980,101 @@ xloadfonts(char *fontstr, double fontsize)
|
||||
FcPatternDestroy(pattern);
|
||||
}
|
||||
|
||||
+int
|
||||
+xloadsparefont(FcPattern *pattern, int flags)
|
||||
+{
|
||||
+ FcPattern *match;
|
||||
+ FcResult result;
|
||||
+
|
||||
+ match = FcFontMatch(NULL, pattern, &result);
|
||||
+ if (!match) {
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ if (!(frc[frclen].font = XftFontOpenPattern(xw.dpy, match))) {
|
||||
+ FcPatternDestroy(match);
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ frc[frclen].flags = flags;
|
||||
+ /* Believe U+0000 glyph will present in each default font */
|
||||
+ frc[frclen].unicodep = 0;
|
||||
+ frclen++;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+xloadsparefonts(void)
|
||||
+{
|
||||
+ FcPattern *pattern;
|
||||
+ double sizeshift, fontval;
|
||||
+ int fc;
|
||||
+ char **fp;
|
||||
+
|
||||
+ if (frclen != 0)
|
||||
+ die("can't embed spare fonts. cache isn't empty");
|
||||
+
|
||||
+ /* Calculate count of spare fonts */
|
||||
+ fc = sizeof(font2) / sizeof(*font2);
|
||||
+ if (fc == 0)
|
||||
+ return;
|
||||
+
|
||||
+ /* Allocate memory for cache entries. */
|
||||
+ if (frccap < 4 * fc) {
|
||||
+ frccap += 4 * fc - frccap;
|
||||
+ frc = xrealloc(frc, frccap * sizeof(Fontcache));
|
||||
+ }
|
||||
+
|
||||
+ for (fp = font2; fp - font2 < fc; ++fp) {
|
||||
+
|
||||
+ if (**fp == '-')
|
||||
+ pattern = XftXlfdParse(*fp, False, False);
|
||||
+ else
|
||||
+ pattern = FcNameParse((FcChar8 *)*fp);
|
||||
+
|
||||
+ if (!pattern)
|
||||
+ die("can't open spare font %s\n", *fp);
|
||||
+
|
||||
+ if (defaultfontsize > 0) {
|
||||
+ sizeshift = usedfontsize - defaultfontsize;
|
||||
+ if (sizeshift != 0 &&
|
||||
+ FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) ==
|
||||
+ FcResultMatch) {
|
||||
+ fontval += sizeshift;
|
||||
+ FcPatternDel(pattern, FC_PIXEL_SIZE);
|
||||
+ FcPatternDel(pattern, FC_SIZE);
|
||||
+ FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontval);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ FcPatternAddBool(pattern, FC_SCALABLE, 1);
|
||||
+
|
||||
+ FcConfigSubstitute(NULL, pattern, FcMatchPattern);
|
||||
+ XftDefaultSubstitute(xw.dpy, xw.scr, pattern);
|
||||
+
|
||||
+ if (xloadsparefont(pattern, FRC_NORMAL))
|
||||
+ die("can't open spare font %s\n", *fp);
|
||||
+
|
||||
+ FcPatternDel(pattern, FC_SLANT);
|
||||
+ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
|
||||
+ if (xloadsparefont(pattern, FRC_ITALIC))
|
||||
+ die("can't open spare font %s\n", *fp);
|
||||
+
|
||||
+ FcPatternDel(pattern, FC_WEIGHT);
|
||||
+ FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
|
||||
+ if (xloadsparefont(pattern, FRC_ITALICBOLD))
|
||||
+ die("can't open spare font %s\n", *fp);
|
||||
+
|
||||
+ FcPatternDel(pattern, FC_SLANT);
|
||||
+ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN);
|
||||
+ if (xloadsparefont(pattern, FRC_BOLD))
|
||||
+ die("can't open spare font %s\n", *fp);
|
||||
+
|
||||
+ FcPatternDestroy(pattern);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
xunloadfont(Font *f)
|
||||
{
|
||||
@@ -1057,6 +1155,9 @@ xinit(int cols, int rows)
|
||||
usedfont = (opt_font == NULL)? font : opt_font;
|
||||
xloadfonts(usedfont, 0);
|
||||
|
||||
+ /* spare fonts */
|
||||
+ xloadsparefonts();
|
||||
+
|
||||
/* colors */
|
||||
xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
|
||||
xloadcols();
|
||||
--
|
||||
2.21.0
|
||||
|
Loading…
Reference in New Issue
Block a user