Elaztek Developer Hub
Blamite Game Engine - Keystone  00402.09.29.23.0627.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 
9 {
10  int width = 0;
11  int height = 0;
12  float uv_x_start = 0.0f;
13  float uv_x_end = 0.0f;
14  float uv_y_start = 0.0f;
15  float uv_y_end = 0.0f;
16 };
17 
18 class FontToolWindow : public QMainWindow
19 {
20  Q_OBJECT
21 
22 private:
23  Ui::FontToolWindow ui;
24 
25  std::string existing_file_path = "";
26  QPixmap cached_atlas = QPixmap();
27  bool any_glyphs_cutoff = false;
28  BlamMap<char, BlamGlyphUVInfo> cached_uvs = BlamMap<char, BlamGlyphUVInfo>();
29 
30  // I/O
31  bool LoadExistingFont();
32  bool SaveAsXMLBitmap(bool use_atlas);
33 
34  // Data Retrieval
35  QFont::HintingPreference GetSelectedHintingPreference();
36  QFont::StyleStrategy GetSelectedStyleStrategy();
37  QFont::Weight GetSelectedFontWeight();
38  QFont GetFont();
39  int GetUnitSize();
40 
41  // UI
42  void SetupUI();
43  void RefreshPreview();
44  void RefreshAtlasPreview(bool regenerate_texture = false);
45  QPixmap GenerateAtlasTexture(int resolution, int unit_size, int units, QColor text_color = QColor(0,0,0, 255));
46 
47  // Image Utils
48  QImage GetCharacterImage(QChar character, QColor color = QColor(0, 0, 0, 255), int max_width = -1, int max_height = -1);
49  QImage CropImage(QImage bitm, bool adjust_width, bool adjust_height, bool baseline_fix, bool x_fix = true,
50  int max_width = -1, int max_height = -1);
51  bool IsRowEmpty(QImage bitm, int row);
52  bool IsColumnEmpty(QImage bitm, int column);
53 
54 public:
55  FontToolWindow(std::string _existing_file_path = "", QWidget *parent = Q_NULLPTR);
57 
58 private slots:
59  void RefreshButtonClicked();
60  void ExitButtonClicked();
61  void ExportButtonClicked();
62  void EditGlyphsButtonClicked();
63  void FontBrowseButtonClicked();
64  void GenerateAtlasButtonClicked();
65 
66  void GenericDropdownChanged(int index);
67  void GenericCheckboxChanged(int state);
68  void SizeSpinboxChanged(double value);
69  void GenericSpinboxChanged(int value);
70 
71  void PreviewTextChanged(QString text);
72 };
FontToolWindow::FontToolWindow
FontToolWindow(std::string _existing_file_path="", QWidget *parent=Q_NULLPTR)
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:14
BlamGlyphUVInfo
Definition: FontToolWindow.h:8
BlamKeystone::Utils::ShowMessageBox
KEYSTONE KeystoneDialogResult ShowMessageBox(std::string message)
Definition: utils.cpp:279
utils.h
FontToolWindow.h
BlamGlyphUVInfo::width
int width
Definition: FontToolWindow.h:10
FontToolWindow::~FontToolWindow
~FontToolWindow()
Definition: FontToolWindow.cpp:74
BlamGlyphUVInfo::height
int height
Definition: FontToolWindow.h:11
BlamGlyphUVInfo::uv_x_start
float uv_x_start
Definition: FontToolWindow.h:12
BlamGlyphUVInfo::uv_x_end
float uv_x_end
Definition: FontToolWindow.h:13
BlamGlyphUVInfo::uv_y_end
float uv_y_end
Definition: FontToolWindow.h:15
FontToolWindow
Definition: FontToolWindow.h:18