Browse Source

Text: add Alignment::TopCenterIntegral.

Not sure why this one was missing. Also clearly document their purpose,
and why there's no such variant for Line, Top, Left and Right
alignments.
pull/168/head
Vladimír Vondruš 3 years ago
parent
commit
7756b8290e
  1. 2
      doc/changelog.dox
  2. 23
      src/Magnum/Text/Alignment.h
  3. 3
      src/Magnum/Text/Test/RendererGLTest.cpp

2
doc/changelog.dox

@ -782,6 +782,8 @@ See also:
- Added @ref Text::AbstractFont::glyphCount() and
@relativeref{Text::AbstractFont,glyphSize()}
- Added @ref Text::Renderer::fontSize()
- Added @ref Text::Alignment::TopCenterIntegral, which is also needed in
order to prevent aligning pixel-perfect fonts to fractional positions
@subsubsection changelog-latest-changes-trade Trade library

23
src/Magnum/Text/Alignment.h

@ -52,6 +52,12 @@ namespace Implementation {
/**
@brief Text rendering alignment
The `*Integer` values are meant to be used for pixel-perfect fonts that always
have glyph sizes, advances and other metrics whole pixels, and need to be
positioned on whole pixels as well in order to avoid making them blurry. These
are only needed for `*Middle` and `*Center` alignments as they may result in
the bounding rectangle to have odd dimensions, which would then result in
half-pixel shifts when divided by 2.
@see @ref Renderer::render(), @ref Renderer::Renderer()
*/
enum class Alignment: UnsignedByte {
@ -92,7 +98,11 @@ enum class Alignment: UnsignedByte {
/** Text start and top is at origin */
TopLeft = Implementation::AlignmentTop|Implementation::AlignmentLeft,
/** Text center and top is at origin */
/**
* Text center and top is at origin
*
* @see @ref Alignment::TopCenterIntegral
*/
TopCenter = Implementation::AlignmentTop|Implementation::AlignmentCenter,
/** Text end and top is at origin */
@ -124,7 +134,16 @@ enum class Alignment: UnsignedByte {
*
* @see @ref Alignment::MiddleRight
*/
MiddleRightIntegral = Implementation::AlignmentMiddle|Implementation::AlignmentRight|Implementation::AlignmentIntegral
MiddleRightIntegral = Implementation::AlignmentMiddle|Implementation::AlignmentRight|Implementation::AlignmentIntegral,
/**
* Text center and line is at origin and alignment offset is integral
*
* @see @ref Alignment::TopCenter
* @m_since_latest
*/
TopCenterIntegral = Implementation::AlignmentTop|Implementation::AlignmentCenter|Implementation::AlignmentIntegral,
};
}}

3
src/Magnum/Text/Test/RendererGLTest.cpp

@ -60,6 +60,9 @@ const struct {
/** @todo for all these, the initial glyph offset is first subtracted and
only then the shift by either half or full size is performed, does that
make sense? why is not done for the LineLeft case, then? */
{"top center, integral", Alignment::TopCenterIntegral,
/* The Y shift is rounded to whole units */
{-5.5f - 2.5f, -7.5f - 3.5f}},
{"top left", Alignment::TopLeft,
{0.0f, -7.0f - 3.5f}},
{"top right", Alignment::TopRight,

Loading…
Cancel
Save