Added maxwidth, lines = font:getWrap(string, wrap) by feature request

This commit is contained in:
bart@bartbes.ath.cx
2010-06-12 15:35:54 +02:00
parent bb2f58c25c
commit 0188572124
4 changed files with 81 additions and 22 deletions
+16 -5
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
@@ -61,7 +61,7 @@ namespace opengl
* @param data The font data to construct from.
**/
Font(love::font::FontData * data);
virtual ~Font();
/**
@@ -104,7 +104,7 @@ namespace opengl
**/
int getWidth(const std::string & line) const;
int getWidth(const char * line) const;
/**
* Returns the width of the passed character.
*
@@ -112,6 +112,17 @@ namespace opengl
**/
int getWidth(const char character) const;
/**
* Returns the maximal width of a wrapped string
* and optionally the number of lines
*
* @param line A line of text
* @param wrap The number of pixels to wrap at
* @param lines Optional output of the number of lines needed
**/
int getWrap(const std::string & line, float wrap, int *lines = 0) const;
int getWrap(const char * line, float wrap, int *lines = 0) const;
/**
* Sets the line height (which should be a number to multiply the font size by,
* example: line height = 1.2 and size = 12 means that rendered line height = 12*1.2)