This is a snapshot of a work-in-progress documentation theme. If you feel lost, miss something, or want to see the original Doxygen docs instead, head over to the archived version of this documentation page.

Magnum::Text::AbstractFontConverter class

Base for font converter plugins.

Provides functionality for converting arbitrary font to different format. See Loading and using plugins for more information and *FontConverter classes in Text namespace for available font converter plugins.

You can use the magnum-fontconverter utility to do font conversion on command-line.

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.

You don't need to do most of the redundant sanity checks, these things are checked by the implementation:

  • Functions doExportFontTo*() are called only if Feature::ExportFont is supported, functions doExportGlyphCacheTo*() are called only if Feature::ExportGlyphCache is supported.
  • Functions doImportGlyphCacheFrom*() are called only if Feature::ImportGlyphCache is supported.
  • Functions doExport*To*Data() and doImport*From*Data() are called only if Feature::ConvertData is supported.
  • Function doImport*FromData() is called only if there is at least one data array passed.

Plugin interface string is "cz.mosra.magnum.Text.AbstractFontConverter/0.1.2".

Derived classes

class MagnumFontConverter
MagnumFont converter plugin.

Public types

enum class Feature: UnsignedByte { ExportFont = 1 << 0, ExportGlyphCache = 1 << 1, ImportGlyphCache = 1 << 2, ConvertData = 1 << 4, MultiFile = 1 << 5 }
Features supported by this converter.
using Features = Containers::EnumSet<Feature>
Features supported by this converter.

Constructors, destructors, conversion operators

AbstractFontConverter() explicit
Default constructor.
AbstractFontConverter(PluginManager::AbstractManager& manager, const std::string& plugin) explicit
Plugin manager constructor.

Public functions

auto features() const -> Features
Features supported by this converter.
auto exportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::string& characters) const -> std::vector<std::pair<std::string, Containers::Array<char>>>
Export font to raw data.
auto exportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::string& characters) const -> Containers::Array<char>
Export font to single raw data.
auto exportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::string& characters) const -> bool
Export font to file.
auto exportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const -> std::vector<std::pair<std::string, Containers::Array<char>>>
Export glyph cache to raw data.
auto exportGlyphCacheToSingleData(GlyphCache& cache) const -> Containers::Array<char>
Export glyph cache to single raw data.
auto exportGlyphCacheToFile(GlyphCache& cache, const std::string& filename) const -> bool
Export glyph cache to file.
auto importGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayView<const char>>>& data) const -> std::unique_ptr<GlyphCache>
Import glyph cache from raw data.
auto importGlyphCacheFromSingleData(Containers::ArrayView<const char> data) const -> std::unique_ptr<GlyphCache>
Import glyph cache from single raw data.
auto importGlyphCacheFromFile(const std::string& filename) const -> std::unique_ptr<GlyphCache>
Import glyph cache from file.

Protected functions

auto doFeatures() const -> Features pure virtual
Implementation for features()
auto doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const -> std::vector<std::pair<std::string, Containers::Array<char>>> virtual
Implementation for exportFontToData()
auto doExportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::u32string& characters) const -> Containers::Array<char> virtual
Implementation for exportFontToSingleData()
auto doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const -> bool virtual
Implementation for exportFontToFile()
auto doExportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const -> std::vector<std::pair<std::string, Containers::Array<char>>> virtual
Implementation for exportGlyphCacheToData()
auto doExportGlyphCacheToSingleData(GlyphCache& cache) const -> Containers::Array<char> virtual
Implementation for exportGlyphCacheToSingleData()
auto doExportGlyphCacheToFile(GlyphCache& cache, const std::string& filename) const -> bool virtual
Implementation for exportGlyphCacheToFile()
auto doImportGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayView<const char>>>& data) const -> std::unique_ptr<GlyphCache> virtual
Implementation for importGlyphCacheFromData()
auto doImportGlyphCacheFromSingleData(Containers::ArrayView<const char> data) const -> std::unique_ptr<GlyphCache> virtual
Implementation for importGlyphCacheFromSingleData()
auto doImportGlyphCacheFromFile(const std::string& filename) const -> std::unique_ptr<GlyphCache> virtual
Implementation for importGlyphCacheFromFile()

Enum documentation

enum class Magnum::Text::AbstractFontConverter::Feature: UnsignedByte

Features supported by this converter.

Enumerators
ExportFont

Exporting font using exportFontToFile(), exportFontToData() or exportFontToSingleData()

ExportGlyphCache

Export glyph cache using exportGlyphCacheToFile(), exportGlyphCacheToData() or exportGlyphCacheToSingleData()

ImportGlyphCache

Import glyph cache using importGlyphCacheFromFile(), importGlyphCacheFromData() or importGlyphCacheFromSingleData()

ConvertData

Convert from/to data using exportFontToData(), exportFontToSingleData(), exportGlyphCacheToData(), exportGlyphCacheToSingleData(), importGlyphCacheFromData() or importGlyphCacheFromSingleData()

MultiFile

The format is multi-file, thus exportFontToSingleData(), exportGlyphCacheToSingleData() and importGlyphCacheFromSingleData() convenience functions cannot be used.

Typedef documentation

typedef Containers::EnumSet<Feature> Magnum::Text::AbstractFontConverter::Features

Features supported by this converter.

Function documentation

std::vector<std::pair<std::string, Containers::Array<char>>> Magnum::Text::AbstractFontConverter::exportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::string& characters) const

