Changeset - r20330:9b5e242a7ad7
[Not reviewed]
master
0 2 0
zuu - 11 years ago 2013-06-09 12:21:44
zuu@openttd.org
(svn r25343) -Add: method to count the number of lines required to draw a string with line warping
2 files changed with 18 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -883,6 +883,23 @@ int GetStringHeight(StringID str, int ma
 
}
 

	
 
/**
 
 * Calculates number of lines of string. The string is changed to a multiline string if needed.
 
 * @param str string to check
 
 * @param maxw maximum string width
 
 * @return number of lines of string when it is drawn
 
 */
 
int GetStringLineCount(StringID str, int maxw)
 
{
 
	char buffer[DRAW_STRING_BUFFER];
 

	
 
	GetString(buffer, str, lastof(buffer));
 

	
 
	uint32 tmp = FormatStringLinebreaks(buffer, lastof(buffer), maxw);
 

	
 
	return 1 + GB(tmp, 0, 16);
 
}
 

	
 
/**
 
 * Calculate string bounding box for multi-line strings.
 
 * @param str        String to check.
 
 * @param suggestion Suggested bounding box.
src/gfx_func.h
Show inline comments
 
@@ -124,6 +124,7 @@ Dimension GetStringBoundingBox(const cha
 
Dimension GetStringBoundingBox(StringID strid);
 
uint32 FormatStringLinebreaks(char *str, const char *last, int maxw, FontSize start_fontsize = FS_NORMAL);
 
int GetStringHeight(StringID str, int maxw);
 
int GetStringLineCount(StringID str, int maxw);
 
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion);
 
Dimension GetStringMultiLineBoundingBox(const char *str, const Dimension &suggestion);
 
void LoadStringWidthTable(bool monospace = false);
0 comments (0 inline, 0 general)