6663b6c9
adorian
projet complet av...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <kandinsky/text.h>
#include <string.h>
#include "small_font.h"
#include "large_font.h"
KDSize KDText::stringSize(const char * text, FontSize size) {
if (text == nullptr) {
return KDSizeZero;
}
KDSize commonCharSize = charSize(size);
KDSize stringSize = KDSize(0, commonCharSize.height());
while (*text != 0) {
KDSize cSize = KDSize(commonCharSize.width(), 0);
if (*text == '\t') {
cSize = KDSize(k_tabCharacterWidth*commonCharSize.width(), 0);
}
if (*text == '\n') {
cSize = KDSize(0, commonCharSize.height());
}
stringSize = KDSize(stringSize.width()+cSize.width(), stringSize.height()+cSize.height());
text++;
}
return stringSize;
}
|