AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
PangoTextLayout.hpp
1/*
2Copyright (C) 2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGUI_PANGOTEXTLAYOUT_H
17#define AEONGUI_PANGOTEXTLAYOUT_H
18#include <cstdint>
19#include <string>
20#include <memory>
21#include "aeongui/TextLayout.hpp"
22
23struct _PangoLayout;
24typedef struct _PangoLayout PangoLayout;
25struct _PangoContext;
26typedef struct _PangoContext PangoContext;
27struct _PangoFontDescription;
28typedef struct _PangoFontDescription PangoFontDescription;
29typedef void* gpointer;
30
31namespace AeonGUI
32{
39 {
40 public:
42 DLL PangoTextLayout();
44 DLL ~PangoTextLayout() override;
48 DLL void SetText ( const std::string& aText ) override;
52 DLL void SetFontFamily ( const std::string& aFamily ) override;
56 DLL void SetFontSize ( double aSize ) override;
60 DLL void SetFontWeight ( int aWeight ) override;
64 DLL void SetFontStyle ( int aStyle ) override;
68 DLL double GetTextWidth() const override;
72 DLL double GetTextHeight() const override;
76 DLL double GetBaseline() const override;
81 DLL double GetCharOffsetX ( long aIndex ) const override;
85 PangoLayout* GetPangoLayout() const;
86 private:
87 void UpdateFontDescription();
88 PangoContext* mPangoContext{};
89 PangoLayout* mLayout{};
90 PangoFontDescription* mFontDescription{};
91 std::string mFontFamily{"sans-serif"};
92 double mFontSize{16.0};
93 int mFontWeight{400};
94 int mFontStyle{0};
95 };
96}
97
98#endif
void SetText(const std::string &aText) override
Set the text content to lay out.
Definition PangoTextLayout.cpp:112
void SetFontStyle(int aStyle) override
Set the font style.
Definition PangoTextLayout.cpp:135
PangoTextLayout()
Default constructor. Creates a layout with default font settings.
Definition PangoTextLayout.cpp:24
double GetCharOffsetX(long aIndex) const override
Get the x-offset of a character at the given byte index.
Definition PangoTextLayout.cpp:165
~PangoTextLayout() override
Destructor. Releases Pango resources.
Definition PangoTextLayout.cpp:38
void SetFontSize(double aSize) override
Set the font size.
Definition PangoTextLayout.cpp:123
void SetFontWeight(int aWeight) override
Set the font weight.
Definition PangoTextLayout.cpp:129
double GetTextWidth() const override
Get the logical width of the laid-out text.
Definition PangoTextLayout.cpp:141
PangoLayout * GetPangoLayout() const
Access the underlying PangoLayout for advanced use.
Definition PangoTextLayout.cpp:172
double GetBaseline() const override
Get the baseline offset from the top of the layout.
Definition PangoTextLayout.cpp:157
void SetFontFamily(const std::string &aFamily) override
Set the font family.
Definition PangoTextLayout.cpp:117
double GetTextHeight() const override
Get the logical height of the laid-out text.
Definition PangoTextLayout.cpp:149
Abstract text layout interface.
Definition TextLayout.hpp:35