mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-26 01:00:50 +01:00
25 lines
703 B
C++
25 lines
703 B
C++
#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;
|
|
}
|