mirror of https://github.com/Poikilos/b3view
check for system fonts
parent
7f2e0a1391
commit
0b1e609575
|
@ -32,9 +32,9 @@ void Engine::setupScene()
|
|||
|
||||
// Setup Camera
|
||||
// (so z-forward characters face camera partially (formerly vector3df( 0, 0, -10 ), vector3df())
|
||||
tmpPosVec3f = vector3df( 4.5, 3, 9 );
|
||||
tmpTargetVec3f = vector3df(0, 3, 0);
|
||||
ICameraSceneNode *camera = m_Scene->addCameraSceneNode(nullptr, tmpPosVec3f, tmpTargetVec3f); // this will be overridden by View m_Yaw and m_Pitch--see "calculate m_Yaw" further down
|
||||
m_CamPos = vector3df( 4.5, 3, 9 );
|
||||
m_CamTarget = vector3df(0, 3, 0);
|
||||
ICameraSceneNode *camera = m_Scene->addCameraSceneNode(nullptr, m_CamPos, m_CamTarget); // this will be overridden by View m_Yaw and m_Pitch--see "calculate m_Yaw" further down
|
||||
camera->setAspectRatio((f32)m_Driver->getScreenSize().Width / m_Driver->getScreenSize().Height);
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,8 @@ Engine::Engine()
|
|||
|
||||
// Load font for displaying Axis names
|
||||
m_AxisFontFace = new CGUITTFace();
|
||||
if (m_AxisFontFace->load( "ClearSansRegular.ttf" )) {
|
||||
// NOTE: m_FontPath is modified y UserInterface constructor above if font was missing
|
||||
if (m_AxisFontFace->load(m_FontPath.c_str())) {
|
||||
m_AxisFont = new CGUITTFont( m_UserInterface->getGUIEnvironment() );
|
||||
m_AxisFont->attach( m_AxisFontFace, 14 );
|
||||
m_AxisFont->AntiAlias = false;
|
||||
|
|
5
Engine.h
5
Engine.h
|
@ -60,8 +60,9 @@ private:
|
|||
// irr::video::SMaterial *lineX;
|
||||
// irr::video::SMaterial *lineY;
|
||||
// irr::video::SMaterial *lineZ;
|
||||
irr::core::vector3df tmpPosVec3f;
|
||||
irr::core::vector3df tmpTargetVec3f;
|
||||
irr::core::vector3df m_CamPos;
|
||||
irr::core::vector3df m_CamTarget;
|
||||
std::wstring m_FontPath = L"ClearSansRegular.ttf"; // core::stringc has implicit conversion to io::path
|
||||
|
||||
public:
|
||||
std::wstring m_PreviousPath;
|
||||
|
|
10
README.md
10
README.md
|
@ -68,7 +68,13 @@ only applies to Visual Studio users.)
|
|||
if your build directory is not `./build`
|
||||
* (optional) Copy your favorite public-licensed font over
|
||||
`./build/ClearSansRegular.tff` or to current working directory of
|
||||
program (unpredictable on Linux when you double-click files)
|
||||
program (varies on Linux when you double-click files). If you don't,
|
||||
and didn't copy the included one to the output directory,
|
||||
the following fonts will be tried, in the following order:
|
||||
* C:\Windows\Fonts: calibrib.ttf, arialbd.ttf
|
||||
* /usr/share/fonts: liberation/LiberationSans-Bold.ttf,
|
||||
gnu-free/FreeSansBold.ttf, dejavu/DejaVuSans-Bold.ttf,
|
||||
google-droid/DroidSans-Bold.ttf
|
||||
|
||||
## Install
|
||||
### Windows
|
||||
|
@ -122,6 +128,8 @@ only applies to Visual Studio users.)
|
|||
## Known Issues
|
||||
* Warn on missing texture.
|
||||
* Test and complete install.bat on Windows.
|
||||
* Look for fonts on OS X (see "Set Font for UI Elements" in
|
||||
UserInterface.cpp).
|
||||
|
||||
## Authors
|
||||
* ClearSansRegular.ttf (**Apache 2.0 License**) by Intel
|
||||
|
|
|
@ -81,15 +81,33 @@ void UserInterface::setupUserInterface()
|
|||
// Set Font for UI Elements
|
||||
m_GuiFontFace = new CGUITTFace();
|
||||
// irrString defines stringc as string<c8>
|
||||
std::wstring fontPath = L"ClearSansRegular.ttf"; // core::stringc has implicit conversion to io::path
|
||||
// if (QFile(fontPath).exists()) {}
|
||||
if (m_GuiFontFace->load(fontPath.c_str())) { // actually takes `const io::path &`
|
||||
if (!Utility::isFile(m_Engine->m_FontPath)) {
|
||||
m_Engine->m_FontPath = L"C:\\Windows\\Fonts\\calibrib.ttf";
|
||||
}
|
||||
if (!Utility::isFile(m_Engine->m_FontPath)) {
|
||||
m_Engine->m_FontPath = L"C:\\Windows\\Fonts\\arialbd.ttf";
|
||||
}
|
||||
if (!Utility::isFile(m_Engine->m_FontPath)) {
|
||||
m_Engine->m_FontPath = L"/usr/share/fonts/gnu-free/FreeSansBold.ttf";
|
||||
}
|
||||
if (!Utility::isFile(m_Engine->m_FontPath)) {
|
||||
m_Engine->m_FontPath = L"/usr/share/fonts/liberation/LiberationSans-Bold.ttf";
|
||||
}
|
||||
if (!Utility::isFile(m_Engine->m_FontPath)) {
|
||||
m_Engine->m_FontPath = L"/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf";
|
||||
}
|
||||
if (!Utility::isFile(m_Engine->m_FontPath)) {
|
||||
m_Engine->m_FontPath = L"/usr/share/fonts/google-droid/DroidSans-Bold.ttf";
|
||||
}
|
||||
|
||||
if (m_GuiFontFace->load(m_Engine->m_FontPath.c_str())) { // actually takes `const io::path &`
|
||||
m_GuiFont = new CGUITTFont( m_Gui );
|
||||
m_GuiFont->attach( m_GuiFontFace, 14 );
|
||||
m_Gui->getSkin()->setFont( m_GuiFont );
|
||||
}
|
||||
else {
|
||||
std::wcerr << L"WARNING: Missing '" << fontPath << L"'" << endl;
|
||||
std::wcerr << L"WARNING: Missing '" << m_Engine->m_FontPath << L"'" << endl;
|
||||
delete m_GuiFontFace;
|
||||
m_GuiFontFace = nullptr;
|
||||
if (m_GuiFont != nullptr) {
|
||||
|
|
6
View.cpp
6
View.cpp
|
@ -54,9 +54,9 @@ View::View( Engine *engine )
|
|||
|
||||
// vectors for angle are opposite, since camera revolves around center
|
||||
vector3df offsetVec3(
|
||||
engine->tmpPosVec3f.X-engine->tmpTargetVec3f.X,
|
||||
engine->tmpPosVec3f.Y-engine->tmpTargetVec3f.Y,
|
||||
engine->tmpPosVec3f.Z-engine->tmpTargetVec3f.Z
|
||||
engine->m_CamPos.X-engine->m_CamTarget.X,
|
||||
engine->m_CamPos.Y-engine->m_CamTarget.Y,
|
||||
engine->m_CamPos.Z-engine->m_CamTarget.Z
|
||||
);
|
||||
// m_CameraDistance = sqrtf()
|
||||
m_CameraDistance = offsetVec3.getLength();
|
||||
|
|
Loading…
Reference in New Issue