1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Added cFont::Width(void) to get the default character width and allow stretched font drawing in high level OSDs

This commit is contained in:
Klaus Schmidinger 2016-12-22 12:53:09 +01:00
parent f91468ff9b
commit b6080634cc
6 changed files with 26 additions and 8 deletions

View File

@ -3332,6 +3332,8 @@ Thomas Reufer <thomas@reufer.ch>
replay of recordings with B-frames replay of recordings with B-frames
for fixing replaying recordings to their very end, if they don't end with an I-frame for fixing replaying recordings to their very end, if they don't end with an I-frame
for implementing a frame parser for H.265 (HEVC) recordings for implementing a frame parser for H.265 (HEVC) recordings
for adding cFont::Width(void) to get the default character width and allow stretched
font drawing in high level OSDs
Eike Sauer <EikeSauer@t-online.de> Eike Sauer <EikeSauer@t-online.de>
for reporting a problem with channels that need more than 5 TS packets for detecting for reporting a problem with channels that need more than 5 TS packets for detecting

View File

@ -8862,3 +8862,5 @@ Video Disk Recorder Revision History
- Fixed replaying recordings to their very end, if they don't end with an I-frame - Fixed replaying recordings to their very end, if they don't end with an I-frame
(thanks to Thomas Reufer). (thanks to Thomas Reufer).
- Implemented a frame parser for H.265 (HEVC) recordings (thanks to Thomas Reufer). - Implemented a frame parser for H.265 (HEVC) recordings (thanks to Thomas Reufer).
- Added cFont::Width(void) to get the default character width and allow stretched
font drawing in high level OSDs (thanks to Thomas Reufer).

View File

@ -130,3 +130,8 @@ VDR Plugin 'skincurses' Revision History
2015-02-19: Version 2.2.0 2015-02-19: Version 2.2.0
- Official release. - Official release.
2016-12-22: Version 2.3.2
- Added cFont::Width(void) to get the default character width and allow stretched
font drawing in high level OSDs (dummy for skincurses).

View File

@ -3,7 +3,7 @@
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
* $Id: skincurses.c 3.3 2015/02/17 13:13:17 kls Exp $ * $Id: skincurses.c 4.1 2016/12/22 12:50:20 kls Exp $
*/ */
#include <ncurses.h> #include <ncurses.h>
@ -12,7 +12,7 @@
#include <vdr/skins.h> #include <vdr/skins.h>
#include <vdr/videodir.h> #include <vdr/videodir.h>
static const char *VERSION = "2.2.0"; static const char *VERSION = "2.3.2";
static const char *DESCRIPTION = trNOOP("A text only skin"); static const char *DESCRIPTION = trNOOP("A text only skin");
static const char *MAINMENUENTRY = NULL; static const char *MAINMENUENTRY = NULL;
@ -20,6 +20,7 @@ static const char *MAINMENUENTRY = NULL;
class cCursesFont : public cFont { class cCursesFont : public cFont {
public: public:
virtual int Width(void) const { return 1; }
virtual int Width(uint c) const { return 1; } virtual int Width(uint c) const { return 1; }
virtual int Width(const char *s) const { return s ? Utf8StrLen(s) : 0; } virtual int Width(const char *s) const { return s ? Utf8StrLen(s) : 0; }
virtual int Height(void) const { return 1; } virtual int Height(void) const { return 1; }

15
font.c
View File

@ -6,7 +6,7 @@
* *
* BiDi support by Osama Alrawab <alrawab@hotmail.com> @2008 Tripoli-Libya. * BiDi support by Osama Alrawab <alrawab@hotmail.com> @2008 Tripoli-Libya.
* *
* $Id: font.c 4.1 2015/04/19 11:13:45 kls Exp $ * $Id: font.c 4.2 2016/12/22 12:31:23 kls Exp $
*/ */
#include "font.h" #include "font.h"
@ -100,6 +100,7 @@ class cFreetypeFont : public cFont {
private: private:
cString fontName; cString fontName;
int size; int size;
int width;
int height; int height;
int bottom; int bottom;
FT_Library library; ///< Handle to library FT_Library library; ///< Handle to library
@ -114,6 +115,7 @@ public:
virtual ~cFreetypeFont(); virtual ~cFreetypeFont();
virtual const char *FontName(void) const { return fontName; } virtual const char *FontName(void) const { return fontName; }
virtual int Size(void) const { return size; } virtual int Size(void) const { return size; }
virtual int Width(void) const { return width; }
virtual int Width(uint c) const; virtual int Width(uint c) const;
virtual int Width(const char *s) const; virtual int Width(const char *s) const;
virtual int Height(void) const { return height; } virtual int Height(void) const { return height; }
@ -125,6 +127,7 @@ cFreetypeFont::cFreetypeFont(const char *Name, int CharHeight, int CharWidth)
{ {
fontName = Name; fontName = Name;
size = CharHeight; size = CharHeight;
width = CharWidth;
height = 0; height = 0;
bottom = 0; bottom = 0;
int error = FT_Init_FreeType(&library); int error = FT_Init_FreeType(&library);
@ -384,10 +387,12 @@ void cFreetypeFont::DrawText(cPixmap *Pixmap, int x, int y, const char *s, tColo
class cDummyFont : public cFont { class cDummyFont : public cFont {
private: private:
int height; int height;
int width;
public: public:
cDummyFont(int CharHeight) { height = CharHeight; } cDummyFont(int CharHeight, int CharWidth) { height = CharHeight; width = CharWidth; }
virtual int Width(uint c) const { return height; } virtual int Width(void) const { return width ? width : height; }
virtual int Width(const char *s) const { return height; } virtual int Width(uint c) const { return width ? width : height; }
virtual int Width(const char *s) const { return width ? width : height; }
virtual int Height(void) const { return height; } virtual int Height(void) const { return height; }
virtual void DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const {} virtual void DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const {}
virtual void DrawText(cPixmap *Pixmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const {}; virtual void DrawText(cPixmap *Pixmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const {};
@ -425,7 +430,7 @@ cFont *cFont::CreateFont(const char *Name, int CharHeight, int CharWidth)
cString fn = GetFontFileName(Name); cString fn = GetFontFileName(Name);
cFont *f = *fn ? new cFreetypeFont(fn, CharHeight, CharWidth) : NULL; cFont *f = *fn ? new cFreetypeFont(fn, CharHeight, CharWidth) : NULL;
if (!f || !f->Height()) if (!f || !f->Height())
f = new cDummyFont(CharHeight); f = new cDummyFont(CharHeight, CharWidth);
return f; return f;
} }

5
font.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: font.h 4.1 2016/12/13 14:58:53 kls Exp $ * $Id: font.h 4.2 2016/12/22 12:43:24 kls Exp $
*/ */
#ifndef __FONT_H #ifndef __FONT_H
@ -45,6 +45,9 @@ public:
///< Returns the original size as requested when the font was created. ///< Returns the original size as requested when the font was created.
///< This may be smaller than the actual height, for instance if the ///< This may be smaller than the actual height, for instance if the
///< font contains descenders. ///< font contains descenders.
virtual int Width(void) const = 0;
///< Returns the original character width as requested when the font was
///< created, or 0 if the default width is used.
virtual int Width(uint c) const = 0; virtual int Width(uint c) const = 0;
///< Returns the width of the given character in pixel. ///< Returns the width of the given character in pixel.
virtual int Width(const char *s) const = 0; virtual int Width(const char *s) const = 0;