From f44f1c8893bbd7127ffde8186514ae1bea944d33 Mon Sep 17 00:00:00 2001 From: lordjaxom Date: Tue, 28 Dec 2004 14:35:54 +0000 Subject: - implemented font width handling --- font.c | 9 +++++---- font.h | 5 +++-- render.c | 5 +++-- xml/object.c | 23 ++++++++++++++++------- xml/object.h | 3 ++- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/font.c b/font.c index 4a77395..134e097 100644 --- a/font.c +++ b/font.c @@ -1,5 +1,5 @@ /* - * $Id: font.c,v 1.1 2004/12/19 22:03:13 lordjaxom Exp $ + * $Id: font.c,v 1.2 2004/12/28 14:35:54 lordjaxom Exp $ */ #include "font.h" @@ -18,7 +18,8 @@ cText2SkinFont::~cText2SkinFont() { } -const cFont *cText2SkinFont::Load(const std::string &Path, const std::string &Filename, int Size) +const cFont *cText2SkinFont::Load(const std::string &Path, const std::string &Filename, int Size, + int Width) { if (Filename == "Osd") return cFont::GetFont(fontOsd); @@ -30,9 +31,9 @@ const cFont *cText2SkinFont::Load(const std::string &Path, const std::string &Fi const cFont *res = NULL; #ifdef HAVE_FREETYPE char *cachename; - asprintf(&cachename, "%s_%d_%d", Filename.c_str(), Size, Setup.OSDLanguage); + asprintf(&cachename, "%s_%d_%d_%d", Filename.c_str(), Size, Width, Setup.OSDLanguage); Dprintf("trying now: %s %s\n", (Path + "/" + Filename).c_str(), cachename); - if (mFontCache.Load(Path + "/" + Filename, cachename, Size, Setup.OSDLanguage)) + if (mFontCache.Load(Path + "/" + Filename, cachename, Size, Setup.OSDLanguage, Width)) res = mFontCache.GetFont(cachename); else esyslog("ERROR: Text2Skin: Couldn't load font %s:%d", Filename.c_str(), Size); diff --git a/font.h b/font.h index f1a818a..99f1cec 100644 --- a/font.h +++ b/font.h @@ -1,5 +1,5 @@ /* - * $Id: font.h,v 1.1 2004/12/19 22:03:13 lordjaxom Exp $ + * $Id: font.h,v 1.2 2004/12/28 14:35:54 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_FONT_H @@ -21,7 +21,8 @@ private: virtual ~cText2SkinFont(); public: - static const cFont *Load(const std::string &Path, const std::string &Filename, int Size); + static const cFont *Load(const std::string &Path, const std::string &Filename, int Size, + int Width); }; #endif // VDR_TEXT2SKIN_FONT_H diff --git a/render.c b/render.c index 470332f..85afdf0 100644 --- a/render.c +++ b/render.c @@ -1,5 +1,5 @@ /* - * $Id: render.c,v 1.7 2004/12/28 02:39:51 lordjaxom Exp $ + * $Id: render.c,v 1.8 2004/12/28 14:35:54 lordjaxom Exp $ */ #include "render.h" @@ -340,7 +340,8 @@ void cText2SkinRender::DrawBlink(const txPoint &Pos, const txSize &Size, const t state = tState(); state.text = Text; } - Dprintf("drawBlink state.text = %s, offset = %d\n", state.text.c_str(), state.offset); + Dprintf("drawBlink index = %d, state.text = %s, offset = %d\n", Index, state.text.c_str(), + state.offset); if (state.nexttime == 0 || mNow >= state.nexttime) { state.nexttime = mNow + Delay; diff --git a/xml/object.c b/xml/object.c index a9fb044..8445361 100644 --- a/xml/object.c +++ b/xml/object.c @@ -1,5 +1,5 @@ /* - * $Id: object.c,v 1.4 2004/12/28 02:03:00 lordjaxom Exp $ + * $Id: object.c,v 1.5 2004/12/28 14:35:54 lordjaxom Exp $ */ #include "xml/object.h" @@ -100,15 +100,22 @@ bool cxObject::ParseAlignment(const std::string &Text) bool cxObject::ParseFontFace(const std::string &Text) { - int size = 0, pos; + int size = 0, width = 0, pos; std::string face = Text; if ((pos = face.find(':')) != -1) { - size = atoi(face.substr(pos + 1).c_str()); + std::string s = face.substr(pos + 1); + const char *p = s.c_str(); + char *end; + size = strtol(p, &end, 10); + if (*end == ',') + width = strtol(end + 1, NULL, 10); + face.erase(pos); } - mFontFace = face; - mFontSize = size; + mFontFace = face; + mFontSize = size; + mFontWidth = width; return true; } @@ -130,10 +137,12 @@ const cFont *cxObject::Font(void) const { const cFont *font; - if ((font = cText2SkinFont::Load(SkinPath() + "/fonts", mFontFace, mFontSize)) != NULL) + if ((font = cText2SkinFont::Load(SkinPath() + "/fonts", mFontFace, mFontSize, mFontWidth)) + != NULL) return font; - if ((font = cText2SkinFont::Load(SkinPath() + "/" + mSkin->Name(), mFontFace, mFontSize)) != NULL) + if ((font = cText2SkinFont::Load(SkinPath() + "/" + mSkin->Name(), mFontFace, mFontSize, + mFontWidth)) != NULL) return font; return cFont::GetFont(fontOsd); diff --git a/xml/object.h b/xml/object.h index 678048b..7d791fd 100644 --- a/xml/object.h +++ b/xml/object.h @@ -1,5 +1,5 @@ /* - * $Id: object.h,v 1.3 2004/12/28 02:03:00 lordjaxom Exp $ + * $Id: object.h,v 1.4 2004/12/28 14:35:54 lordjaxom Exp $ */ #ifndef VDR_TEXT2SKIN_XML_OBJECT_H @@ -82,6 +82,7 @@ private: cxString mTotal; std::string mFontFace; int mFontSize; + int mFontWidth; uint mDelay; uint mIndex; cxObjects *mObjects; // used for block objects such as -- cgit v1.2.3