Browse Source

Text: doc++

pull/34/head
Vladimír Vondruš 13 years ago
parent
commit
446b48bbb7
  1. 47
      src/Text/AbstractFont.h
  2. 16
      src/Text/AbstractFontConverter.h
  3. 16
      src/Text/DistanceFieldGlyphCache.h
  4. 24
      src/Text/GlyphCache.h
  5. 8
      src/Text/Renderer.h

47
src/Text/AbstractFont.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::Text::AbstractFont, Magnum::Text::AbstractLayouter
* @brief Class @ref Magnum::Text::AbstractFont, @ref Magnum::Text::AbstractLayouter
*/
#include <memory>
@ -45,9 +45,10 @@ namespace Magnum { namespace Text {
@section AbstractFont-usage Usage
First step is to open the font using @ref open(), next step is to prerender all
the glyphs which will be used in text rendering later, see @ref GlyphCache for
more information. See @ref Renderer for information about text rendering.
First step is to open the font using @ref openData(), @ref openSingleData() or
@ref openFile(). Next step is to prerender all the glyphs which will be used in
text rendering later, see @ref GlyphCache for more information. See
@ref Renderer for information about text rendering.
@section AbstractFont-subclassing Subclassing
@ -72,14 +73,14 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
/**
* @brief Features supported by this importer
*
* @see Features, features()
* @see @ref Features, @ref features()
*/
enum class Feature: UnsignedByte {
/** Opening fonts from raw data using openData() */
/** Opening fonts from raw data using @ref openData() */
OpenData = 1 << 0,
/**
* The format is multi-file, thus openSingleData() convenience
* The format is multi-file, thus @ref openSingleData() convenience
* function cannot be used.
*/
MultiFile = 1 << 1,
@ -87,7 +88,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
/**
* The font contains prepared glyph cache.
*
* @see fillGlyphCache(), createGlyphCache()
* @see @ref fillGlyphCache(), @ref createGlyphCache()
*/
PreparedGlyphCache = 1 << 2
};
@ -163,7 +164,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
*
* @note This function is not meant to be used in performance-critical
* code, only for font observations and conversions.
* @see glyphId()
* @see @ref glyphId()
*/
Vector2 glyphAdvance(UnsignedInt glyph);
@ -194,7 +195,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @param size Font size
* @param text %Text to layout
*
* @see fillGlyphCache(), createGlyphCache()
* @see @ref fillGlyphCache(), @ref createGlyphCache()
*/
std::unique_ptr<AbstractLayouter> layout(const GlyphCache& cache, Float size, const std::string& text);
@ -210,25 +211,25 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
#else
private:
#endif
/** @brief Implementation for features() */
/** @brief Implementation for @ref features() */
virtual Features doFeatures() const = 0;
/** @brief Implementation for isOpened() */
/** @brief Implementation for @ref isOpened() */
virtual bool doIsOpened() const = 0;
/**
* @brief Implementation for openData()
* @brief Implementation for @ref openData()
*
* If the plugin doesn't have @ref Feature::MultiFile, default
* implementation calls @ref doOpenSingleData().
*/
virtual void doOpenData(const std::vector<std::pair<std::string, Containers::ArrayReference<const unsigned char>>>& data, Float size);
/** @brief Implementation for openSingleData() */
/** @brief Implementation for @ref openSingleData() */
virtual void doOpenSingleData(Containers::ArrayReference<const unsigned char> data, Float size);
/**
* @brief Implementation for openFile()
* @brief Implementation for @ref openFile()
*
* If @ref Feature::OpenData is supported and the plugin doesn't have
* @ref Feature::MultiFile, default implementation opens the file and
@ -236,17 +237,17 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
*/
virtual void doOpenFile(const std::string& filename, Float size);
/** @brief Implementation for close() */
/** @brief Implementation for @ref close() */
virtual void doClose() = 0;
/** @brief Implementation for glyphId() */
/** @brief Implementation for @ref glyphId() */
virtual UnsignedInt doGlyphId(char32_t character) = 0;
/** @brief Implementation for glyphAdvance() */
/** @brief Implementation for @ref glyphAdvance() */
virtual Vector2 doGlyphAdvance(UnsignedInt glyph) = 0;
/**
* @brief Implementation for createGlyphCache()
* @brief Implementation for @ref fillGlyphCache()
*
* The string is converted from UTF-8 to UTF-32, unique characters are
* *not* removed.
@ -260,12 +261,10 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
virtual void doFillGlyphCache(GlyphCache& cache, const std::vector<char32_t>& characters);
#endif
/**
* @brief Implementation for createGlyphCache()
*/
/** @brief Implementation for @ref createGlyphCache() */
virtual std::unique_ptr<GlyphCache> doCreateGlyphCache();
/** @brief Implementation for layout() */
/** @brief Implementation for @ref layout() */
virtual std::unique_ptr<AbstractLayouter> doLayout(const GlyphCache& cache, Float size, const std::string& text) = 0;
};
@ -274,7 +273,7 @@ CORRADE_ENUMSET_OPERATORS(AbstractFont::Features)
/**
@brief Base for text layouters
Returned by AbstractFont::layout().
Returned by @ref AbstractFont::layout().
*/
class MAGNUM_TEXT_EXPORT AbstractLayouter {
AbstractLayouter(const AbstractLayouter&) = delete;

16
src/Text/AbstractFontConverter.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::Text::AbstractFontConverter
* @brief Class @ref Magnum::Text::AbstractFontConverter
*/
#include <memory>
@ -44,9 +44,10 @@ Provides functionality for converting arbitrary font to different format.
@section AbstractFontConverter-subclassing Subclassing
Plugin implements doFeatures() and one or more of `exportTo*()` / `importFrom*()`
functions based on what features are supported. Characters passed to font
exporting functions are converted to list of unique UTF-32 characters.
Plugin implements @ref doFeatures() and one or more of `exportTo*()` /
`importFrom*()` functions based on what features are supported. Characters
passed to font exporting functions are converted to list of unique UTF-32
characters.
You don't need to do most of the redundant sanity checks, these things are
checked by the implementation:
@ -290,7 +291,8 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
* @brief Implementation for @ref exportFontToFile()
*
* If @ref Feature::ConvertData is supported, default implementation
* calls doExportFontToData() and saves the result to given file(s).
* calls @ref doExportFontToData() and saves the result to given
* file(s).
* @note On Windows uses `std::vector<char32_t>` instead of
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
* for more information.
@ -309,7 +311,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
*/
virtual std::vector<std::pair<std::string, Containers::Array<unsigned char>>> doExportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const;
/** @brief Implementation for exportGlyphCacheToSingleData() */
/** @brief Implementation for @ref exportGlyphCacheToSingleData() */
virtual Containers::Array<unsigned char> doExportGlyphCacheToSingleData(GlyphCache& cache) const;
/**
@ -329,7 +331,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
*/
virtual std::unique_ptr<GlyphCache> doImportGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayReference<const unsigned char>>>& data) const;
/** @brief Implementation for importGlyphCacheFromSingleData() */
/** @brief Implementation for @ref importGlyphCacheFromSingleData() */
virtual std::unique_ptr<GlyphCache> doImportGlyphCacheFromSingleData(Containers::ArrayReference<const unsigned char> data) const;
/**

16
src/Text/DistanceFieldGlyphCache.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::Text::DistanceFieldGlyphCache
* @brief Class @ref Magnum::Text::DistanceFieldGlyphCache
*/
#include "Text/GlyphCache.h"
@ -35,13 +35,13 @@ namespace Magnum { namespace Text {
/**
@brief Glyph cache with distance field rendering
Unlike original GlyphCache converts each binary image to distance field. It is
not possible to use non-binary colors with this cache, internal texture format
is red channel only.
Unlike original @ref GlyphCache converts each binary image to distance field.
It is not possible to use non-binary colors with this cache, internal texture
format is red channel only.
@section GlyphCache-usage Usage
Usage is similar to GlyphCache, additionally you need to specify size of
Usage is similar to @ref GlyphCache, additionally you need to specify size of
resulting distance field texture.
@code
Text::AbstractFont* font;
@ -51,7 +51,7 @@ font->createGlyphCache(cache, "abcdefghijklmnopqrstuvwxyz"
"0123456789 ");
@endcode
@see TextureTools::distanceField()
@see @ref TextureTools::distanceField()
*/
class MAGNUM_TEXT_EXPORT DistanceFieldGlyphCache: public GlyphCache {
public:
@ -61,8 +61,8 @@ class MAGNUM_TEXT_EXPORT DistanceFieldGlyphCache: public GlyphCache {
* @param size Actual glyph cache texture size
* @param radius Distance field computation radius
*
* See TextureTools::distanceField() for more information about the
* parameters. Sets internal texture format to red channel only. On
* See @ref TextureTools::distanceField() for more information about
* the parameters. Sets internal texture format to red channel only. On
* desktop OpenGL requires @extension{ARB,texture_rg} (also part of
* OpenGL ES 3.0), in ES2 uses @es_extension{EXT,texture_rg} if
* available or @ref TextureFormat::RGB as fallback.

24
src/Text/GlyphCache.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::Text::GlyphCache
* @brief Class @ref Magnum::Text::GlyphCache
*/
#include <vector>
@ -127,8 +127,8 @@ class MAGNUM_TEXT_EXPORT GlyphCache {
*
* If no glyph is found, glyph `0` is returned, which is by default on
* zero position and has zero region in texture atlas. You can reset it
* to some meaningful value in insert().
* @see padding()
* to some meaningful value in @ref insert().
* @see @ref padding()
*/
std::pair<Vector2i, Rectanglei> operator[](UnsignedInt glyph) const {
auto it = glyphs.find(glyph);
@ -149,15 +149,15 @@ class MAGNUM_TEXT_EXPORT GlyphCache {
* @brief Layout glyphs with given sizes to the cache
*
* Returns non-overlapping regions in cache texture to store glyphs.
* The reserved space is reused on next call to reserve() if no glyph
* was stored there, use insert() to store actual glyph on given
* position and setImage() to upload glyph image.
* The reserved space is reused on next call to @ref reserve() if no
* glyph was stored there, use @ref insert() to store actual glyph on
* given position and @ref setImage() to upload glyph image.
*
* Glyph @p sizes are expected to be without padding.
*
* @attention Cache size must be large enough to contain all rendered
* glyphs.
* @see padding()
* @see @ref padding()
*/
std::vector<Rectanglei> reserve(const std::vector<Vector2i>& sizes);
@ -167,14 +167,14 @@ class MAGNUM_TEXT_EXPORT GlyphCache {
* @param position Position relative to point on baseline
* @param rectangle Region in texture atlas
*
* You can obtain unused non-overlapping regions with reserve(). You
* can't overwrite already inserted glyph, however you can reset glyph
* `0` to some meaningful value.
* You can obtain unused non-overlapping regions with @ref reserve().
* You can't overwrite already inserted glyph, however you can reset
* glyph `0` to some meaningful value.
*
* Glyph parameters are expected to be without padding.
*
* See also setImage() to upload glyph image.
* @see padding()
* See also @ref setImage() to upload glyph image.
* @see @ref padding()
*/
void insert(UnsignedInt glyph, Vector2i position, Rectanglei rectangle);

8
src/Text/Renderer.h

@ -24,7 +24,7 @@
DEALINGS IN THE SOFTWARE.
*/
/** @file
/** @file Text/Renderer.h
* @brief Class @ref Magnum::Text::AbstractRenderer, @ref Magnum::Text::Renderer, typedef @ref Magnum::Text::Renderer2D, @ref Magnum::Text::Renderer3D
*/
@ -197,8 +197,8 @@ shader.setTransformationProjectionMatrix(projection*Matrix3::translation(-rectan
glyphCache->texture()->bind(Shaders::VectorShader2D::FontTextureLayer);
mesh.draw();
@endcode
See @ref render(AbstractFont&, const GlyphCache&, Float, const std::string&) and
@ref render(AbstractFont&, const GlyphCache&, Float, const std::string&, Buffer&, Buffer&, Buffer::Usage)
See @ref render(AbstractFont&, const GlyphCache&, Float, const std::string&, Alignment) and
@ref render(AbstractFont&, const GlyphCache&, Float, const std::string&, Buffer&, Buffer&, Buffer::Usage, Alignment)
for more information.
While this method is sufficient for one-shot rendering of static texts, for
@ -247,6 +247,7 @@ template<UnsignedInt dimensions> class MAGNUM_TEXT_EXPORT Renderer: public Abstr
* @param vertexBuffer %Buffer where to store vertices
* @param indexBuffer %Buffer where to store indices
* @param usage Usage of vertex and index buffer
* @param alignment Text alignment
*
* Returns mesh prepared for use with @ref Shaders::AbstractVector
* subclasses and rectangle spanning the rendered text.
@ -258,6 +259,7 @@ template<UnsignedInt dimensions> class MAGNUM_TEXT_EXPORT Renderer: public Abstr
* @param font Font
* @param cache Glyph cache
* @param size Font size
* @param alignment Text alignment
*/
explicit Renderer(AbstractFont& font, const GlyphCache& cache, Float size, Alignment alignment = Alignment::LineLeft);
Renderer(AbstractFont&, GlyphCache&&, Float, Alignment alignment = Alignment::LineLeft) = delete; /**< @overload */

Loading…
Cancel
Save