Introduction
Introduction Statistics Contact Development Disclaimer Help
st-font2-0.8.5.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
st-font2-0.8.5.diff (4196B)
---
1 From 1635e04d3643dd4caa0c7c2043b585c6d7e4705f Mon Sep 17 00:00:00 2001
2 From: Rizqi Nur Assyaufi <[email protected]>
3 Date: Mon, 18 Jul 2022 01:15:45 +0800
4 Subject: [PATCH] [st][patch][font2] Add patch for st-0.8.5
5
6 ---
7 config.def.h | 6 +++
8 x.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++
9 2 files changed, 107 insertions(+)
10
11 diff --git a/config.def.h b/config.def.h
12 index 91ab8ca..717b2f0 100644
13 --- a/config.def.h
14 +++ b/config.def.h
15 @@ -6,6 +6,12 @@
16 * font: see http://freedesktop.org/software/fontconfig/fontconfig-user…
17 */
18 static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohi…
19 +/* Spare fonts */
20 +static char *font2[] = {
21 +/* "Inconsolata for Powerline:pixelsize=12:antialias=true:autohi…
22 +/* "Hack Nerd Font Mono:pixelsize=11:antialias=true:autohint=tru…
23 +};
24 +
25 static int borderpx = 2;
26
27 /*
28 diff --git a/x.c b/x.c
29 index 8a16faa..220fc4f 100644
30 --- a/x.c
31 +++ b/x.c
32 @@ -157,6 +157,8 @@ static void xhints(void);
33 static int xloadcolor(int, const char *, Color *);
34 static int xloadfont(Font *, FcPattern *);
35 static void xloadfonts(const char *, double);
36 +static int xloadsparefont(FcPattern *, int);
37 +static void xloadsparefonts(void);
38 static void xunloadfont(Font *);
39 static void xunloadfonts(void);
40 static void xsetenv(void);
41 @@ -306,6 +308,7 @@ zoomabs(const Arg *arg)
42 {
43 xunloadfonts();
44 xloadfonts(usedfont, arg->f);
45 + xloadsparefonts();
46 cresize(0, 0);
47 redraw();
48 xhints();
49 @@ -1034,6 +1037,101 @@ xloadfonts(const char *fontstr, double fontsize)
50 FcPatternDestroy(pattern);
51 }
52
53 +int
54 +xloadsparefont(FcPattern *pattern, int flags)
55 +{
56 + FcPattern *match;
57 + FcResult result;
58 +
59 + match = FcFontMatch(NULL, pattern, &result);
60 + if (!match) {
61 + return 1;
62 + }
63 +
64 + if (!(frc[frclen].font = XftFontOpenPattern(xw.dpy, match))) {
65 + FcPatternDestroy(match);
66 + return 1;
67 + }
68 +
69 + frc[frclen].flags = flags;
70 + /* Believe U+0000 glyph will present in each default font */
71 + frc[frclen].unicodep = 0;
72 + frclen++;
73 +
74 + return 0;
75 +}
76 +
77 +void
78 +xloadsparefonts(void)
79 +{
80 + FcPattern *pattern;
81 + double sizeshift, fontval;
82 + int fc;
83 + char **fp;
84 +
85 + if (frclen != 0)
86 + die("can't embed spare fonts. cache isn't empty");
87 +
88 + /* Calculate count of spare fonts */
89 + fc = sizeof(font2) / sizeof(*font2);
90 + if (fc == 0)
91 + return;
92 +
93 + /* Allocate memory for cache entries. */
94 + if (frccap < 4 * fc) {
95 + frccap += 4 * fc - frccap;
96 + frc = xrealloc(frc, frccap * sizeof(Fontcache));
97 + }
98 +
99 + for (fp = font2; fp - font2 < fc; ++fp) {
100 +
101 + if (**fp == '-')
102 + pattern = XftXlfdParse(*fp, False, False);
103 + else
104 + pattern = FcNameParse((FcChar8 *)*fp);
105 +
106 + if (!pattern)
107 + die("can't open spare font %s\n", *fp);
108 +
109 + if (defaultfontsize > 0) {
110 + sizeshift = usedfontsize - defaultfontsize;
111 + if (sizeshift != 0 &&
112 + FcPatternGetDouble(pattern, FC_…
113 + FcResultMatch) {
114 + fontval += sizeshift;
115 + FcPatternDel(pattern, FC_PIXEL_SIZE);
116 + FcPatternDel(pattern, FC_SIZE);
117 + FcPatternAddDouble(pattern, FC_PIXEL_SI…
118 + }
119 + }
120 +
121 + FcPatternAddBool(pattern, FC_SCALABLE, 1);
122 +
123 + FcConfigSubstitute(NULL, pattern, FcMatchPattern);
124 + XftDefaultSubstitute(xw.dpy, xw.scr, pattern);
125 +
126 + if (xloadsparefont(pattern, FRC_NORMAL))
127 + die("can't open spare font %s\n", *fp);
128 +
129 + FcPatternDel(pattern, FC_SLANT);
130 + FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
131 + if (xloadsparefont(pattern, FRC_ITALIC))
132 + die("can't open spare font %s\n", *fp);
133 +
134 + FcPatternDel(pattern, FC_WEIGHT);
135 + FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
136 + if (xloadsparefont(pattern, FRC_ITALICBOLD))
137 + die("can't open spare font %s\n", *fp);
138 +
139 + FcPatternDel(pattern, FC_SLANT);
140 + FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN);
141 + if (xloadsparefont(pattern, FRC_BOLD))
142 + die("can't open spare font %s\n", *fp);
143 +
144 + FcPatternDestroy(pattern);
145 + }
146 +}
147 +
148 void
149 xunloadfont(Font *f)
150 {
151 @@ -1131,6 +1229,9 @@ xinit(int cols, int rows)
152 usedfont = (opt_font == NULL)? font : opt_font;
153 xloadfonts(usedfont, 0);
154
155 + /* spare fonts */
156 + xloadsparefonts();
157 +
158 /* colors */
159 xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
160 xloadcols();
161 --
162 2.37.1
163
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.