Numworks Epsilon
1.4.1
Graphing Calculator Operating System
text.cpp
Go to the documentation of this file.
1
#include <
kandinsky/text.h
>
2
#include <string.h>
3
#include "small_font.h"
4
#include "large_font.h"
5
6
KDSize
KDText::stringSize
(
const
char
* text,
FontSize
size) {
7
if
(text ==
nullptr
) {
8
return
KDSizeZero
;
9
}
10
KDSize
commonCharSize =
charSize
(size);
11
KDSize
stringSize
=
KDSize
(0, commonCharSize.
height
());
12
while
(*text != 0) {
13
KDSize
cSize =
KDSize
(commonCharSize.
width
(), 0);
14
if
(*text ==
'\t'
) {
15
cSize =
KDSize
(
k_tabCharacterWidth
*commonCharSize.
width
(), 0);
16
}
17
if
(*text ==
'\n'
) {
18
cSize =
KDSize
(0, commonCharSize.
height
());
19
}
20
stringSize
=
KDSize
(
stringSize
.
width
()+cSize.
width
(),
stringSize
.
height
()+cSize.
height
());
21
text++;
22
}
23
return
stringSize
;
24
}
KDSize::width
constexpr KDCoordinate width() const
Definition:
size.h:10
text.h
KDText::stringSize
static KDSize stringSize(const char *text, FontSize size=FontSize::Large)
Definition:
text.cpp:6
KDSize
Definition:
size.h:6
KDSizeZero
constexpr KDSize KDSizeZero
Definition:
size.h:17
KDText::charSize
static constexpr KDSize charSize(FontSize size=FontSize::Large)
Definition:
text.h:16
KDText::FontSize
FontSize
Definition:
text.h:10
KDText::k_tabCharacterWidth
static constexpr int k_tabCharacterWidth
Definition:
text.h:14
KDSize::height
constexpr KDCoordinate height() const
Definition:
size.h:11
epsilon
kandinsky
src
text.cpp
Generated by
1.8.14