This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] windres - FONT statement in DIALOGEX resources



Hi!

The FONT statement in DIALOGEX resources can use up to five parameters. 
The parameters are:
  - font height (required)
  - font name (required)
  - font weight (optional, only in DIALOGEX)
  - italic (optional, only in DIALOGEX)
  - character set (optional, only in DIALOGEX)

A test case is included.


Best regards,
Eric Kohl

----

[binutils/ChangeLog]
         * rcparse.y: Allow two to five parameter in FONT statement of
DIALOGEX resources.

         *resbin.c (bin_to_res_dialog): Fixed read/write code for dialogex 
resource data.
         (res_to_bin_dialog): Likewise.

         *windres.h: Added misssing charset variable to dialog_ex structure.


[binutils/testsuite/ChangeLog]
        *binutils-all/windres/dlgfont.rc: New test case: Checks FONT 
statement in DIALOG and DIALOGEX resources.

        *binutils-all/windres/dlgfont.rsd: Expected output.

Index: rcparse.y
===================================================================
RCS file: /cvs/src/src/binutils/rcparse.y,v
retrieving revision 1.12
diff -b -u -p -r1.12 rcparse.y
--- rcparse.y	10 Apr 2002 08:14:27 -0000	1.12
+++ rcparse.y	13 Apr 2002 18:02:44 -0000
@@ -439,6 +439,27 @@ styles:
 	    style |= DS_SETFONT;
 	    dialog.pointsize = $3;
 	    unicode_from_ascii ((int *) NULL, &dialog.font, $5);
+	    if (dialog.ex != NULL)
+	      {
+		dialog.ex->weight = 0;
+		dialog.ex->italic = 0;
+		dialog.ex->charset = 1;
+	      }
+	  }
+	| styles FONT numexpr ',' QUOTEDSTRING cnumexpr
+	  {
+	    dialog.style |= DS_SETFONT;
+	    style |= DS_SETFONT;
+	    dialog.pointsize = $3;
+	    unicode_from_ascii ((int *) NULL, &dialog.font, $5);
+	    if (dialog.ex == NULL)
+	      rcparse_warning (_("extended FONT requires DIALOGEX"));
+	    else
+	      {
+		dialog.ex->weight = $6;
+		dialog.ex->italic = 0;
+		dialog.ex->charset = 1;
+	      }
 	  }
 	| styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr
 	  {
@@ -452,6 +473,22 @@ styles:
 	      {
 		dialog.ex->weight = $6;
 		dialog.ex->italic = $7;
+		dialog.ex->charset = 1;
+	      }
+	  }
+	| styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr cnumexpr
+	  {
+	    dialog.style |= DS_SETFONT;
+	    style |= DS_SETFONT;
+	    dialog.pointsize = $3;
+	    unicode_from_ascii ((int *) NULL, &dialog.font, $5);
+	    if (dialog.ex == NULL)
+	      rcparse_warning (_("extended FONT requires DIALOGEX"));
+	    else
+	      {
+		dialog.ex->weight = $6;
+		dialog.ex->italic = $7;
+		dialog.ex->charset = $8;
 	      }
 	  }
 	| styles MENU id
Index: resbin.c
===================================================================
RCS file: /cvs/src/src/binutils/resbin.c,v
retrieving revision 1.4
diff -b -u -p -r1.4 resbin.c
--- resbin.c	9 Apr 2002 17:14:59 -0000	1.4
+++ resbin.c	13 Apr 2002 18:02:47 -0000
@@ -30,6 +30,7 @@
 
 /* Macros to swap in values.  */
 
+#define get_8(s)      (*((unsigned char *)(s)))
 #define get_16(be, s) ((be) ? bfd_getb16 (s) : bfd_getl16 (s))
 #define get_32(be, s) ((be) ? bfd_getb32 (s) : bfd_getl32 (s))
 
@@ -528,6 +529,7 @@ bin_to_res_dialog (data, length, big_end
 	{
 	  d->ex->weight = 0;
 	  d->ex->italic = 0;
+	  d->ex->charset = 1; /* Default charset  */
 	}
     }
   else
@@ -543,7 +545,8 @@ bin_to_res_dialog (data, length, big_end
 	  if (length < off + 4)
 	    toosmall (_("dialogex font information"));
 	  d->ex->weight = get_16 (big_endian, data + off);
-	  d->ex->italic = get_16 (big_endian, data + off + 2);
+	  d->ex->italic = get_8 (data + off + 2);
+	  d->ex->charset = get_8 (data + off + 3);
 	  off += 4;
 	}
 
@@ -1257,6 +1260,7 @@ bin_to_res_userdata (data, length, big_e
 
 /* Macros to swap out values.  */
 
+#define put_8(v, s)      (*((unsigned char *)(s)) = (unsigned char)(v))
 #define put_16(be, v, s) ((be) ? bfd_putb16 ((v), (s)) : bfd_putl16 ((v), 
(s)))
 #define put_32(be, v, s) ((be) ? bfd_putb32 ((v), (s)) : bfd_putl32 ((v), 
(s)))
 
@@ -1626,12 +1630,14 @@ res_to_bin_dialog (dialog, big_endian)
 	  if (dialog->ex == NULL)
 	    {
 	      put_16 (big_endian, 0, d->data + 2);
-	      put_16 (big_endian, 0, d->data + 4);
+	      put_8 (0, d->data + 4);
+	      put_8 (1, d->data + 5);
 	    }
 	  else
 	    {
 	      put_16 (big_endian, dialog->ex->weight, d->data + 2);
-	      put_16 (big_endian, dialog->ex->italic, d->data + 4);
+	      put_8 (dialog->ex->italic, d->data + 4);
+	      put_8 (dialog->ex->charset, d->data + 5);
 	    }
 	}
 
