uLib  User mode C/C++ extended API library for Win32 programmers.
ResFont.h
Go to the documentation of this file.
1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 // Project: uLib - User mode utility library.
3 // Module: Resource fonts - Allow using custom fonts without installing them.
4 // Author: Copyright (c) Love Nystrom
5 // License: NNOSL (BSD descendant, see NNOSL.txt in the base directory).
6 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 
8 #ifdef __cplusplus
9 #ifndef __ResFont_h_incl__
10 #define __ResFont_h_incl__
11 
12 #include <uLib/TTFFile.h>
13 
14 //==---------------------------------------------------------------------------
21 //==---------------------------------------------------------------------------
23 
27 
28 class TTResFont {
29 public:
30  TCHAR TypeFace[ LF_FACESIZE ];
31 
32  TTResFont();
33  TTResFont( HMODULE hModule, CSTR Id, CSTR Type );
34  virtual ~TTResFont();
35 
38 
39  bool Load( HMODULE hModule, CSTR Id, CSTR Type );
40 
43 
44  HFONT CreateFont(
45  int Points,
46  int Weight,
47  DWORD CharSet = ANSI_CHARSET,
48  DWORD Quality = ANTIALIASED_QUALITY
49  );
50 
51 protected:
53  PTTFDirectory _pDir; // Loaded TrueType resource.
54  HANDLE _hfMemo; // Handle to OS "mem font" data.
55  UINT _Size, _nFonts; // Resource size & nr of fonts.
56 
57  bool _getTypeface(); //>> TypeFace
58  void _freeFontMem(); //>> _hfMemo
60 };
61 
63 #endif//ndef __ResFont_h_incl__
64 #endif//def __cplusplus
65 // EOF
unsigned long DWORD
Definition: Common.h:414
#define CSTR
Definition: Common.h:329
TTResFont supports TrueType fonts embedded as resources.
Definition: ResFont.h:28
bool Load(HMODULE hModule, CSTR Id, CSTR Type)
Definition: ResFont.cpp:30
virtual ~TTResFont()
Definition: ResFont.cpp:25
HFONT CreateFont(int Points, int Weight, DWORD CharSet=ANSI_CHARSET, DWORD Quality=ANTIALIASED_QUALITY)
Definition: ResFont.cpp:44
TCHAR TypeFace[LF_FACESIZE]
Definition: ResFont.h:30
TTResFont()
Definition: ResFont.cpp:12