mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-15 05:33:14 +03:00
Added a basic RichText class (and added tests and an example).
Fixed LineWrap when using initial X offset and the word does not fit in the current line but it fits in the next. Added basic agent rules.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include "compareimages.hpp"
|
||||
#include "utest.hpp"
|
||||
|
||||
#include <eepp/graphics/batchrenderer.hpp>
|
||||
@@ -10,6 +11,7 @@
|
||||
#include <eepp/graphics/image.hpp>
|
||||
#include <eepp/graphics/primitives.hpp>
|
||||
#include <eepp/graphics/renderer/renderergl.hpp>
|
||||
#include <eepp/graphics/richtext.hpp>
|
||||
#include <eepp/graphics/text.hpp>
|
||||
#include <eepp/scene/scenemanager.hpp>
|
||||
#include <eepp/system/filesystem.hpp>
|
||||
@@ -24,8 +26,6 @@
|
||||
#include <eepp/ui/uithememanager.hpp>
|
||||
#include <eepp/window/engine.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace EE;
|
||||
using namespace EE::Scene;
|
||||
using namespace EE::System;
|
||||
@@ -33,52 +33,6 @@ using namespace EE::Graphics;
|
||||
using namespace EE::Window;
|
||||
using namespace EE::UI;
|
||||
|
||||
static void compareImages( utest_state_s& utest_state, int* utest_result, EE::Window::Window* win,
|
||||
const std::string& imageName ) {
|
||||
auto saveType = Image::SaveType::WEBP;
|
||||
auto saveExt( Image::saveTypeToExtension( saveType ) );
|
||||
std::string expectedImagePath( "assets/fontrendering/" + imageName + "." + saveExt );
|
||||
|
||||
Image::FormatConfiguration fconf;
|
||||
fconf.webpSaveLossless( true );
|
||||
|
||||
Image actualImage = win->getFrontBufferImage();
|
||||
actualImage.setImageFormatConfiguration( fconf );
|
||||
|
||||
if ( !FileSystem::fileExists( expectedImagePath ) )
|
||||
actualImage.saveToFile( expectedImagePath, saveType );
|
||||
|
||||
Image expectedImage( expectedImagePath );
|
||||
ASSERT_TRUE( expectedImage.getPixelsPtr() != nullptr );
|
||||
EXPECT_EQ_MSG( expectedImage.getWidth(), actualImage.getWidth(), "Images width not equal" );
|
||||
EXPECT_EQ_MSG( expectedImage.getHeight(), actualImage.getHeight(), "Images height not equal" );
|
||||
|
||||
Image::DiffResult result = actualImage.diff( expectedImage );
|
||||
EXPECT_TRUE( result.areSame() );
|
||||
if ( !result.areSame() ) {
|
||||
auto saveExt( Image::saveTypeToExtension( saveType ) );
|
||||
std::string withTextShaper =
|
||||
Text::TextShaperEnabled
|
||||
? ( Text::TextShaperOptimizations ? "_text_shape_no_opt" : "_text_shape" )
|
||||
: "";
|
||||
std::cerr << "Test FAILED: " << result.numDifferentPixels << " pixels differ." << std::endl;
|
||||
std::cerr << "Maximum perceptual difference (Delta E): " << result.maxDeltaE << std::endl;
|
||||
if ( !FileSystem::fileExists( "output" ) )
|
||||
FileSystem::makeDir( "output" );
|
||||
std::string actualImagePath =
|
||||
"output/" + imageName + "_actual_output" + withTextShaper + "." + saveExt;
|
||||
actualImage.saveToFile( actualImagePath, saveType );
|
||||
std::cerr << "Actual image saved to: " << actualImagePath << std::endl;
|
||||
if ( result.diffImage ) {
|
||||
std::string diffImagePath =
|
||||
"output/" + imageName + "_diff_output" + withTextShaper + "." + saveExt;
|
||||
result.diffImage->setImageFormatConfiguration( fconf );
|
||||
result.diffImage->saveToFile( diffImagePath, saveType );
|
||||
std::cerr << "Visual diff saved to: " << diffImagePath << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UTEST( FontRendering, fontsTest ) {
|
||||
FileSystem::changeWorkingDirectory( Sys::getProcessPath() );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user