Merge font2 patch
This commit is contained in:
commit
452af3549d
12
config.def.h
12
config.def.h
@ -5,7 +5,15 @@
|
|||||||
*
|
*
|
||||||
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
||||||
*/
|
*/
|
||||||
|
<<<<<<< HEAD
|
||||||
static char *font = "mono:pixelsize=14:antialias=true:autohint=true";
|
static char *font = "mono:pixelsize=14: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;
|
static int borderpx = 2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -125,7 +133,6 @@ static const char *colorname[] = {
|
|||||||
"black",
|
"black",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default colors (colorname index)
|
* Default colors (colorname index)
|
||||||
* foreground, background, cursor, reverse cursor
|
* foreground, background, cursor, reverse cursor
|
||||||
@ -508,7 +515,6 @@ static uint selmasks[] = {
|
|||||||
* Printable characters in ASCII, used to estimate the advance width
|
* Printable characters in ASCII, used to estimate the advance width
|
||||||
* of single wide characters.
|
* of single wide characters.
|
||||||
*/
|
*/
|
||||||
static char ascii_printable[] =
|
static char ascii_printable[] = " !\"#$%&'()*+,-./0123456789:;<=>?"
|
||||||
" !\"#$%&'()*+,-./0123456789:;<=>?"
|
|
||||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
||||||
"`abcdefghijklmnopqrstuvwxyz{|}~";
|
"`abcdefghijklmnopqrstuvwxyz{|}~";
|
||||||
|
1
config.h
1
config.h
@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
static char *font =
|
static char *font =
|
||||||
"FiraCode Nerd Font Mono:pixelsize=13:antialias=true:autohint=true";
|
"FiraCode Nerd Font Mono:pixelsize=13:antialias=true:autohint=true";
|
||||||
|
static char *font2[] = {"Noto Color Emoji: pixelsize=12"};
|
||||||
static int borderpx = 4;
|
static int borderpx = 4;
|
||||||
static int dark = 0;
|
static int dark = 0;
|
||||||
|
|
||||||
|
97
x.c
97
x.c
@ -169,7 +169,9 @@ static void xresize(int, int);
|
|||||||
static void xhints(void);
|
static void xhints(void);
|
||||||
static int xloadcolor(int, const char *, Color *);
|
static int xloadcolor(int, const char *, Color *);
|
||||||
static int xloadfont(Font *, FcPattern *);
|
static int xloadfont(Font *, FcPattern *);
|
||||||
static void xloadfonts(char *, double);
|
static void xloadfonts(char *fontstr, double fontsize);
|
||||||
|
static int xloadsparefont(FcPattern *, int);
|
||||||
|
static void xloadsparefonts(void);
|
||||||
static void xunloadfont(Font *);
|
static void xunloadfont(Font *);
|
||||||
static void xunloadfonts(void);
|
static void xunloadfonts(void);
|
||||||
static void xsetenv(void);
|
static void xsetenv(void);
|
||||||
@ -423,6 +425,7 @@ void zoom(const Arg *arg) {
|
|||||||
void zoomabs(const Arg *arg) {
|
void zoomabs(const Arg *arg) {
|
||||||
xunloadfonts();
|
xunloadfonts();
|
||||||
xloadfonts(usedfont, arg->f);
|
xloadfonts(usedfont, arg->f);
|
||||||
|
xloadsparefonts();
|
||||||
cresize(0, 0);
|
cresize(0, 0);
|
||||||
redraw();
|
redraw();
|
||||||
xhints();
|
xhints();
|
||||||
@ -1060,6 +1063,96 @@ void xloadfonts(char *fontstr, double fontsize) {
|
|||||||
FcPatternDestroy(pattern);
|
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) {
|
void xunloadfont(Font *f) {
|
||||||
XftFontClose(xw.dpy, f->match);
|
XftFontClose(xw.dpy, f->match);
|
||||||
FcPatternDestroy(f->pattern);
|
FcPatternDestroy(f->pattern);
|
||||||
@ -1149,6 +1242,8 @@ void xinit(int cols, int rows) {
|
|||||||
|
|
||||||
usedfont = (opt_font == NULL) ? font : opt_font;
|
usedfont = (opt_font == NULL) ? font : opt_font;
|
||||||
xloadfonts(usedfont, 0);
|
xloadfonts(usedfont, 0);
|
||||||
|
/* spare fonts */
|
||||||
|
xloadsparefonts();
|
||||||
|
|
||||||
/* colors */
|
/* colors */
|
||||||
xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None);
|
xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user