Verovio
Source code documentation
vrv::Resources Class Reference

This class provides resource values. More...

#include <resources.h>

Public Types

using GlyphNameTable = std::unordered_map< std::string, char32_t >
 
using FaceStyle = std::pair< FontStore::Weight, FontStore::Style >
 

Public Member Functions

bool Ok () const
 Status checker.
 
bool IsSmuflFallbackNeeded (const std::u32string &text) const
 Check if the text has any character that needs the smufl fallback font.
 
Constructors, destructors, and other standard methods
 Resources ()
 
virtual ~Resources ()=default
 
bool InitFonts ()
 Font initialization. More...
 
std::optional< FontStore::FontFile > GetMusicFontForEmbedding (const std::string &fontName, std::string &bundledFile) const
 Return the font file of a music font for embedding in the SVG, which is a subset for the bundled fonts. More...
 
bool SetFallbackFont (const std::string &fontName)
 Set the music fallback family, which has to be registered. More...
 
std::string GetFallbackFont () const
 Get the fallback font name.
 
bool SetCurrentFont (const std::string &fontName)
 Select a particular font.
 
std::string GetCurrentFont () const
 
bool IsFontLoaded (const std::string &fontName) const
 
const Glyph * GetGlyph (char32_t smuflCode) const
 Retrieving glyphs. More...
 
const Glyph * GetGlyph (char32_t smuflCode, const std::string &fontName) const
 Returns a music glyph using an explicit registered family.
 
const Glyph * GetGlyph (const std::string &smuflName) const
 Returns the glyph (if exists) for a glyph name in the current SMuFL font.
 
char32_t GetGlyphCode (const std::string &smuflName) const
 Returns the glyph (if exists) for a glyph name in the current SMuFL font.
 
bool SetTextFont (const std::string &fontName)
 Text fonts. More...
 
std::string GetTextFont () const
 Return the default text family.
 
std::string GetTextFontMetricEquivalent () const
 The widespread font family with the same metrics as the text font, if any (e.g., Times for Tinos)
 
std::optional< FontStore::ShapedRun > ShapeText (const FontInfo &font, const std::u32string &text) const
 Shape text using the family and style requested by a drawing font.
 
int GetTextAdvance (const FontInfo &font, const FontStore::ShapedRun &run) const
 Return the scaled advance of a shaped run, including letter spacing.
 
const Glyph * GetTextGlyph (char32_t code, const FontInfo &font) const
 Returns a glyph from the runtime face selected by a drawing font.
 
const Glyph * GetRuntimeGlyph (FontStore::FaceIdentity face, int glyphId, const std::string &code="") const
 Returns a cached runtime glyph by immutable face identity and glyph ID.
 
bool FontHasGlyphAvailable (const std::string &fontName, char32_t smuflCode) const
 Returns true if the specified font is loaded and it contains the requested glyph.
 

Static Public Member Functions

static char32_t GetSmuflGlyphForUnicodeChar (const char32_t unicodeChar)
 Static method that converts unicode music code points to SMuFL equivalent. More...
 
static FaceStyle GetFaceStyle (const FontInfo &font)
 Static method that returns the weight and style of the face for a drawing font.
 
static std::string FindSmuflMetadata (const std::string &fontFilename)
 Static method that looks for the SMuFL metadata file of a music font file. More...
 

Setters and getters

std::string GetPath () const
 
void SetPath (const std::string &path)
 
const FontStore & GetFontStore () const
 
FontStore & GetFontStoreForModification ()
 
static std::string GetDefaultPath ()
 
static void SetDefaultPath (const std::string &path)
 

Detailed Description

This class provides resource values.

It manages fonts and glyph tables.

Member Function Documentation

◆ FindSmuflMetadata()

static std::string vrv::Resources::FindSmuflMetadata ( const std::string &  fontFilename)
static

Static method that looks for the SMuFL metadata file of a music font file.

The metadata is looked for next to the font file and in the standard SMuFL locations. Return an empty string if it is not found.

◆ GetGlyph()

const Glyph* vrv::Resources::GetGlyph ( char32_t  smuflCode) const

Retrieving glyphs.

Returns the glyph (if exists) for a glyph code in the current SMuFL font

◆ GetMusicFontForEmbedding()

std::optional<FontStore::FontFile> vrv::Resources::GetMusicFontForEmbedding ( const std::string &  fontName,
std::string &  bundledFile 
) const

Return the font file of a music font for embedding in the SVG, which is a subset for the bundled fonts.

The file name is given for the bundled fonts, which are also published on the website.

◆ GetSmuflGlyphForUnicodeChar()

static char32_t vrv::Resources::GetSmuflGlyphForUnicodeChar ( const char32_t  unicodeChar)
static

Static method that converts unicode music code points to SMuFL equivalent.

Return the parameter char if nothing can be converted.

◆ InitFonts()

bool vrv::Resources::InitFonts ( )

Font initialization.

Register the bundled Leipzig, Bravura, and Tinos faces

◆ SetFallbackFont()

bool vrv::Resources::SetFallbackFont ( const std::string &  fontName)

Set the music fallback family, which has to be registered.

Bravura remains the final fallback.

◆ SetTextFont()

bool vrv::Resources::SetTextFont ( const std::string &  fontName)

Text fonts.

Set the default text family, which has to be registered


The documentation for this class was generated from the following file: