summaryrefslogtreecommitdiff
path: root/Build/source/libs/graphite2/graphite2-src/src/gr_font.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/graphite2/graphite2-src/src/gr_font.cpp')
-rw-r--r--Build/source/libs/graphite2/graphite2-src/src/gr_font.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/Build/source/libs/graphite2/graphite2-src/src/gr_font.cpp b/Build/source/libs/graphite2/graphite2-src/src/gr_font.cpp
index ed70ab7381e..7470e1bb5f1 100644
--- a/Build/source/libs/graphite2/graphite2-src/src/gr_font.cpp
+++ b/Build/source/libs/graphite2/graphite2-src/src/gr_font.cpp
@@ -47,10 +47,16 @@ gr_font* gr_make_font(float ppm/*pixels per em*/, const gr_face *face)
gr_font* gr_make_font_with_ops(float ppm/*pixels per em*/, const void* appFontHandle/*non-NULL*/, const gr_font_ops * font_ops, const gr_face * face/*needed for scaling*/)
{ //the appFontHandle must stay alive all the time when the gr_font is alive. When finished with the gr_font, call destroy_gr_font
- if (face == 0) return 0;
+ if (face == 0 || ppm <= 0) return 0;
Font * const res = new Font(ppm, *face, appFontHandle, font_ops);
- return static_cast<gr_font*>(res);
+ if (*res)
+ return static_cast<gr_font*>(res);
+ else
+ {
+ delete res;
+ return 0;
+ }
}
gr_font* gr_make_font_with_advance_fn(float ppm/*pixels per em*/, const void* appFontHandle/*non-NULL*/, gr_advance_fn getAdvance, const gr_face * face/*needed for scaling*/)
@@ -61,7 +67,7 @@ gr_font* gr_make_font_with_advance_fn(float ppm/*pixels per em*/, const void* ap
void gr_font_destroy(gr_font *font)
{
- delete font;
+ delete static_cast<Font*>(font);
}