1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// src/cpp/font.h
#pragma once
#include <QFont>
#include <QString>
#include <string>
#include "rust/cxx.h"
// ============================================================
// Constructor
// ============================================================
/// Create a new QFont with default settings.
inline QFont* QFont_new() {
return new QFont();
}
/// Create a new QFont with a specific family.
inline QFont* QFont_new_with_family(const std::string& family) {
return new QFont(QString::fromStdString(family));
}
// ============================================================
// Setters
// ============================================================
/// Set the font family (e.g., "Arial", "WenQuanYi Micro Hei").
inline void QFont_setFamily(QFont* font, const std::string& family) {
font->setFamily(QString::fromStdString(family));
}
/// Set the font size in points (1/72 inch).
inline void QFont_setPointSize(QFont* font, int size) {
font->setPointSize(size);
}
/// Set the font size in pixels.
inline void QFont_setPixelSize(QFont* font, int size) {
font->setPixelSize(size);
}
/// Enable/disable bold.
inline void QFont_setBold(QFont* font, bool bold) {
font->setBold(bold);
}
/// Enable/disable italic.
inline void QFont_setItalic(QFont* font, bool italic) {
font->setItalic(italic);
}
/// Enable/disable underline.
inline void QFont_setUnderline(QFont* font, bool underline) {
font->setUnderline(underline);
}
/// Enable/disable strikethrough.
inline void QFont_setStrikeOut(QFont* font, bool strike) {
font->setStrikeOut(strike);
}
/// Set the font weight (0-99).
///
/// Common values:
/// - 50 = Normal (default)
/// - 75 = Bold
/// - 25 = Light
/// - 87 = Black
inline void QFont_setWeight(QFont* font, int weight) {
font->setWeight(static_cast<QFont::Weight>(weight));
}
// ============================================================
// Getters
// ============================================================
/// Get the font family name.
inline rust::String QFont_family(QFont* font) {
return rust::String(font->family().toStdString());
}
/// Get the point size (returns -1 if not set).
inline int QFont_pointSize(QFont* font) {
return font->pointSize();
}
/// Get the pixel size (returns -1 if not set).
inline int QFont_pixelSize(QFont* font) {
return font->pixelSize();
}
/// Check if the font is bold.
inline bool QFont_bold(QFont* font) {
return font->bold();
}
/// Check if the font is italic.
inline bool QFont_italic(QFont* font) {
return font->italic();
}
/// Check if the font is underlined.
inline bool QFont_underline(QFont* font) {
return font->underline();
}
/// Check if the font has strikethrough.
inline bool QFont_strikeOut(QFont* font) {
return font->strikeOut();
}
/// Get the font weight (0-99).
inline int QFont_weight(QFont* font) {
return font->weight();
}
// ============================================================
// Destructor
// ============================================================
/// Delete a QFont.
inline void QFont_delete(QFont* font) {
delete font;
}