diff --git a/CHANGES.md b/CHANGES.md
index 6dc3450..a6df050 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,12 @@ Changes in PDFio
================
+v1.1.3 (Month DD, YYYY)
+-----------------------
+
+- Fixed Unicode font support (Issue #16)
+
+
v1.1.2 (October 10, 2023)
-------------------------
diff --git a/Makefile b/Makefile
index c2bd89a..15531b9 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ DSONAME =
LDFLAGS =
LIBS = -lm -lz
RANLIB = ranlib
-VERSION = 1.1.2
+VERSION = 1.1.3
prefix = /usr/local
diff --git a/pdfio-content.c b/pdfio-content.c
index f88d265..e352b66 100644
--- a/pdfio-content.c
+++ b/pdfio-content.c
@@ -1526,7 +1526,7 @@ pdfioFileCreateFontObjFromFile(
{
// Encode a repeating sequence...
pdfioArrayAppendNumber(w_array, start);
- pdfioArrayAppendNumber(w_array, i);
+ pdfioArrayAppendNumber(w_array, i - 1);
pdfioArrayAppendNumber(w_array, w0);
}
else
@@ -1551,6 +1551,8 @@ pdfioFileCreateFontObjFromFile(
if (i == 65536)
pdfioArrayAppendNumber(temp_array, w0);
+ else
+ i --;
pdfioArrayAppendArray(w_array, temp_array);
}
diff --git a/pdfio.h b/pdfio.h
index 842564c..3166549 100644
--- a/pdfio.h
+++ b/pdfio.h
@@ -23,7 +23,7 @@ extern "C" {
// Version number...
//
-# define PDFIO_VERSION "1.1.2"
+# define PDFIO_VERSION "1.1.3"
//
diff --git a/pdfio_native.nuspec b/pdfio_native.nuspec
index f18dcac..36983c0 100644
--- a/pdfio_native.nuspec
+++ b/pdfio_native.nuspec
@@ -3,7 +3,7 @@
pdfio_native
PDFio Library for VS2019+
- 1.1.2
+ 1.1.3
Michael R Sweet
michaelrsweet
https://github.com/michaelrsweet/pappl
@@ -16,7 +16,7 @@
Copyright © 2019-2023 by Michael R Sweet
pdf file native
-
+
diff --git a/pdfio_native.redist.nuspec b/pdfio_native.redist.nuspec
index 32c7cae..20d05a3 100644
--- a/pdfio_native.redist.nuspec
+++ b/pdfio_native.redist.nuspec
@@ -3,7 +3,7 @@
pdfio_native.redist
PDFio Library for VS2019+
- 1.1.2
+ 1.1.3
Michael R Sweet
michaelrsweet
https://github.com/michaelrsweet/pappl
diff --git a/testpdfio.c b/testpdfio.c
index a8653d0..c37faee 100644
--- a/testpdfio.c
+++ b/testpdfio.c
@@ -2391,24 +2391,11 @@ write_font_test(pdfio_file_t *pdf, // I - PDF file
};
-#if 0
- if (unicode)
- {
- fputs("pdfioFileCreateFontObjFromFile(NotoSansJP-Regular.otf): ", stdout);
- if ((opensans = pdfioFileCreateFontObjFromFile(pdf, "testfiles/NotoSansJP-Regular.otf", true)) != NULL)
- puts("PASS");
- else
- return (1);
- }
+ fputs("pdfioFileCreateFontObjFromFile(OpenSans-Regular.ttf): ", stdout);
+ if ((opensans = pdfioFileCreateFontObjFromFile(pdf, "testfiles/OpenSans-Regular.ttf", unicode)) != NULL)
+ puts("PASS");
else
-#endif // 0
- {
- fputs("pdfioFileCreateFontObjFromFile(OpenSans-Regular.ttf): ", stdout);
- if ((opensans = pdfioFileCreateFontObjFromFile(pdf, "testfiles/OpenSans-Regular.ttf", unicode)) != NULL)
- puts("PASS");
- else
- return (1);
- }
+ return (1);
fputs("pdfioDictCreate: ", stdout);
if ((dict = pdfioDictCreate(pdf)) != NULL)
diff --git a/ttf.c b/ttf.c
index 99c42ec..c066eec 100644
--- a/ttf.c
+++ b/ttf.c
@@ -71,11 +71,10 @@ typedef __int64 ssize_t; // POSIX type not present on Windows...
//
-// DEBUG is typically defined for debug builds. TTF_DEBUG maps to printf when
+// DEBUG is typically defined for debug builds. TTF_DEBUG maps to fprintf when
// DEBUG is defined and is a no-op otherwise...
//
-#define DEBUG
#ifdef DEBUG
# define TTF_DEBUG(...) fprintf(stderr, __VA_ARGS__)
#else
@@ -459,8 +458,7 @@ ttfCreate(const char *filename, // I - Filename
if (font->cmap[i] >= 0)
{
int bin = (int)i / 256, // Sub-array bin
- glyph = font->cmap[i] + 1;
- // Glyph index (+1 to get past .notdef)
+ glyph = font->cmap[i]; // Glyph index
// Update min/max...
if (font->min_char < 0)
@@ -479,6 +477,11 @@ ttfCreate(const char *filename, // I - Filename
else
font->widths[bin][i & 255] = widths[glyph];
}
+
+#ifdef DEBUG
+ if (i >= ' ' && i < 127)
+ TTF_DEBUG("ttfCreate: width['%c']=%d(%d)\n", (char)i, font->widths[0][i].width, font->widths[0][i].left_bearingx);
+#endif // DEBUG
}
// Cleanup and return the font...
@@ -735,17 +738,6 @@ ttfGetFamily(ttf_t *font) // I - Font
}
-//
-// 'ttfIsFixedPitch()' - Determine whether a font is fixedpitch.
-//
-
-bool // O - `true` if fixed pitch, `false` otherwise
-ttfIsFixedPitch(ttf_t *font) // I - Font
-{
- return (font ? font->is_fixed : false);
-}
-
-
//
// 'ttfGetItalicAngle()' - Get the italic angle.
//
@@ -854,7 +846,6 @@ int // O - Width in 1000ths
ttfGetWidth(ttf_t *font, // I - Font
int ch) // I - Unicode character
{
- ch --;
int bin = ch >> 8; // Bin in widths array
@@ -882,6 +873,17 @@ ttfGetXHeight(ttf_t *font) // I - Font
}
+//
+// 'ttfIsFixedPitch()' - Determine whether a font is fixedpitch.
+//
+
+bool // O - `true` if fixed pitch, `false` otherwise
+ttfIsFixedPitch(ttf_t *font) // I - Font
+{
+ return (font ? font->is_fixed : false);
+}
+
+
//
// 'copy_name()' - Copy a name string from a font.
//
@@ -1582,6 +1584,8 @@ read_hmtx(ttf_t *font, // I - Font
{
widths[i].width = (short)read_ushort(font);
widths[i].left_bearing = (short)read_short(font);
+
+ TTF_DEBUG("read_hmtx: widths[%d].width=%d, .left_bearing=%d\n", i, widths[i].width, widths[i].left_bearing);
}
return (widths);