summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/twm.c20
-rw-r--r--src/util.c19
-rw-r--r--src/util.h1
3 files changed, 40 insertions, 0 deletions
diff --git a/src/twm.c b/src/twm.c
index 1221bf8..d383873 100644
--- a/src/twm.c
+++ b/src/twm.c
@@ -813,6 +813,25 @@ CreateFonts(void)
Scr->HaveFonts = TRUE;
}
+static void
+DestroyFonts(void)
+{
+ for (int i = 0; i < NumScreens; ++i) {
+ ScreenInfo *scr = ScreenList[i];
+
+ if (!scr) {
+ continue;
+ }
+
+ DestroyFont(&scr->TitleBarFont);
+ DestroyFont(&scr->MenuFont);
+ DestroyFont(&scr->IconFont);
+ DestroyFont(&scr->SizeFont);
+ DestroyFont(&scr->IconManagerFont);
+ DestroyFont(&scr->DefaultFont);
+ }
+}
+
void
RestoreWithdrawnLocation(TwmWindow *tmp)
{
@@ -903,6 +922,7 @@ Done(XtPointer client_data _X_UNUSED, XtSignalId *si2 _X_UNUSED)
{
if (dpy) {
Reborder(CurrentTime);
+ DestroyFonts();
XCloseDisplay(dpy);
}
diff --git a/src/util.c b/src/util.c
index 9a04ac1..52f6148 100644
--- a/src/util.c
+++ b/src/util.c
@@ -607,6 +607,7 @@ FindFontSet(MyFont *font, const char *fontname)
twmVerbose("font for charset %s is lacking.",
missing_charset_list_return[i]);
}
+ XFreeStringList(missing_charset_list_return);
}
font_extents = XExtentsOfFontSet(font->fontset);
@@ -672,6 +673,24 @@ GetFont(MyFont *font)
}
}
+void
+DestroyFont(MyFont *font)
+{
+ if (!font) {
+ return;
+ }
+
+ if (font->fontset) {
+ XFreeFontSet(dpy, font->fontset);
+ font->fontset = NULL;
+ }
+
+ if (font->font) {
+ XFreeFont(dpy, font->font);
+ font->font = NULL;
+ }
+}
+
int
MyFont_TextWidth(MyFont *font, const char *string, int len)
{
diff --git a/src/util.h b/src/util.h
index 6adeed9..a7ded89 100644
--- a/src/util.h
+++ b/src/util.h
@@ -77,6 +77,7 @@ extern void LocateStandardColormaps(void);
extern void GetColor(int kind, Pixel *what, const char *name);
extern void GetColorValue(int kind, XColor *what, const char *name);
extern void GetFont(MyFont *font);
+extern void DestroyFont(MyFont *font);
extern int MyFont_TextWidth(MyFont *font, const char *string, int len);
extern void MyFont_DrawImageString(Display *dpy, Drawable d, MyFont *font,
GC gc, int x, int y, const char *string,