diff options
author | lordjaxom <lordjaxom> | 2004-05-31 19:56:56 +0000 |
---|---|---|
committer | lordjaxom <lordjaxom> | 2004-05-31 19:56:56 +0000 |
commit | b968a310699595ff139278440ae278aebf112c1f (patch) | |
tree | 1944e18832ee3f7420634db6a607aec6c35b76e8 /font.c | |
parent | 377ef2b18a6499a1ef0e540a74c4e54317efee85 (diff) | |
download | vdr-plugin-text2skin-b968a310699595ff139278440ae278aebf112c1f.tar.gz vdr-plugin-text2skin-b968a310699595ff139278440ae278aebf112c1f.tar.bz2 |
- "Background" may be initialized with a color nowv0.0.1-rc1
- fixed channel name/number display
- added parameter type (to store logo's filetype)
- "Timebar", "Progressbar" and "Volumebar": Background is only drawn if bg is
specified
- fixed timebar (was running backwards)
- renamed "Progressbar" to "Replaybar" for more consistency
- renamed "Logo" to "ChannelLogo"
- introduced items "Language" (for audio language texts or symbols) and "Image"
(foreground images)
- adopted SKINS document (SKINS.de is not up-to-date yet)
- introduced item "MenuTitle"
- introduced items "MenuRed", "MenuGreen", "MenuYellow" and "MenuBlue"
- activated message items for display in menu
- introcuded parameter "arc" and item "Slope"
- fixed possible segfault in Item=Message
- implemented items "SymbolReplaying" and "SymbolRadio"
- added "text" parameter for all text like Items (explanation follows)
- added "SymbolPlay", "SymbolPause", "SymbolFastFwd", "SymbolFastRew",
"SymbolSlowFwd", "SymbolSlowRew" items.
Diffstat (limited to 'font.c')
-rw-r--r-- | font.c | 127 |
1 files changed, 127 insertions, 0 deletions
@@ -0,0 +1,127 @@ +/* + * $Id: font.c,v 1.5 2004/05/30 21:48:21 austriancoder Exp $ + */ + +#include "font.h" + +// ================================== +// constr. +cText2SkinFont::cText2SkinFont() +{ + m_library = 0; + m_face = 0; + + // init freetype2 lib + int error = FT_Init_FreeType(&m_library); + if (error) + { + esyslog("ERROR: Could not init freetype library\n"); + } +} + +// ================================== +// deconstr. +cText2SkinFont::~cText2SkinFont() +{ + if (m_face) + { + FT_Done_Face(m_face); + } + + if (m_library) + { + FT_Done_FreeType(m_library); + } +} + +// ================================== +// try to load a font +bool cText2SkinFont::LoadFontFile(string Filename) +{ + int error = FT_New_Face(m_library, Filename.c_str(), 0, &m_face); + + // every thing ok? + if (error == FT_Err_Unknown_File_Format) + { + esyslog("ERROR: Font file (%s) could be opened and read, but it appears that its font format is unsupported\n", Filename.c_str()); + return false; + } + else if (error) + { + esyslog("ERROR: Font file (%s) could be opened or read, or simply it is broken\n", Filename.c_str()); + return false; + } + + // set slot + m_slot = m_face->glyph; + + return true; +} + +// ================================== +// sets size of font +void cText2SkinFont::SetFontSize(int size) +{ + FT_Set_Char_Size + ( + m_face, // handle to face object + 0, // char_width in 1/64th of points + size*64, // char_height in 1/64th of points + 300, // horizontal device resolution (dpi) + 300 // vertical device resolution (dpi) + ); +} + +// ================================== +// write some text :) +void cText2SkinFont::DrawTextTransparent(cOsd *Osd, int x, int y, const char *s, tColor ColorFg, int Width, int Height, int Alignment) +{ + // where to get this infos? +// int w = Font->Width(s); +// int h = Font->Height(); + + int limit = 0; + if (Width || Height) + { + int cw = Width ? Width : w; + limit = x + cw; + if (Width) + { + if ((Alignment & taLeft) != 0) + ; + else if ((Alignment & taRight) != 0) + { + if (w < Width) + x += Width - w; + } + else + { + // taCentered + if (w < Width) + x += (Width - w) / 2; + } + } + + if (Height) + { + if ((Alignment & taTop) != 0) + ; + else if ((Alignment & taBottom) != 0) + { + if (h < Height) + y += Height - h; + } + else + { + // taCentered + if (h < Height) + y += (Height - h) / 2; + } + } + } + + // write text + while (s && *s) + { + } +} |