diff options
author | lordjaxom <lordjaxom> | 2004-12-14 20:05:40 +0000 |
---|---|---|
committer | lordjaxom <lordjaxom> | 2004-12-14 20:05:40 +0000 |
commit | b8f29c674cc0ccca207123342c1344bbd0f13796 (patch) | |
tree | 2af468bf7acc6df510241c1090d7e6538b6b3cf1 /graphtft | |
parent | 3b0999969632e2820b846ca8adcef6b346ff7441 (diff) | |
download | vdr-plugin-text2skin-b8f29c674cc0ccca207123342c1344bbd0f13796.tar.gz vdr-plugin-text2skin-b8f29c674cc0ccca207123342c1344bbd0f13796.tar.bz2 |
1.0-pre4v1.0-pre4
Diffstat (limited to 'graphtft')
-rw-r--r-- | graphtft/font.c | 65 | ||||
-rw-r--r-- | graphtft/font.h | 5 |
2 files changed, 59 insertions, 11 deletions
diff --git a/graphtft/font.c b/graphtft/font.c index e38b283..54b6083 100644 --- a/graphtft/font.c +++ b/graphtft/font.c @@ -1,10 +1,11 @@ /* - * $Id: font.c,v 1.3 2004/12/09 12:43:14 lordjaxom Exp $ + * $Id: font.c,v 1.6 2004/12/14 20:02:31 lordjaxom Exp $ * * Taken from GraphTFT */ #include "font.h" +#include <iconv.h> #include <stdio.h> cGraphtftFont::cGraphtftFont() @@ -16,7 +17,7 @@ cGraphtftFont::cGraphtftFont() int error = FT_Init_FreeType(&_library); if (error) { - fprintf(stderr, "ERROR: Could not init freetyie library\n"); + esyslog("ERROR: Could not init freetype library"); } } @@ -35,22 +36,22 @@ cGraphtftFont::~cGraphtftFont() } } -bool cGraphtftFont::Load(string Filename, string CacheName, int Size, int Width) +bool cGraphtftFont::Load(string Filename, string CacheName, int Size, int Language, int Width, int format) { if ( _cache.find(CacheName) != _cache.end() ) return true; - int error = FT_New_Face(_library, Filename.c_str(), 0, &_face); + int error = FT_New_Face(_library, Filename.c_str(), format, &_face); // every thing ok? if (error == FT_Err_Unknown_File_Format) { - fprintf(stderr, "ERROR: Font file (%s) could be opened and read, but it appears that its font format is unsupported\n", Filename.c_str()); + esyslog("ERROR: Font file (%s) could be opened and read, but it appears that its font format is unsupported", Filename.c_str()); return false; } else if (error) { - fprintf(stderr, "ERROR: Font file (%s) could be opened or read, or simply it is broken\n", Filename.c_str()); + esyslog("ERROR: Font file (%s) could be opened or read, or simply it is broken", Filename.c_str()); return false; } @@ -67,6 +68,52 @@ bool cGraphtftFont::Load(string Filename, string CacheName, int Size, int Width) 0 // vertical device resolution (dpi) ); + iconv_t cd; + char from_code[255]; + wchar_t utf_buff[256]; + + // XXX: Get this values from i18n + switch(Language) { + case 11: + strcpy(from_code,"ISO8859-7"); + break; + case 13: + case 17: + strcpy(from_code,"ISO8859-2"); + break; + case 16: + strcpy(from_code,"ISO8859-5"); + break; + default : + strcpy(from_code,"ISO8859-15"); + break; + } + + if ((cd = iconv_open("WCHAR_T",from_code)) == (iconv_t)-1) { + esyslog("ERROR: Iconv encoding not supported: %m"); + return false; //encoding no supportet + } + + for (int c = 0; c < 256; c++) { + + char char_buff = c; + wchar_t wchar_buff; + + char *in_buff,*out_buff; + size_t in_len, out_len, count; + + in_len=1; out_len=4; + in_buff=(char*)&char_buff; + out_buff=(char *)&wchar_buff; + count = iconv(cd,&in_buff,&in_len,&out_buff,&out_len); + if ( (size_t)-1 == count ){ + //printf("ERROR - PREPARING TABLE CHAR %d \n", c); + utf_buff[c] = 0; + } + utf_buff[c] = wchar_buff; + } + iconv_close(cd); + /* load glyph image into the slot (erase previous one) */ error = FT_Load_Char( _face, '_', FT_LOAD_RENDER ); if ( error ) @@ -80,7 +127,7 @@ bool cGraphtftFont::Load(string Filename, string CacheName, int Size, int Width) for (int i = 0; i < 225; i++) for (int j = 0; j < num_rows; j++) - font_data[(i*num_rows)+j]=0x00; + font_data[(i*num_rows)+j]=0x0000000000000000; font_data[0+0]=_slot->bitmap.width+2; font_data[0+1]=num_rows_global; @@ -91,13 +138,13 @@ bool cGraphtftFont::Load(string Filename, string CacheName, int Size, int Width) { //Get FT char index - glyph_index = FT_Get_Char_Index( _face, num_char ); + glyph_index = FT_Get_Char_Index( _face, utf_buff[num_char] ); //Load the char error = FT_Load_Glyph( _face, glyph_index, FT_LOAD_DEFAULT ); if ( error ) continue; /* ignore errors */ - // convert to an mono bitmap + // convert to a mono bitmap error = FT_Render_Glyph( _face->glyph, ft_render_mode_mono ); if ( error ) continue; diff --git a/graphtft/font.h b/graphtft/font.h index 5e23498..8969287 100644 --- a/graphtft/font.h +++ b/graphtft/font.h @@ -1,5 +1,5 @@ /* - * $Id: font.h,v 1.2 2004/12/06 21:19:07 lordjaxom Exp $ + * $Id: font.h,v 1.5 2004/12/14 20:02:31 lordjaxom Exp $ * * Taken from GraphTFT */ @@ -13,6 +13,7 @@ #include <ft2build.h> #include FT_FREETYPE_H #include <vdr/font.h> +#include <vdr/config.h> using std::map; using std::string; @@ -29,7 +30,7 @@ public: cGraphtftFont(); ~cGraphtftFont(); - bool Load(string Filename, string CacheName, int Size, int Width = 0); + 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(); |