[ft-devel] Patch to allow '\0' in sfnt name table entries

2012-03-14 Thread Huw Davies
Hi,

The attached patch fixes a problem with fonts that include a trailing
'\0' in name table entries.  Currently the font name would have a
question mark appended to it.

Huw.
From 7949fcbd2e865b2a1fcf61a0cae04401169ea858 Mon Sep 17 00:00:00 2001
From: Huw Davies h...@codeweavers.com
Date: Wed, 14 Mar 2012 11:12:23 +
Subject: [sfnt] Don't replace '\0' with question marks when converting
 strings from the name table.

---
 src/sfnt/sfobjs.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index d7be631..10d188b 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -64,7 +64,7 @@
 for ( n = 0; n  len; n++ )
 {
   code = FT_NEXT_USHORT( read );
-  if ( code  32 || code  127 )
+  if ( code != 0  ( code  32 || code  127 ) )
 code = '?';
 
   string[n] = (char)code;
@@ -95,7 +95,7 @@
 for ( n = 0; n  len; n++ )
 {
   code = *read++;
-  if ( code  32 || code  127 )
+  if ( code != 0  ( code  32 || code  127 ) )
 code = '?';
 
   string[n] = (char)code;
-- 
1.7.0.4

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] Patch to allow '\0' in sfnt name table entries

2012-03-14 Thread Alexei Podtelezhnikov
On Wed, Mar 14, 2012 at 7:26 AM, Huw Davies h...@codeweavers.com wrote:
 The attached patch fixes a problem with fonts that include a trailing
 '\0' in name table entries.  Currently the font name would have a
 question mark appended to it.

Why would the name contain \0?
Is this because entry-stringLength is larger than it should be?
May this bug be somewhere else?

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] Patch to allow '\0' in sfnt name table entries

2012-03-14 Thread Huw Davies
On Wed, Mar 14, 2012 at 07:58:55AM -0400, Alexei Podtelezhnikov wrote:
 On Wed, Mar 14, 2012 at 7:26 AM, Huw Davies h...@codeweavers.com wrote:
  The attached patch fixes a problem with fonts that include a trailing
  '\0' in name table entries.  Currently the font name would have a
  question mark appended to it.
 
 Why would the name contain \0?
 Is this because entry-stringLength is larger than it should be?
 May this bug be somewhere else?

Yes, the name table entries of these fonts include a trailing '\0' and
the character counts include that '\0'.  The fonts are part of a
Windows resource (the Copyright entry says they're autogenerated from
'Bitstream TrueDoc').  I have no control over these resources - I'm
trying to make the program that uses them run with Wine.

Windows itself has no issues with these fonts, and simply uses the
name upto the '\0'.  It seems right to me that FreeType should do this
too.

Huw.

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] Patch to allow '\0' in sfnt name table entries

2012-03-14 Thread Huw Davies
On Wed, Mar 14, 2012 at 08:53:28AM -0400, Alexei Podtelezhnikov wrote:
 Then I would prefer
 
 if (code == 0)
break;

Works for me.  See attached.

Huw.


From 137db2199aee433badb892bc7287d3eca5d4f2a4 Mon Sep 17 00:00:00 2001
From: Huw Davies h...@codeweavers.com
Date: Wed, 14 Mar 2012 13:21:36 +
Subject: [sfnt] Don't replace '\0' with question marks when converting
 strings from the name table.

---
 src/sfnt/sfobjs.c |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index d7be631..b53402f 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -64,13 +64,17 @@
 for ( n = 0; n  len; n++ )
 {
   code = FT_NEXT_USHORT( read );
+
+  if ( code == 0 )
+break;
+
   if ( code  32 || code  127 )
 code = '?';
 
   string[n] = (char)code;
 }
 
-string[len] = 0;
+string[n] = 0;
 
 return string;
   }
@@ -95,13 +99,17 @@
 for ( n = 0; n  len; n++ )
 {
   code = *read++;
+
+  if ( code == 0 )
+break;
+
   if ( code  32 || code  127 )
 code = '?';
 
   string[n] = (char)code;
 }
 
-string[len] = 0;
+string[n] = 0;
 
 return string;
   }
-- 
1.7.0.4

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] Patch to allow '\0' in sfnt name table entries

2012-03-14 Thread Werner LEMBERG

 Then I would prefer
 
 if (code == 0)
break;
 
 Works for me.  See attached.

I was quicker :-)  Please resend your patch relative to the current
git.


   Werner

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] Patch to allow '\0' in sfnt name table entries

2012-03-14 Thread Huw Davies
On Wed, Mar 14, 2012 at 05:20:34PM +0100, Werner LEMBERG wrote:
 I was quicker :-)  Please resend your patch relative to the current
 git.

Here you go.

Huw.
From 53f1b3aa88055a4fbc36e9654a48ed84d395f502 Mon Sep 17 00:00:00 2001
From: Huw Davies h...@codeweavers.com
Date: Wed, 14 Mar 2012 16:25:28 +
Subject: [sfnt] Don't bother copying characters after a '\0'.

---
 src/sfnt/sfobjs.c |   16 
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 3b9fd47..2bc4bd9 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -64,13 +64,17 @@
 for ( n = 0; n  len; n++ )
 {
   code = FT_NEXT_USHORT( read );
-  if ( code != 0  ( code  32 || code  127 ) )
+
+  if ( code == 0 )
+break;
+
+  if ( code  32 || code  127 )
 code = '?';
 
   string[n] = (char)code;
 }
 
-string[len] = 0;
+string[n] = 0;
 
 return string;
   }
@@ -95,13 +99,17 @@
 for ( n = 0; n  len; n++ )
 {
   code = *read++;
-  if ( code != 0  ( code  32 || code  127 ) )
+
+  if ( code == 0 )
+break;
+
+  if ( code  32 || code  127 )
 code = '?';
 
   string[n] = (char)code;
 }
 
-string[len] = 0;
+string[n] = 0;
 
 return string;
   }
-- 
1.7.0.4

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] Patch to allow '\0' in sfnt name table entries

2012-03-14 Thread Werner LEMBERG
 I was quicker :-)  Please resend your patch relative to the current
 git.
 
 Here you go.

Applied, thanks.


Werner

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel