8 #ifndef __VRV_FONTSTORE_H__
9 #define __VRV_FONTSTORE_H__
29 enum class Kind { Music,
Text };
30 enum class Weight { Normal, Bold };
31 enum class Style { Normal, Italic };
37 explicit operator bool()
const {
return m_value != 0; }
76 std::vector<GlyphPlacement> m_glyphs;
77 bool operator==(
const ShapedRun &)
const =
default;
85 Weight m_weight = Weight::Normal;
86 Style m_style = Style::Normal;
89 std::string m_mimeType;
90 std::vector<unsigned char> m_data;
95 int m_decodedFonts = 0;
96 int m_extractedMetrics = 0;
97 int m_extractedOutlines = 0;
119 std::
string RegisterTextFont(const
unsigned char *data,
int length, const std::
string &alias = "");
120 std::
string RegisterMusicFont(
121 const
unsigned char *data,
int length, const std::
string &smuflMetadataJson, const std::
string &alias = "");
129 Kind kind, const std::
string &family, Weight weight = Weight::Normal, Style style = Style::Normal) const;
130 std::optional<
GlyphMetrics> GetGlyphMetrics(Kind kind, const std::
string &family, char32_t codepoint,
131 Weight weight = Weight::Normal, Style style = Style::Normal) const;
133 std::optional<std::
string> GetGlyphOutline(Kind kind, const std::
string &family,
int glyphId,
134 Weight weight = Weight::Normal, Style style = Style::Normal) const;
135 std::optional<std::
string> GetGlyphOutline(
FaceIdentity face,
int glyphId) const;
136 std::vector<
GlyphAnchor> GetMusicGlyphAnchors(const std::
string &family, const std::
string &glyphName) const;
146 Weight weight = Weight::Normal, Style style = Style::Normal, const std::
string &musicFamily = "",
147 const std::
string &musicFallbackFamily = "") const;
159 static std::vector<
unsigned char>
ReadFile(const std::
string &filename);
163 std::unique_ptr<Impl> m_impl;
This class registers OpenType fonts at runtime and gives access to their glyph metrics,...
Definition: fontstore.h:27
void PinBundledData()
Pin the currently registered bundled faces in the process cache.
Counters GetCounters() const
Return the amount of work done by the store.
std::optional< ShapedRun > ShapeText(const std::string &family, const std::u32string &text, Weight weight=Weight::Normal, Style style=Style::Normal, const std::string &musicFamily="", const std::string &musicFallbackFamily="") const
Shape a text with a text family.
static std::vector< unsigned char > ReadFile(const std::string &filename)
Read a font or metadata file, which is empty if it cannot be read or is too large to be registered.
std::vector< FontFile > GetFontFiles(Kind kind, const std::string &family) const
Return the files of all faces registered for a family (or alias), without synthesized faces.
uint64_t GetGeneration() const
Return a value changed with each registration.
This class models CDATA (text)
Definition: text.h:23
The amount of work done by the store, for checking that the glyph data is extracted lazily.
Definition: fontstore.h:94
The identity of a face, which is the same for identical font data.
Definition: fontstore.h:34
A registered font file, kept in the format it was registered with (e.g., WOFF2 is not decompressed)
Definition: fontstore.h:84
std::string m_format
The CSS @font-face format: "woff2", "woff", "opentype", or "truetype".
Definition: fontstore.h:88
A SMuFL anchor of a glyph, in staff spaces.
Definition: fontstore.h:53
The metrics of a glyph, in font units.
Definition: fontstore.h:41
The placement of a glyph in a shaped run, in font units.
Definition: fontstore.h:60
A shaped text run.
Definition: fontstore.h:73
int GetClusterGapCount() const
Return the number of gaps between clusters, where letter spacing applies.