-/*
- * Font.cpp
- *
- * Created on: Aug 8, 2012
- * Author: holy
- */
-
#include "Font.h"
#include "../loader/Interpreter.h"
namespace graphics {
+int Font::StringWidth(const char *s) const {
+ int width(0), col(0);
+ for (int i(0); s[i]; ++i) {
+ if (s[i] == '\n') {
+ if (width < col) {
+ width = col;
+ }
+ col = 0;
+ } else {
+ ++col;
+ }
+ }
+ return (width < col ? col : width) * CharWidth();
+}
+
+int Font::StringHeight(const char *s) const {
+ if (*s == '\0') {
+ return 0;
+ }
+ int height(1);
+ for (; *s; ++s) {
+ if (*s == '\n') {
+ ++height;
+ }
+ }
+ return height * CharHeight();
+}
+
+
void Font::DrawChar(char c, SDL_Surface *dest, const Vector<int> &position) const {
if (!sprite) return;