xtd - Reference Guide  0.2.0
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:
35 
40  explicit font_family(const xtd::ustring& name);
41 
45 
50  font_family(const xtd::ustring& name, const text::font_collection& font_collection);
52 
54  ~font_family();
55  font_family(const font_family& value);
56  font_family() = default;
57  font_family& operator=(const font_family& value);
58  bool operator==(const font_family& value) const {return data_->name_ == value.data_->name_;}
59  bool operator!=(const font_family& value) const {return !operator==(value);}
61 
63 
67  static std::vector<font_family> families();
68 
72 
76 
80 
83  const xtd::ustring& name() const {return data_->name_;}
85 
87 
92  int32_t get_cell_ascent(font_style style) const;
93 
97  int32_t get_cell_descent(font_style style) const;
98 
102  int32_t get_em_height(font_style style) const;
103 
107  int32_t get_line_spacing(font_style style) const;
108 
113  xtd::ustring get_name(int32_t language) const;
114 
118  bool is_style_available(font_style style) const;
119 
122  xtd::ustring to_string() const noexcept override {return ustring::format("[{}: name={}]", ustring::class_name(*this), data_->name_);}
124 
126  friend std::ostream& operator<<(std::ostream& os, const xtd::drawing::font_family& font_family) noexcept {
127  return os << font_family.to_string();
128  }
130 
131  private:
132  struct data {
133  intptr_t handle_ = 0;
134  xtd::ustring name_;
135  };
136  std::shared_ptr<data> data_ = std::make_shared<data>();
137  };
138  }
139 }
static font_family generic_sans_serif()
Gets a generic sans serif font_family.
Definition: font_family.h:75
Defines a group of type faces having a similar basic design and certain variations in styles...
Definition: font_family.h:32
Contains xtd::drawing::font_style enum class.
generic_font_families
Specifies a generic font_family object.
Definition: generic_font_families.h:19
Provides a base class for installed and private font collections.
Definition: font_collection.h:22
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
A generic Serif font_family object.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:50
A generic Sans Serif font_family object.
xtd::ustring to_string() const noexcept override
Converts this font_family to a human-readable string representation.
Definition: font_family.h:122
Contains xtd::ustring class.
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:30
font_style
Specifies style information applied to text. This enumeration has a flags attribute that allows a bit...
Definition: font_style.h:17
static ustring class_name()
Gets the class name of the object_t.
Definition: ustring.h:461
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:708
const xtd::ustring & name() const
Gets the name of this font_family.
Definition: font_family.h:83
A generic Monospace font_family object.
static font_family generic_serif()
Gets a generic serif font_family.
Definition: font_family.h:79
static font_family generic_monospace()
Gets a generic monospace font_family.
Definition: font_family.h:71
Contains xtd::drawing::text::generic_font_families enum class.