|
|
|
|
#
|
|
|
|
|
# This file is part of Magnum.
|
|
|
|
|
#
|
|
|
|
|
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
|
|
|
|
|
# 2020, 2021, 2022, 2023 Vladimír Vondruš <mosra@centrum.cz>
|
|
|
|
|
#
|
|
|
|
|
# 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.
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# IDE folder in VS, Xcode etc. CMake 3.12+, older versions have only the FOLDER
|
|
|
|
|
# property that would have to be set on each target separately.
|
|
|
|
|
set(CMAKE_FOLDER "Magnum/Text/Test")
|
|
|
|
|
|
|
|
|
|
if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID)
|
|
|
|
|
set(TEXT_TEST_DIR ".")
|
|
|
|
|
set(TEXT_TEST_OUTPUT_DIR "./write")
|
|
|
|
|
set(TEXTURETOOLS_DISTANCEFIELDGLTEST_DIR ".")
|
|
|
|
|
else()
|
|
|
|
|
set(TEXT_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
set(TEXT_TEST_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
set(TEXTURETOOLS_DISTANCEFIELDGLTEST_DIR ${PROJECT_SOURCE_DIR}/src/Magnum/TextureTools/Test/DistanceFieldGLTestFiles)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(MAGNUM_TARGET_GL AND MAGNUM_BUILD_GL_TESTS)
|
|
|
|
|
if(NOT MAGNUM_BUILD_PLUGINS_STATIC)
|
|
|
|
|
if(MAGNUM_WITH_ANYIMAGEIMPORTER)
|
|
|
|
|
set(ANYIMAGEIMPORTER_PLUGIN_FILENAME $<TARGET_FILE:AnyImageImporter>)
|
|
|
|
|
endif()
|
|
|
|
|
if(MAGNUM_WITH_TGAIMPORTER)
|
|
|
|
|
set(TGAIMPORTER_PLUGIN_FILENAME $<TARGET_FILE:TgaImporter>)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# First replace ${} variables, then $<> generator expressions
|
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/configure.h.in)
|
|
|
|
|
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/configure.h
|
|
|
|
|
INPUT ${CMAKE_CURRENT_BINARY_DIR}/configure.h.in)
|
|
|
|
|
|
|
|
|
|
corrade_add_test(TextAbstractFontTest AbstractFontTest.cpp
|
|
|
|
|
LIBRARIES Magnum MagnumTextTestLib
|
|
|
|
|
FILES data.bin)
|
|
|
|
|
target_include_directories(TextAbstractFontTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
|
|
|
|
|
|
|
|
|
|
corrade_add_test(TextAbstractFontConverterTest AbstractFontConverterTest.cpp
|
|
|
|
|
LIBRARIES Magnum MagnumTextTestLib
|
|
|
|
|
FILES data.bin)
|
|
|
|
|
target_include_directories(TextAbstractFontConverterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
|
|
|
|
|
|
Text: rework AbstractGlyphCache for better flexibility and efficiency.
The class now supports incremental filling, multiple fonts, texture
arrays, removes all reliance on STL containers and is finally properly
documented.
To avoid complete breakage of every use, as much as possible was kept as
deprecated APIs -- in particular the reserve() with the nasty
std::vectors, the insert() that assumes a 2D cache and a single font
and textureSize() that returns a 2D vector. Those behave the same as
before, but will assert if the cache is an array or contains more than
one font.
On the other hand, begin() / end() access with std::unordered_map iterators
(ew!) was removed as the internals simply aren't a hashmap anymore. The
image() that returned an Image2D is now used to fill the glyph cache
instead of querying its potentially processed contents, and returns a
MutableImageView3D. I considered keeping it and adding sourceImage()
instead, but such naming turned out to be too inconsistent. For querying
processed image data (such as with the distance field cache) there's a
new processedImage() query, guarded by new GlyphCacheFeature bits -- if
both ImageProcessing and ProcessedImageDownload is set, it can be used
to retrieve the processed image (so, similar as ImageDownload was
before), and if neither is set, the cache contents are queryable
directly through image(), without needing any special support from
the GPU API.
Existing code is updated only in the minimal way possible to ensure that
no serious breakage was introduced by reimplementing the deprecated APIs
on top of the new backend. Porting away from deprecated APIs will be
done in next commits. The GlyphCache and DistanceFieldGlyphCache have
their public API kept intact for now, as a similar rework will be needed
for them as well.
Additionally, the MagnumFont and MagnumFontConverter plugins aren't
compiling yet as they require substantial changes to deal with the new
glyph cache features. That is not the case with other plugins in the
magnum-plugins repository tho, for those the backwards compatibility
"just works". On the other hand, since layout of the AbstractGlyphChange
changed, I'm bumping the AbstractFont plugin interface version to
force-trigger a rebuild of dependent projects. Because I ran a stale
magnum-player binary, it worked without crashing or GL errors but just
didn't show ANY text whatsoever due to ABI differences, and I wasted
some precious minutes before realizing that a simple rebuild would fix
it.
3 years ago
|
|
|
corrade_add_test(TextAbstractGlyphCacheTest AbstractGlyphCacheTest.cpp
|
|
|
|
|
LIBRARIES MagnumTextTestLib MagnumDebugTools)
|
|
|
|
|
if(CORRADE_TARGET_EMSCRIPTEN)
|
|
|
|
|
if(CMAKE_VERSION VERSION_LESS 3.13)
|
|
|
|
|
message(FATAL_ERROR "CMake 3.13+ is required in order to specify Emscripten linker options")
|
|
|
|
|
endif()
|
|
|
|
|
# Some of the glyph caches tested are rather large
|
|
|
|
|
target_link_options(TextAbstractGlyphCacheTest PRIVATE "SHELL:-s ALLOW_MEMORY_GROWTH=1")
|
|
|
|
|
endif()
|
|
|
|
|
|
Text: new AbstractShaper interface for shaping.
Replaces the previous, grossly inefficient AbstractLayouter which was
performing one virtual call per glyph (!). It's now also reusable,
meaning it doesn't need to be allocated anew for every new shaped text,
and it no longer requires each and every font plugin to implement the
same redundant glyph data fetching from the glyph cache, scaling etc. --
all that is meant to be done by the users of AbstractShaper, i.e.
Renderer. The independency on a glyph cache theorerically also means it
can be used for a completely different, non-texture-based way to render
text (such as direct path drawing directly on the GPU), although I won't
be exploring that path now.
It also exposes an interface for specifying script, language,
direction and typographic features. Such interface will be currently
only implemented in HarfBuzz, but that's the intent -- to provide a
flexible enough interface to support all possible use cases that a font
or a font plugin may support, instead of exposing a least common
denominator and then having no easy way to shape a text in a non-Latin
script or use a fancy OpenType feature the chosen font has.
The old public interface is preserved for backwards compatibility,
marked as deprecated, however the virtual APIs are not, as supporting
that would be too nasty. I don't think any user code ever implemented a
font plugin so this should be okay.
To ensure smooth transition with no regressions, the Renderer class and
MagnumFont tests still use the old API in this commit, and their test
pass the same way as they did before (except for two removed MagnumFont
test cases which tested errors that are now an assertion in the
deprecated layout() API and thus cannot be tested from the plugin
anymore). Porting them away from the deprecated API will be done in
separate commits.
3 years ago
|
|
|
corrade_add_test(TextAbstractShaperTest AbstractShaperTest.cpp
|
|
|
|
|
LIBRARIES MagnumTextTestLib)
|
|
|
|
|
|
|
|
|
|
corrade_add_test(TextAlignmentTest AlignmentTest.cpp LIBRARIES MagnumTextTestLib)
|
|
|
|
|
corrade_add_test(TextDirectionTest DirectionTest.cpp LIBRARIES MagnumText)
|
|
|
|
|
corrade_add_test(TextFeatureTest FeatureTest.cpp LIBRARIES MagnumTextTestLib)
|
|
|
|
|
corrade_add_test(TextRendererTest RendererTest.cpp LIBRARIES MagnumTextTestLib)
|
|
|
|
|
corrade_add_test(TextScriptTest ScriptTest.cpp LIBRARIES MagnumTextTestLib)
|
|
|
|
|
|
|
|
|
|
if(MAGNUM_TARGET_GL)
|
|
|
|
|
corrade_add_test(TextGlyphCacheGL_Test GlyphCacheGL_Test.cpp LIBRARIES MagnumText)
|
|
|
|
|
corrade_add_test(TextDistanceFieldGlyphCacheGL_Test DistanceFieldGlyphCacheGL_Test.cpp LIBRARIES MagnumText)
|
|
|
|
|
|
|
|
|
|
if(MAGNUM_BUILD_GL_TESTS)
|
|
|
|
|
corrade_add_test(TextDistanceFieldGlyphCacheGLTest DistanceFieldGlyphCacheGLTest.cpp
|
|
|
|
|
LIBRARIES
|
|
|
|
|
MagnumTextTestLib
|
|
|
|
|
MagnumOpenGLTester
|
|
|
|
|
MagnumDebugTools
|
|
|
|
|
FILES
|
|
|
|
|
${PROJECT_SOURCE_DIR}/src/Magnum/TextureTools/Test/DistanceFieldGLTestFiles/input.tga
|
|
|
|
|
${PROJECT_SOURCE_DIR}/src/Magnum/TextureTools/Test/DistanceFieldGLTestFiles/output.tga)
|
|
|
|
|
target_include_directories(TextDistanceFieldGlyphCacheGLTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
|
|
|
|
|
if(MAGNUM_BUILD_PLUGINS_STATIC)
|
|
|
|
|
if(MAGNUM_WITH_ANYIMAGEIMPORTER)
|
|
|
|
|
target_link_libraries(TextDistanceFieldGlyphCacheGLTest PRIVATE AnyImageImporter)
|
|
|
|
|
endif()
|
|
|
|
|
if(MAGNUM_WITH_TGAIMPORTER)
|
|
|
|
|
target_link_libraries(TextDistanceFieldGlyphCacheGLTest PRIVATE TgaImporter)
|
|
|
|
|
endif()
|
|
|
|
|
else()
|
|
|
|
|
# So the plugins get properly built when building the test
|
|
|
|
|
if(MAGNUM_WITH_ANYIMAGEIMPORTER)
|
|
|
|
|
add_dependencies(TextDistanceFieldGlyphCacheGLTest AnyImageImporter)
|
|
|
|
|
endif()
|
|
|
|
|
if(MAGNUM_WITH_TGAIMPORTER)
|
|
|
|
|
add_dependencies(TextDistanceFieldGlyphCacheGLTest TgaImporter)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
corrade_add_test(TextGlyphCacheGLTest GlyphCacheGLTest.cpp
|
|
|
|
|
LIBRARIES
|
|
|
|
|
MagnumTextTestLib
|
|
|
|
|
MagnumOpenGLTester
|
|
|
|
|
MagnumDebugTools)
|
|
|
|
|
corrade_add_test(TextRendererGLTest RendererGLTest.cpp
|
|
|
|
|
LIBRARIES
|
|
|
|
|
MagnumTextTestLib
|
|
|
|
|
MagnumOpenGLTester)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|