summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Docs/Reference.txt22
-rw-r--r--Docs/Tutorial.txt15
-rw-r--r--HISTORY17
-rw-r--r--Makefile11
-rw-r--r--README14
-rw-r--r--font.c64
-rw-r--r--font.h35
-rw-r--r--graphtft/font.c70
-rw-r--r--graphtft/font.h44
-rw-r--r--xml/object.c8
10 files changed, 117 insertions, 183 deletions
diff --git a/Docs/Reference.txt b/Docs/Reference.txt
index eca00f8..718737f 100644
--- a/Docs/Reference.txt
+++ b/Docs/Reference.txt
@@ -371,7 +371,7 @@ A multiline text.
| font | STRING | Font name (see 4.3 font)
-----------------------------------------------------------------------------
- <scrolltext x1="24" y1="138" y2="-72" x2="583" font="helmetr.ttf:20" color="#AFFFFF00">
+ <scrolltext x1="24" y1="138" y2="-72" x2="583" font="Sans Serif@20" color="#AFFFFF00">
{PresentShortText}
{PresentDescription}
</scrolltext>
@@ -918,15 +918,23 @@ There are three predefined fonts
* Fix
* Sml
-If the freetype library is installed it is possible to use every True-Type font in the directories
- /etc/vdr/plugins/text2skin/fonts/
-or
- /etc/vdr/plugins/text2skin/SkinName/
+It is possible to use True Type fonts installed and configured for fontconfig's
+use on the system. See the fontconfig documentation for details how to do
+that; usually it's a matter of copying the font files somewhere and running
+fc-cache(1) (as root or the VDR user).
In the skin file the font is defined with
font="Osd"
-or with True-Type fonts with the desired size and width (optional)
+or with True Type fonts
- font="helmetr.ttf:size[,width]"
+ font="name@size[,width]"
+
+where "name" is a string understood by VDR's CreateFont() method
+(Family:Style where Style is optional as of writing this), size is the font's
+size, and width its width. For example:
+
+ font="Serif@20"
+ font="Monospaced:Bold@22"
+ font="Bitstream Vera Sans:Italic@22,85"
diff --git a/Docs/Tutorial.txt b/Docs/Tutorial.txt
index b173824..da87ad2 100644
--- a/Docs/Tutorial.txt
+++ b/Docs/Tutorial.txt
@@ -117,7 +117,7 @@ Scroll- and progress-bars also need "bgColor", progress-bars "current" and "tota
<rectangle x1="20" x2="99" y1="-83" y2="-44" color="#00000000"/>
<text x1="42" x2="571" y1="-113" y2="-86" color="#FF000000" font="Osd">{ReplayTitle}</text>
<progress x1="124" x2="577" y1="-70" y2="-55" color="#FF84ff00" bgColor="#FFFFFFFF" current="{ReplayPositionIndex}" total="{ReplayDurationIndex}"/>
- <scrolltext x1="24" y1="138" y2="-72" x2="583" font="helmetr.ttf:20" color="#AFFFFF00">
+ <scrolltext x1="24" y1="138" y2="-72" x2="583" font="Sans Serif@20" color="#AFFFFF00">
{PresentShortText}
{PresentDescription}
</scrolltext>
@@ -269,15 +269,16 @@ There are three predefined fonts
* Fix
* Sml
-If the freetype library is installed it is possible to use every True-Type font in the directories
- /etc/vdr/plugins/text2skin/fonts/
-or
- /etc/vdr/plugins/text2skin/SkinName/
+It is possible to use True Type fonts installed and configured for fontconfig's
+use on the system. See the fontconfig documentation for details how to do
+that; usually it's a matter of copying the font files somewhere and running
+fc-cache(1) (as root or the VDR user).
In the skin file the font is defined with
font="Osd"
-or with True-Type fonts with the desired size and if desirable width
+or with True Type fonts with the desired size and if desirable width
- font="helmetr.ttf:size[,width]"
+ font="Sans Serif@size[,width]"
+ font="Monospaced:Bold@size[,width]"
diff --git a/HISTORY b/HISTORY
index 4db84c7..1b7480b 100644
--- a/HISTORY
+++ b/HISTORY
@@ -22,8 +22,6 @@ ____-__-__: Version 1.3
RecordingLength, RecordingCuttedLength
- added tokens:
OsdWidth, OsdHeight
- - switched the search-order for the fonts to priorise the skin-folder
- (this avoids error-messages in the log)
- added the possibility to have a scrollbar in every menu - not fully
implemented yet (to position in menu-lists is not necessarily correct,
if there are more items with the same osd-text)
@@ -74,11 +72,24 @@ ____-__-__: Version 1.3
- Updated gettext language files
- Removed backward compatibility to VDR < 1.6.0 (closes #137)
- Fixed compile error if ImageMagick has double as Quantum type (closes #140)
-- Use pkg-config to find compilation flags, libs etc for FreeType and Imlib2.
+- Use pkg-config to find compilation flags, libs etc for Imlib2.
- Fixed crash with FrontendHasLock and FrontendHasSignal (closes #147 -
thanks to a.g.prosat at tochka.ru for reporting this)
- Replaced asprintf with cString::sprintf in GetFrontend*()
- Removed useless code in loader.c
+- Replace internal freetype font handling with VDR's font facilities. Skins
+ that use fonts other than VDR's standard "Osd", "Fix", and "Sml" need to be
+ adapted to use font names as understood by VDR's CreateFont()
+ (Family:Style as of writing this) instead of filenames in their font
+ attributes' names, to use '@' instead of ':' as the separator before sizes,
+ and have fonts shipped with the skin installed and configured in fontconfig.
+ Typically, install font files (if necessary) to a dir somewhere, run
+ fc-cache(1) on the dir, replace for example font="SomeFont.ttf:22,85" with
+ font="Some Font@22,85" or font="SomeFontBold.ttf:22,85" with
+ font="Some Font:Bold@22,85" in the *.skin file. Also, in case the shipped
+ fonts are derivatives of some existing ones, they may need to be properly
+ renamed to something so they will be used instead of the original if it
+ happens to be installed. (closes #36)
2009-06-01: Version 1.2
diff --git a/Makefile b/Makefile
index 947e71c..51a403e 100644
--- a/Makefile
+++ b/Makefile
@@ -10,10 +10,6 @@ HAVE_IMAGEMAGICK=1
#HAVE_IMLIB2=1
# not recommended
-# comment this out if you don't want to use FreeType font rendering
-
-HAVE_FREETYPE=1
-
# DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING
# -------------------------------------------------------------
@@ -85,13 +81,6 @@ ifdef HAVE_IMAGEMAGICK
LIBS += $(shell pkg-config --libs ImageMagick++)
endif
-ifdef HAVE_FREETYPE
- DEFINES += -DHAVE_FREETYPE
- INCLUDES += $(shell pkg-config --cflags freetype2)
- LIBS += $(shell pkg-config --libs freetype2)
- OBJS += graphtft/font.o
-endif
-
ifdef DEBUG
CXXFLAGS += -g -fno-inline
DEFINES += -DDEBUG
diff --git a/README b/README
index 25cb133..ed86e37 100644
--- a/README
+++ b/README
@@ -46,10 +46,6 @@ HINT: Although the manual of ImageMagick claims that the used library Magick++
is part of the source distribution, some binary distributions may have to
install Magick++ separately.
-Some skins may use True Type Fonts, which requires the FreeType package to be
-installed. If you don't want to use FreeType font rendering, you may disable
-that in the Makefile, too.
-
The Makefile uses pkg-config by default to find out the necessary compiler,
preprocessor and linker flags and libraries for the above, so you'll need it
and the *.pc files for the above packages properly installed as well.
@@ -101,10 +97,6 @@ it there.
Where to put the fonts:
-----------------------
-Font files (.ttf) can be placed either in the directory of the skin itself or
-in a subfolder fonts inside the text2skin directory.
-
-Example:
-/video0/plugins/text2skin/fonts/arial.ttf
-/video0/plugins/text2skin/myskin/arial.ttf
-
+Font files (.ttf) must be installed so that fontconfig can find them, see the
+fontconfig documentation for more information (usually copy *.ttf to some dir,
+run fc-cache on that dir as root or the vdr user).
diff --git a/font.c b/font.c
index 78c5cc7..0792b2e 100644
--- a/font.c
+++ b/font.c
@@ -6,9 +6,48 @@
#include "render.h"
#include <vdr/tools.h>
-#ifdef HAVE_FREETYPE
-cGraphtftFont cText2SkinFont::mFontCache;
-#endif
+
+cText2SkinFontCache::cText2SkinFontCache(void)
+{
+}
+
+cText2SkinFontCache::~cText2SkinFontCache()
+{
+ Clear();
+}
+
+bool cText2SkinFontCache::Load(string Name, string CacheName, int Size)
+{
+ if ( _cache.find(CacheName) != _cache.end() )
+ return true;
+ cFont* newFont = cFont::CreateFont(Name.c_str(), Size);
+ if ( newFont == NULL )
+ return false;
+ _cache[CacheName] = newFont;
+ return true;
+}
+
+const cFont* cText2SkinFontCache::GetFont(string CacheName)
+{
+ if (CacheName == "Sml") return cFont::GetFont(fontSml);
+ else if (CacheName == "Fix") return cFont::GetFont(fontFix);
+ else if ( _cache.find(CacheName) != _cache.end() )
+ {
+ return _cache[CacheName];
+ }
+ return cFont::GetFont(fontOsd);
+}
+
+void cText2SkinFontCache::Clear()
+{
+ cache_map::iterator it = _cache.begin();
+ for (; it != _cache.end(); ++it)
+ delete((*it).second);
+ _cache.clear();
+}
+
+
+cText2SkinFontCache cText2SkinFont::mFontCache;
cText2SkinFont::cText2SkinFont(void)
{
@@ -18,27 +57,22 @@ cText2SkinFont::~cText2SkinFont()
{
}
-const cFont *cText2SkinFont::Load(const std::string &Path, const std::string &Filename, int Size,
- int Width)
+const cFont *cText2SkinFont::Load(const string &Name, int Size)
{
- if (Filename == "Osd")
+ if (Name == "Osd")
return cFont::GetFont(fontOsd);
- else if (Filename == "Fix")
+ else if (Name == "Fix")
return cFont::GetFont(fontFix);
- else if (Filename == "Sml")
+ else if (Name == "Sml")
return cFont::GetFont(fontSml);
const cFont *res = NULL;
-#ifdef HAVE_FREETYPE
char *cachename;
- asprintf(&cachename, "%s_%d_%d_%d", Filename.c_str(), Size, Width, I18nCurrentLanguage());
- if (mFontCache.Load(Path + "/" + Filename, cachename, Size, I18nCurrentLanguage(), Width))
+ asprintf(&cachename, "%s_%d", Name.c_str(), Size);
+ if (mFontCache.Load(Name, cachename, Size))
res = mFontCache.GetFont(cachename);
else
- esyslog("ERROR: Text2Skin: Couldn't load font %s:%d", Filename.c_str(), Size);
+ esyslog("ERROR: Text2Skin: Couldn't load font %s:%d", Name.c_str(), Size);
free(cachename);
-#else
- esyslog("ERROR: Text2Skin: Font engine not enabled at compile time!");
-#endif
return res;
}
diff --git a/font.h b/font.h
index 99f1cec..090ac56 100644
--- a/font.h
+++ b/font.h
@@ -6,23 +6,40 @@
#define VDR_TEXT2SKIN_FONT_H
#include "common.h"
-#ifdef HAVE_FREETYPE
-# include "graphtft/font.h"
-#endif
+#include <map>
+#include <string>
+#include <vdr/font.h>
+
+using std::map;
+using std::string;
+
+
+class cText2SkinFontCache
+{
+private:
+ typedef map<string,cFont*> cache_map;
+
+public:
+ cText2SkinFontCache();
+ ~cText2SkinFontCache();
+
+ bool Load(string Name, string CacheName, int Size);
+ const cFont* GetFont(string CacheName);
+ void Clear();
-class cText2SkinFont {
private:
-#ifdef HAVE_FREETYPE
- static cGraphtftFont mFontCache;
-#endif
+ cache_map _cache;
+};
+class cText2SkinFont {
+private:
+ static cText2SkinFontCache mFontCache;
// disallow direct construction
cText2SkinFont(void);
virtual ~cText2SkinFont();
public:
- static const cFont *Load(const std::string &Path, const std::string &Filename, int Size,
- int Width);
+ static const cFont *Load(const string &Name, int Size);
};
#endif // VDR_TEXT2SKIN_FONT_H
diff --git a/graphtft/font.c b/graphtft/font.c
deleted file mode 100644
index 278e9dc..0000000
--- a/graphtft/font.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * $Id: font.c,v 1.4 2005/01/30 18:09:42 lordjaxom Exp $
- *
- * Taken from GraphTFT
- */
-
-#include "font.h"
-#include <iconv.h>
-#include <stdio.h>
-
-cGraphtftFont::cGraphtftFont()
-{
- _library = 0;
- _face = 0;
-
- // init freetype2 lib
- int error = FT_Init_FreeType(&_library);
- if (error)
- {
- esyslog("ERROR: Could not init freetype library");
- }
-}
-
-cGraphtftFont::~cGraphtftFont()
-{
- Clear();
-
- if (_face)
- {
- FT_Done_Face(_face);
- }
-
- if (_library)
- {
- FT_Done_FreeType(_library);
- }
-}
-
-bool cGraphtftFont::Load(string Filename, string CacheName, int Size, int Language, int Width, int format)
-{
- if ( _cache.find(CacheName) != _cache.end() )
- return true;
- cFont* newFont = cFont::CreateFont(Filename.c_str(), Size);
- if ( newFont == NULL )
- return false;
- _cache[CacheName] = newFont;
- return true;
-}
-
-const cFont* cGraphtftFont::GetFont(string CacheName){
- if (CacheName == "Sml") return cFont::GetFont(fontSml);
- else if (CacheName == "Fix") return cFont::GetFont(fontFix);
- else if ( _cache.find(CacheName) != _cache.end() ){
- return _cache[CacheName];
- }
- return cFont::GetFont(fontOsd);
-}
-
-void cGraphtftFont::Clear(string CacheName)
-{
- Clear();
-}
-
-void cGraphtftFont::Clear()
-{
- cache_map::iterator it = _cache.begin();
- for (; it != _cache.end(); ++it)
- delete((*it).second);
- _cache.clear();
-}
diff --git a/graphtft/font.h b/graphtft/font.h
deleted file mode 100644
index d8c804f..0000000
--- a/graphtft/font.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * $Id: font.h,v 1.1 2004/12/19 22:03:24 lordjaxom Exp $
- *
- * Taken from GraphTFT
- */
-
-#ifndef VDR__GRAPHTFTFONT_H
-#define VDR__GRAPHTFTFONT_H
-
-#include <map>
-#include <string>
-#include <vector>
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include <vdr/font.h>
-#include <vdr/config.h>
-
-using std::map;
-using std::string;
-using std::vector;
-
-
-class cGraphtftFont
-{
-private:
- typedef map<string,cFont*> cache_map;
-
-public:
- cGraphtftFont();
- ~cGraphtftFont();
-
- bool Load(string Filename, string CacheName, int Size, int Language = 0, int Width = 0, int Format = 0);
- const cFont* GetFont(string CacheName);
- void Clear(string CacheName);
- void Clear();
-
-private:
- FT_Library _library;
- FT_Face _face;
- FT_GlyphSlot _slot;
- cache_map _cache;
-};
-
-#endif
diff --git a/xml/object.c b/xml/object.c
index ec69fe7..421c00d 100644
--- a/xml/object.c
+++ b/xml/object.c
@@ -116,7 +116,7 @@ bool cxObject::ParseFontFace(const std::string &Text)
{
int size = 0, width = 0, pos;
std::string face = Text;
- if ((pos = face.find(':')) != -1) {
+ if ((pos = face.find('@')) != -1) {
std::string s = face.substr(pos + 1);
const char *p = s.c_str();
char *end;
@@ -152,11 +152,7 @@ const cFont *cxObject::Font(void) const
{
const cFont *font;
- if ((font = cText2SkinFont::Load(SkinPath() + "/" + mSkin->Name(), mFontFace, mFontSize,
- mFontWidth)) != NULL)
- return font;
-
- if ((font = cText2SkinFont::Load(SkinPath() + "/fonts", mFontFace, mFontSize, mFontWidth)) != NULL)
+ if ((font = cText2SkinFont::Load(mFontFace, mFontSize)) != NULL)
return font;
return cFont::GetFont(fontOsd);