Sha256: c1925fb1fd0b7ec6ad52c9ccba567ed3173b799a25abf7416292aa5cc3766a7f

Contents?: true

Size: 1.45 KB

Versions: 34

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&
	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

34 entries across 34 versions & 1 rubygems

Version Path
rays-0.1.47 src/win32/font.cpp
rays-0.1.46 src/win32/font.cpp
rays-0.1.45 src/win32/font.cpp
rays-0.1.44 src/win32/font.cpp
rays-0.1.43 src/win32/font.cpp
rays-0.1.42 src/win32/font.cpp
rays-0.1.40 src/win32/font.cpp
rays-0.1.39 src/win32/font.cpp
rays-0.1.38 src/win32/font.cpp
rays-0.1.37 src/win32/font.cpp
rays-0.1.36 src/win32/font.cpp
rays-0.1.35 src/win32/font.cpp
rays-0.1.34 src/win32/font.cpp
rays-0.1.33 src/win32/font.cpp
rays-0.1.32 src/win32/font.cpp
rays-0.1.31 src/win32/font.cpp
rays-0.1.30 src/win32/font.cpp
rays-0.1.29 src/win32/font.cpp
rays-0.1.28 src/win32/font.cpp
rays-0.1.27 src/win32/font.cpp