Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
text_renderer_tests.cpp
Go to the documentation of this file.
1#include <stdio.h>
2#include <cstdint>
3#include "gtest/gtest.h"
4
7
8using ::testing::EmptyTestEventListener;
9using ::testing::InitGoogleTest;
10using ::testing::Test;
11using ::testing::TestEventListeners;
12using ::testing::TestInfo;
13using ::testing::TestPartResult;
14using ::testing::TestSuite;
15using ::testing::UnitTest;
16
17using namespace rendering_engine;
18
19TEST(ImageDataTest, CreateGlyphBitmapStatic)
20{
21 std::string const pathToFont{ "../Content/Fonts/Exo/Exo-Medium.otf" };
22
23 auto imageData = std::make_shared<ImageData>(TextRenderer::CreateGlyphBitmap(pathToFont, '7' ));
24 imageData->WritePngFile("testGlyphStatic.png");
25
26 EXPECT_NE( imageData, nullptr );
27}
28
29TEST(ImageDataTest, CreateGlyphBitmap)
30{
31 std::string const pathToFont{ "../Content/Fonts/Exo/Exo-Medium.otf" };
32
33 TextRenderer textRenderer(pathToFont, 14);
34
35 auto imageData = std::make_shared<ImageData>( textRenderer.CreateGlyphBitmap('4') );
36 imageData->WritePngFile("testGlyphBitmap.png");
37
38 EXPECT_NE(imageData, nullptr);
39}
40
41TEST(ImageDataTest, CreateTextBitmap1)
42{
43 std::string const pathToFont{ "../Content/Fonts/Pirulen/pirulen_rg.otf" };
44
45 TextRenderer textRenderer( pathToFont, 48 );
46
47 std::string testText{"This is Pirulen font test text 123 string"};
48 auto imageData = std::make_shared<ImageData>( textRenderer.CreateStringBitmap(testText) );
49 imageData->WritePngFile("testPirulenFontTextString.png");
50
51 EXPECT_NE(imageData, nullptr);
52}
53
54TEST(ImageDataTest, CreateTextBitmap2)
55{
56 std::string const pathToFont{ "../Content/Fonts/DigitalDream/DIGITALDREAM.ttf" };
57
58 TextRenderer textRenderer(pathToFont, 48);
59
60 std::string testText{ "This_is_DIGITAL-DREAM_font_test_text_123_string" };
61 auto imageData = std::make_shared<ImageData>( textRenderer.CreateStringBitmap(testText) );
62 imageData->WritePngFile("testDigitalDreamFontTextString.png");
63
64 EXPECT_NE(imageData, nullptr);
65}
ImageData CreateGlyphBitmap(char const character)
ImageData CreateStringBitmap(std::string text)
TEST(ImageDataTest, CreateGlyphBitmapStatic)