Verovio
Source code documentation
vrv::Resources Class Reference

This class provides resource values. More...

#include <resources.h>

Public Types

using StyleAttributes = std::pair< data_FONTWEIGHT, data_FONTSTYLE >
 
using GlyphTable = std::unordered_map< char32_t, Glyph >
 
using GlyphNameTable = std::unordered_map< std::string, char32_t >
 
using GlyphTextMap = std::map< StyleAttributes, GlyphTable >
 

Public Member Functions

bool IsSmuflFallbackNeeded (const std::u32string &text) const
 Check if the text has any charachter that needs the smufl fallback font.
 
bool IsCurrentFontFallback () const
 Check if the current font is the fallback font.
 
std::string GetCSSFontFor (const std::string &fontName) const
 Get the CSS font string for the corresponding font. More...
 
std::string GetCustomFontname (const std::string &filename, const ZipFileReader &zipFile)
 Retrieve the font name either from the filename path or from the zipFile content.
 
Constructors, destructors, and other standard methods
 Resources ()
 
virtual ~Resources ()=default
 
bool InitFonts ()
 Font initialization. More...
 
bool SetFont (const std::string &fontName)
 Set the font to be used and loads it if necessary.
 
bool AddCustom (const std::vector< std::string > &extraFonts)
 Add custom (external) fonts.
 
bool LoadAll ()
 Load all music fonts available in the resource directory.
 
void SetFallbackFont (const std::string &fontName)
 Set the fallback font (Leipzig or Bravura) when some glyphs are missing in the current font.
 
std::string GetFallbackFont () const
 Get the fallback font name.
 
bool SetCurrentFont (const std::string &fontName, bool allowLoading=false)
 Select a particular font.
 
std::string GetCurrentFont () const
 
bool IsFontLoaded (const std::string &fontName) const
 
const GlyphGetGlyph (char32_t smuflCode) const
 Retrieving glyphs. More...
 
const GlyphGetGlyph (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.
 
void SelectTextFont (data_FONTWEIGHT fontWeight, data_FONTSTYLE fontStyle) const
 Text fonts. More...
 
const GlyphGetTextGlyph (char32_t code) const
 Returns the glyph (if exists) for the text font (bounding box and ASCII only)
 
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...
 

Setters and getters

std::string GetPath () const
 
void SetPath (const std::string &path)
 
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

◆ GetCSSFontFor()

std::string vrv::Resources::GetCSSFontFor ( const std::string &  fontName) const

Get the CSS font string for the corresponding font.

Return an empty string if the font has not been loaded.

◆ 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

◆ 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.

Init the SMufL music and text fonts

◆ SelectTextFont()

void vrv::Resources::SelectTextFont ( data_FONTWEIGHT  fontWeight,
data_FONTSTYLE  fontStyle 
) const

Text fonts.

Set current text style


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