-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add FontVariation
unit test
#99687
Closed
JustinBraben
wants to merge
3
commits into
godotengine:master
from
JustinBraben:FontVariation-unit-test
Closed
Add FontVariation
unit test
#99687
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/**************************************************************************/ | ||
/* test_font_variation.h */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT ENGINE */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | ||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/**************************************************************************/ | ||
|
||
#ifndef TEST_FONT_VARIATION_H | ||
#define TEST_FONT_VARIATION_H | ||
|
||
#include "modules/modules_enabled.gen.h" | ||
|
||
#include "scene/resources/font.h" | ||
#include "tests/test_macros.h" | ||
|
||
namespace TestFontVariation { | ||
|
||
TEST_CASE("[FontVariation] Create font variation") { | ||
// Create FontFile, which will be used in the font_variation | ||
Ref<FontFile> font_file; | ||
font_file.instantiate(); | ||
|
||
// Create test instance. | ||
Ref<FontVariation> font_variation; | ||
font_variation.instantiate(); | ||
|
||
CHECK_MESSAGE(font_variation->get_base_font().is_valid() == false, "FontVariation base font should not be valid."); | ||
|
||
#ifdef MODULE_FREETYPE_ENABLED | ||
// Load a valid file. | ||
CHECK(font_file->load_dynamic_font("thirdparty/fonts/NotoSans_Regular.woff2") == OK); | ||
|
||
font_variation->set_base_font(font_file); | ||
font_variation->get_base_font()->set_name(font_file->get_font_name()); | ||
|
||
// Check font_variation data. | ||
CHECK_MESSAGE(font_variation->get_base_font().is_valid() == true, "FontVariation base font should be valid."); | ||
CHECK_MESSAGE(font_variation->get_base_font()->get_name() == "Noto Sans", "Loaded correct font name."); | ||
|
||
font_variation->set_variation_embolden(1.2); | ||
|
||
CHECK_MESSAGE(font_file->get_embolden(0) == 0.0f, "FontFile embolden should be default 0.0."); | ||
CHECK_MESSAGE(font_file->get_embolden(0) != font_variation->get_variation_embolden(), "FontFile embolden should be different than FontVariation embolden."); | ||
CHECK_MESSAGE(font_variation->get_variation_embolden() == 1.2f, "FontVariation embolden should be 1.2."); | ||
|
||
Dictionary p_coords; | ||
p_coords.get_or_add("wght", 900); | ||
p_coords["custom_hght"] = 1000; | ||
font_variation->set_variation_opentype(p_coords); | ||
|
||
CHECK_MESSAGE(font_variation->get_variation_opentype().size() == 2, "FontVariation opentype size should be 2."); | ||
|
||
CHECK_MESSAGE(int(font_variation->get_variation_opentype().get_valid("wght")) == 900, "FontVariation wght should be 900."); | ||
CHECK_MESSAGE(int(font_variation->get_variation_opentype()["custom_hght"]) == 1000, "FontVariation custom_hght should be 1000."); | ||
#endif | ||
} | ||
|
||
} // namespace TestFontVariation | ||
|
||
#endif // TEST_FONT_VARIATION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What this supposed to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_base_font
sets the base font, but not the name of the base font. So this is just setting the name and aforementioned