[cairo] CFF fonts compile error

Daniel Amelang daniel.amelang at gmail.com
Sun Feb 11 03:44:46 PST 2007


So the Visual C++ 2005 compiler chokes a part of the new CFF fonts
code. The attached (inlined!) patch solves the problem.

Dan

>From 08157949a6196310d8864951105f0af52ce8be68 Mon Sep 17 00:00:00 2001
From: Dan Amelang <dan at amelang.net>
Date: Sun, 11 Feb 2007 02:40:22 -0800
Subject: [PATCH] Fix compile error in CFF fonts code

The Visual C++ 2005 compiler apparently only allows structure
initialization at the time of structure declaration.
---
 src/cairo-cff-subset.c |   33 +++++++++++++++++++++++----------
 1 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index b02983a..1a73273 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -825,7 +825,7 @@ cff_charset_read_data (cff_charset_t *charset,
const unsigned char *data,
     return CAIRO_STATUS_SUCCESS;
 }

-static const uint16_t ISOAdobe_charset[] = {
+static const uint16_t ISOAdobe_charset_data[] = {
     1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
     17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
     31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
@@ -847,7 +847,13 @@ static const uint16_t ISOAdobe_charset[] = {
     222, 223, 224, 225, 226, 227, 228,
 };

-static const uint16_t Expert_charset[] = {
+static const cff_charset_t ISOAdobe_charset = {
+    TRUE,
+    (const unsigned char *) &ISOAdobe_charset_data,
+    sizeof (ISOAdobe_charset_data)
+};
+
+static const uint16_t Expert_charset_data[] = {
     1, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 13,
     14, 15, 99, 239, 240, 241, 242, 243, 244, 245, 246, 247,
     248, 27, 28, 249, 250, 251, 252, 253, 254, 255, 256, 257,
@@ -865,7 +871,13 @@ static const uint16_t Expert_charset[] = {
     371, 372, 373, 374, 375, 376, 377, 378,
 };

-static const uint16_t ExpertSubset_charset[] = {
+static const cff_charset_t Expert_charset = {
+    TRUE,
+    (const unsigned char *) &Expert_charset_data,
+    sizeof (Expert_charset_data)
+};
+
+static const uint16_t ExpertSubset_charset_data[] = {
     1, 231, 232, 235, 236, 237, 238, 13, 14, 15, 99, 239, 240,
     241, 242, 243, 244, 245, 246, 247, 248, 27, 28, 249, 250,
     251, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262,
@@ -876,23 +888,24 @@ static const uint16_t ExpertSubset_charset[] = {
     341, 342, 343, 344, 345, 346,
 };

-#define BUILTIN_CHARSET(name) ((cff_charset_t){TRUE, (const unsigned
char *)&(name), sizeof(name)})
+static const cff_charset_t ExpertSubset_charset = {
+    TRUE,
+    (const unsigned char *) &ExpertSubset_charset_data,
+    sizeof (ExpertSubset_charset_data)
+};

 static cairo_int_status_t
 cairo_cff_font_read_charset (cairo_cff_font_t *font)
 {
     switch (font->charset_offset) {
     case 0:
-	/* ISOAdobe charset */
-	font->charset = BUILTIN_CHARSET(ISOAdobe_charset);
+	font->charset = ISOAdobe_charset;
 	return CAIRO_STATUS_SUCCESS;
     case 1:
-	/* Expert charset */
-	font->charset = BUILTIN_CHARSET(Expert_charset);
+	font->charset = Expert_charset;
 	return CAIRO_STATUS_SUCCESS;
     case 2:
-	/* ExpertSubset charset */;
-	font->charset = BUILTIN_CHARSET(ExpertSubset_charset);
+	font->charset = ExpertSubset_charset;
 	return CAIRO_STATUS_SUCCESS;
     default:
 	break;
-- 
1.4.4.4


More information about the cairo mailing list