Elaztek Developer Hub
Blamite Game Engine - Keystone  00433.02.16.25.2127.blamite
A library that enables the use of Qt in Blamite's editing tools.
FontToolWindow.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <QMainWindow>
4 #include "ui_FontToolWindow.h"
5 
6 #include <Strings/components/classes/map/map.h>
7 
12 {
13  int width = 0;
14  int height = 0;
15  float uv_x_start = 0.0f;
16  float uv_x_end = 0.0f;
17  float uv_y_start = 0.0f;
18  float uv_y_end = 0.0f;
19 };
20 
30 class FontToolWindow : public QMainWindow
31 {
32  Q_OBJECT
33 
34 private:
35  Ui::FontToolWindow ui;
36 
37  std::string existing_file_path = "";
38  QPixmap cached_atlas = QPixmap();
39  bool any_glyphs_cutoff = false;
40  BlamMap<char, BlamGlyphUVInfo> cached_uvs = BlamMap<char, BlamGlyphUVInfo>();
41 
42  // I/O
43 
51  bool LoadExistingFont();
52 
61  bool SaveAsXMLBitmap(bool use_atlas);
62 
63  // Data Retrieval
64 
70  QFont::HintingPreference GetSelectedHintingPreference();
71 
77  QFont::StyleStrategy GetSelectedStyleStrategy();
78 
84  QFont::Weight GetSelectedFontWeight();
85 
91  QFont GetFont();
92 
98  int GetUnitSize();
99 
100  // UI
101 
105  void SetupUI();
106 
110  void RefreshPreview();
111 
117  void RefreshAtlasPreview(bool regenerate_texture = false);
118 
129  QPixmap GenerateAtlasTexture(int resolution, int unit_size, int units, QColor text_color = QColor(0,0,0, 255));
130 
131  // Image Utils
132 
143  QImage GetCharacterImage(QChar character, QColor color = QColor(0, 0, 0, 255), int max_width = -1, int max_height = -1);
144 
160  QImage CropImage(QImage bitm, bool adjust_width, bool adjust_height, bool baseline_fix, bool x_fix = true,
161  int max_width = -1, int max_height = -1);
162 
173  bool IsRowEmpty(QImage bitm, int row);
174 
185  bool IsColumnEmpty(QImage bitm, int column);
186 
187 public:
194  FontToolWindow(std::string _existing_file_path = "", QWidget* parent = Q_NULLPTR);
195  ~FontToolWindow();
196 
197 private slots:
198 
202  void RefreshButtonClicked();
203 
207  void ExitButtonClicked();
208 
212  void ExportButtonClicked();
213 
217  void EditGlyphsButtonClicked();
218 
222  void FontBrowseButtonClicked();
223 
227  void GenerateAtlasButtonClicked();
228 
234  void GenericDropdownChanged(int index);
235 
241  void GenericCheckboxChanged(int state);
242 
248  void SizeSpinboxChanged(double value);
249 
255  void GenericSpinboxChanged(int value);
256 
262  void PreviewTextChanged(QString text);
263 };
FontToolWindow::FontToolWindow
FontToolWindow(std::string _existing_file_path="", QWidget *parent=Q_NULLPTR)
Constructs a new FontTool Window.
Definition: FontToolWindow.cpp:13
KeystoneMessageBoxButtons::Ok
@ Ok
Dialog is shown with an [OK] button.
KeystoneMessageBoxType::Error
@ Error
Dialog icon will be a red circle with an X.
BlamGlyphUVInfo::uv_y_start
float uv_y_start
Definition: FontToolWindow.h:17
BlamGlyphUVInfo
Data structure containing glyph UV information.
Definition: FontToolWindow.h:11
BlamKeystone::Utils::ShowMessageBox
KEYSTONE KeystoneDialogResult ShowMessageBox(std::string message)
Definition: utils.cpp:294
utils.h
FontToolWindow.h
BlamGlyphUVInfo::width
int width
Definition: FontToolWindow.h:13
FontToolWindow::~FontToolWindow
~FontToolWindow()
Definition: FontToolWindow.cpp:74
BlamGlyphUVInfo::height
int height
Definition: FontToolWindow.h:14
BlamGlyphUVInfo::uv_x_start
float uv_x_start
Definition: FontToolWindow.h:15
BlamGlyphUVInfo::uv_x_end
float uv_x_end
Definition: FontToolWindow.h:16
BlamGlyphUVInfo::uv_y_end
float uv_y_end
Definition: FontToolWindow.h:18
FontToolWindow
Main window for FontTool.
Definition: FontToolWindow.h:30