SimpleWindow
载入中...
搜索中...
未找到
Font.h
1#pragma once
2
3#include <windows.h>
4#include <cstdint>
5#include <string>
6
7namespace sw
8{
12 enum class FontWeight : int {
13 DontCare = 0,
14 Thin = 100,
15 ExtraLight = 200,
16 UltraLight = 200,
17 Light = 300,
18 Normal = 400,
19 Regular = 400,
20 Medium = 500,
21 SemiBold = 600,
22 DemiBold = 600,
23 Bold = 700,
24 ExtraBold = 800,
25 UltraBold = 800,
26 Heavy = 900,
27 Black = 900,
28 };
29
33 enum class FontCharSet : uint8_t {
49
50 // Windows 的朝鲜语版本:
52
53 // Windows 中东语言版本:
56
57 // Windows 的泰语版本:
59 };
60
76
83
84#if defined(CLIP_DFA_DISABLE)
86#endif
87
90 Mask = CLIP_MASK,
91
92#if defined(CLIP_DFA_OVERRIDE)
94#endif
95
98 };
99
111
115 enum class FontPitch : uint8_t {
119 };
120
132
136 class Font
137 {
138 public:
142 std::wstring name = L"";
143
147 double size = 12;
148
152 int escapement = 0;
153
157 int orientation = 0;
158
163
167 bool italic = false;
168
172 bool underline = false;
173
177 bool strikeOut = false;
178
183
188
193
198
202 /*uint8_t pitchAndFamily;*/
203
208
213
214 public:
219
223 Font(const std::wstring &name, FontCharSet charSet);
224
228 Font(const std::wstring &name, double size = 12, FontWeight weight = FontWeight::DontCare);
229
234
238 operator LOGFONTW() const;
239
244
249
256 static Font &GetDefaultFont(bool update = false);
257 };
258}
字体类
Definition Font.h:137
FontFamily family
字体系列
Definition Font.h:212
HFONT CreateHandle() const
创建HFONT句柄
bool strikeOut
是否有删除线
Definition Font.h:177
std::wstring name
字体的字体名称,此字符串的长度不能超过 32
Definition Font.h:142
FontClipPrecision clipPrecision
裁剪精度
Definition Font.h:192
static Font GetFont(HFONT hFont)
通过HFONT获取字体信息
Font()
构造字体对象
bool underline
是否有下划线
Definition Font.h:172
int escapement
转义向量与设备的 x 轴之间的角度(以十分之一度为单位)
Definition Font.h:152
FontQuality quality
输出质量
Definition Font.h:197
Font(const LOGFONTW &logFont)
从LOGFONTW构造字体对象
Font(const std::wstring &name, double size=12, FontWeight weight=FontWeight::DontCare)
构造指定字体名称、大小与粗细的字体对象
FontOutPrecision outPrecision
输出精度
Definition Font.h:187
FontWeight weight
字体的粗细,范围为 0 到 1000
Definition Font.h:162
bool italic
是否为斜体
Definition Font.h:167
double size
字体大小,以dip为单位
Definition Font.h:147
FontCharSet charSet
字符集
Definition Font.h:182
static Font & GetDefaultFont(bool update=false)
获取默认字体,线程中首次调用或参数update为true时会获取系统默认字体
Font(const std::wstring &name, FontCharSet charSet)
构造指定字体名称和字符集的字体对象
FontPitch pitch
字体的间距和系列
Definition Font.h:207
int orientation
每个字符的基线和设备 x 轴之间的角度(以十分之一度为单位)
Definition Font.h:157
值转换器接口
Definition IValueConverter.h:14
SimpleWindow框架的顶级命名空间,所有公共类型、控件、枚举和工具函数均定义于此。
Definition Alignment.h:4
FontQuality
输出质量
Definition Font.h:103
@ ClearType
如果设置,则尽可能使用 ClearType 抗锯齿方法呈现文本。
@ Default
字体的外观并不重要。
@ Proof
字体的字符质量比逻辑字体属性的精确匹配更重要。 对于 GDI 光栅字体,将禁用缩放,并选择大小最接近的字体。 虽然在使用PROOF_QUALITY时可能无法精确映射所选字号,但字体质量较高,外观不会失真...
@ NoAntiAliased
字体永远不会抗锯齿。
@ AntiAliased
如果字体支持该字体,并且字体大小不是太小或太大,则字体始终为抗锯齿。
@ Draft
字体的外观不如使用PROOF_QUALITY时重要。 对于 GDI 光栅字体,会启用缩放,这意味着可以使用更多字号,但质量可能较低。 如有必要,将合成粗体、斜体、下划线和删除线字体。
FontPitch
字体的间距
Definition Font.h:115
@ Fixed
等宽间距(所有字符宽度相同,如 Courier New)
@ Variable
可变间距(字符宽度随字形变化,如 Arial)
@ Default
默认间距(由字体映射器选择)
FontFamily
字体系列
Definition Font.h:124
@ Swiss
笔划宽度可变的字体 (成比例) 且不带衬线。 例如 MS Sans Serif。
@ DontCare
使用默认字体。
@ Modern
具有固定笔划宽度的字体 (带衬线或无衬线) 的空白字体。 Monospace 字体通常是新式字体。 例如,Pica、Elite 和 CourierNew。
@ Roman
笔划宽度可变的字体 (比例) 和衬线。 例如 MS Serif。
@ Decorative
新奇字体。 例如 Old English。
@ Script
设计为类似于手写的字体。 例如 Script 和 Cursive。
FontOutPrecision
输出质量
Definition Font.h:64
@ String
字体映射器不使用此值,但在枚举光栅字体时会返回此值。
@ TrueType
当系统包含多个同名字体时,指示字体映射器选择 TrueType 字体。
@ Outline
此值指示字体映射器从 TrueType 和其他基于大纲的字体中进行选择。
@ Raster
当系统包含多个同名字体时,指示字体映射器选择光栅字体。
@ Character
未使用。
@ Default
指定默认字体映射器行为。
@ Stroke
字体映射器不使用此值,但在枚举 TrueType、其他基于轮廓的字体和矢量字体时返回此值。
@ TrueTypeOnly
指示字体映射器仅从 TrueType 字体中进行选择。 如果系统中没有安装 TrueType 字体,字体映射器将返回到默认行为。
@ PostScriptOnly
指示字体映射器仅从 PostScript 字体中进行选择。 如果系统中没有安装 PostScript 字体,字体映射器将返回到默认行为。
@ Device
当系统包含多个同名字体时,指示字体映射器选择设备字体。
FontWeight
字体的粗细
Definition Font.h:12
@ UltraLight
超细,同 ExtraLight
@ DemiBold
半粗,同 SemiBold
@ SemiBold
半粗,同 DemiBold
@ DontCare
不指定(由字体映射器选择默认粗细)
@ ExtraBold
特粗,同 UltraBold
@ Regular
常规,同 Normal
@ Black
黑体,同 Heavy
@ ExtraLight
特细,同 UltraLight
@ UltraBold
超粗,同 ExtraBold
@ Heavy
重磅,同 Black
@ Normal
位图置于BmpBox左上角
FontClipPrecision
剪裁精度
Definition Font.h:80
@ Embedded
必须指定此标志才能使用嵌入的只读字体。
@ CharacterPrecis
未使用。
@ Mask
未使用。
@ DefaultPrecis
指定默认剪辑行为。
@ StrokePrecis
字体映射器不使用,但在枚举光栅、矢量或 TrueType 字体时返回。 为了兼容,枚举字体时始终返回此值。
@ LH_Angles
使用此值时,所有字体的旋转取决于坐标系的方向是左手还是右手。如果未使用,设备字体始终逆时针旋转,但其他字体的旋转取决于坐标系的方向。
@ TT_Always
未使用。
FontCharSet
字符集
Definition Font.h:33
@ ShiftJIS
日语 Shift-JIS 字符集
@ Symbol
Symbol 符号字符集
@ Greek
希腊语字符集
@ Mac
Mac 字符集
@ GB2312
简体中文(GB2312)字符集
@ Arabic
阿拉伯语字符集
@ Thai
泰语字符集
@ CheneseBig5
繁体中文(Big5)字符集
@ Hangul
韩语字符集
@ Default
默认字符集(随系统区域设置而定)
@ Vietnamese
越南语字符集
@ EastEurope
东欧字符集
@ Turkish
土耳其语字符集
@ Hebrew
希伯来语字符集
@ ANSI
ANSI 字符集(Windows-1252,西欧)
@ Johab
韩语 Johab 字符集
@ Oem
OEM 字符集(随系统 OEM 代码页)
@ Russian
俄语字符集
@ Baltic
波罗的海字符集