30 class i_native_font_face;
58 return static_cast<font_style>(~static_cast<uint32_t>(aLhs));
63 return static_cast<font_style>(
static_cast<uint32_t
>(aLhs) |
static_cast<uint32_t
>(aRhs));
68 return static_cast<font_style>(
static_cast<uint32_t
>(aLhs) &
static_cast<uint32_t
>(aRhs));
73 return static_cast<font_style>(
static_cast<uint32_t
>(aLhs) ^
static_cast<uint32_t
>(aRhs));
78 return aLhs =
static_cast<font_style>(
static_cast<uint32_t
>(aLhs) |
static_cast<uint32_t
>(aRhs));
83 return aLhs =
static_cast<font_style>(
static_cast<uint32_t
>(aLhs) &
static_cast<uint32_t
>(aRhs));
88 return aLhs =
static_cast<font_style>(
static_cast<uint32_t
>(aLhs) ^
static_cast<uint32_t
>(aRhs));
114 enum class font_weight : uint32_t
137 struct unknown_style : std::logic_error { unknown_style() :
std::logic_error(
"neogfx::font_info::unknown_style") {} };
138 struct unknown_style_name : std::logic_error { unknown_style_name() :
std::logic_error(
"neogfx::font_info::unknown_style_name") {} };
141 typedef font_info abstract_type;
142 typedef double point_size;
144 typedef std::optional<font_style> optional_style;
145 typedef std::optional<string> optional_style_name;
150 font_info(std::string
const& aFamilyName, font_style aStyle, point_size aSize);
151 font_info(std::string
const& aFamilyName, std::string
const& aStyleName, point_size aSize);
152 font_info(std::string
const& aFamilyName, font_style aStyle, std::string
const& aStyleName, point_size aSize);
153 font_info(
const font_info& aOther);
154 virtual ~font_info();
155 font_info& operator=(
const font_info& aOther);
157 font_info(std::string
const& aFamilyName,
const optional_style& aStyle,
const optional_style_name& aStyleName, point_size aSize);
159 virtual i_string
const& family_name()
const;
160 virtual bool style_available()
const;
162 virtual bool style_name_available()
const;
163 virtual i_string
const& style_name()
const;
166 virtual font_weight weight()
const;
167 virtual point_size
size()
const;
168 virtual bool kerning()
const;
169 virtual void enable_kerning();
170 virtual void disable_kerning();
172 font_info with_style(font_style aStyle)
const;
173 font_info with_style_xor(font_style aStyle)
const;
174 font_info with_underline(
bool aUnderline)
const;
175 font_info with_size(point_size aSize)
const;
178 bool operator<(
const font_info& aRhs)
const;
179 std::strong_ordering
operator<=>(
const font_info& aRhs)
const;
181 static font_weight weight_from_style(font_style aStyle);
182 static font_weight weight_from_style_name(std::string aStyleName,
bool aUnknownAsRegular =
true);
184 mutable std::shared_ptr<instance> iInstance;
187 typedef optional<font_info> optional_font_info;
192 class font :
public font_info
194 friend class font_manager;
195 friend class graphics_context;
198 struct no_fallback_font : std::logic_error { no_fallback_font() :
std::logic_error(
"neogfx::font::no_fallback_font") {} };
201 typedef font abstract_type;
207 font(std::string
const& aFamilyName, font_style aStyle, point_size aSize);
208 font(std::string
const& aFamilyName, std::string
const& aStyleName, point_size aSize);
209 font(
const font_info& aFontInfo);
210 font(
const font& aOther);
211 font(
const font& aOther, font_style aStyle, point_size aSize);
212 font(
const font& aOther, std::string
const& aStyleName, point_size aSize);
213 static font load_from_file(std::string
const& aFileName);
214 static font load_from_file(std::string
const& aFileName, font_style aStyle, point_size aSize);
215 static font load_from_file(std::string
const& aFileName, std::string
const& aStyleName, point_size aSize);
216 static font load_from_memory(
const void* aData, std::size_t aSizeInBytes);
217 static font load_from_memory(
const void* aData, std::size_t aSizeInBytes, font_style aStyle, point_size aSize);
218 static font load_from_memory(
const void* aData, std::size_t aSizeInBytes, std::string
const& aStyleName, point_size aSize);
220 font& operator=(
const font& aOther);
222 font(i_native_font_face& aNativeFontFace);
223 font(i_native_font_face& aNativeFontFace, font_style aStyle);
227 bool has_fallback()
const;
228 font fallback()
const;
231 i_string
const& family_name()
const override;
233 i_string
const& style_name()
const override;
234 point_size
size()
const override;
241 using font_info::kerning;
242 dimension kerning(uint32_t aLeftGlyphIndex, uint32_t aRightGlyphIndex)
const;
243 bool is_bitmap_font()
const;
244 uint32_t num_fixed_sizes()
const;
245 point_size fixed_size(uint32_t aFixedSizeIndex)
const;
247 const i_glyph& glyph(
const glyph_char& aGlyphChar)
const;
251 std::strong_ordering
operator<=>(
const font& aRhs)
const;
253 i_native_font_face& native_font_face()
const;
256 mutable std::shared_ptr<instance> iInstance;
259 typedef optional<font> optional_font;
261 template <
typename Elem,
typename Traits>
262 inline std::basic_ostream<Elem, Traits>&
operator<<(std::basic_ostream<Elem, Traits>& aStream,
const font_info& aFont)
265 aStream << aFont.family_name();
267 if (aFont.style_available())
268 aStream << aFont.style();
270 aStream << aFont.style_name();
272 aStream << aFont.size();
274 aStream << aFont.underline();
276 aStream << aFont.kerning();
281 template <
typename Elem,
typename Traits>
282 inline std::basic_istream<Elem, Traits>&
operator>>(std::basic_istream<Elem, Traits>& aStream, font_info& aFont)
284 std::string familyName;
285 std::variant<font_style, std::string> style;
286 font_info::point_size
size;
290 auto previousImbued = aStream.getloc();
295 aStream >> familyName;
311 aStream.imbue(previousImbued);
313 if (std::holds_alternative<font_style>(style))
314 aFont = font_info{ familyName, std::get<font_style>(style),
size };
316 aFont = font_info{ familyName, std::get<std::string>(style),
size };
319 aFont.enable_kerning();
321 aFont.disable_kerning();
#define end_declare_enum(enumName)
#define declare_enum_string(enumName, enumEnumerator)
#define begin_declare_enum(enumName)
#define define_setting_type_as(T, Name)
std::basic_ostream< Elem, Traits > & operator<<(std::basic_ostream< Elem, Traits > &aStream, const basic_point< T > &aPoint)
constexpr font_style & operator&=(font_style &aLhs, font_style aRhs)
constexpr style_aspect operator&(style_aspect aLhs, style_aspect aRhs)
bool underline(glyph_char const &g)
audio_channel operator^(audio_channel lhs, audio_channel rhs)
audio_channel operator~(audio_channel lhs)
default_geometry_value_type dimension
std::basic_istream< Elem, Traits > & operator>>(std::basic_istream< Elem, Traits > &aStream, basic_point< T > &aPoint)
bool operator<(const basic_rect< CoordinateType, CoordinateSystem > &left, const basic_rect< CoordinateType, CoordinateSystem > &right)
bool operator==(const basic_rect< CoordinateType, CoordinateSystem > &left, const basic_rect< CoordinateType, CoordinateSystem > &right)
constexpr font_style & operator|=(font_style &aLhs, font_style aRhs)
constexpr style_aspect operator|(style_aspect aLhs, style_aspect aRhs)
void set_underline(glyph_char &g, bool aUnderline)
constexpr font_style & operator^=(font_style &aLhs, font_style aRhs)
std::partial_ordering operator<=>(const gradient &aLhs, const gradient &aRhs)
basic_size< coordinate > size
ref_ptr< ConcreteType > make_ref(Args &&... args)