Index: windres.h
===================================================================
RCS file: /cvs/src/src/binutils/windres.h,v
retrieving revision 1.6
diff -b -u -p -r1.6 windres.h
--- windres.h	17 Jul 2001 01:19:19 -0000	1.6
+++ windres.h	13 Apr 2002 18:02:48 -0000
@@ -315,7 +315,9 @@ struct dialog_ex
   /* Font weight.  */
   unsigned short weight;
   /* Whether the font is italic.  */
-  unsigned short italic;
+  unsigned char italic;
+  /* Character set.  */
+  unsigned char charset;
 };
 
 /* Window style flags, from the winsup Defines.h header file.  These
--- /dev/NULL	Wed Feb 14 17:38:44 2001
+++ testsuite/binutils-all/windres/dlgfont.rc	Sat Apr 13 16:37:22 2002
@@ -0,0 +1,30 @@
+101 DIALOG DISCARDABLE 0, 0, 186, 95
+FONT 8, "Tahoma"
+BEGIN
+    DEFPUSHBUTTON "OK", 1, 129, 7, 50, 14
+END
+
+102 DIALOGEX DISCARDABLE 0, 0, 186, 95
+FONT 8, "Tahoma"
+BEGIN
+    DEFPUSHBUTTON "OK", 1, 129, 7, 50, 14
+END
+
+103 DIALOGEX DISCARDABLE 0, 0, 186, 95
+FONT 8, "Tahoma", 0
+BEGIN
+    DEFPUSHBUTTON "OK", 1, 129, 7, 50, 14
+END
+
+104 DIALOGEX DISCARDABLE 0, 0, 186, 95
+FONT 8, "Tahoma", 0, 0
+BEGIN
+    DEFPUSHBUTTON "OK", 1, 129, 7, 50, 14
+END
+
+105 DIALOGEX DISCARDABLE 0, 0, 186, 95
+FONT 8, "Tahoma", 0, 0, 1
+BEGIN
+    DEFPUSHBUTTON "OK", 1, 129, 7, 50, 14
+END
+
--- /dev/NULL	Wed Feb 14 17:38:44 2001
+++ testsuite/binutils-all/windres/dlgfont.rsd	Sat Apr 13 16:38:57 2002
@@ -0,0 +1,39 @@
+ 0000 00000000 20000000 ffff0000 ffff0000  .... ...........
+ 0010 00000000 00000000 00000000 00000000  ................
+ 0020 46000000 20000000 ffff0500 ffff6500  F... .........e.
+ 0030 00000000 30100904 00000000 00000000  ....0...........
+ 0040 40008880 00000000 01000000 0000ba00  @...............
+ 0050 5f000000 00000000 08005400 61006800  _.........T.a.h.
+ 0060 6f006d00 61000000 01000150 00000000  o.m.a......P....
+ 0070 81000700 32000e00 0100ffff 80004f00  ....2.........O.
+ 0080 4b000000 00000000 58000000 20000000  K.......X... ...
+ 0090 ffff0500 ffff6600 00000000 30100904  ......f.....0...
+ 00a0 00000000 00000000 0100ffff 00000000  ................
+ 00b0 00000000 40008880 01000000 0000ba00  ....@...........
+ 00c0 5f000000 00000000 08000000 00015400  _.............T.
+ 00d0 61006800 6f006d00 61000000 00000000  a.h.o.m.a.......
+ 00e0 00000000 01000150 81000700 32000e00  .......P....2...
+ 00f0 01000000 ffff8000 4f004b00 00000000  ........O.K.....
+ 0100 58000000 20000000 ffff0500 ffff6700  X... .........g.
+ 0110 00000000 30100904 00000000 00000000  ....0...........
+ 0120 0100ffff 00000000 00000000 40008880  ............@...
+ 0130 01000000 0000ba00 5f000000 00000000  ........_.......
+ 0140 08000000 00015400 61006800 6f006d00  ......T.a.h.o.m.
+ 0150 61000000 00000000 00000000 01000150  a..............P
+ 0160 81000700 32000e00 01000000 ffff8000  ....2...........
+ 0170 4f004b00 00000000 58000000 20000000  O.K.....X... ...
+ 0180 ffff0500 ffff6800 00000000 30100904  ......h.....0...
+ 0190 00000000 00000000 0100ffff 00000000  ................
+ 01a0 00000000 40008880 01000000 0000ba00  ....@...........
+ 01b0 5f000000 00000000 08000000 00015400  _.............T.
+ 01c0 61006800 6f006d00 61000000 00000000  a.h.o.m.a.......
+ 01d0 00000000 01000150 81000700 32000e00  .......P....2...
+ 01e0 01000000 ffff8000 4f004b00 00000000  ........O.K.....
+ 01f0 58000000 20000000 ffff0500 ffff6900  X... .........i.
+ 0200 00000000 30100904 00000000 00000000  ....0...........
+ 0210 0100ffff 00000000 00000000 40008880  ............@...
+ 0220 01000000 0000ba00 5f000000 00000000  ........_.......
+ 0230 08000000 00015400 61006800 6f006d00  ......T.a.h.o.m.
+ 0240 61000000 00000000 00000000 01000150  a..............P
+ 0250 81000700 32000e00 01000000 ffff8000  ....2...........
+ 0260 4f004b00 00000000                    O.K.....        


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]