xtd - Reference Guide  0.1.1
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
font_family.h
Go to the documentation of this file.
1 #pragma once
5 #include <cstdint>
6 #include <memory>
7 #include <ostream>
8 #include <stdexcept>
9 #include <vector>
10 #include <xtd/object.h>
11 #include <xtd/ustring.h>
12 #include "../drawing_export.h"
13 #include "font_style.h"
15 
17 namespace xtd {
19  namespace drawing {
21  namespace text {
22  class font_collection;
23  }
25 
32  class drawing_export_ font_family final : public object {
33  public:
37  font_family(const xtd::ustring& name);
38 
42 
47  font_family(const xtd::ustring& name, const text::font_collection& font_collection);
48 
50  ~font_family();
51  font_family(const font_family& value);
52  font_family() = default;
53  font_family& operator=(const font_family& value);
54  bool operator==(const font_family& value) const {return data_->name_ == value.data_->name_;}
55  bool operator!=(const font_family& value) const {return !operator==(value);}
57 
60  static std::vector<font_family> families();
61 
65 
69 
73 
76  const xtd::ustring& name() const {return data_->name_;}
77 
81  int32_t get_cell_ascent(font_style style) const;
82 
86  int32_t get_cell_descent(font_style style) const;
87 
91  int32_t get_em_height(font_style style) const;
92 
96  int32_t get_line_spacing(font_style style) const;
97 
102  xtd::ustring get_name(int32_t language) const;
103 
107  bool is_style_available(font_style style) const;
108 
111  xtd::ustring to_string() const noexcept override {return ustring::format("[{}: name={}]", ustring::class_name(*this), data_->name_);}
112 
114  friend std::ostream& operator<<(std::ostream& os, const xtd::drawing::font_family& font_family) noexcept {
115  return os << font_family.to_string();
116  }
118 
119  private:
120  struct data {
121  intptr_t handle_ = 0;
122  xtd::ustring name_;
123  };
124  std::shared_ptr<data> data_ = std::make_shared<data>();
125  };
126  }
127 }
Defines a group of type faces having a similar basic design and certain variations in styles....
Definition: font_family.h:32
static font_family generic_sans_serif()
Gets a generic sans serif font_family.
Definition: font_family.h:68
int32_t get_cell_ascent(font_style style) const
Returns the cell ascent, in design units, of the font_family of the specified style.
font_family(const xtd::ustring &name, const text::font_collection &font_collection)
Initializes a new xtd::drawing::font_family in the specified font_collection with the specified name.
int32_t get_cell_descent(font_style style) const
Returns the cell descent, in design units, of the font_family of the specified style.
static font_family generic_serif()
Gets a generic serif font_family.
Definition: font_family.h:72
static font_family generic_monospace()
Gets a generic monospace font_family.
Definition: font_family.h:64
font_family(const xtd::ustring &name)
Initializes a new xtd::drawing::font_family with the specified name.
int32_t get_line_spacing(font_style style) const
Returns the line spacing, in design units, of the font_family of the specified style....
int32_t get_em_height(font_style style) const
Gets the height, in font design units, of the em square for the specified style.
font_family(text::generic_font_families generic_font_families)
Initializes a new xtd::drawing::font_family from the specified generic font family.
bool is_style_available(font_style style) const
Indicates whether the specified font_style enumeration is available.
const xtd::ustring & name() const
Gets the name of this font_family.
Definition: font_family.h:76
xtd::ustring to_string() const noexcept override
Converts this font_family to a human-readable string representation.
Definition: font_family.h:111
static std::vector< font_family > families()
Returns an array that contains all the font_family objects associated with the current graphics conte...
xtd::ustring get_name(int32_t language) const
Returns the name, in the specified language, of this font_family.
Provides a base class for installed and private font collections.
Definition: font_collection.h:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition: object.h:26
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
static ustring class_name()
Gets the class name of the object_t.
Definition: ustring.h:444
Contains xtd::drawing::font_style enum class.
Contains xtd::drawing::text::generic_font_families enum class.
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition: ustring.h:689
#define drawing_export_
Define shared library export.
Definition: drawing_export.h:13
font_style
Specifies style information applied to text. This enumeration has a flags attribute that allows a bit...
Definition: font_style.h:17
generic_font_families
Specifies a generic font_family object.
Definition: generic_font_families.h:19
@ sans_serif
A generic Sans Serif font_family object.
@ monospace
A generic Monospace font_family object.
@ serif
A generic Serif font_family object.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::object class.
Contains xtd::ustring class.