vdr 1.5.16 - minor problem in font.c

Message ID 47C92EDA.6010107@cadsoft.de
State New
Headers

Commit Message

Klaus Schmidinger March 1, 2008, 10:24 a.m. UTC
  On 02/29/08 23:01, Tobi wrote:
> Klaus Schmidinger wrote:
> 
>>> Can you please verify if the attached patch does this correctly?
>> Maybe the attached version is even better, because there are also other
>> places where Glyph() is called.
> 
> The patch works, but you should also pass the AntiAliased parameter when
> recursivly calling Glyph().

Right.

> Besides this - I have the 0xA0 about 80 times in my epg.data (very often on
> DMAX). As far as I can tell, the 0xA0 is used as NON-BREAKING SPACE to avoid the
> collapsing of two or more spaces. Therefore the 0xA0 might as well be rendered
> as normal single space by default:
> 
> if (CharCode == 0xA0)
>    CharCode = 0x20;

That's certainly the correct solution - 0xA0 is officially specified as
non-breaking space.

Attached is the complete patch, please verify.

Klaus
  

Comments

Tobias Grimm March 1, 2008, 2:14 p.m. UTC | #1
Klaus Schmidinger wrote:

> Attached is the complete patch, please verify.

I'm in Chemnitz at the "Linux-Tage" right now, so I can' test it, but the patch
looks fine to me.

bye,

Tobias
  

Patch

--- font.c	2008/02/09 11:52:25	1.23
+++ font.c	2008/03/01 10:19:41
@@ -4,7 +4,7 @@ 
  * See the main source file 'vdr.c' for copyright information and
  * how to reach the author.
  *
- * $Id: font.c 1.23 2008/02/09 11:52:25 kls Exp $
+ * $Id: font.c 1.24 2008/02/29 13:35:15 kls Exp kls $
  */
 
 #include "font.h"
@@ -184,6 +184,10 @@ 
 
 cGlyph* cFreetypeFont::Glyph(uint CharCode, bool AntiAliased) const
 {
+  // Non-breaking space:
+  if (CharCode == 0xA0)
+     CharCode = 0x20;
+
   // Lookup in cache:
   cList<cGlyph> *glyphCache = AntiAliased ? &glyphCacheAntiAliased : &glyphCacheMonochrome;
   for (cGlyph *g = glyphCache->First(); g; g = glyphCache->Next(g)) {
@@ -214,6 +218,9 @@ 
         return Glyph;
         }
      }
+#define UNKNOWN_GLYPH_INDICATOR '?'
+  if (CharCode != UNKNOWN_GLYPH_INDICATOR)
+     return Glyph(UNKNOWN_GLYPH_INDICATOR, AntiAliased);
   return NULL;
 }
 
@@ -258,6 +265,8 @@ 
            uint sym = Utf8CharGet(s, sl);
            s += sl;
            cGlyph *g = Glyph(sym, AntiAliased);
+           if (!g)
+              continue;
            int kerning = Kerning(g, prevSym);
            prevSym = sym;
            uchar *buffer = g->Bitmap();