Sha256: e38f156e5d679ce41360a4c62f5efc714dd61d14f51eb7a7f41dbb236e1aa787
Contents?: true
Size: 1.45 KB
Versions: 4
Compression:
Stored size: 1.45 KB
Contents
#include "font.h" namespace Rays { struct Font::Data { Win32::Font font; };// Window::Data Font::Font () { } Font::Font (const char* name, coord size) { self->font = Win32::Font(name, size); } Font::~Font () { } String Font::name () const { return self->font.name(); } coord Font::size () const { return self->font.size(); } bool Font::get_extent (coord* width, coord* height, const char* str) const { return self->font.get_extent(width, height, str); } Font::operator bool () const { return self && self->font; } bool Font::operator ! () const { return !operator bool(); } const Font& get_default_font () { static const Font FONT(NULL); return FONT; } void Font_draw_string ( const Font& font, HDC hdc, coord context_height, const char* str, coord x, coord y) { using namespace Win32; if (!font || !hdc || !str) argument_error(__FILE__, __LINE__); if (*str == '\0') return; coord width = 0, height = 0; if (!font.get_extent(&width, &height, str)) rays_error(__FILE__, __LINE__, "getting font extent failed."); DC dc = hdc; RECT rect = {x, y, x + (int) width, y + (int) height}; FillRect(dc.handle(), &rect, Brush(0, 0, 0).handle()); Win32::Font old = dc.font(); dc.set_font(font.self->font.handle()); BOOL ret = TextOutA(dc.handle(), x, y, str, strlen(str)); dc.set_font(old); if (ret == FALSE) rays_error(__FILE__, __LINE__, "drawing text failed."); } }// Rays
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rays-0.2.1 | src/win32/font.cpp |
rays-0.2 | src/win32/font.cpp |
rays-0.1.49 | src/win32/font.cpp |
rays-0.1.48 | src/win32/font.cpp |