AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
SkiaTextLayout.hpp
1/*
2Copyright (C) 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_SKIATEXTLAYOUT_H
17#define AEONGUI_SKIATEXTLAYOUT_H
18#include <cstdint>
19#include <string>
20#include <vector>
21#include "aeongui/TextLayout.hpp"
22
23struct _PangoLayout;
24typedef struct _PangoLayout PangoLayout;
25struct _PangoContext;
26typedef struct _PangoContext PangoContext;
27struct _PangoFontDescription;
28typedef struct _PangoFontDescription PangoFontDescription;
29
30namespace AeonGUI
31{
36 class SkiaTextLayout : public TextLayout
37 {
38 public:
39 DLL SkiaTextLayout();
40 DLL ~SkiaTextLayout() override;
41 DLL void SetText ( const std::string& aText ) override;
42 DLL void SetFontFamily ( const std::string& aFamily ) override;
43 DLL void SetFontSize ( double aSize ) override;
44 DLL void SetFontWeight ( int aWeight ) override;
45 DLL void SetFontStyle ( int aStyle ) override;
46 DLL double GetTextWidth() const override;
47 DLL double GetTextHeight() const override;
48 DLL double GetBaseline() const override;
49 DLL double GetCharOffsetX ( long aIndex ) const override;
53 PangoLayout* GetPangoLayout() const;
54 private:
55 void UpdateFontDescription();
56 std::string mFontFamily{"sans-serif"};
57 double mFontSize{16.0};
58 int mFontWeight{400};
59 int mFontStyle{0};
60 PangoContext* mPangoContext{nullptr};
61 PangoLayout* mLayout{nullptr};
62 PangoFontDescription* mFontDescription{nullptr};
63 };
64}
65#endif
double GetTextHeight() const override
Get the logical height of the laid-out text.
Definition SkiaTextLayout.cpp:152
double GetCharOffsetX(long aIndex) const override
Definition SkiaTextLayout.cpp:168
void SetFontStyle(int aStyle) override
Set the font style.
Definition SkiaTextLayout.cpp:138
double GetBaseline() const override
Get the baseline offset from the top.
Definition SkiaTextLayout.cpp:160
void SetFontWeight(int aWeight) override
Set the font weight.
Definition SkiaTextLayout.cpp:132
void SetText(const std::string &aText) override
Set the text content to lay out.
Definition SkiaTextLayout.cpp:115
void SetFontFamily(const std::string &aFamily) override
Set the font family.
Definition SkiaTextLayout.cpp:120
PangoLayout * GetPangoLayout() const
Get the underlying PangoLayout.
Definition SkiaTextLayout.cpp:175
void SetFontSize(double aSize) override
Set the font size.
Definition SkiaTextLayout.cpp:126
double GetTextWidth() const override
Get the logical width of the laid-out text.
Definition SkiaTextLayout.cpp:144
Abstract text layout interface.
Definition TextLayout.hpp:35