diff --git a/ScriptingAPI-Documentation.md b/ScriptingAPI-Documentation.md
index a38000083..e94db5d88 100644
--- a/ScriptingAPI-Documentation.md
+++ b/ScriptingAPI-Documentation.md
@@ -84,9 +84,9 @@ are also displayed here.
The scripting API provides some functions which manipulate the BackLog. These functions are in he global scope:
- backlog_clear()
- backlog_post(string params,,,)
-- backlog_fontsize(float size)
+- backlog_fontsize(int size)
- backlog_isactive() : boolean result
-- backlog_fontrowspacing(float spacing)
+- backlog_fontrowspacing(int spacing)
### Renderer
This is the graphics renderer, which is also responsible for managing the scene graph which consists of keeping track of
@@ -146,7 +146,7 @@ Gives you the ability to render text with a custom font.
- [constructor]Font(opt string text)
- SetStyle(string fontstyle)
- SetText(opt string text)
-- SetSize(float size)
+- SetSize(int size)
- SetPos(Vector pos)
- SetSpacing(Vector spacing)
- SetAlign(WIFALIGN Halign, opt WIFALIGN Valign)
@@ -157,7 +157,7 @@ Gives you the ability to render text with a custom font.
- [outer]WIFALIGN_TOP : int
- [outer]WIFALIGN_BOTTOM : int
- GetText() : string result
-- GetSize() : float result
+- GetSize() : int result
- GetPos() : Vector result
- GetSpacing() : Vector result
- GetAlign() : WIFALIGN halign,valign
diff --git a/WickedEngine/Editor.cpp b/WickedEngine/Editor.cpp
index bf80ef19c..a392613ad 100644
--- a/WickedEngine/Editor.cpp
+++ b/WickedEngine/Editor.cpp
@@ -64,7 +64,7 @@ void Editor::Initialize()
wiHairParticle::Settings(400, 1000, 2000);
- wiFont::addFontStyle("basic");
+ //wiFont::addFontStyle("basic");
wiInputManager::GetInstance()->addXInput(new wiXInput());
renderComponent = new EditorComponent;
@@ -100,7 +100,7 @@ void EditorLoadingScreen::Compose()
{
__super::Compose();
- wiFont("Loading...", wiFontProps(wiRenderer::GetDevice()->GetScreenWidth() * 0.5f, wiRenderer::GetDevice()->GetScreenHeight() * 0.5f, 22,
+ wiFont("Loading...", wiFontProps(wiRenderer::GetDevice()->GetScreenWidth() / 2, wiRenderer::GetDevice()->GetScreenHeight() / 2, 22,
WIFALIGN_MID, WIFALIGN_MID)).Draw();
}
void EditorLoadingScreen::Unload()
@@ -245,7 +245,6 @@ void EditorComponent::Load()
wiButton* rendererWnd_Toggle = new wiButton("Renderer");
rendererWnd_Toggle->SetPos(XMFLOAT2(x += step, screenH - 40));
rendererWnd_Toggle->SetSize(XMFLOAT2(100, 40));
- rendererWnd_Toggle->SetFontScaling(0.3f);
rendererWnd_Toggle->OnClick([=](wiEventArgs args) {
rendererWnd->rendererWindow->SetVisible(!rendererWnd->rendererWindow->IsVisible());
});
@@ -254,7 +253,6 @@ void EditorComponent::Load()
wiButton* worldWnd_Toggle = new wiButton("World");
worldWnd_Toggle->SetPos(XMFLOAT2(x += step, screenH - 40));
worldWnd_Toggle->SetSize(XMFLOAT2(100, 40));
- worldWnd_Toggle->SetFontScaling(0.4f);
worldWnd_Toggle->OnClick([=](wiEventArgs args) {
worldWnd->worldWindow->SetVisible(!worldWnd->worldWindow->IsVisible());
});
@@ -263,7 +261,6 @@ void EditorComponent::Load()
wiButton* objectWnd_Toggle = new wiButton("Object");
objectWnd_Toggle->SetPos(XMFLOAT2(x += step, screenH - 40));
objectWnd_Toggle->SetSize(XMFLOAT2(100, 40));
- objectWnd_Toggle->SetFontScaling(0.4f);
objectWnd_Toggle->OnClick([=](wiEventArgs args) {
objectWnd->objectWindow->SetVisible(!objectWnd->objectWindow->IsVisible());
});
@@ -272,7 +269,6 @@ void EditorComponent::Load()
wiButton* meshWnd_Toggle = new wiButton("Mesh");
meshWnd_Toggle->SetPos(XMFLOAT2(x += step, screenH - 40));
meshWnd_Toggle->SetSize(XMFLOAT2(100, 40));
- meshWnd_Toggle->SetFontScaling(0.4f);
meshWnd_Toggle->OnClick([=](wiEventArgs args) {
meshWnd->meshWindow->SetVisible(!meshWnd->meshWindow->IsVisible());
});
@@ -281,7 +277,6 @@ void EditorComponent::Load()
wiButton* materialWnd_Toggle = new wiButton("Material");
materialWnd_Toggle->SetPos(XMFLOAT2(x += step, screenH - 40));
materialWnd_Toggle->SetSize(XMFLOAT2(100, 40));
- materialWnd_Toggle->SetFontScaling(0.3f);
materialWnd_Toggle->OnClick([=](wiEventArgs args) {
materialWnd->materialWindow->SetVisible(!materialWnd->materialWindow->IsVisible());
});
@@ -290,7 +285,6 @@ void EditorComponent::Load()
wiButton* postprocessWnd_Toggle = new wiButton("PostProcess");
postprocessWnd_Toggle->SetPos(XMFLOAT2(x += step, screenH - 40));
postprocessWnd_Toggle->SetSize(XMFLOAT2(100, 40));
- postprocessWnd_Toggle->SetFontScaling(0.22f);
postprocessWnd_Toggle->OnClick([=](wiEventArgs args) {
postprocessWnd->ppWindow->SetVisible(!postprocessWnd->ppWindow->IsVisible());
});
@@ -299,7 +293,6 @@ void EditorComponent::Load()
wiButton* cameraWnd_Toggle = new wiButton("Camera");
cameraWnd_Toggle->SetPos(XMFLOAT2(x += step, screenH - 40));
cameraWnd_Toggle->SetSize(XMFLOAT2(100, 40));
- cameraWnd_Toggle->SetFontScaling(0.3f);
cameraWnd_Toggle->OnClick([=](wiEventArgs args) {
cameraWnd->cameraWindow->SetVisible(!cameraWnd->cameraWindow->IsVisible());
});
@@ -308,7 +301,6 @@ void EditorComponent::Load()
wiButton* envProbeWnd_Toggle = new wiButton("EnvProbe");
envProbeWnd_Toggle->SetPos(XMFLOAT2(x += step, screenH - 40));
envProbeWnd_Toggle->SetSize(XMFLOAT2(100, 40));
- envProbeWnd_Toggle->SetFontScaling(0.3f);
envProbeWnd_Toggle->OnClick([=](wiEventArgs args) {
envProbeWnd->envProbeWindow->SetVisible(!envProbeWnd->envProbeWindow->IsVisible());
});
@@ -317,7 +309,6 @@ void EditorComponent::Load()
wiButton* decalWnd_Toggle = new wiButton("Decal");
decalWnd_Toggle->SetPos(XMFLOAT2(x += step, screenH - 40));
decalWnd_Toggle->SetSize(XMFLOAT2(100, 40));
- decalWnd_Toggle->SetFontScaling(0.3f);
decalWnd_Toggle->OnClick([=](wiEventArgs args) {
decalWnd->decalWindow->SetVisible(!decalWnd->decalWindow->IsVisible());
});
@@ -326,7 +317,6 @@ void EditorComponent::Load()
wiButton* lightWnd_Toggle = new wiButton("Light");
lightWnd_Toggle->SetPos(XMFLOAT2(x += step, screenH - 40));
lightWnd_Toggle->SetSize(XMFLOAT2(100, 40));
- lightWnd_Toggle->SetFontScaling(0.3f);
lightWnd_Toggle->OnClick([=](wiEventArgs args) {
lightWnd->lightWindow->SetVisible(!lightWnd->lightWindow->IsVisible());
});
@@ -378,7 +368,6 @@ void EditorComponent::Load()
wiButton* saveButton = new wiButton("Save");
saveButton->SetPos(XMFLOAT2(screenW - 470, 0));
saveButton->SetSize(XMFLOAT2(100, 40));
- saveButton->SetFontScaling(0.25f);
saveButton->SetColor(wiColor(0, 198, 101, 200), wiWidget::WIDGETSTATE::IDLE);
saveButton->SetColor(wiColor(0, 255, 140, 255), wiWidget::WIDGETSTATE::FOCUS);
saveButton->OnClick([=](wiEventArgs args) {
@@ -442,7 +431,6 @@ void EditorComponent::Load()
wiButton* modelButton = new wiButton("LoadModel");
modelButton->SetPos(XMFLOAT2(screenW - 365, 0));
modelButton->SetSize(XMFLOAT2(100, 40));
- modelButton->SetFontScaling(0.25f);
modelButton->SetColor(wiColor(0, 89, 255, 200), wiWidget::WIDGETSTATE::IDLE);
modelButton->SetColor(wiColor(112, 155, 255, 255), wiWidget::WIDGETSTATE::FOCUS);
modelButton->OnClick([=](wiEventArgs args) {
@@ -496,7 +484,6 @@ void EditorComponent::Load()
wiButton* skyButton = new wiButton("LoadSky");
skyButton->SetPos(XMFLOAT2(screenW - 260, 0));
skyButton->SetSize(XMFLOAT2(100, 18));
- skyButton->SetFontScaling(0.5f);
skyButton->SetColor(wiColor(0, 89, 255, 200), wiWidget::WIDGETSTATE::IDLE);
skyButton->SetColor(wiColor(112, 155, 255, 255), wiWidget::WIDGETSTATE::FOCUS);
skyButton->OnClick([=](wiEventArgs args) {
@@ -540,7 +527,6 @@ void EditorComponent::Load()
wiButton* colorGradingButton = new wiButton("ColorGrading");
colorGradingButton->SetPos(XMFLOAT2(screenW - 260, 22));
colorGradingButton->SetSize(XMFLOAT2(100, 18));
- colorGradingButton->SetFontScaling(0.45f);
colorGradingButton->SetColor(wiColor(0, 89, 255, 200), wiWidget::WIDGETSTATE::IDLE);
colorGradingButton->SetColor(wiColor(112, 155, 255, 255), wiWidget::WIDGETSTATE::FOCUS);
colorGradingButton->OnClick([=](wiEventArgs args) {
@@ -584,7 +570,6 @@ void EditorComponent::Load()
wiButton* clearButton = new wiButton("ClearWorld");
clearButton->SetPos(XMFLOAT2(screenW - 155, 0));
clearButton->SetSize(XMFLOAT2(100, 40));
- clearButton->SetFontScaling(0.25f);
clearButton->SetColor(wiColor(190, 0, 0, 200), wiWidget::WIDGETSTATE::IDLE);
clearButton->SetColor(wiColor(255, 0, 0, 255), wiWidget::WIDGETSTATE::FOCUS);
clearButton->OnClick([](wiEventArgs args) {
@@ -598,7 +583,6 @@ void EditorComponent::Load()
wiButton* exitButton = new wiButton("X");
exitButton->SetPos(XMFLOAT2(screenW - 50, 0));
exitButton->SetSize(XMFLOAT2(50, 40));
- exitButton->SetFontScaling(0.25f);
exitButton->SetColor(wiColor(190, 0, 0, 200), wiWidget::WIDGETSTATE::IDLE);
exitButton->SetColor(wiColor(255, 0, 0, 255), wiWidget::WIDGETSTATE::FOCUS);
exitButton->OnClick([](wiEventArgs args) {
diff --git a/WickedEngine/LightWindow.cpp b/WickedEngine/LightWindow.cpp
index f43dc8bf6..60e4b89e9 100644
--- a/WickedEngine/LightWindow.cpp
+++ b/WickedEngine/LightWindow.cpp
@@ -2,7 +2,7 @@
#include "LightWindow.h"
-LightWindow::LightWindow(wiGUI* gui) : GUI(gui)
+LightWindow::LightWindow(wiGUI* gui) : GUI(gui), light(nullptr)
{
assert(GUI && "Invalid GUI!");
diff --git a/WickedEngine/MainComponent.cpp b/WickedEngine/MainComponent.cpp
index 034fd15fc..ea8d6d4e0 100644
--- a/WickedEngine/MainComponent.cpp
+++ b/WickedEngine/MainComponent.cpp
@@ -177,7 +177,7 @@ void MainComponent::Compose()
{
ss << "CPU: " << wiCpuInfo::GetCpuPercentage() << "%" << endl;
}
- wiFont(ss.str(), wiFontProps(0, 0, infoDisplay.size, WIFALIGN_LEFT, WIFALIGN_TOP, -2)).Draw();
+ wiFont(ss.str(), wiFontProps(0, 0, infoDisplay.size, WIFALIGN_LEFT, WIFALIGN_TOP)).Draw();
}
// Draw the color grading palette
diff --git a/WickedEngine/MainComponent.h b/WickedEngine/MainComponent.h
index 284e194cc..18d32b523 100644
--- a/WickedEngine/MainComponent.h
+++ b/WickedEngine/MainComponent.h
@@ -68,10 +68,10 @@ public:
// display resolution info
bool resolution;
// text size
- float size;
+ int size;
InfoDisplayer() :active(false), watermark(true), fpsinfo(true), cpuinfo(true),
- resolution(false), size(12.f)
+ resolution(false), size(-1)
{}
};
// display all-time engine information text
diff --git a/WickedEngine/WickedEngine_SHARED.vcxitems b/WickedEngine/WickedEngine_SHARED.vcxitems
index 6b760301b..29fa75a0d 100644
--- a/WickedEngine/WickedEngine_SHARED.vcxitems
+++ b/WickedEngine/WickedEngine_SHARED.vcxitems
@@ -684,7 +684,7 @@
-
+
true
@@ -695,14 +695,13 @@
-
- true
- Document
-
+
+ true
+
\ No newline at end of file
diff --git a/WickedEngine/WickedEngine_SHARED.vcxitems.filters b/WickedEngine/WickedEngine_SHARED.vcxitems.filters
index 4a9905be8..eda309f00 100644
--- a/WickedEngine/WickedEngine_SHARED.vcxitems.filters
+++ b/WickedEngine/WickedEngine_SHARED.vcxitems.filters
@@ -1852,24 +1852,24 @@
-
- fonts
-
logo
+
+ fonts
+
-
- fonts
-
+
+ fonts
+
\ No newline at end of file
diff --git a/WickedEngine/fonts/basic.dds b/WickedEngine/fonts/basic.dds
deleted file mode 100644
index c4488731c..000000000
Binary files a/WickedEngine/fonts/basic.dds and /dev/null differ
diff --git a/WickedEngine/fonts/basic.wifont b/WickedEngine/fonts/basic.wifont
deleted file mode 100644
index dac8c9db5..000000000
--- a/WickedEngine/fonts/basic.wifont
+++ /dev/null
@@ -1,94 +0,0 @@
-20
-25
-65 0 0 25
-66 1 0 25
-67 2 0 25
-68 3 0 25
-69 4 0 25
-70 5 0 25
-71 6 0 25
-72 7 0 25
-73 8 0 25
-74 9 0 25
-75 0 1 25
-76 1 1 25
-77 2 1 25
-78 3 1 25
-79 4 1 25
-80 5 1 25
-81 6 1 25
-82 7 1 25
-83 8 1 25
-84 9 1 25
-85 0 2 25
-86 1 2 25
-87 2 2 25
-88 3 2 25
-89 4 2 25
-90 5 2 25
-97 0 3 25
-98 1 3 25
-99 2 3 25
-100 3 3 25
-101 4 3 25
-102 5 3 25
-103 6 3 25
-104 7 3 25
-105 8 3 25
-106 9 3 25
-107 0 4 25
-108 1 4 25
-109 2 4 25
-110 3 4 25
-111 4 4 25
-112 5 4 25
-113 6 4 25
-114 7 4 25
-115 8 4 25
-116 9 4 25
-117 0 5 25
-118 1 5 25
-119 2 5 25
-120 3 5 25
-121 4 5 25
-122 5 5 25
-48 0 6 25
-49 1 6 25
-50 2 6 25
-51 3 6 25
-52 4 6 25
-53 5 6 25
-54 6 6 25
-55 7 6 25
-56 8 6 25
-57 9 6 25
-46 0 7 25
-44 1 7 25
-47 2 7 25
-37 3 7 25
-35 4 7 25
-64 5 7 25
-45 6 7 25
-43 7 7 25
-92 8 7 25
-123 7 9 25
-124 9 7 25
-125 8 9 25
-38 0 8 25
-60 1 8 25
-62 2 8 25
-91 3 8 25
-93 4 8 25
-40 5 8 25
-41 6 8 25
-39 7 8 25
-34 8 8 25
-33 9 8 25
-63 0 9 25
-58 1 9 25
-59 2 9 25
-95 3 9 25
-61 4 9 25
-94 5 9 25
-126 6 9 25
-42 9 9 25
diff --git a/WickedEngine/fonts/default_font.dds b/WickedEngine/fonts/default_font.dds
new file mode 100644
index 000000000..7bb66a38c
Binary files /dev/null and b/WickedEngine/fonts/default_font.dds differ
diff --git a/WickedEngine/fonts/default_font.wifont b/WickedEngine/fonts/default_font.wifont
new file mode 100644
index 000000000..e228f084f
--- /dev/null
+++ b/WickedEngine/fonts/default_font.wifont
@@ -0,0 +1,95 @@
+lineHeight= 16
+33 ! 0.0 0.000976563 1
+34 " 0.00195313 0.00488281 3
+35 # 0.00585938 0.0136719 8
+36 $ 0.0146484 0.0195313 5
+37 % 0.0205078 0.0302734 10
+38 & 0.03125 0.0390625 8
+39 ' 0.0400391 0.0410156 1
+40 ( 0.0419922 0.0449219 3
+41 ) 0.0458984 0.0488281 3
+42 * 0.0498047 0.0546875 5
+43 + 0.0556641 0.0625 7
+44 , 0.0634766 0.0644531 1
+45 - 0.0654297 0.0683594 3
+46 . 0.0693359 0.0703125 1
+47 / 0.0712891 0.0751953 4
+48 0 0.0761719 0.0820313 6
+49 1 0.0830078 0.0859375 3
+50 2 0.0869141 0.0927734 6
+51 3 0.09375 0.0996094 6
+52 4 0.100586 0.106445 6
+53 5 0.107422 0.113281 6
+54 6 0.114258 0.120117 6
+55 7 0.121094 0.126953 6
+56 8 0.12793 0.133789 6
+57 9 0.134766 0.140625 6
+58 : 0.141602 0.142578 1
+59 ; 0.143555 0.144531 1
+60 < 0.145508 0.151367 6
+61 = 0.152344 0.15918 7
+62 > 0.160156 0.166016 6
+63 ? 0.166992 0.171875 5
+64 @ 0.172852 0.18457 12
+65 A 0.185547 0.194336 9
+66 B 0.195313 0.202148 7
+67 C 0.203125 0.209961 7
+68 D 0.210938 0.217773 7
+69 E 0.21875 0.225586 7
+70 F 0.226563 0.232422 6
+71 G 0.233398 0.241211 8
+72 H 0.242188 0.249023 7
+73 I 0.25 0.250977 1
+74 J 0.251953 0.256836 5
+75 K 0.257813 0.265625 8
+76 L 0.266602 0.272461 6
+77 M 0.273438 0.282227 9
+78 N 0.283203 0.290039 7
+79 O 0.291016 0.298828 8
+80 P 0.299805 0.306641 7
+81 Q 0.307617 0.31543 8
+82 R 0.316406 0.323242 7
+83 S 0.324219 0.331055 7
+84 T 0.332031 0.338867 7
+85 U 0.339844 0.34668 7
+86 V 0.347656 0.356445 9
+87 W 0.357422 0.370117 13
+88 X 0.371094 0.37793 7
+89 Y 0.378906 0.385742 7
+90 Z 0.386719 0.393555 7
+91 [ 0.394531 0.396484 2
+92 \ 0.397461 0.401367 4
+93 ] 0.402344 0.404297 2
+94 ^ 0.405273 0.410156 5
+95 _ 0.411133 0.417969 7
+96 ` 0.418945 0.420898 2
+97 a 0.421875 0.426758 5
+98 b 0.427734 0.432617 5
+99 c 0.433594 0.438477 5
+100 d 0.439453 0.444336 5
+101 e 0.445313 0.450195 5
+102 f 0.451172 0.455078 4
+103 g 0.456055 0.460938 5
+104 h 0.461914 0.466797 5
+105 i 0.467773 0.46875 1
+106 j 0.469727 0.472656 3
+107 k 0.473633 0.478516 5
+108 l 0.479492 0.480469 1
+109 m 0.481445 0.490234 9
+110 n 0.491211 0.496094 5
+111 o 0.49707 0.501953 5
+112 p 0.50293 0.507813 5
+113 q 0.508789 0.513672 5
+114 r 0.514648 0.517578 3
+115 s 0.518555 0.523438 5
+116 t 0.524414 0.527344 3
+117 u 0.52832 0.533203 5
+118 v 0.53418 0.539063 5
+119 w 0.540039 0.548828 9
+120 x 0.549805 0.554688 5
+121 y 0.555664 0.560547 5
+122 z 0.561523 0.566406 5
+123 { 0.567383 0.570313 3
+124 | 0.571289 0.572266 1
+125 } 0.573242 0.576172 3
+126 ~ 0.577148 0.583984 7
\ No newline at end of file
diff --git a/WickedEngine/wiBackLog.cpp b/WickedEngine/wiBackLog.cpp
index 5c0787a6c..d429b2848 100644
--- a/WickedEngine/wiBackLog.cpp
+++ b/WickedEngine/wiBackLog.cpp
@@ -28,7 +28,7 @@ void wiBackLog::Initialize(){
inputArea=stringstream("");
const unsigned char colorData[] = { 0, 0, 43, 200, 43, 31, 141, 223 };
wiTextureHelper::CreateTexture(backgroundTex, colorData, 1, 2, 4);
- font = wiFont("", wiFontProps(5, 0, 15, WIFALIGN_LEFT, WIFALIGN_BOTTOM, -8));
+ font = wiFont("", wiFontProps(5, 0, -1, WIFALIGN_LEFT, WIFALIGN_BOTTOM));
}
void wiBackLog::CleanUp(){
stream.clear();
@@ -71,9 +71,9 @@ void wiBackLog::Draw(){
fx.opacity = wiMath::Lerp(1, 0, -pos / wiRenderer::GetDevice()->GetScreenHeight());
wiImage::Draw(backgroundTex, fx);
font.SetText(getText());
- font.props.posY = wiRenderer::GetDevice()->GetScreenHeight() - 75 + pos + scroll;
+ font.props.posY = wiRenderer::GetDevice()->GetScreenHeight() - 75 + (int)pos + (int)scroll;
font.Draw();
- wiFont(inputArea.str().c_str(), wiFontProps(5, (float)wiRenderer::GetDevice()->GetScreenHeight() - 10, 20, WIFALIGN_LEFT, WIFALIGN_BOTTOM, -8)).Draw();
+ wiFont(inputArea.str().c_str(), wiFontProps(5, wiRenderer::GetDevice()->GetScreenHeight() - 10, -1, WIFALIGN_LEFT, WIFALIGN_BOTTOM)).Draw();
}
}
diff --git a/WickedEngine/wiBackLog_BindLua.cpp b/WickedEngine/wiBackLog_BindLua.cpp
index 5c31487a7..6340ca197 100644
--- a/WickedEngine/wiBackLog_BindLua.cpp
+++ b/WickedEngine/wiBackLog_BindLua.cpp
@@ -31,10 +31,10 @@ namespace wiBackLog_BindLua
if (argc > 0)
{
- wiBackLog::font.props.size = wiLua::SGetFloat(L, 1);
+ wiBackLog::font.props.size = wiLua::SGetInt(L, 1);
}
else
- wiLua::SError(L, "backlog_fontsize(float val) not enough arguments!");
+ wiLua::SError(L, "backlog_fontsize(int val) not enough arguments!");
return 0;
}
@@ -48,10 +48,10 @@ namespace wiBackLog_BindLua
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
- wiBackLog::font.props.spacingY = wiLua::SGetFloat(L, 1);
+ wiBackLog::font.props.spacingY = wiLua::SGetInt(L, 1);
}
else
- wiLua::SError(L, "backlog_fontrowspacing(float val) not enough arguments!");
+ wiLua::SError(L, "backlog_fontrowspacing(int val) not enough arguments!");
return 0;
}
diff --git a/WickedEngine/wiFont.cpp b/WickedEngine/wiFont.cpp
index 7463581ba..9c6988bd7 100644
--- a/WickedEngine/wiFont.cpp
+++ b/WickedEngine/wiFont.cpp
@@ -7,6 +7,8 @@
using namespace wiGraphicsTypes;
+#define WHITESPACE_SIZE 3
+
GPUBuffer *wiFont::vertexBuffer = nullptr, *wiFont::indexBuffer = nullptr;
VertexLayout *wiFont::vertexLayout = nullptr;
@@ -141,6 +143,9 @@ void wiFont::SetUpStaticComponents()
LoadShaders();
LoadVertexBuffer();
LoadIndices();
+
+ // add default font:
+ addFontStyle("default_font");
}
void wiFont::CleanUpStatic()
{
@@ -174,51 +179,51 @@ void wiFont::BindPersistentState(GRAPHICSTHREAD threadID)
void wiFont::ModifyGeo(const wstring& text, wiFontProps props, int style, GRAPHICSTHREAD threadID)
{
- const float fontSize = (props.size < 0 ? fontStyles[style].recSize : props.size);
+ const int lineHeight = (props.size < 0 ? fontStyles[style].lineHeight : props.size);
+ const float relativeSize = (props.size < 0 ? 1 : (float)props.size / (float)fontStyles[style].lineHeight);
- float line = 0, pos = 0;
+ int line = 0;
+ int pos = 0;
vertexList.resize(text.length() * 4);
- for (unsigned int i = 0; iCreateBuffer( &bd, NULL, vertexBuffer );
+ GPUBufferDesc bd;
+ ZeroMemory(&bd, sizeof(bd));
+ bd.Usage = USAGE_DYNAMIC;
+ bd.ByteWidth = sizeof(Vertex) * MAX_TEXT * 4;
+ bd.BindFlags = BIND_VERTEX_BUFFER;
+ bd.CPUAccessFlags = CPU_ACCESS_WRITE;
+ vertexBuffer = new GPUBuffer;
+ wiRenderer::GetDevice()->CreateBuffer(&bd, NULL, vertexBuffer);
}
void wiFont::LoadIndices()
{
std::vectorindices;
- indices.resize(MAX_TEXT*6);
- for(unsigned long i=0;iCreateBuffer( &bd, &InitData, indexBuffer );
+ wiRenderer::GetDevice()->CreateBuffer(&bd, &InitData, indexBuffer);
}
-void wiFont::Draw(GRAPHICSTHREAD threadID, bool scissorTest){
+void wiFont::Draw(GRAPHICSTHREAD threadID, bool scissorTest)
+{
wiFontProps newProps = props;
if(props.h_align==WIFALIGN_CENTER || props.h_align==WIFALIGN_MID)
- newProps.posX-= textWidth()*0.5f;
+ newProps.posX-= textWidth()/2;
else if(props.h_align==WIFALIGN_RIGHT)
newProps.posX -= textWidth();
if (props.v_align == WIFALIGN_CENTER || props.h_align == WIFALIGN_MID)
- newProps.posY -= textHeight()*0.5f;
+ newProps.posY -= textHeight()/2;
else if(props.v_align==WIFALIGN_BOTTOM)
newProps.posY -= textHeight();
@@ -303,7 +309,7 @@ void wiFont::Draw(GRAPHICSTHREAD threadID, bool scissorTest){
ConstantBuffer cb;
cb.mTransform = XMMatrixTranspose(
- XMMatrixTranslation(newProps.posX, newProps.posY, 0)
+ XMMatrixTranslation((float)newProps.posX, (float)newProps.posY, 0)
* device->GetScreenProjection()
);
@@ -328,39 +334,49 @@ void wiFont::Draw(GRAPHICSTHREAD threadID, bool scissorTest){
int wiFont::textWidth()
{
- int i=0;
- int max=0,lineW=0;
- int len=(int)text.length();
- while(iadd(ss1.str());
texWidth = texture->GetDesc().Width;
texHeight = texture->GetDesc().Height;
- file>>recSize>>charSize;
- int i=0;
- while(!file.eof()){
- i++;
- int code=0;
- file>>code;
- lookup[code].code=code;
- file>>lookup[code].offX>>lookup[code].offY>>lookup[code].width;
+ //file>>recSize>>charSize;
+ //int i=0;
+ //while(!file.eof()){
+ // i++;
+ // int code=0;
+ // file>>code;
+ // lookup[code].code=code;
+ // file>>lookup[code].offX>>lookup[code].offY>>lookup[code].width;
+ //}
+
+ string voidStr;
+ file >> voidStr >> lineHeight;
+ while (!file.eof())
+ {
+ int code = 0;
+ file >> code;
+ lookup[code].ascii = code;
+ file >> lookup[code].character >> lookup[code].left >> lookup[code].right >> lookup[code].pixelWidth;
}
+
+
file.close();
}
- else {
+ else
+ {
wiHelper::messageBox(name, "Could not load Font Data: " + ss.str());
}
}
diff --git a/WickedEngine/wiFont.h b/WickedEngine/wiFont.h
index 4c3bc6183..c74abe656 100644
--- a/WickedEngine/wiFont.h
+++ b/WickedEngine/wiFont.h
@@ -21,13 +21,13 @@ enum wiFontAlign
class wiFontProps
{
public:
- float size;
- float spacingX, spacingY;
- float posX, posY;
+ int size;
+ int spacingX, spacingY;
+ int posX, posY;
wiFontAlign h_align, v_align;
- wiFontProps(float posX = 0, float posY = 0, float size = 14, wiFontAlign h_align = WIFALIGN_LEFT, wiFontAlign v_align = WIFALIGN_TOP
- , float spacingX = 0, float spacingY = 0)
+ wiFontProps(int posX = 0, int posY = 0, int size = -1, wiFontAlign h_align = WIFALIGN_LEFT, wiFontAlign v_align = WIFALIGN_TOP
+ , int spacingX = 2, int spacingY = 1)
:posX(posX), posY(posY), size(size), h_align(h_align), v_align(v_align), spacingX(spacingX), spacingY(spacingY)
{}
};
@@ -78,11 +78,15 @@ private:
wiGraphicsTypes::Texture2D* texture;
struct LookUp{
- int code;
- int offX,offY,width;
+ int ascii;
+ char character;
+ float left;
+ float right;
+ int pixelWidth;
};
LookUp lookup[128];
- int texWidth,texHeight,charSize,recSize;
+ int texWidth, texHeight;
+ int lineHeight;
wiFontStyle(){}
wiFontStyle(const string& newName);
diff --git a/WickedEngine/wiFont_BindLua.cpp b/WickedEngine/wiFont_BindLua.cpp
index 4e4e8cba2..f404c984c 100644
--- a/WickedEngine/wiFont_BindLua.cpp
+++ b/WickedEngine/wiFont_BindLua.cpp
@@ -78,10 +78,10 @@ int wiFont_BindLua::SetSize(lua_State* L)
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
- font->props.size = wiLua::SGetFloat(L, 1);
+ font->props.size = wiLua::SGetInt(L, 1);
}
else
- wiLua::SError(L, "SetSize(float size) not enough arguments!");
+ wiLua::SError(L, "SetSize(int size) not enough arguments!");
return 0;
}
int wiFont_BindLua::SetPos(lua_State* L)
@@ -92,11 +92,11 @@ int wiFont_BindLua::SetPos(lua_State* L)
Vector_BindLua* param = Luna::lightcheck(L, 1);
if (param != nullptr)
{
- font->props.posX = XMVectorGetX(param->vector);
- font->props.posY = XMVectorGetY(param->vector);
+ font->props.posX = (int)XMVectorGetX(param->vector);
+ font->props.posY = (int)XMVectorGetY(param->vector);
}
else
- wiLua::SError(L, "SetSize(Vector pos) argument is not a vector!");
+ wiLua::SError(L, "SetPos(Vector pos) argument is not a vector!");
}
else
wiLua::SError(L, "SetPos(Vector pos) not enough arguments!");
@@ -110,8 +110,8 @@ int wiFont_BindLua::SetSpacing(lua_State* L)
Vector_BindLua* param = Luna::lightcheck(L, 1);
if (param != nullptr)
{
- font->props.spacingX = XMVectorGetX(param->vector);
- font->props.spacingY = XMVectorGetY(param->vector);
+ font->props.spacingX = (int)XMVectorGetX(param->vector);
+ font->props.spacingY = (int)XMVectorGetY(param->vector);
}
else
wiLua::SError(L, "SetSpacing(Vector spacing) argument is not a vector!");
@@ -143,17 +143,17 @@ int wiFont_BindLua::GetText(lua_State* L)
}
int wiFont_BindLua::GetSize(lua_State* L)
{
- wiLua::SSetFloat(L, font->props.size);
+ wiLua::SSetInt(L, font->props.size);
return 1;
}
int wiFont_BindLua::GetPos(lua_State* L)
{
- Luna::push(L, new Vector_BindLua(XMVectorSet(font->props.posX, font->props.posY, 0, 0)));
+ Luna::push(L, new Vector_BindLua(XMVectorSet((float)font->props.posX, (float)font->props.posY, 0, 0)));
return 1;
}
int wiFont_BindLua::GetSpacing(lua_State* L)
{
- Luna::push(L, new Vector_BindLua(XMVectorSet(font->props.spacingX, font->props.spacingY, 0, 0)));
+ Luna::push(L, new Vector_BindLua(XMVectorSet((float)font->props.spacingX, (float)font->props.spacingY, 0, 0)));
return 1;
}
int wiFont_BindLua::GetAlign(lua_State* L)
diff --git a/WickedEngine/wiWidget.cpp b/WickedEngine/wiWidget.cpp
index 8da0ba2a4..ab6460d9a 100644
--- a/WickedEngine/wiWidget.cpp
+++ b/WickedEngine/wiWidget.cpp
@@ -12,7 +12,6 @@ using namespace wiGraphicsTypes;
wiWidget::wiWidget():Transform()
{
- SetFontScaling(0.5f);
state = IDLE;
enabled = true;
visible = true;
@@ -127,18 +126,6 @@ wiColor wiWidget::GetColor()
}
return retVal;
}
-float wiWidget::GetScaledFontSize()
-{
- return GetFontScaling() * min(scale.x, scale.y);
-}
-void wiWidget::SetFontScaling(float val)
-{
- fontScaling = val;
-}
-float wiWidget::GetFontScaling()
-{
- return fontScaling;
-}
void wiWidget::SetScissorRect(const wiGraphicsTypes::Rect& rect)
{
scissorRect = rect;
@@ -284,7 +271,7 @@ void wiButton::Render(wiGUI* gui)
scissorRect.right = (LONG)(translation.x + scale.x);
scissorRect.top = (LONG)(translation.y);
wiRenderer::GetDevice()->SetScissorRects(1, &scissorRect, gui->GetGraphicsThread());
- wiFont(text, wiFontProps(translation.x + scale.x*0.5f, translation.y + scale.y*0.5f, GetScaledFontSize(), WIFALIGN_CENTER, WIFALIGN_CENTER)).Draw(gui->GetGraphicsThread(), true);
+ wiFont(text, wiFontProps((int)(translation.x + scale.x*0.5f), (int)(translation.y + scale.y*0.5f), -1, WIFALIGN_CENTER, WIFALIGN_CENTER)).Draw(gui->GetGraphicsThread(), true);
}
void wiButton::OnClick(function func)
@@ -351,7 +338,7 @@ void wiLabel::Render(wiGUI* gui)
scissorRect.right = (LONG)(translation.x + scale.x);
scissorRect.top = (LONG)(translation.y);
wiRenderer::GetDevice()->SetScissorRects(1, &scissorRect, gui->GetGraphicsThread());
- wiFont(text, wiFontProps(translation.x, translation.y, GetScaledFontSize(), WIFALIGN_LEFT, WIFALIGN_TOP)).Draw(gui->GetGraphicsThread(), true);
+ wiFont(text, wiFontProps((int)translation.x, (int)translation.y, -1, WIFALIGN_LEFT, WIFALIGN_TOP)).Draw(gui->GetGraphicsThread(), true);
}
@@ -480,11 +467,11 @@ void wiSlider::Render(wiGUI* gui)
wiRenderer::GetDevice()->SetScissorRects(1, &scissorRect, gui->GetGraphicsThread());
}
// text
- wiFont(text, wiFontProps(translation.x - headWidth * 0.5f, translation.y + scale.y*0.5f, GetScaledFontSize(), WIFALIGN_RIGHT, WIFALIGN_CENTER)).Draw(gui->GetGraphicsThread(), parent != nullptr);
+ wiFont(text, wiFontProps((int)(translation.x - headWidth * 0.5f), (int)(translation.y + scale.y*0.5f), -1, WIFALIGN_RIGHT, WIFALIGN_CENTER)).Draw(gui->GetGraphicsThread(), parent != nullptr);
// value
stringstream ss("");
ss << value;
- wiFont(ss.str(), wiFontProps(translation.x + scale.x + headWidth * 0.5f, translation.y + scale.y*0.5f, GetScaledFontSize(), WIFALIGN_LEFT, WIFALIGN_CENTER)).Draw(gui->GetGraphicsThread(), parent != nullptr);
+ wiFont(ss.str(), wiFontProps((int)(translation.x + scale.x + headWidth * 0.5f), (int)(translation.y + scale.y*0.5f), -1, WIFALIGN_LEFT, WIFALIGN_CENTER)).Draw(gui->GetGraphicsThread(), parent != nullptr);
}
void wiSlider::OnSlide(function func)
{
@@ -608,7 +595,7 @@ void wiCheckBox::Render(wiGUI* gui)
{
wiRenderer::GetDevice()->SetScissorRects(1, &scissorRect, gui->GetGraphicsThread());
}
- wiFont(text, wiFontProps(translation.x, translation.y + scale.y*0.5f, GetScaledFontSize(), WIFALIGN_RIGHT, WIFALIGN_CENTER)).Draw(gui->GetGraphicsThread(), parent != nullptr);
+ wiFont(text, wiFontProps((int)(translation.x), (int)(translation.y + scale.y*0.5f), -1, WIFALIGN_RIGHT, WIFALIGN_CENTER)).Draw(gui->GetGraphicsThread(), parent != nullptr);
}
void wiCheckBox::OnClick(function func)
{
@@ -798,7 +785,7 @@ void wiWindow::Render(wiGUI* gui)
scissorRect.right = (LONG)(translation.x + scale.x);
scissorRect.top = (LONG)(translation.y);
wiRenderer::GetDevice()->SetScissorRects(1, &scissorRect, gui->GetGraphicsThread());
- wiFont(text, wiFontProps(translation.x, translation.y, moveDragger->scale.y, WIFALIGN_LEFT, WIFALIGN_TOP)).Draw(gui->GetGraphicsThread(),true);
+ wiFont(text, wiFontProps((int)(translation.x), (int)(translation.y), (int)moveDragger->scale.y, WIFALIGN_LEFT, WIFALIGN_TOP)).Draw(gui->GetGraphicsThread(),true);
}
void wiWindow::SetVisible(bool value)
{
@@ -1180,15 +1167,11 @@ void wiColorPicker::Render(wiGUI* gui)
wiRenderer::GetDevice()->Draw(vb_preview.GetDesc().ByteWidth / sizeof(Vertex), threadID);
// RGB values:
- stringstream _r("");
- stringstream _g("");
- stringstream _b("");
- _r << "R: " << (int)(final_color.x * 255);
- _g << "G: " << (int)(final_color.y * 255);
- _b << "B: " << (int)(final_color.z * 255);
- wiFont(_r.str(), wiFontProps(translation.x + 200, translation.y + 200)).Draw(threadID, true);
- wiFont(_g.str(), wiFontProps(translation.x + 200, translation.y + 210)).Draw(threadID, true);
- wiFont(_b.str(), wiFontProps(translation.x + 200, translation.y + 220)).Draw(threadID, true);
+ stringstream _rgb("");
+ _rgb << "R: " << (int)(final_color.x * 255) << endl;
+ _rgb << "G: " << (int)(final_color.y * 255) << endl;
+ _rgb << "B: " << (int)(final_color.z * 255) << endl;
+ wiFont(_rgb.str(), wiFontProps((int)(translation.x + 200), (int)(translation.y + 200))).Draw(threadID, true);
}
XMFLOAT4 wiColorPicker::GetColor()
diff --git a/WickedEngine/wiWidget.h b/WickedEngine/wiWidget.h
index 60540554f..89206ef94 100644
--- a/WickedEngine/wiWidget.h
+++ b/WickedEngine/wiWidget.h
@@ -47,7 +47,6 @@ protected:
void Activate();
void Deactivate();
wiColor colors[WIDGETSTATE_COUNT];
- float GetScaledFontSize();
wiGraphicsTypes::Rect scissorRect;
public:
wiWidget();
@@ -67,8 +66,6 @@ public:
// last param default: set color for all states
void SetColor(const wiColor& color, WIDGETSTATE state = WIDGETSTATE_COUNT);
wiColor GetColor();
- void SetFontScaling(float val);
- float GetFontScaling();
void SetScissorRect(const wiGraphicsTypes::Rect& rect);
virtual void Update(wiGUI* gui);