2006-11-16 22:05:33 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file fontcache.h Functions to read fonts from files and cache them. */
|
|
|
|
|
2006-11-16 22:05:33 +00:00
|
|
|
#ifndef FONTCACHE_H
|
|
|
|
#define FONTCACHE_H
|
|
|
|
|
2007-12-23 10:56:02 +00:00
|
|
|
#include "gfx_type.h"
|
2007-12-22 23:30:28 +00:00
|
|
|
|
2006-11-16 22:05:33 +00:00
|
|
|
/** Get the SpriteID mapped to the given font size and key */
|
|
|
|
SpriteID GetUnicodeGlyph(FontSize size, uint32 key);
|
|
|
|
|
|
|
|
/** Map a SpriteID to the font size and key */
|
|
|
|
void SetUnicodeGlyph(FontSize size, uint32 key, SpriteID sprite);
|
|
|
|
|
|
|
|
/** Initialize the glyph map */
|
2007-03-07 11:47:46 +00:00
|
|
|
void InitializeUnicodeGlyphMap();
|
2006-11-16 22:05:33 +00:00
|
|
|
|
|
|
|
#ifdef WITH_FREETYPE
|
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct FreeTypeSettings {
|
2006-11-16 22:05:33 +00:00
|
|
|
char small_font[260];
|
|
|
|
char medium_font[260];
|
|
|
|
char large_font[260];
|
|
|
|
uint small_size;
|
|
|
|
uint medium_size;
|
|
|
|
uint large_size;
|
2007-06-15 16:21:56 +00:00
|
|
|
bool small_aa;
|
|
|
|
bool medium_aa;
|
|
|
|
bool large_aa;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2006-11-16 22:05:33 +00:00
|
|
|
|
|
|
|
extern FreeTypeSettings _freetype;
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void InitFreeType();
|
2006-11-16 22:05:33 +00:00
|
|
|
const struct Sprite *GetGlyph(FontSize size, uint32 key);
|
|
|
|
uint GetGlyphWidth(FontSize size, uint32 key);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
/* Stub for initializiation */
|
2007-03-07 11:47:46 +00:00
|
|
|
static inline void InitFreeType() {}
|
2006-11-16 22:05:33 +00:00
|
|
|
|
|
|
|
/** Get the Sprite for a glyph */
|
|
|
|
static inline const Sprite *GetGlyph(FontSize size, uint32 key)
|
|
|
|
{
|
|
|
|
SpriteID sprite = GetUnicodeGlyph(size, key);
|
|
|
|
if (sprite == 0) sprite = GetUnicodeGlyph(size, '?');
|
|
|
|
return GetSprite(sprite);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Get the width of a glyph */
|
|
|
|
static inline uint GetGlyphWidth(FontSize size, uint32 key)
|
|
|
|
{
|
|
|
|
SpriteID sprite = GetUnicodeGlyph(size, key);
|
|
|
|
if (sprite == 0) sprite = GetUnicodeGlyph(size, '?');
|
|
|
|
return SpriteExists(sprite) ? GetSprite(sprite)->width + (size != FS_NORMAL) : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* WITH_FREETYPE */
|
|
|
|
|
|
|
|
#endif /* FONTCACHE_H */
|