#ifndef GVPLUGIN_GDIPLUS_H
#define GVPLUGIN_GDIPLUS_H
+#include <memory>
#include <vector>
#include <Windows.h>
struct Layout
{
- Gdiplus::Font* font;
+ std::unique_ptr<Gdiplus::Font> font;
std::vector<WCHAR> text;
Layout(char *fontname, double fontsize, char* string);
- ~Layout();
};
static const int BYTES_PER_PIXEL = 4; /* bytes per pixel */
/* draw the text */
SolidBrush brush(Color(job->obj->pencolor.u.rgba [3], job->obj->pencolor.u.rgba [0], job->obj->pencolor.u.rgba [1], job->obj->pencolor.u.rgba [2]));
- context->DrawString(&layout->text[0], layout->text.size(), layout->font, PointF(p.x, -p.y), GetGenericTypographic(), &brush);
+ context->DrawString(&layout->text[0], layout->text.size(), layout->font.get(), PointF(p.x, -p.y), GetGenericTypographic(), &brush);
if (span->free_layout != &gdiplus_free_layout)
delete layout;
#include "config.h"
+#include <memory>
#include <stdlib.h>
#include <string.h>
0) == 0) {
found_font.lfHeight = (LONG)-fontsize;
found_font.lfWidth = 0;
- font = new Font(reference.hdc, &found_font);
+ font = std::unique_ptr<Font>(new Font(reference.hdc, &found_font));
}
else
- font = new Font(FontFamily::GenericSerif(), fontsize);
-}
-
-Layout::~Layout()
-{
- delete font;
+ font = std::unique_ptr<Font>(new Font(FontFamily::GenericSerif(), fontsize));
}
void gdiplus_free_layout(void *layout)
measureGraphics.MeasureString(
&layout->text[0],
layout->text.size(),
- layout->font,
+ layout->font.get(),
PointF(0.0f, 0.0f),
GetGenericTypographic(),
&boundingBox);