1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # T2 SDE: package/.../vdr-text2skin/graphtft-font.patch
5 # Copyright (C) 2008 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
15 # --- T2-COPYRIGHT-NOTE-END ---
17 http://vdrportal.de/board/thread.php?postid=621984#post621984
20 diff -ru text2skin-1.1-cvs_ext-0.10.orig/graphtft/font.h text2skin-1.1-cvs_ext-0.10/graphtft/font.h
21 --- text2skin-1.1-cvs_ext-0.10.orig/graphtft/font.h 2007-06-19 19:56:34.000000000 -0700
22 +++ text2skin-1.1-cvs_ext-0.10/graphtft/font.h 2007-06-11 17:43:26.000000000 -0700
26 typedef map<string,cFont*> cache_map;
27 - typedef map<string,cFont::tPixelData*> del_map;
35 - FT_Library _library;
38 + FT_Library _library;
46 --- text2skin/graphtft/font.c.orig 2005-01-30 19:09:42.000000000 +0100
47 +++ text2skin/graphtft/font.c 2008-03-17 17:56:26.000000000 +0100
50 bool cGraphtftFont::Load(string Filename, string CacheName, int Size, int Language, int Width, int format)
52 - if ( _cache.find(CacheName) != _cache.end() )
55 - int error = FT_New_Face(_library, Filename.c_str(), format, &_face);
58 - if (error == FT_Err_Unknown_File_Format)
60 - esyslog("ERROR: Font file (%s) could be opened and read, but it appears that its font format is unsupported", Filename.c_str());
65 - esyslog("ERROR: Font file (%s) could be opened or read, or simply it is broken", Filename.c_str());
70 - _slot = _face->glyph;
73 - Width = Size * Width / 100;
78 - _face, // handle to face object
79 - Width*64, // char_width in 1/64th of points
80 - Size*64, // char_height in 1/64th of points
81 - 0, // horizontal device resolution (dpi)
82 - 0 // vertical device resolution (dpi)
86 - char from_code[255];
87 - wchar_t utf_buff[256];
89 - // XXX: Get this values from i18n
92 - strcpy(from_code,"ISO8859-7");
96 - strcpy(from_code,"ISO8859-2");
99 - strcpy(from_code,"ISO8859-5");
102 - strcpy(from_code,"ISO8859-15");
106 - if ((cd = iconv_open("WCHAR_T",from_code)) == (iconv_t)-1) {
107 - esyslog("ERROR: Iconv encoding not supported: %m");
108 - return false; //encoding no supportet
111 - for (int c = 0; c < 256; c++) {
113 - char char_buff = c;
114 - wchar_t wchar_buff;
116 - char *in_buff,*out_buff;
117 - size_t in_len, out_len, count;
119 - in_len=1; out_len=4;
120 - in_buff=(char*)&char_buff;
121 - out_buff=(char *)&wchar_buff;
122 - count = iconv(cd,&in_buff,&in_len,&out_buff,&out_len);
123 - if ( (size_t)-1 == count ){
124 - //printf("ERROR - PREPARING TABLE CHAR %d \n", c);
127 - utf_buff[c] = wchar_buff;
131 - cFont::tPixelData value;
132 - int num_rows_global = (_face->size->metrics.height / 64 )+1;
133 - int num_rows = num_rows_global + 2;
135 - cFont::tPixelData * font_data = new cFont::tPixelData[225 * num_rows];
137 - for (int i = 0; i < 225; i++)
138 - for (int j = 0; j < num_rows; j++)
139 - font_data[(i*num_rows)+j]=0x0000000000000000;
141 - // Time to put char 32..255 in font_data
142 - FT_UInt glyph_index;
143 - for ( int num_char = 32, num_char_array = 0; num_char < 256; num_char++, num_char_array++ )
146 - //Get FT char index
147 - glyph_index = FT_Get_Char_Index( _face, utf_buff[num_char] );
150 - error = FT_Load_Glyph( _face, glyph_index, FT_LOAD_DEFAULT );
151 - if ( error ) continue; /* ignore errors */
153 - // convert to a mono bitmap
154 - error = FT_Render_Glyph( _face->glyph, ft_render_mode_mono );
155 - if ( error ) continue;
157 - // now, convert to vdr font data
158 - int width = (_slot->metrics.horiAdvance / 64) + 1;
159 - int bearingX = (_slot->metrics.horiBearingX / 64) +1;
160 - width = (width > (int)sizeof(cFont::tPixelData) * 8) ? (((int)sizeof(cFont::tPixelData) * 8)-2) :width ;
161 - int top = _slot->bitmap_top;
162 - int y_off = Size - top;
164 - font_data[(num_char_array*num_rows)+0]=width;
165 - font_data[(num_char_array*num_rows)+1]=num_rows_global;
167 - unsigned char *bmp = _slot->bitmap.buffer;
169 - for (int y = 0; y < _slot->bitmap.rows; ++y , y_off++) {
174 - for (int x = 0; x < _slot->bitmap.width; ++x) {
175 - if (bmp[pos] & bit && x < width + 1 )
176 - value = value | (cFont::tPixelData)1 << width - bearingX - x ;
184 - bmp += _slot->bitmap.pitch;
185 - font_data[(num_char_array*num_rows)+y_off+2] = value;
189 - // If all was ok, put the vdr font into the cache and return true
190 - cFont* newFont = NULL;
191 - newFont = new cFont(font_data);
193 - _cache[CacheName] = newFont;
194 - _del[CacheName] = font_data;
198 - // Something went wrong!
200 + if ( _cache.find(CacheName) != _cache.end() )
202 + cFont* newFont = cFont::CreateFont(Filename.c_str(), Size);
203 + if ( newFont == NULL )
205 + _cache[CacheName] = newFont;
209 const cFont* cGraphtftFont::GetFont(string CacheName){
211 for (; it != _cache.end(); ++it)
212 delete((*it).second);
215 - del_map::iterator del_it = _del.begin();
216 - for (; del_it != _del.end(); ++del_it)
217 - delete((*del_it).second);
221 cGraphtftFont GraphtftFont;