mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-12-27 21:58:22 +01:00
Compare commits
10 Commits
0c1122b689
...
90923c3818
Author | SHA1 | Date | |
---|---|---|---|
|
90923c3818 | ||
|
986cc512cd | ||
|
c35ddbec00 | ||
|
e4e1c39578 | ||
|
1d4f77cab1 | ||
|
b035130cde | ||
|
d6d5813b04 | ||
|
6492f210cf | ||
|
207062a996 | ||
|
7d37abb0df |
@ -2,6 +2,14 @@ Changes in PDFio
|
|||||||
================
|
================
|
||||||
|
|
||||||
|
|
||||||
|
v1.3.1 (August 5, 2024)
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
- CVE 2024-42358: Updated TrueType font reader to avoid large memory
|
||||||
|
allocations.
|
||||||
|
- Fixed some documentation errors and added examples (Issue #68, Issue #69)
|
||||||
|
|
||||||
|
|
||||||
v1.3.0 (June 28, 2024)
|
v1.3.0 (June 28, 2024)
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
24
configure
vendored
24
configure
vendored
@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# Guess values for system-dependent variables and create Makefiles.
|
||||||
# Generated by GNU Autoconf 2.71 for pdfio 1.3.0.
|
# Generated by GNU Autoconf 2.71 for pdfio 1.3.1.
|
||||||
#
|
#
|
||||||
# Report bugs to <https://github.com/michaelrsweet/pdfio/issues>.
|
# Report bugs to <https://github.com/michaelrsweet/pdfio/issues>.
|
||||||
#
|
#
|
||||||
@ -610,8 +610,8 @@ MAKEFLAGS=
|
|||||||
# Identity of this package.
|
# Identity of this package.
|
||||||
PACKAGE_NAME='pdfio'
|
PACKAGE_NAME='pdfio'
|
||||||
PACKAGE_TARNAME='pdfio'
|
PACKAGE_TARNAME='pdfio'
|
||||||
PACKAGE_VERSION='1.3.0'
|
PACKAGE_VERSION='1.3.1'
|
||||||
PACKAGE_STRING='pdfio 1.3.0'
|
PACKAGE_STRING='pdfio 1.3.1'
|
||||||
PACKAGE_BUGREPORT='https://github.com/michaelrsweet/pdfio/issues'
|
PACKAGE_BUGREPORT='https://github.com/michaelrsweet/pdfio/issues'
|
||||||
PACKAGE_URL='https://www.msweet.org/pdfio'
|
PACKAGE_URL='https://www.msweet.org/pdfio'
|
||||||
|
|
||||||
@ -1293,7 +1293,7 @@ if test "$ac_init_help" = "long"; then
|
|||||||
# Omit some internal or obsolete options to make the list less imposing.
|
# Omit some internal or obsolete options to make the list less imposing.
|
||||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||||
cat <<_ACEOF
|
cat <<_ACEOF
|
||||||
\`configure' configures pdfio 1.3.0 to adapt to many kinds of systems.
|
\`configure' configures pdfio 1.3.1 to adapt to many kinds of systems.
|
||||||
|
|
||||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||||
|
|
||||||
@ -1359,7 +1359,7 @@ fi
|
|||||||
|
|
||||||
if test -n "$ac_init_help"; then
|
if test -n "$ac_init_help"; then
|
||||||
case $ac_init_help in
|
case $ac_init_help in
|
||||||
short | recursive ) echo "Configuration of pdfio 1.3.0:";;
|
short | recursive ) echo "Configuration of pdfio 1.3.1:";;
|
||||||
esac
|
esac
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
|
|
||||||
@ -1456,7 +1456,7 @@ fi
|
|||||||
test -n "$ac_init_help" && exit $ac_status
|
test -n "$ac_init_help" && exit $ac_status
|
||||||
if $ac_init_version; then
|
if $ac_init_version; then
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
pdfio configure 1.3.0
|
pdfio configure 1.3.1
|
||||||
generated by GNU Autoconf 2.71
|
generated by GNU Autoconf 2.71
|
||||||
|
|
||||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||||
@ -1612,7 +1612,7 @@ cat >config.log <<_ACEOF
|
|||||||
This file contains any messages produced by compilers while
|
This file contains any messages produced by compilers while
|
||||||
running configure, to aid debugging if configure makes a mistake.
|
running configure, to aid debugging if configure makes a mistake.
|
||||||
|
|
||||||
It was created by pdfio $as_me 1.3.0, which was
|
It was created by pdfio $as_me 1.3.1, which was
|
||||||
generated by GNU Autoconf 2.71. Invocation command line was
|
generated by GNU Autoconf 2.71. Invocation command line was
|
||||||
|
|
||||||
$ $0$ac_configure_args_raw
|
$ $0$ac_configure_args_raw
|
||||||
@ -2368,9 +2368,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
PDFIO_VERSION="1.3.0"
|
PDFIO_VERSION="1.3.1"
|
||||||
PDFIO_VERSION_MAJOR="`echo 1.3.0 | awk -F. '{print $1}'`"
|
PDFIO_VERSION_MAJOR="`echo 1.3.1 | awk -F. '{print $1}'`"
|
||||||
PDFIO_VERSION_MINOR="`echo 1.3.0 | awk -F. '{printf("%d\n",$2);}'`"
|
PDFIO_VERSION_MINOR="`echo 1.3.1 | awk -F. '{printf("%d\n",$2);}'`"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -4935,7 +4935,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
|||||||
# report actual input values of CONFIG_FILES etc. instead of their
|
# report actual input values of CONFIG_FILES etc. instead of their
|
||||||
# values after options handling.
|
# values after options handling.
|
||||||
ac_log="
|
ac_log="
|
||||||
This file was extended by pdfio $as_me 1.3.0, which was
|
This file was extended by pdfio $as_me 1.3.1, which was
|
||||||
generated by GNU Autoconf 2.71. Invocation command line was
|
generated by GNU Autoconf 2.71. Invocation command line was
|
||||||
|
|
||||||
CONFIG_FILES = $CONFIG_FILES
|
CONFIG_FILES = $CONFIG_FILES
|
||||||
@ -4991,7 +4991,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
|
|||||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||||
ac_cs_config='$ac_cs_config_escaped'
|
ac_cs_config='$ac_cs_config_escaped'
|
||||||
ac_cs_version="\\
|
ac_cs_version="\\
|
||||||
pdfio config.status 1.3.0
|
pdfio config.status 1.3.1
|
||||||
configured by $0, generated by GNU Autoconf 2.71,
|
configured by $0, generated by GNU Autoconf 2.71,
|
||||||
with options \\"\$ac_cs_config\\"
|
with options \\"\$ac_cs_config\\"
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ AC_PREREQ([2.70])
|
|||||||
|
|
||||||
|
|
||||||
dnl Package name and version...
|
dnl Package name and version...
|
||||||
AC_INIT([pdfio], [1.3.0], [https://github.com/michaelrsweet/pdfio/issues], [pdfio], [https://www.msweet.org/pdfio])
|
AC_INIT([pdfio], [1.3.1], [https://github.com/michaelrsweet/pdfio/issues], [pdfio], [https://www.msweet.org/pdfio])
|
||||||
|
|
||||||
PDFIO_VERSION="AC_PACKAGE_VERSION"
|
PDFIO_VERSION="AC_PACKAGE_VERSION"
|
||||||
PDFIO_VERSION_MAJOR="`echo AC_PACKAGE_VERSION | awk -F. '{print $1}'`"
|
PDFIO_VERSION_MAJOR="`echo AC_PACKAGE_VERSION | awk -F. '{print $1}'`"
|
||||||
|
123
doc/pdfio.3
123
doc/pdfio.3
@ -1,4 +1,4 @@
|
|||||||
.TH pdfio 3 "pdf read/write library" "2024-06-24" "pdf read/write library"
|
.TH pdfio 3 "pdf read/write library" "2024-08-05" "pdf read/write library"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
pdfio \- pdf read/write library
|
pdfio \- pdf read/write library
|
||||||
.SH Introduction
|
.SH Introduction
|
||||||
@ -361,7 +361,7 @@ pdfioStreamWrite writes a buffer of data to the stream
|
|||||||
.PP
|
.PP
|
||||||
The PDF content helper functions provide additional functions for writing specific PDF page stream commands.
|
The PDF content helper functions provide additional functions for writing specific PDF page stream commands.
|
||||||
.PP
|
.PP
|
||||||
When you are done writing the stream, call pdfioStreamCLose to close both the stream and the object.
|
When you are done writing the stream, call pdfioStreamClose to close both the stream and the object.
|
||||||
.SS PDF Content Helper Functions
|
.SS PDF Content Helper Functions
|
||||||
.PP
|
.PP
|
||||||
PDFio includes many helper functions for embedding or writing specific kinds of content to a PDF file. These functions can be roughly grouped into five categories:
|
PDFio includes many helper functions for embedding or writing specific kinds of content to a PDF file. These functions can be roughly grouped into five categories:
|
||||||
@ -787,6 +787,125 @@ pdfioContentTextShowf draws a formatted string in a text block
|
|||||||
pdfioContentTextShowJustified draws an array of literal strings with offsets between them
|
pdfioContentTextShowJustified draws an array of literal strings with offsets between them
|
||||||
|
|
||||||
|
|
||||||
|
.SH Examples
|
||||||
|
.SS Read PDF Metadata
|
||||||
|
.PP
|
||||||
|
The following example function will open a PDF file and print the title, author, creation date, and number of pages:
|
||||||
|
.nf
|
||||||
|
|
||||||
|
#include <pdfio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
show_pdf_info(const char *filename)
|
||||||
|
{
|
||||||
|
pdfio_file_t *pdf;
|
||||||
|
time_t creation_date;
|
||||||
|
struct tm *creation_tm;
|
||||||
|
char creation_text[256];
|
||||||
|
|
||||||
|
|
||||||
|
// Open the PDF file with the default callbacks...
|
||||||
|
pdf = pdfioFileOpen(filename, /*password_cb*/NULL, /*password_cbdata*/NULL, /*error_cb*/NULL, /*error_cbdata*/NULL);
|
||||||
|
if (pdf == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Get the creation date and convert to a string...
|
||||||
|
creation_date = pdfioFileGetCreationDate(pdf);
|
||||||
|
creation_tm = localtime(&creation_date);
|
||||||
|
strftime(creation_text, sizeof(creation_text), "%c", &creation_tm);
|
||||||
|
|
||||||
|
// Print file information to stdout...
|
||||||
|
printf("%s:\\n", filename);
|
||||||
|
printf(" Title: %s\\n", pdfioFileGetTitle(pdf));
|
||||||
|
printf(" Author: %s\\n", pdfioFileGetAuthor(pdf));
|
||||||
|
printf(" Created On: %s\\n", creation_text);
|
||||||
|
printf(" Number Pages: %u\\n", (unsigned)pdfioFileGetNumPages(pdf));
|
||||||
|
|
||||||
|
// Close the PDF file...
|
||||||
|
pdfioFileClose(pdf);
|
||||||
|
}
|
||||||
|
.fi
|
||||||
|
.SS Create PDF File With Text and Image
|
||||||
|
.PP
|
||||||
|
The following example function will create a PDF file, embed a base font and the named JPEG or PNG image file, and then creates a page with the image centered on the page with the text centered below:
|
||||||
|
.nf
|
||||||
|
|
||||||
|
#include <pdfio.h>
|
||||||
|
#include <pdfio\-content.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
create_pdf_image_file(const char *pdfname, const char *imagename, const char *caption)
|
||||||
|
{
|
||||||
|
pdfio_file_t *pdf;
|
||||||
|
pdfio_obj_t *font;
|
||||||
|
pdfio_obj_t *image;
|
||||||
|
pdfio_dict_t *dict;
|
||||||
|
pdfio_stream_t *page;
|
||||||
|
double width, height;
|
||||||
|
double swidth, sheight;
|
||||||
|
double tx, ty;
|
||||||
|
|
||||||
|
|
||||||
|
// Create the PDF file...
|
||||||
|
pdf = pdfioFileCreate(pdfname, /*version*/NULL, /*media_box*/NULL, /*crop_box*/NULL, /*error_cb*/NULL, /*error_cbdata*/NULL);
|
||||||
|
|
||||||
|
// Create a Courier base font for the caption
|
||||||
|
font = pdfioFileCreateFontObjFromBase(pdf, "Courier");
|
||||||
|
|
||||||
|
// Create an image object from the JPEG/PNG image file...
|
||||||
|
image = pdfioFileCreateImageObjFromFile(pdf, imagename, true);
|
||||||
|
|
||||||
|
// Create a page dictionary with the font and image...
|
||||||
|
dict = pdfioDictCreate(pdf);
|
||||||
|
pdfioPageDictAddFont(dict, "F1", font);
|
||||||
|
pdfioPageDictAddImage(dict, "IM1", image);
|
||||||
|
|
||||||
|
// Create the page and its content stream...
|
||||||
|
page = pdfioFileCreatePage(pdf, dict);
|
||||||
|
|
||||||
|
// Position and scale the image on the page...
|
||||||
|
width = pdfioImageGetWidth(image);
|
||||||
|
height = pdfioImageGetHeight(image);
|
||||||
|
|
||||||
|
// Default media_box is "universal" 595.28x792 points (8.27x11in or 210x279mm)
|
||||||
|
// Use margins of 36 points (0.5in or 12.7mm) with another 36 points for the
|
||||||
|
// caption underneath...
|
||||||
|
swidth = 595.28 \- 72.0;
|
||||||
|
sheight = swidth * height / width;
|
||||||
|
if (sheight > (792.0 \- 36.0 \- 72.0))
|
||||||
|
{
|
||||||
|
sheight = 792.0 \- 36.0 \- 72.0;
|
||||||
|
swidth = sheight * width / height;
|
||||||
|
}
|
||||||
|
|
||||||
|
tx = 0.5 * (595.28 \- swidth);
|
||||||
|
ty = 0.5 * (792 \- 36 \- sheight);
|
||||||
|
|
||||||
|
pdfioContentDrawImage(page, "IM1", tx, ty + 36.0, swidth, sheight);
|
||||||
|
|
||||||
|
// Draw the caption in black...
|
||||||
|
pdfioContentSetFillColorDeviceGray(page, 0.0);
|
||||||
|
|
||||||
|
// Compute the starting point for the text \- Courier is monospaced with a
|
||||||
|
// nominal width of 0.6 times the text height...
|
||||||
|
tx = 0.5 * (595.28 \- 18.0 * 0.6 * strlen(caption));
|
||||||
|
|
||||||
|
// Position and draw the caption underneath...
|
||||||
|
pdfioContentTextBegin(page);
|
||||||
|
pdfioContentSetTextFont(page, "F1", 18.0);
|
||||||
|
pdfioContentTextMoveTo(page, tx, ty);
|
||||||
|
pdfioContentTextShow(page, /*unicode*/false, caption);
|
||||||
|
pdfioContentTextEnd(page);
|
||||||
|
|
||||||
|
// Close the page stream and the PDF file...
|
||||||
|
pdfioStreamClose(page);
|
||||||
|
pdfioFileClose(pdf);
|
||||||
|
}
|
||||||
|
.fi
|
||||||
|
|
||||||
.SH ENUMERATIONS
|
.SH ENUMERATIONS
|
||||||
.SS pdfio_cs_e
|
.SS pdfio_cs_e
|
||||||
|
121
doc/pdfio.html
121
doc/pdfio.html
@ -273,6 +273,10 @@ span.string {
|
|||||||
<li><a href="#pdf-streams">PDF Streams</a></li>
|
<li><a href="#pdf-streams">PDF Streams</a></li>
|
||||||
<li><a href="#pdf-content-helper-functions">PDF Content Helper Functions</a></li>
|
<li><a href="#pdf-content-helper-functions">PDF Content Helper Functions</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
|
<li><a href="#examples">Examples</a><ul class="subcontents">
|
||||||
|
<li><a href="#read-pdf-metadata">Read PDF Metadata</a></li>
|
||||||
|
<li><a href="#create-pdf-file-with-text-and-image">Create PDF File With Text and Image</a></li>
|
||||||
|
</ul></li>
|
||||||
<li><a href="#FUNCTIONS">Functions</a><ul class="subcontents">
|
<li><a href="#FUNCTIONS">Functions</a><ul class="subcontents">
|
||||||
<li><a href="#pdfioArrayAppendArray">pdfioArrayAppendArray</a></li>
|
<li><a href="#pdfioArrayAppendArray">pdfioArrayAppendArray</a></li>
|
||||||
<li><a href="#pdfioArrayAppendBinary">pdfioArrayAppendBinary</a></li>
|
<li><a href="#pdfioArrayAppendBinary">pdfioArrayAppendBinary</a></li>
|
||||||
@ -709,7 +713,7 @@ pdfio_stream_t *st = pdfioFileCreatePage(pdf, dict);
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>The <a href="#pdf-content-helper-functions">PDF content helper functions</a> provide additional functions for writing specific PDF page stream commands.</p>
|
<p>The <a href="#pdf-content-helper-functions">PDF content helper functions</a> provide additional functions for writing specific PDF page stream commands.</p>
|
||||||
<p>When you are done writing the stream, call <a href="#pdfioStreamCLose"><code>pdfioStreamCLose</code></a> to close both the stream and the object.</p>
|
<p>When you are done writing the stream, call <a href="#pdfioStreamClose"><code>pdfioStreamClose</code></a> to close both the stream and the object.</p>
|
||||||
<h3 class="title" id="pdf-content-helper-functions">PDF Content Helper Functions</h3>
|
<h3 class="title" id="pdf-content-helper-functions">PDF Content Helper Functions</h3>
|
||||||
<p>PDFio includes many helper functions for embedding or writing specific kinds of content to a PDF file. These functions can be roughly grouped into five categories:</p>
|
<p>PDFio includes many helper functions for embedding or writing specific kinds of content to a PDF file. These functions can be roughly grouped into five categories:</p>
|
||||||
<ul>
|
<ul>
|
||||||
@ -943,6 +947,119 @@ pdfio_obj_t *img = pdfioFileCreateImageObjFromFile(pdf, <span class="string">&qu
|
|||||||
<li><p><a href="#pdfioContentTextShowJustified"><code>pdfioContentTextShowJustified</code></a> draws an array of literal strings with offsets between them</p>
|
<li><p><a href="#pdfioContentTextShowJustified"><code>pdfioContentTextShowJustified</code></a> draws an array of literal strings with offsets between them</p>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<h2 class="title" id="examples">Examples</h2>
|
||||||
|
<h3 class="title" id="read-pdf-metadata">Read PDF Metadata</h3>
|
||||||
|
<p>The following example function will open a PDF file and print the title, author, creation date, and number of pages:</p>
|
||||||
|
<pre><code class="language-c"><span class="directive">#include <pdfio.h></span>
|
||||||
|
<span class="directive">#include <time.h></span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class="reserved">void</span>
|
||||||
|
show_pdf_info(<span class="reserved">const</span> <span class="reserved">char</span> *filename)
|
||||||
|
{
|
||||||
|
pdfio_file_t *pdf;
|
||||||
|
time_t creation_date;
|
||||||
|
<span class="reserved">struct</span> tm *creation_tm;
|
||||||
|
<span class="reserved">char</span> creation_text[<span class="number">256</span>];
|
||||||
|
|
||||||
|
|
||||||
|
<span class="comment">// Open the PDF file with the default callbacks...</span>
|
||||||
|
pdf = pdfioFileOpen(filename, <span class="comment">/*password_cb*/</span>NULL, <span class="comment">/*password_cbdata*/</span>NULL, <span class="comment">/*error_cb*/</span>NULL, <span class="comment">/*error_cbdata*/</span>NULL);
|
||||||
|
<span class="reserved">if</span> (pdf == NULL)
|
||||||
|
<span class="reserved">return</span>;
|
||||||
|
|
||||||
|
<span class="comment">// Get the creation date and convert to a string...</span>
|
||||||
|
creation_date = pdfioFileGetCreationDate(pdf);
|
||||||
|
creation_tm = localtime(&creation_date);
|
||||||
|
strftime(creation_text, <span class="reserved">sizeof</span>(creation_text), <span class="string">"%c"</span>, &creation_tm);
|
||||||
|
|
||||||
|
<span class="comment">// Print file information to stdout...</span>
|
||||||
|
printf(<span class="string">"%s:\n"</span>, filename);
|
||||||
|
printf(<span class="string">" Title: %s\n"</span>, pdfioFileGetTitle(pdf));
|
||||||
|
printf(<span class="string">" Author: %s\n"</span>, pdfioFileGetAuthor(pdf));
|
||||||
|
printf(<span class="string">" Created On: %s\n"</span>, creation_text);
|
||||||
|
printf(<span class="string">" Number Pages: %u\n"</span>, (<span class="reserved">unsigned</span>)pdfioFileGetNumPages(pdf));
|
||||||
|
|
||||||
|
<span class="comment">// Close the PDF file...</span>
|
||||||
|
pdfioFileClose(pdf);
|
||||||
|
}
|
||||||
|
</code></pre>
|
||||||
|
<h3 class="title" id="create-pdf-file-with-text-and-image">Create PDF File With Text and Image</h3>
|
||||||
|
<p>The following example function will create a PDF file, embed a base font and the named JPEG or PNG image file, and then creates a page with the image centered on the page with the text centered below:</p>
|
||||||
|
<pre><code class="language-c"><span class="directive">#include <pdfio.h></span>
|
||||||
|
<span class="directive">#include <pdfio-content.h></span>
|
||||||
|
<span class="directive">#include <string.h></span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class="reserved">void</span>
|
||||||
|
create_pdf_image_file(<span class="reserved">const</span> <span class="reserved">char</span> *pdfname, <span class="reserved">const</span> <span class="reserved">char</span> *imagename, <span class="reserved">const</span> <span class="reserved">char</span> *caption)
|
||||||
|
{
|
||||||
|
pdfio_file_t *pdf;
|
||||||
|
pdfio_obj_t *font;
|
||||||
|
pdfio_obj_t *image;
|
||||||
|
pdfio_dict_t *dict;
|
||||||
|
pdfio_stream_t *page;
|
||||||
|
<span class="reserved">double</span> width, height;
|
||||||
|
<span class="reserved">double</span> swidth, sheight;
|
||||||
|
<span class="reserved">double</span> tx, ty;
|
||||||
|
|
||||||
|
|
||||||
|
<span class="comment">// Create the PDF file...</span>
|
||||||
|
pdf = pdfioFileCreate(pdfname, <span class="comment">/*version*/</span>NULL, <span class="comment">/*media_box*/</span>NULL, <span class="comment">/*crop_box*/</span>NULL, <span class="comment">/*error_cb*/</span>NULL, <span class="comment">/*error_cbdata*/</span>NULL);
|
||||||
|
|
||||||
|
<span class="comment">// Create a Courier base font for the caption</span>
|
||||||
|
font = pdfioFileCreateFontObjFromBase(pdf, <span class="string">"Courier"</span>);
|
||||||
|
|
||||||
|
<span class="comment">// Create an image object from the JPEG/PNG image file...</span>
|
||||||
|
image = pdfioFileCreateImageObjFromFile(pdf, imagename, <span class="reserved">true</span>);
|
||||||
|
|
||||||
|
<span class="comment">// Create a page dictionary with the font and image...</span>
|
||||||
|
dict = pdfioDictCreate(pdf);
|
||||||
|
pdfioPageDictAddFont(dict, <span class="string">"F1"</span>, font);
|
||||||
|
pdfioPageDictAddImage(dict, <span class="string">"IM1"</span>, image);
|
||||||
|
|
||||||
|
<span class="comment">// Create the page and its content stream...</span>
|
||||||
|
page = pdfioFileCreatePage(pdf, dict);
|
||||||
|
|
||||||
|
<span class="comment">// Position and scale the image on the page...</span>
|
||||||
|
width = pdfioImageGetWidth(image);
|
||||||
|
height = pdfioImageGetHeight(image);
|
||||||
|
|
||||||
|
<span class="comment">// Default media_box is "universal" 595.28x792 points (8.27x11in or 210x279mm)</span>
|
||||||
|
<span class="comment">// Use margins of 36 points (0.5in or 12.7mm) with another 36 points for the</span>
|
||||||
|
<span class="comment">// caption underneath...</span>
|
||||||
|
swidth = <span class="number">595.28</span> - <span class="number">72.0</span>;
|
||||||
|
sheight = swidth * height / width;
|
||||||
|
<span class="reserved">if</span> (sheight > (<span class="number">792.0</span> - <span class="number">36.0</span> - <span class="number">72.0</span>))
|
||||||
|
{
|
||||||
|
sheight = <span class="number">792.0</span> - <span class="number">36.0</span> - <span class="number">72.0</span>;
|
||||||
|
swidth = sheight * width / height;
|
||||||
|
}
|
||||||
|
|
||||||
|
tx = <span class="number">0.5</span> * (<span class="number">595.28</span> - swidth);
|
||||||
|
ty = <span class="number">0.5</span> * (<span class="number">792</span> - <span class="number">36</span> - sheight);
|
||||||
|
|
||||||
|
pdfioContentDrawImage(page, <span class="string">"IM1"</span>, tx, ty + <span class="number">36.0</span>, swidth, sheight);
|
||||||
|
|
||||||
|
<span class="comment">// Draw the caption in black...</span>
|
||||||
|
pdfioContentSetFillColorDeviceGray(page, <span class="number">0.0</span>);
|
||||||
|
|
||||||
|
<span class="comment">// Compute the starting point for the text - Courier is monospaced with a</span>
|
||||||
|
<span class="comment">// nominal width of 0.6 times the text height...</span>
|
||||||
|
tx = <span class="number">0.5</span> * (<span class="number">595.28</span> - <span class="number">18.0</span> * <span class="number">0.6</span> * strlen(caption));
|
||||||
|
|
||||||
|
<span class="comment">// Position and draw the caption underneath...</span>
|
||||||
|
pdfioContentTextBegin(page);
|
||||||
|
pdfioContentSetTextFont(page, <span class="string">"F1"</span>, <span class="number">18.0</span>);
|
||||||
|
pdfioContentTextMoveTo(page, tx, ty);
|
||||||
|
pdfioContentTextShow(page, <span class="comment">/*unicode*/</span><span class="reserved">false</span>, caption);
|
||||||
|
pdfioContentTextEnd(page);
|
||||||
|
|
||||||
|
<span class="comment">// Close the page stream and the PDF file...</span>
|
||||||
|
pdfioStreamClose(page);
|
||||||
|
pdfioFileClose(pdf);
|
||||||
|
}
|
||||||
|
</code></pre>
|
||||||
<h2 class="title"><a id="FUNCTIONS">Functions</a></h2>
|
<h2 class="title"><a id="FUNCTIONS">Functions</a></h2>
|
||||||
<h3 class="function"><a id="pdfioArrayAppendArray">pdfioArrayAppendArray</a></h3>
|
<h3 class="function"><a id="pdfioArrayAppendArray">pdfioArrayAppendArray</a></h3>
|
||||||
<p class="description">Add an array value to an array.</p>
|
<p class="description">Add an array value to an array.</p>
|
||||||
@ -3447,7 +3564,7 @@ array that was created using the
|
|||||||
<tr><th>dict</th>
|
<tr><th>dict</th>
|
||||||
<td class="description">Page dictionary</td></tr>
|
<td class="description">Page dictionary</td></tr>
|
||||||
<tr><th>name</th>
|
<tr><th>name</th>
|
||||||
<td class="description">Font name</td></tr>
|
<td class="description">Font name; must not contain spaces</td></tr>
|
||||||
<tr><th>obj</th>
|
<tr><th>obj</th>
|
||||||
<td class="description">Font object</td></tr>
|
<td class="description">Font object</td></tr>
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
|
132
doc/pdfio.md
132
doc/pdfio.md
@ -345,7 +345,7 @@ to the stream:
|
|||||||
The [PDF content helper functions](@) provide additional functions for writing
|
The [PDF content helper functions](@) provide additional functions for writing
|
||||||
specific PDF page stream commands.
|
specific PDF page stream commands.
|
||||||
|
|
||||||
When you are done writing the stream, call [`pdfioStreamCLose`](@@) to close
|
When you are done writing the stream, call [`pdfioStreamClose`](@@) to close
|
||||||
both the stream and the object.
|
both the stream and the object.
|
||||||
|
|
||||||
|
|
||||||
@ -586,3 +586,133 @@ escaping, as needed:
|
|||||||
- [`pdfioContentTextShowf`](@@) draws a formatted string in a text block
|
- [`pdfioContentTextShowf`](@@) draws a formatted string in a text block
|
||||||
- [`pdfioContentTextShowJustified`](@@) draws an array of literal strings with
|
- [`pdfioContentTextShowJustified`](@@) draws an array of literal strings with
|
||||||
offsets between them
|
offsets between them
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
========
|
||||||
|
|
||||||
|
Read PDF Metadata
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
The following example function will open a PDF file and print the title, author,
|
||||||
|
creation date, and number of pages:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#include <pdfio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
show_pdf_info(const char *filename)
|
||||||
|
{
|
||||||
|
pdfio_file_t *pdf;
|
||||||
|
time_t creation_date;
|
||||||
|
struct tm *creation_tm;
|
||||||
|
char creation_text[256];
|
||||||
|
|
||||||
|
|
||||||
|
// Open the PDF file with the default callbacks...
|
||||||
|
pdf = pdfioFileOpen(filename, /*password_cb*/NULL, /*password_cbdata*/NULL, /*error_cb*/NULL, /*error_cbdata*/NULL);
|
||||||
|
if (pdf == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Get the creation date and convert to a string...
|
||||||
|
creation_date = pdfioFileGetCreationDate(pdf);
|
||||||
|
creation_tm = localtime(&creation_date);
|
||||||
|
strftime(creation_text, sizeof(creation_text), "%c", &creation_tm);
|
||||||
|
|
||||||
|
// Print file information to stdout...
|
||||||
|
printf("%s:\n", filename);
|
||||||
|
printf(" Title: %s\n", pdfioFileGetTitle(pdf));
|
||||||
|
printf(" Author: %s\n", pdfioFileGetAuthor(pdf));
|
||||||
|
printf(" Created On: %s\n", creation_text);
|
||||||
|
printf(" Number Pages: %u\n", (unsigned)pdfioFileGetNumPages(pdf));
|
||||||
|
|
||||||
|
// Close the PDF file...
|
||||||
|
pdfioFileClose(pdf);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Create PDF File With Text and Image
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
The following example function will create a PDF file, embed a base font and the
|
||||||
|
named JPEG or PNG image file, and then creates a page with the image centered on
|
||||||
|
the page with the text centered below:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#include <pdfio.h>
|
||||||
|
#include <pdfio-content.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
create_pdf_image_file(const char *pdfname, const char *imagename, const char *caption)
|
||||||
|
{
|
||||||
|
pdfio_file_t *pdf;
|
||||||
|
pdfio_obj_t *font;
|
||||||
|
pdfio_obj_t *image;
|
||||||
|
pdfio_dict_t *dict;
|
||||||
|
pdfio_stream_t *page;
|
||||||
|
double width, height;
|
||||||
|
double swidth, sheight;
|
||||||
|
double tx, ty;
|
||||||
|
|
||||||
|
|
||||||
|
// Create the PDF file...
|
||||||
|
pdf = pdfioFileCreate(pdfname, /*version*/NULL, /*media_box*/NULL, /*crop_box*/NULL, /*error_cb*/NULL, /*error_cbdata*/NULL);
|
||||||
|
|
||||||
|
// Create a Courier base font for the caption
|
||||||
|
font = pdfioFileCreateFontObjFromBase(pdf, "Courier");
|
||||||
|
|
||||||
|
// Create an image object from the JPEG/PNG image file...
|
||||||
|
image = pdfioFileCreateImageObjFromFile(pdf, imagename, true);
|
||||||
|
|
||||||
|
// Create a page dictionary with the font and image...
|
||||||
|
dict = pdfioDictCreate(pdf);
|
||||||
|
pdfioPageDictAddFont(dict, "F1", font);
|
||||||
|
pdfioPageDictAddImage(dict, "IM1", image);
|
||||||
|
|
||||||
|
// Create the page and its content stream...
|
||||||
|
page = pdfioFileCreatePage(pdf, dict);
|
||||||
|
|
||||||
|
// Position and scale the image on the page...
|
||||||
|
width = pdfioImageGetWidth(image);
|
||||||
|
height = pdfioImageGetHeight(image);
|
||||||
|
|
||||||
|
// Default media_box is "universal" 595.28x792 points (8.27x11in or 210x279mm)
|
||||||
|
// Use margins of 36 points (0.5in or 12.7mm) with another 36 points for the
|
||||||
|
// caption underneath...
|
||||||
|
swidth = 595.28 - 72.0;
|
||||||
|
sheight = swidth * height / width;
|
||||||
|
if (sheight > (792.0 - 36.0 - 72.0))
|
||||||
|
{
|
||||||
|
sheight = 792.0 - 36.0 - 72.0;
|
||||||
|
swidth = sheight * width / height;
|
||||||
|
}
|
||||||
|
|
||||||
|
tx = 0.5 * (595.28 - swidth);
|
||||||
|
ty = 0.5 * (792 - 36 - sheight);
|
||||||
|
|
||||||
|
pdfioContentDrawImage(page, "IM1", tx, ty + 36.0, swidth, sheight);
|
||||||
|
|
||||||
|
// Draw the caption in black...
|
||||||
|
pdfioContentSetFillColorDeviceGray(page, 0.0);
|
||||||
|
|
||||||
|
// Compute the starting point for the text - Courier is monospaced with a
|
||||||
|
// nominal width of 0.6 times the text height...
|
||||||
|
tx = 0.5 * (595.28 - 18.0 * 0.6 * strlen(caption));
|
||||||
|
|
||||||
|
// Position and draw the caption underneath...
|
||||||
|
pdfioContentTextBegin(page);
|
||||||
|
pdfioContentSetTextFont(page, "F1", 18.0);
|
||||||
|
pdfioContentTextMoveTo(page, tx, ty);
|
||||||
|
pdfioContentTextShow(page, /*unicode*/false, caption);
|
||||||
|
pdfioContentTextEnd(page);
|
||||||
|
|
||||||
|
// Close the page stream and the PDF file...
|
||||||
|
pdfioStreamClose(page);
|
||||||
|
pdfioFileClose(pdf);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
@ -2349,7 +2349,7 @@ pdfioPageDictAddColorSpace(
|
|||||||
bool // O - `true` on success, `false` on failure
|
bool // O - `true` on success, `false` on failure
|
||||||
pdfioPageDictAddFont(
|
pdfioPageDictAddFont(
|
||||||
pdfio_dict_t *dict, // I - Page dictionary
|
pdfio_dict_t *dict, // I - Page dictionary
|
||||||
const char *name, // I - Font name
|
const char *name, // I - Font name; must not contain spaces
|
||||||
pdfio_obj_t *obj) // I - Font object
|
pdfio_obj_t *obj) // I - Font object
|
||||||
{
|
{
|
||||||
pdfio_dict_t *resources; // Resource dictionary
|
pdfio_dict_t *resources; // Resource dictionary
|
||||||
|
2
pdfio.h
2
pdfio.h
@ -23,7 +23,7 @@ extern "C" {
|
|||||||
// Version number...
|
// Version number...
|
||||||
//
|
//
|
||||||
|
|
||||||
# define PDFIO_VERSION "1.3.0"
|
# define PDFIO_VERSION "1.3.1"
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
LIBRARY pdfio1
|
LIBRARY pdfio1
|
||||||
VERSION 1.2
|
VERSION 1.3
|
||||||
EXPORTS
|
EXPORTS
|
||||||
_pdfioArrayDebug
|
_pdfioArrayDebug
|
||||||
|
_pdfioArrayDecrypt
|
||||||
_pdfioArrayDelete
|
_pdfioArrayDelete
|
||||||
_pdfioArrayGetValue
|
_pdfioArrayGetValue
|
||||||
_pdfioArrayRead
|
_pdfioArrayRead
|
||||||
@ -24,6 +25,7 @@ _pdfioCryptoSHA256Init
|
|||||||
_pdfioCryptoUnlock
|
_pdfioCryptoUnlock
|
||||||
_pdfioDictClear
|
_pdfioDictClear
|
||||||
_pdfioDictDebug
|
_pdfioDictDebug
|
||||||
|
_pdfioDictDecrypt
|
||||||
_pdfioDictDelete
|
_pdfioDictDelete
|
||||||
_pdfioDictGetValue
|
_pdfioDictGetValue
|
||||||
_pdfioDictRead
|
_pdfioDictRead
|
||||||
@ -61,9 +63,12 @@ _pdfioTokenPush
|
|||||||
_pdfioTokenRead
|
_pdfioTokenRead
|
||||||
_pdfioValueCopy
|
_pdfioValueCopy
|
||||||
_pdfioValueDebug
|
_pdfioValueDebug
|
||||||
|
_pdfioValueDecrypt
|
||||||
_pdfioValueDelete
|
_pdfioValueDelete
|
||||||
_pdfioValueRead
|
_pdfioValueRead
|
||||||
_pdfioValueWrite
|
_pdfioValueWrite
|
||||||
|
_pdfio_strtod
|
||||||
|
_pdfio_vsnprintf
|
||||||
pdfioArrayAppendArray
|
pdfioArrayAppendArray
|
||||||
pdfioArrayAppendBinary
|
pdfioArrayAppendBinary
|
||||||
pdfioArrayAppendBoolean
|
pdfioArrayAppendBoolean
|
||||||
@ -190,6 +195,7 @@ pdfioFileCreateStringObj
|
|||||||
pdfioFileCreateTemporary
|
pdfioFileCreateTemporary
|
||||||
pdfioFileFindObj
|
pdfioFileFindObj
|
||||||
pdfioFileGetAuthor
|
pdfioFileGetAuthor
|
||||||
|
pdfioFileGetCatalog
|
||||||
pdfioFileGetCreationDate
|
pdfioFileGetCreationDate
|
||||||
pdfioFileGetCreator
|
pdfioFileGetCreator
|
||||||
pdfioFileGetID
|
pdfioFileGetID
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<metadata>
|
<metadata>
|
||||||
<id>pdfio_native</id>
|
<id>pdfio_native</id>
|
||||||
<title>PDFio Library for VS2019+</title>
|
<title>PDFio Library for VS2019+</title>
|
||||||
<version>1.3.0</version>
|
<version>1.3.1</version>
|
||||||
<authors>Michael R Sweet</authors>
|
<authors>Michael R Sweet</authors>
|
||||||
<owners>michaelrsweet</owners>
|
<owners>michaelrsweet</owners>
|
||||||
<projectUrl>https://github.com/michaelrsweet/pappl</projectUrl>
|
<projectUrl>https://github.com/michaelrsweet/pappl</projectUrl>
|
||||||
@ -16,7 +16,7 @@
|
|||||||
<copyright>Copyright © 2019-2024 by Michael R Sweet</copyright>
|
<copyright>Copyright © 2019-2024 by Michael R Sweet</copyright>
|
||||||
<tags>pdf file native</tags>
|
<tags>pdf file native</tags>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency id="pdfio_native.redist" version="1.3.0" />
|
<dependency id="pdfio_native.redist" version="1.3.1" />
|
||||||
<dependency id="zlib_native.redist" version="1.2.11" />
|
<dependency id="zlib_native.redist" version="1.2.11" />
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<metadata>
|
<metadata>
|
||||||
<id>pdfio_native.redist</id>
|
<id>pdfio_native.redist</id>
|
||||||
<title>PDFio Library for VS2019+</title>
|
<title>PDFio Library for VS2019+</title>
|
||||||
<version>1.3.0</version>
|
<version>1.3.1</version>
|
||||||
<authors>Michael R Sweet</authors>
|
<authors>Michael R Sweet</authors>
|
||||||
<owners>michaelrsweet</owners>
|
<owners>michaelrsweet</owners>
|
||||||
<projectUrl>https://github.com/michaelrsweet/pappl</projectUrl>
|
<projectUrl>https://github.com/michaelrsweet/pappl</projectUrl>
|
||||||
|
39
ttf.c
39
ttf.c
@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// https://github.com/michaelrsweet/ttf
|
// https://github.com/michaelrsweet/ttf
|
||||||
//
|
//
|
||||||
// Copyright © 2018-2023 by Michael R Sweet.
|
// Copyright © 2018-2024 by Michael R Sweet.
|
||||||
//
|
//
|
||||||
// Licensed under Apache License v2.0. See the file "LICENSE" for more
|
// Licensed under Apache License v2.0. See the file "LICENSE" for more
|
||||||
// information.
|
// information.
|
||||||
@ -99,7 +99,7 @@ typedef __int64 ssize_t; // POSIX type not present on Windows...
|
|||||||
//
|
//
|
||||||
|
|
||||||
#define TTF_FONT_MAX_CHAR 262144 // Maximum number of character values
|
#define TTF_FONT_MAX_CHAR 262144 // Maximum number of character values
|
||||||
|
#define TTF_FONT_MAX_GROUPS 65536 // Maximum number of sub-groups
|
||||||
|
|
||||||
//
|
//
|
||||||
// TTF/OFF tag constants...
|
// TTF/OFF tag constants...
|
||||||
@ -1285,7 +1285,14 @@ read_cmap(ttf_t *font) // I - Font
|
|||||||
// segCount --; // Last segment is not used (sigh)
|
// segCount --; // Last segment is not used (sigh)
|
||||||
|
|
||||||
font->num_cmap = segments[segCount - 1].endCode + 1;
|
font->num_cmap = segments[segCount - 1].endCode + 1;
|
||||||
font->cmap = cmapptr = (int *)malloc(font->num_cmap * sizeof(int));
|
|
||||||
|
if (font->num_cmap > TTF_FONT_MAX_CHAR)
|
||||||
|
{
|
||||||
|
errorf(font, "Invalid cmap table with %u characters.", (unsigned)font->num_cmap);
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
font->cmap = cmapptr = (int *)malloc(font->num_cmap * sizeof(int));
|
||||||
|
|
||||||
if (!font->cmap)
|
if (!font->cmap)
|
||||||
{
|
{
|
||||||
@ -1356,6 +1363,12 @@ read_cmap(ttf_t *font) // I - Font
|
|||||||
|
|
||||||
TTF_DEBUG("read_cmap: nGroups=%u\n", nGroups);
|
TTF_DEBUG("read_cmap: nGroups=%u\n", nGroups);
|
||||||
|
|
||||||
|
if (nGroups > TTF_FONT_MAX_GROUPS)
|
||||||
|
{
|
||||||
|
errorf(font, "Invalid cmap table with %u groups.", nGroups);
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
if ((groups = (_ttf_off_cmap12_t *)calloc(nGroups, sizeof(_ttf_off_cmap12_t))) == NULL)
|
if ((groups = (_ttf_off_cmap12_t *)calloc(nGroups, sizeof(_ttf_off_cmap12_t))) == NULL)
|
||||||
{
|
{
|
||||||
errorf(font, "Unable to allocate memory for cmap.");
|
errorf(font, "Unable to allocate memory for cmap.");
|
||||||
@ -1376,6 +1389,13 @@ read_cmap(ttf_t *font) // I - Font
|
|||||||
// Based on the end code of the segent table, allocate space for the
|
// Based on the end code of the segent table, allocate space for the
|
||||||
// uncompressed cmap table...
|
// uncompressed cmap table...
|
||||||
TTF_DEBUG("read_cmap: num_cmap=%u\n", (unsigned)font->num_cmap);
|
TTF_DEBUG("read_cmap: num_cmap=%u\n", (unsigned)font->num_cmap);
|
||||||
|
|
||||||
|
if (font->num_cmap > TTF_FONT_MAX_CHAR)
|
||||||
|
{
|
||||||
|
errorf(font, "Invalid cmap table with %u characters.", (unsigned)font->num_cmap);
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
font->cmap = cmapptr = (int *)malloc(font->num_cmap * sizeof(int));
|
font->cmap = cmapptr = (int *)malloc(font->num_cmap * sizeof(int));
|
||||||
|
|
||||||
if (!font->cmap)
|
if (!font->cmap)
|
||||||
@ -1426,6 +1446,12 @@ read_cmap(ttf_t *font) // I - Font
|
|||||||
|
|
||||||
TTF_DEBUG("read_cmap: nGroups=%u\n", nGroups);
|
TTF_DEBUG("read_cmap: nGroups=%u\n", nGroups);
|
||||||
|
|
||||||
|
if (nGroups > TTF_FONT_MAX_GROUPS)
|
||||||
|
{
|
||||||
|
errorf(font, "Invalid cmap table with %u groups.", nGroups);
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
if ((groups = (_ttf_off_cmap13_t *)calloc(nGroups, sizeof(_ttf_off_cmap13_t))) == NULL)
|
if ((groups = (_ttf_off_cmap13_t *)calloc(nGroups, sizeof(_ttf_off_cmap13_t))) == NULL)
|
||||||
{
|
{
|
||||||
errorf(font, "Unable to allocate memory for cmap.");
|
errorf(font, "Unable to allocate memory for cmap.");
|
||||||
@ -1446,6 +1472,13 @@ read_cmap(ttf_t *font) // I - Font
|
|||||||
// Based on the end code of the segent table, allocate space for the
|
// Based on the end code of the segent table, allocate space for the
|
||||||
// uncompressed cmap table...
|
// uncompressed cmap table...
|
||||||
TTF_DEBUG("read_cmap: num_cmap=%u\n", (unsigned)font->num_cmap);
|
TTF_DEBUG("read_cmap: num_cmap=%u\n", (unsigned)font->num_cmap);
|
||||||
|
|
||||||
|
if (font->num_cmap > TTF_FONT_MAX_CHAR)
|
||||||
|
{
|
||||||
|
errorf(font, "Invalid cmap table with %u characters.", (unsigned)font->num_cmap);
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
font->cmap = cmapptr = (int *)malloc(font->num_cmap * sizeof(int));
|
font->cmap = cmapptr = (int *)malloc(font->num_cmap * sizeof(int));
|
||||||
|
|
||||||
if (!font->cmap)
|
if (!font->cmap)
|
||||||
|
Loading…
Reference in New Issue
Block a user