[ANNOUNCE] VDR developer version 1.5.4

Message ID 467D03A5.10506@cadsoft.de
State New
Headers

Commit Message

Klaus Schmidinger June 23, 2007, 11:27 a.m. UTC
  On 06/17/07 18:16, Anssi Hannula wrote:
> Klaus Schmidinger wrote:
>> VDR developer version 1.5.4 is now available 
> 
>> - Now using 'fontconfig' to determine which fonts to use (thanks to Anssi Hannula
>>   for code and hints on how to do this).
> 
>> +         char *s = (char *)FcNameUnparse(fontset->fonts[i]);
>> +         if (s) {
>> +            // Strip i18n stuff:
>> +            char *p = strchr(s, ',');
>> +            if (p)
>> +               *p = 0;
> 
> Dropping everything after ',' seems correct, but AFAICS it should be 
> processed separately for the family name and style.
> 
> Currently, AFAICS,
> DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique
> becomes
> DejaVu Sans
> while I think it should become
> DejaVu Sans:style=Condensed Oblique

Looks like I don't have any font here that has a comma in its name,
so I hope I got this right.

Can you please verify the attached patch?

Klaus
  

Comments

Anssi Hannula June 23, 2007, 12:11 p.m. UTC | #1
Klaus Schmidinger wrote:
> On 06/17/07 18:16, Anssi Hannula wrote:
>> Klaus Schmidinger wrote:
>>> VDR developer version 1.5.4 is now available 
>>> - Now using 'fontconfig' to determine which fonts to use (thanks to Anssi Hannula
>>>   for code and hints on how to do this).
>>> +         char *s = (char *)FcNameUnparse(fontset->fonts[i]);
>>> +         if (s) {
>>> +            // Strip i18n stuff:
>>> +            char *p = strchr(s, ',');
>>> +            if (p)
>>> +               *p = 0;
>> Dropping everything after ',' seems correct, but AFAICS it should be 
>> processed separately for the family name and style.
>>
>> Currently, AFAICS,
>> DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique
>> becomes
>> DejaVu Sans
>> while I think it should become
>> DejaVu Sans:style=Condensed Oblique
> 
> Looks like I don't have any font here that has a comma in its name,
> so I hope I got this right.
> 
> Can you please verify the attached patch?

I don't really use VDR 1.5 yet, but I tried to run the attached test 
program. However, it segfaults in *p = 0. I also tested the previous 
implementation quoted above, and it segfaults similarly.
  
Wolfgang Rohdewald June 23, 2007, 12:28 p.m. UTC | #2
On Samstag, 23. Juni 2007, Anssi Hannula wrote:

> I don't really use VDR 1.5 yet, but I tried to run the attached test 
> program. However, it segfaults in *p = 0. I also tested the previous 
> implementation quoted above, and it segfaults similarly.

you try to write into a constant string.

This would work:

        char *s;
        s=strdup("DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique");
  
Anssi Hannula June 23, 2007, 12:33 p.m. UTC | #3
Wolfgang Rohdewald wrote:
> On Samstag, 23. Juni 2007, Anssi Hannula wrote:
> 
>> I don't really use VDR 1.5 yet, but I tried to run the attached test 
>> program. However, it segfaults in *p = 0. I also tested the previous 
>> implementation quoted above, and it segfaults similarly.
> 
> you try to write into a constant string.
> 
> This would work:
> 
>         char *s;
>         s=strdup("DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique");
> 

Right.

It works correctly.
  

Patch

--- font.c	2007/06/23 10:41:10	1.20
+++ font.c	2007/06/23 11:25:42
@@ -354,9 +354,19 @@ 
          char *s = (char *)FcNameUnparse(fontset->fonts[i]);
          if (s) {
             // Strip i18n stuff:
+            char *c = strchr(s, ':');
+            if (c) {
+               char *p = strchr(c + 1, ',');
+               if (p)
+                  *p = 0;
+               }
             char *p = strchr(s, ',');
-            if (p)
-               *p = 0;
+            if (p) {
+               if (c)
+                  memmove(p, c, strlen(c) + 1);
+               else
+                  *p = 0;
+               }
             // Make it user presentable:
             s = strreplace(s, "\\", ""); // '-' is escaped
             s = strreplace(s, "style=", "");