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  }
21  text++;
22  }
23  return stringSize;
24 }
constexpr KDCoordinate width() const
Definition: size.h:10
static KDSize stringSize(const char *text, FontSize size=FontSize::Large)
Definition: text.cpp:6
Definition: size.h:6
constexpr KDSize KDSizeZero
Definition: size.h:17
static constexpr KDSize charSize(FontSize size=FontSize::Large)
Definition: text.h:16
FontSize
Definition: text.h:10
static constexpr int k_tabCharacterWidth
Definition: text.h:14
constexpr KDCoordinate height() const
Definition: size.h:11