Export font to raw data.

Parameters
font Opened font
cache Populated glyph cache
filename Output filename
characters Characters to export

Available only if Feature::ConvertData and Feature::ExportFont is supported. Returns pairs of filename and data on success, empty vector otherwise. All data will be sharing common basename derived from filename. If the plugin doesn't have Feature::MultiFile, only one pair is returned, thus using exportFontToSingleData() might be more convenient in that case.

Containers::Array<char> Magnum::Text::AbstractFontConverter::exportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::string& characters) const

Export font to single raw data.

Available only if Feature::ConvertData and Feature::ExportFont is supported and the plugin doesn't have Feature::MultiFile. Returns data on success, zero-sized array otherwise. See exportFontToData() for more information.

bool Magnum::Text::AbstractFontConverter::exportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::string& characters) const

Export font to file.

Available only if Feature::ExportFont is supported. If the plugin has Feature::MultiFile, the function will create more than one file in given path, all sharing common basename derived from filename. Returns true on success, false otherwise. See exportFontToData() for more information.

std::vector<std::pair<std::string, Containers::Array<char>>> Magnum::Text::AbstractFontConverter::exportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const

Export glyph cache to raw data.

Parameters
cache Populated glyph cache
filename Output filename

Available only if Feature::ConvertData and Feature::ExportGlyphCache is supported. Returns pairs of filename and data on success, empty vector otherwise. All data will be sharing common basename derived from filename. If the plugin doesn't have Feature::MultiFile, only one pair is returned, thus using exportGlyphCacheToSingleData() might be more convenient in that case.

All glyphs from given cache will be exported. If you want to export smaller subset, fill the cache with less characters.

Containers::Array<char> Magnum::Text::AbstractFontConverter::exportGlyphCacheToSingleData(GlyphCache& cache) const

Export glyph cache to single raw data.

Available only if Feature::ConvertData and Feature::ExportGlyphCache is supported and the plugin doesn't have Feature::MultiFile. Returns data on success, zero-sized array otherwise. See exportGlyphCacheToData() for more information.

bool Magnum::Text::AbstractFontConverter::exportGlyphCacheToFile(GlyphCache& cache, const std::string& filename) const

Export glyph cache to file.

Available only if Feature::ExportGlyphCache is supported. If the plugin has Feature::MultiFile, the function will create more than one file in given path, all sharing common basename derived from filename. Returns true on success, false otherwise.

std::unique_ptr<GlyphCache> Magnum::Text::AbstractFontConverter::importGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayView<const char>>>& data) const

Import glyph cache from raw data.

Parameters
data Pairs of filename and file data

Available only if Feature::ConvertData and Feature::ImportGlyphCache is supported. Returns imported cache on success, nullptr otherwise. If the plugin doesn't have Feature::MultiFile, only one file is needed, thus using importGlyphCacheFromSingleData() might be more convenient in that case.

std::unique_ptr<GlyphCache> Magnum::Text::AbstractFontConverter::importGlyphCacheFromSingleData(Containers::ArrayView<const char> data) const

Import glyph cache from single raw data.

Available only if Feature::ConvertData and Feature::ImportGlyphCache is supported and the plugin doesn't have Feature::MultiFile. Returns imported cache on success, nullptr otherwise. See importGlyphCacheFromData() for multi-file conversion.

std::unique_ptr<GlyphCache> Magnum::Text::AbstractFontConverter::importGlyphCacheFromFile(const std::string& filename) const

Import glyph cache from file.

Available only if Feature::ImportGlyphCache is supported. If the plugin has Feature::MultiFile, the function will use additional files in given path, all sharing common basename derived from filename. Returns imported cache on success, nullptr otherwise.

std::vector<std::pair<std::string, Containers::Array<char>>> Magnum::Text::AbstractFontConverter::doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const virtual protected

Implementation for exportFontToData()

If the plugin doesn't have Feature::MultiFile, default implementation calls doExportFontToSingleData().

bool Magnum::Text::AbstractFontConverter::doExportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const virtual protected

Implementation for exportFontToFile()

If Feature::ConvertData is supported, default implementation calls doExportFontToData() and saves the result to given file(s).

std::vector<std::pair<std::string, Containers::Array<char>>> Magnum::Text::AbstractFontConverter::doExportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const virtual protected

Implementation for exportGlyphCacheToData()

If the plugin doesn't have Feature::MultiFile, default implementation calls doExportGlyphCacheToSingleData().

bool Magnum::Text::AbstractFontConverter::doExportGlyphCacheToFile(GlyphCache& cache, const std::string& filename) const virtual protected

Implementation for exportGlyphCacheToFile()

If Feature::ConvertData is supported, default implementation calls doExportGlyphCacheToData() and saves the result to given file(s).

std::unique_ptr<GlyphCache> Magnum::Text::AbstractFontConverter::doImportGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayView<const char>>>& data) const virtual protected

Implementation for importGlyphCacheFromData()

If the plugin doesn't have Feature::MultiFile, default implementation calls doImportGlyphCacheFromSingleData().

std::unique_ptr<GlyphCache> Magnum::Text::AbstractFontConverter::doImportGlyphCacheFromFile(const std::string& filename) const virtual protected

Implementation for importGlyphCacheFromFile()

If Feature::ConvertData is supported and the plugin doesn't have Feature::MultiFile, default implementation opens the file and calls doImportGlyphCacheFromSingleData() with its contents.