Skip to content

Commit 48bdaca

Browse files
committed
Cad Example: SingleLineText to take wchar
1 parent 8125ddd commit 48bdaca

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

62_CAD/SingleLineText.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "SingleLineText.h"
22

3-
SingleLineText::SingleLineText(nbl::ext::TextRendering::FontFace* face, const std::string& text)
3+
SingleLineText::SingleLineText(nbl::ext::TextRendering::FontFace* face, const std::wstring& text)
44
{
55
m_glyphBoxes.reserve(text.length());
66

@@ -11,7 +11,7 @@ SingleLineText::SingleLineText(nbl::ext::TextRendering::FontFace* face, const st
1111
float64_t2 currentPos = float32_t2(0.0, 0.0);
1212
for (uint32_t i = 0; i < text.length(); i++)
1313
{
14-
const auto glyphIndex = face->getGlyphIndex(wchar_t(text.at(i)));
14+
const auto glyphIndex = face->getGlyphIndex(text.at(i));
1515
const auto glyphMetrics = face->getGlyphMetrics(glyphIndex);
1616
const bool skipGenerateGlyph = (glyphIndex == 0 || (glyphMetrics.size.x == 0.0 && glyphMetrics.size.y == 0.0));
1717

62_CAD/SingleLineText.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class SingleLineText
1212
{
1313
public:
1414
// constructs and fills the `glyphBoxes`
15-
SingleLineText(nbl::ext::TextRendering::FontFace* face, const std::string& text);
15+
SingleLineText(nbl::ext::TextRendering::FontFace* face, const std::wstring& text);
1616

1717
struct BoundingBox
1818
{

62_CAD/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ constexpr std::array<float, (uint32_t)ExampleMode::CASE_COUNT> cameraExtents =
8383
1000.0 // CASE_11
8484
};
8585

86-
constexpr ExampleMode mode = ExampleMode::CASE_5;
86+
constexpr ExampleMode mode = ExampleMode::CASE_8;
8787

8888
class Camera2D
8989
{
@@ -1098,10 +1098,10 @@ class ComputerAidedDesign final : public nbl::examples::SimpleWindowedApplicatio
10981098
if (m_font->getFreetypeFace()->num_charmaps > 0)
10991099
FT_Set_Charmap(m_font->getFreetypeFace(), m_font->getFreetypeFace()->charmaps[0]);
11001100

1101-
const auto str = "MSDF: ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnoprstuvwxyz '1234567890-=\"!@#$%&*()_+";
1101+
const std::wstring str = L"MSDF: ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnoprstuvwxyz '1234567890-=\"!@#$%&*()_+";
11021102
singleLineText = std::unique_ptr<SingleLineText>(new SingleLineText(
11031103
m_font.get(),
1104-
std::string(str)));
1104+
str));
11051105

11061106
drawResourcesFiller.setGlyphMSDFTextureFunction(
11071107
[&](nbl::ext::TextRendering::FontFace* face, uint32_t glyphIdx) -> core::smart_refctd_ptr<asset::ICPUImage>

0 commit comments

Comments
 (0)