MUSX Document Model
Loading...
Searching...
No Matches
musx::dom::FontInfo Struct Reference

Represents the default font settings for a particular element type. More...

#include <CommonClasses.h>

+ Inheritance diagram for musx::dom::FontInfo:

Public Member Functions

 FontInfo (const DocumentWeakPtr &document, bool sizeIsPercent=false)
 constructor
 
bool getSizeIsPercent () const
 If true, the size of this font is calculated as a percent of the preceding font size (in an Enigma string)
 
std::string getName () const
 Get the name of the font.
 
void setFontIdByName (const std::string &name)
 Sets the id of the font from a string name.
 
void setEnigmaStyles (uint16_t efx)
 Set style effects based on a bitmask. This is mainly useful for capturing text styles from enigma strings. (See musx::util::EnigmaString::parseStyleCommand.)
 
uint16_t getEnigmaStyles () const
 Returns the font styles as an nfx bitmask.
 
bool calcIsDefaultMusic () const
 Calculates if this is the default music font.
 
bool calcIsSymbolFont () const
 Calculates if this is a symbol font. (See others::FontDefinition::calcIsSymbolFont.)
 
std::optional< std::filesystem::path > calcSMuFLMetaDataPath () const
 Returns the filepath of the SMuFL font's metadata json file, if any.
 
bool calcIsSMuFL () const
 Calculates whether this is a SMuFL font.
 
- Public Member Functions inherited from musx::dom::CommonClassBase
 CommonClassBase (const DocumentWeakPtr &document)
 Constructs a CommonClassBase object.
 
- Public Member Functions inherited from musx::dom::Base
virtual ~Base () noexcept(false)=default
 Virtual destructor for polymorphic behavior.
 
DocumentPtr getDocument () const
 Gets a reference to the Document.
 
Cmper getSourcePartId () const
 Gets the source partId for this instance. If an instance is fully shared with the score, the source is SCORE_PARTID. If an instance is partially shared or non shared, the source is the ID of the part that sourced it.
 
ShareMode getShareMode () const
 Gets the sharing mode for this instance.
 
const SharedNodesgetUnlinkedNodes () const
 Gets the unlinked nodes for this instance. (Only populated for ShareMode::Partial)
 
void addUnlinkedNode (const std::string &nodeName)
 Adds a shared node for this instance.
 
virtual void integrityCheck (const std::shared_ptr< Base > &ptrToThis)
 Allows a class to determine if it has been properly contructed by the factory and fix issues that it can, such as creating default instances of contained classes.
 
virtual bool requireAllFields () const
 Specifies if the parser should alert (print or throw) when an unknown xml tag is found for this class.
 

Static Public Member Functions

static std::optional< std::filesystem::path > calcSMuFLMetaDataPath (const std::string &fontName)
 Returns the filepath of the SMuFL font's metadata json file, if any.
 
static std::vector< std::filesystem::path > calcSMuFLPaths ()
 Returns the standard SMuFL font folder.
 
static const xml::XmlElementArray< FontInfo > & xmlMappingArray ()
 Required for musx::factory::FieldPopulator.
 

Public Attributes

Cmper fontId {}
 Font identifier. This is a Cmper for others::FontDefinition.
 
int fontSize {}
 Font size or percent (where 100 is 100%) of preceding font size. (See getSizeIsPercent.)
 
bool bold {}
 Bold effect.
 
bool italic {}
 Italic effect.
 
bool underline {}
 Underline effect.
 
bool strikeout {}
 Strikeout effect.
 
bool absolute {}
 Fixed size effect.
 
bool hidden {}
 Hidden effect.
 

Static Public Attributes

Enigma style bitmask constants

These are used to encode and decode style effects in Enigma strings.

static constexpr uint16_t EnigmaStyleBold = 0x01
 Bold style bit.
 
static constexpr uint16_t EnigmaStyleItalic = 0x02
 Italic style bit.
 
static constexpr uint16_t EnigmaStyleUnderline = 0x04
 Underline style bit.
 
static constexpr uint16_t EnigmaStyleStrikeout = 0x20
 Strikeout style bit.
 
static constexpr uint16_t EnigmaStyleAbsolute = 0x40
 Fixed-size (absolute) bit.
 
static constexpr uint16_t EnigmaStyleHidden = 0x80
 Hidden text bit.
 

Additional Inherited Members

- Public Types inherited from musx::dom::Base
enum class  ShareMode { All , Partial , None }
 Describes how this instance is shared between part and score. More...
 
using SharedNodes = std::set< std::string >
 The container type for shared nodes.
 
- Protected Member Functions inherited from musx::dom::CommonClassBase
ShareMode getShareMode () const
 Gets the sharing mode for this instance.
 
const SharedNodesgetUnlinkedNodes () const
 Gets the unlinked nodes for this instance. (Only populated for ShareMode::Partial)
 
- Protected Member Functions inherited from musx::dom::Base
 Base (const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode)
 Constructs the base class.
 
 Base (const Base &)=default
 explicit default copy constructor
 
 Base (Base &&) noexcept=default
 explicit default move constructor
 
Baseoperator= (const Base &)
 no-op copy assignment operator allows subclasses to copy their values.
 
Baseoperator= (Base &&) noexcept
 no-op move assignment operator allows subclasses to move their values.
 

Detailed Description

Represents the default font settings for a particular element type.

The FontInfo struct holds information about font properties, such as the font ID, size, and styles like bold, italic, underline, strikeout, fixed size, and visibility.

Constructor & Destructor Documentation

◆ FontInfo()

musx::dom::FontInfo::FontInfo ( const DocumentWeakPtr document,
bool  sizeIsPercent = false 
)
inline

constructor

Parameters
documentthe document containing the font
sizeIsPercentif true, the size is a percent relative to the preceding font size in an Enigma string.

Member Function Documentation

◆ calcSMuFLMetaDataPath()

std::optional< std::filesystem::path > musx::dom::FontInfo::calcSMuFLMetaDataPath ( const std::string &  fontName)
static

Returns the filepath of the SMuFL font's metadata json file, if any.

Parameters
fontNameThe font name to find.

◆ calcSMuFLPaths()

std::vector< std::filesystem::path > musx::dom::FontInfo::calcSMuFLPaths ( )
static

Returns the standard SMuFL font folder.

Returns
a std::vector<std::filesystem::path> where element 0 is the user path and element 1 is the system path

◆ getName()

std::string musx::dom::FontInfo::getName ( ) const

Get the name of the font.

Returns
The name of the font as a string.

◆ setEnigmaStyles()

void musx::dom::FontInfo::setEnigmaStyles ( uint16_t  efx)
inline

Set style effects based on a bitmask. This is mainly useful for capturing text styles from enigma strings. (See musx::util::EnigmaString::parseStyleCommand.)

Parameters
efxA 16-bit integer representing style effects with specific bit masks.

◆ setFontIdByName()

void musx::dom::FontInfo::setFontIdByName ( const std::string &  name)

Sets the id of the font from a string name.

Parameters
nameThe font name to find.
Exceptions
std::invalid_parameterif the name is not found.