mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[kandinsky] Get rid of KDText
This commit is contained in:
committed by
LeaNumworks
parent
f8beae3b86
commit
c183f0147e
@@ -14,7 +14,6 @@ objs += $(addprefix kandinsky/src/,\
|
||||
ion_context.o\
|
||||
point.o\
|
||||
rect.o\
|
||||
text.o\
|
||||
)
|
||||
|
||||
objs += kandinsky/src/external/lz4/lz4.o
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef KANDINSKY_TEXT_H
|
||||
#define KANDINSKY_TEXT_H
|
||||
|
||||
#include <kandinsky/size.h>
|
||||
#include "../src/large_font.h"
|
||||
#include "../src/small_font.h"
|
||||
|
||||
class KDText {
|
||||
public:
|
||||
enum class FontSize {
|
||||
Small,
|
||||
Large
|
||||
};
|
||||
constexpr static int k_tabCharacterWidth = 4;
|
||||
static KDSize stringSize(const char * text, FontSize size = FontSize::Large);
|
||||
constexpr static KDSize charSize(FontSize size = FontSize::Large) {
|
||||
return size == FontSize::Large ? KDSize(BITMAP_LargeFont_CHARACTER_WIDTH, BITMAP_LargeFont_CHARACTER_HEIGHT) : KDSize(BITMAP_SmallFont_CHARACTER_WIDTH, BITMAP_SmallFont_CHARACTER_HEIGHT);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user