6#ifndef VCL_BGFX_TEXT_FONT_FONT_MANAGER_H
7#define VCL_BGFX_TEXT_FONT_FONT_MANAGER_H
9#include <bx/handlealloc.h>
17#define MAX_OPENED_FILES 64
18#define MAX_OPENED_FONT 64
20#define FONT_TYPE_ALPHA UINT32_C(0x00000100)
23#define FONT_TYPE_DISTANCE UINT32_C(0x00000400)
24#define FONT_TYPE_DISTANCE_SUBPIXEL UINT32_C(0x00000500)
25#define FONT_TYPE_DISTANCE_OUTLINE UINT32_C(0x00000600)
26#define FONT_TYPE_DISTANCE_OUTLINE_IMAGE UINT32_C(0x00001600)
27#define FONT_TYPE_DISTANCE_DROP_SHADOW UINT32_C(0x00002700)
28#define FONT_TYPE_DISTANCE_DROP_SHADOW_IMAGE UINT32_C(0x00003800)
29#define FONT_TYPE_DISTANCE_OUTLINE_DROP_SHADOW_IMAGE UINT32_C(0x00003900)
30#define FONT_TYPE_MASK_DISTANCE_IMAGE UINT32_C(0x00001000)
31#define FONT_TYPE_MASK_DISTANCE_DROP_SHADOW UINT32_C(0x00002000)
47 float maxAdvanceWidth;
49 float underlineThickness;
51 float underlinePosition;
89typedef int32_t CodePoint;
126 uint16_t regionIndex;
129BGFX_HANDLE(TrueTypeHandle)
130BGFX_HANDLE(FontHandle)
137 FontManager(Atlas* _atlas);
141 FontManager(uint16_t _textureSideWidth = 512);
146 const Atlas* getAtlas()
const
155 TrueTypeHandle createTtf(
const uint8_t* _buffer, uint32_t _size);
158 void destroyTtf(TrueTypeHandle _handle);
161 FontHandle createFontByPixelSize(TrueTypeHandle _handle, uint32_t _typefaceIndex, uint32_t _pixelSize, uint32_t _fontType = FONT_TYPE_ALPHA,
162 uint16_t _glyphWidthPadding = 6, uint16_t glyphHeightPadding = 6);
165 FontHandle createScaledFontToPixelSize(FontHandle _baseFontHandle, uint32_t _pixelSize);
168 void destroyFont(FontHandle _handle);
174 bool preloadGlyph(FontHandle _handle,
const wchar_t* _string);
177 bool preloadGlyph(FontHandle _handle, CodePoint _character);
179 bool addGlyphBitmap(FontHandle _handle, CodePoint _character, uint16_t _width, uint16_t height, uint16_t _pitch,
float extraScale,
const uint8_t* _bitmapBuffer,
float glyphOffsetX,
float glyphOffsetY);
184 const FontInfo& getFontInfo(FontHandle _handle)
const;
189 const GlyphInfo* getGlyphInfo(FontHandle _handle, CodePoint _codePoint);
191 float getKerning(FontHandle _handle, CodePoint _prevCodePoint, CodePoint _codePoint);
193 const GlyphInfo& getBlackGlyph()
const
207 bool addBitmap(GlyphInfo& _glyphInfo,
const uint8_t* _data);
212 bx::HandleAllocT<MAX_OPENED_FONT> m_fontHandles;
213 CachedFont* m_cachedFonts;
215 bx::HandleAllocT<MAX_OPENED_FILES> m_filesHandles;
216 CachedFile* m_cachedFiles;
218 GlyphInfo m_blackGlyph;