Commit ea6d003c authored by Davis King's avatar Davis King

Added more error handling to the nativefont. Also changed the

code so that the native font object isn't instantiated unless
you try to use it for something.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402454
parent 4d95091d
......@@ -24,7 +24,6 @@
#include "../logger.h"
#include <vector>
#include <set>
#include "../gui_widgets/fonts.h"
namespace dlib
{
......@@ -1570,7 +1569,8 @@ namespace dlib
int mcount;
char *def_str;
char fontset[256];
sprintf(fontset, "-*-*-medium-r-normal--%lu-*-*-*-", get_native_font()->height());
const long native_font_height = 12;
sprintf(fontset, "-*-*-medium-r-normal--%lu-*-*-*-", native_font_height);
XFontSet fs = XCreateFontSet(gui_core_kernel_2_globals::disp, fontset, &mlist, &mcount, &def_str);
xpoint.x = 0;
xpoint.y = 0;
......
......@@ -372,6 +372,8 @@ namespace nativefont
XFreeFontSet(d, fs);
}
fs = XCreateFontSet(d, fontset, &mlist, &mcount, &def_str);
if (fs == NULL)
throw dlib::gui_error("gui_error: XCreateFontSet() failure");
XFontSetExtents *extent;
extent = XExtentsOfFontSet(fs);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment