diff options
| author | crupest <crupest@outlook.com> | 2022-06-04 23:09:08 +0800 |
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2022-06-04 23:09:08 +0800 |
| commit | a49064e065eef5de51ba188f691c610dd0a9fcaf (patch) | |
| tree | e98bd45d0167a794ae42ed9105d9a525c26dc43d | |
| parent | ea913d6818ae7dfa0663ab99c5908d1008a076b1 (diff) | |
| download | cru-a49064e065eef5de51ba188f691c610dd0a9fcaf.tar.gz cru-a49064e065eef5de51ba188f691c610dd0a9fcaf.tar.bz2 cru-a49064e065eef5de51ba188f691c610dd0a9fcaf.zip | |
...
| -rw-r--r-- | include/cru/platform/graphics/cairo/PangoFont.h | 7 | ||||
| -rw-r--r-- | src/platform/graphics/cairo/PangoFont.cpp | 12 |
2 files changed, 17 insertions, 2 deletions
diff --git a/include/cru/platform/graphics/cairo/PangoFont.h b/include/cru/platform/graphics/cairo/PangoFont.h index 75e139af..0e080c18 100644 --- a/include/cru/platform/graphics/cairo/PangoFont.h +++ b/include/cru/platform/graphics/cairo/PangoFont.h @@ -3,6 +3,8 @@ #include "../Font.h" #include "CairoResource.h" +#include <pango/pango.h> + namespace cru::platform::graphics::cairo { class PangoFont : public CairoResource, public virtual IFont { public: @@ -14,8 +16,13 @@ class PangoFont : public CairoResource, public virtual IFont { String GetFontName() override; float GetFontSize() override; + PangoFontDescription* GetPangoFontDescription() { + return pango_font_description_; + } + private: String font_family_; float font_size_; + PangoFontDescription* pango_font_description_; }; } // namespace cru::platform::graphics::cairo diff --git a/src/platform/graphics/cairo/PangoFont.cpp b/src/platform/graphics/cairo/PangoFont.cpp index f43b6c55..0de17add 100644 --- a/src/platform/graphics/cairo/PangoFont.cpp +++ b/src/platform/graphics/cairo/PangoFont.cpp @@ -5,9 +5,17 @@ PangoFont::PangoFont(CairoGraphicsFactory* factory, String font_family, float font_size) : CairoResource(factory), font_family_(std::move(font_family)), - font_size_(font_size) {} + font_size_(font_size) { + pango_font_description_ = pango_font_description_new(); + auto font_family_str = font_family_.ToUtf8(); + pango_font_description_set_family(pango_font_description_, + font_family_str.c_str()); + pango_font_description_set_size(pango_font_description_, font_size); +} -PangoFont::~PangoFont() {} +PangoFont::~PangoFont() { + pango_font_description_free(pango_font_description_); +} String PangoFont::GetFontName() { return font_family_; } |
