summaryrefslogtreecommitdiff
path: root/common/vgui_surfacelib/BitmapFont.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /common/vgui_surfacelib/BitmapFont.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'common/vgui_surfacelib/BitmapFont.h')
-rw-r--r--common/vgui_surfacelib/BitmapFont.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/common/vgui_surfacelib/BitmapFont.h b/common/vgui_surfacelib/BitmapFont.h
new file mode 100644
index 0000000..42305f9
--- /dev/null
+++ b/common/vgui_surfacelib/BitmapFont.h
@@ -0,0 +1,55 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Baked Bitmap fonts
+//
+//===========================================================================
+
+#ifndef _BITMAPFONT_H_
+#define _BITMAPFONT_H_
+
+#include "vguifont.h"
+#include "BitmapFontFile.h"
+
+class ITexture;
+
+//-----------------------------------------------------------------------------
+// Purpose: encapsulates a windows font
+//-----------------------------------------------------------------------------
+class CBitmapFont : public font_t
+{
+public:
+ CBitmapFont();
+ virtual ~CBitmapFont();
+
+ // creates the font. returns false if the compiled font does not exist.
+ virtual bool Create(const char *windowsFontName, float scalex, float scaley, int flags);
+
+ // returns true if the font is equivalent to that specified
+ virtual bool IsEqualTo(const char *windowsFontName, float scalex, float scaley, int flags);
+
+ // gets the abc widths for a character
+ virtual void GetCharABCWidths(int ch, int &a, int &b, int &c);
+
+ // writes the char into the specified 32bpp texture. We're overloading this because
+ // we derive off font_t, and the implementation there doesn't work for bitmap fonts.
+ virtual void GetCharRGBA( wchar_t ch, int rgbaWide, int rgbaTall, unsigned char *prgba );
+
+ // gets the width of ch given its position around before and after chars
+ virtual void GetKernedCharWidth( wchar_t ch, wchar_t chBefore, wchar_t chAfter, float &wide, float &abcA, float &abcC );
+
+ // gets the texture coords in the compiled texture page
+ void GetCharCoords( int ch, float *left, float *top, float *right, float *bottom );
+
+ // sets the scale of the font.
+ void SetScale( float sx, float sy );
+
+ // gets the compiled texture page
+ ITexture *GetTexturePage();
+
+private:
+ int m_bitmapFontHandle;
+ float m_scalex;
+ float m_scaley;
+};
+
+#endif // _BITMAPFONT_H