summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2007-09-08 16:39:55 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2007-09-08 16:39:55 +0000
commitfdc39c7e9488fb0441bfade6d614661d6d8fb8ad (patch)
treeb93b72ce25b3acd111507da4ac00cad11a8e3e65
parentd5cbccbea2f75d2267c1b19ff04f73213b56eb5f (diff)
Merge freetype 2.3.5. Tested by naddy@ and mbalmer@.
-rw-r--r--lib/freetype/Makefile17
-rw-r--r--lib/freetype/docs/INSTALL.UNX79
-rw-r--r--lib/freetype/docs/UPGRADE.UNX137
-rw-r--r--lib/freetype/docs/reference/ft2-ttengine.html122
-rw-r--r--lib/freetype/include/freetype/config/ftoption.h96
-rw-r--r--lib/freetype/shlib_version2
-rw-r--r--lib/freetype/src/bdf/bdflib.c65
-rw-r--r--lib/freetype/src/sfnt/ttsbit0.h7
-rw-r--r--lib/freetype/src/truetype/ttgload.c363
9 files changed, 349 insertions, 539 deletions
diff --git a/lib/freetype/Makefile b/lib/freetype/Makefile
index 9fb9272cf..422802bc3 100644
--- a/lib/freetype/Makefile
+++ b/lib/freetype/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.8 2007/05/29 15:37:57 matthieu Exp $
+# $OpenBSD: Makefile,v 1.9 2007/09/08 16:39:54 matthieu Exp $
FREETYPESRC= ${.CURDIR}/src
@@ -12,11 +12,14 @@ DEBUG?=
LIB= freetype
-SRCS= ftapi.c ftbase.c ftbbox.c ftbdf.c ftbitmap.c ftdebug.c ftglyph.c \
+SRCS= ftbase.c ftbbox.c ftbdf.c ftbitmap.c ftdebug.c ftcache.c ftgasp.c \
+ ftglyph.c \
+ ftgxval.c ftlcdfil.c ftotval.c ftpatent.c \
ftinit.c ftlzw.c ftmm.c ftpfr.c ftstroke.c ftsynth.c ftsystem.c \
fttype1.c ftwinfnt.c ftxf86.c autofit.c bdf.c cff.c \
type1cid.c ftgzip.c pcf.c pfr.c psaux.c pshinter.c psnames.c \
- raster.c sfnt.c smooth.c truetype.c type1.c type42.c winfnt.c
+ raster.c sfnt.c smooth.c truetype.c type1.c type1cid.c type42.c \
+ winfnt.c
CPPFLAGS+= -I${.CURDIR}/include -I${.CURDIR}/src/lzw -DFT2_BUILD_LIBRARY
@@ -50,13 +53,14 @@ freetype2.pc: freetype2.in Makefile
sed -e s%@prefix@%${X11BASE}% -e s%@exec_prefix@%${X11BASE}% \
-e s%@ft_version@%${FT_VERSION_INFO}% \
-e s%@includedir@%${INCSDIR}% -e s%@libdir@%${LIBDIR}% \
- -e s%@LIBZ@%-lz% < ${.CURDIR}/builds/unix/freetype2.in \
- > freetype2.pc
+ -e s%@LIBZ@%-lz% -e s%@FT2_EXTRA_LIBS@%% \
+ < ${.CURDIR}/builds/unix/freetype2.in > freetype2.pc
freetype-config: freetype-config.in
sed -e s%@prefix@%${X11BASE}% -e s%@exec_prefix@%${X11BASE}% \
-e s%@includedir@%${INCSDIR}% -e s%@libdir@%${LIBDIR}% \
- -e s%@LIBZ@%-lz% -e s%@enable_shared@%yes% \
+ -e s%@LIBZ@%-lz% -e s%@FT2_EXTRA_LIBS@%% \
+ -e s%@enable_shared@%yes% \
-e 's%@hardcode_libdir_flag_spec@%%' \
-e 's%@ft_version@%9.7.3%' -e 's%@wl@%%' \
< ${.CURDIR}/builds/unix/freetype-config.in \
@@ -70,6 +74,7 @@ NOPROFILE=
.PATH: ${FREETYPESRC}/autofit
.PATH: ${FREETYPESRC}/base
.PATH: ${FREETYPESRC}/bdf
+.PATH: ${FREETYPESRC}/cache
.PATH: ${FREETYPESRC}/cff
.PATH: ${FREETYPESRC}/cid
.PATH: ${FREETYPESRC}/gzip
diff --git a/lib/freetype/docs/INSTALL.UNX b/lib/freetype/docs/INSTALL.UNX
deleted file mode 100644
index 13cb896ba..000000000
--- a/lib/freetype/docs/INSTALL.UNX
+++ /dev/null
@@ -1,79 +0,0 @@
-This document contains instructions on how to build the FreeType
-library on Unix systems. This also works for emulations like Cygwin
-or MSys on Win32:
-
-
- 1. Ensure that you are using GNU Make
- -------------------------------------
-
- The FreeType build system _exclusively_ works with GNU Make. You
- will not be able to compile the library with the instructions
- below using any other alternative (including BSD Make).
-
- [Well, this is not really correct. A few years ago a perl
- implementation of make called `makepp' has appeared which can also
- build FreeType 2 successfully on Unix platforms. See
-
- http://makepp.sourceforge.net
-
- for more details; you need version 1.19 or newer, and you must
- pass option `--norc-substitution'.]
-
- Trying to compile the library with a different Make tool will
- print a message like:
-
- Sorry, GNU make is required to build FreeType2.
-
- and the build process will be aborted. If this happens, install
- GNU Make on your system, and use the GNUMAKE environment variable
- to name it, if necessary.
-
-
- 2. Build and install the library
- --------------------------------
-
- The following should work on all Unix systems where the `make'
- command invokes GNU Make:
-
- ./configure [options]
- make
- make install (as root)
-
- The default installation path is `/usr/local'. It can be changed
- with the `--prefix=<path>' option. Example:
-
- ./configure --prefix=/usr
-
- When using a different command to invoke GNU Make, use the GNUMAKE
- variable. For example, if `gmake' is the command to use on your
- system, do something like:
-
- GNUMAKE=gmake ./configure [options]
- gmake
- gmake install (as root)
-
- If this still doesn't work, there must be a problem with your
- system (e.g., you are using a very old version of GNU Make).
-
- It is possible to compile FreeType in a different directory.
- Assuming the FreeType source files in directory `/src/freetype' a
- compilation in directory `foo' works as follows:
-
- cd foo
- /src/freetype/configure [options]
- make
- make install
-
-----------------------------------------------------------------------
-
-Copyright 2003, 2004, 2005, 2006 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute
-this file you indicate that you have read the license and understand
-and accept it fully.
-
-
---- end of INSTALL.UNX ---
diff --git a/lib/freetype/docs/UPGRADE.UNX b/lib/freetype/docs/UPGRADE.UNX
deleted file mode 100644
index de1b35b32..000000000
--- a/lib/freetype/docs/UPGRADE.UNX
+++ /dev/null
@@ -1,137 +0,0 @@
-
-SPECIAL NOTE FOR UNIX USERS
-===========================
-
- If you are installing this release of FreeType on a system that
- already uses release 2.0.5 (or even an older version), you have to
- perform a few special steps to ensure that everything goes well.
-
-
- 1. Enable the TrueType bytecode hinter if you need it
- -----------------------------------------------------
-
- See the instructions in the file `TRUETYPE' of this directory.
-
- Note that FreeType supports TrueType fonts without the bytecode
- interpreter through its auto-hinter, which now generates relatively
- good results with most fonts.
-
-
- 2. Determine the correct installation path
- ------------------------------------------
-
- By default, the configure script installs the library in
- `/usr/local'. However, many Unix distributions now install the
- library in `/usr', since FreeType is becoming a critical system
- component.
-
- If FreeType is already installed on your system, type
-
- freetype-config --prefix
-
- on the command line. This should return the installation path
- (e.g., `/usr' or `/usr/local'). To avoid problems of parallel
- FreeType versions, use this path for the --prefix option of the
- configure script.
-
- Otherwise, simply use `/usr' (or whatever you think is adequate for
- your installation).
-
-
- 3. Ensure that you are using GNU Make
- -------------------------------------
-
- The FreeType build system _exclusively_ works with GNU Make (as an
- exception you can use make++ which emulates GNU Make sufficiently;
- see http://makepp.sourceforge.net). You will not be able to compile
- the library with the instructions below using any other alternative
- (including BSD Make).
-
- Trying to compile the library with a different Make tool prints a
- message like:
-
- Sorry, GNU make is required to build FreeType2.
-
- and the build process is aborted. If this happens, install GNU Make
- on your system, and use the GNUMAKE environment variable to name it.
-
-
- 4. Build and install the library
- --------------------------------
-
- The following should work on all Unix systems where the `make'
- command invokes GNU Make:
-
- ./configure --prefix=<yourprefix>
- make
- make install (as root)
-
- where `<yourprefix>' must be replaced by the prefix returned by the
- `freetype-config' command.
-
- When using a different command to invoke GNU Make, use the GNUMAKE
- variable. For example, if `gmake' is the command to use on your
- system, do something like:
-
- GNUMAKE=gmake ./configure --prefix=<yourprefix>
- gmake
- gmake install (as root)
-
-
- 5. Take care of XFree86 version 4
- ---------------------------------
-
- Certain Linux distributions install _several_ versions of FreeType
- on your system. For example, on a fresh Mandrake 8.1 system, you
- can find the following files:
-
- /usr/lib/libfreetype.so which links to
- /usr/lib/libfreetype.6.1.0.so
-
- and
-
- /usr/X11R6/lib/libfreetype.so which links to
- /usr/X11R6/lib/libfreetype.6.0.so
-
- Note that these files correspond to two distinct versions of the
- library! It seems that this surprising issue is due to the install
- scripts of recent XFree86 servers (from 4.1.0) which install their
- own (dated) version of the library in `/usr/X11R6/lib'.
-
- In certain _rare_ cases you may experience minor problems if you
- install this release of the library in `/usr' only, namely, that
- certain applications do not benefit from the bug fixes and rendering
- improvements you would expect.
-
- There are two good ways to deal with this situation:
-
- - Install the library _twice_, in `/usr' and in `/usr/X11R6' (you
- have to do that each time you install a new FreeType release
- though).
-
- - Change the link in /usr/X11R6/lib/libfreetype.so to point to
-
- /usr/lib/libfreetype.so,
-
- and get rid of
-
- /usr/X11R6/lib/libfreetype.6.0.so
-
- The FreeType Team is not responsible for this problem, so please
- contact either the XFree86 development team or your Linux
- distributor to help clear this issue in case the information given
- here doesn't help.
-
-------------------------------------------------------------------------
-
-Copyright 2003, 2005 by
-David Turner, Robert Wilhelm, and Werner Lemberg.
-
-This file is part of the FreeType project, and may only be used,
-modified, and distributed under the terms of the FreeType project
-license, LICENSE.TXT. By continuing to use, modify, or distribute this
-file you indicate that you have read the license and understand and
-accept it fully.
-
-
----- end of UPGRADE.UNX ---
diff --git a/lib/freetype/docs/reference/ft2-ttengine.html b/lib/freetype/docs/reference/ft2-ttengine.html
deleted file mode 100644
index e15e563b9..000000000
--- a/lib/freetype/docs/reference/ft2-ttengine.html
+++ /dev/null
@@ -1,122 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-"http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-<title>FreeType-2.2.1 API Reference</title>
-<style type="text/css">
- body { font-family: Verdana, Geneva, Arial, Helvetica, serif;
- color: #000000;
- background: #FFFFFF; }
-
- p { text-align: justify; }
- h1 { text-align: center; }
- li { text-align: justify; }
- td { padding: 0 0.5em 0 0.5em }
-
- a:link { color: #0000EF; }
- a:visited { color: #51188E; }
- a:hover { color: #FF0000; }
-
- span.keyword { font-family: monospace;
- text-align: left;
- white-space: pre;
- color: darkblue; }
-
- pre.colored { color: blue; }
-
- ul.empty { list-style-type: none; }
-</style>
-</head>
-<body>
-<center><h1>FreeType-2.2.1 API Reference</h1></center>
-
-<center><h1>
-The TrueType Engine
-</h1></center>
-<h2>Synopsis</h2>
-<table align=center cellspacing=5 cellpadding=0 border=0>
-<tr><td></td><td><a href="#FT_TrueTypeEngineType">FT_TrueTypeEngineType</a></td><td></td><td><a href="#FT_Get_TrueType_Engine_Type">FT_Get_TrueType_Engine_Type</a></td></tr>
-</table><br><br>
-
-<table align=center width="87%"><tr><td>
-<p>This section contains a function used to query the level of TrueType bytecode support compiled in this version of the library.</p>
-</td></tr></table><br>
-<table align=center width="75%"><tr><td>
-<h4><a name="FT_TrueTypeEngineType">FT_TrueTypeEngineType</a></h4>
-<table align=center width="87%"><tr bgcolor="#D6E8FF"><td><pre>
-
- <span class="keyword">typedef</span> <span class="keyword">enum</span>
- {
- <a href="ft2-ttengine.html#FT_TrueTypeEngineType">FT_TRUETYPE_ENGINE_TYPE_NONE</a> = 0,
- <a href="ft2-ttengine.html#FT_TrueTypeEngineType">FT_TRUETYPE_ENGINE_TYPE_UNPATENTED</a>,
- <a href="ft2-ttengine.html#FT_TrueTypeEngineType">FT_TRUETYPE_ENGINE_TYPE_PATENTED</a>
-
- } <b>FT_TrueTypeEngineType</b>;
-
-</pre></table><br>
-<table align=center width="87%"><tr><td>
-<p>A list of values describing which kind of TrueType bytecode engine is implemented in a given FT_Library instance. It is used by the <a href="ft2-ttengine.html#FT_Get_TrueType_Engine_Type">FT_Get_TrueType_Engine_Type</a> function.</p>
-</td></tr></table><br>
-<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>values</b></em></td></tr><tr><td>
-<table cellpadding=3 border=0>
-<tr valign=top><td colspan=0><b>FT_TRUETYPE_ENGINE_TYPE_NONE</b></td></tr>
-<tr valign=top><td></td><td>
-<p>The library doesn't implement any kind of bytecode interpreter.</p>
-</td></tr>
-<tr valign=top><td colspan=0><b>FT_TRUETYPE_ENGINE_TYPE_UNPATENTED</b></td></tr>
-<tr valign=top><td></td><td>
-<p>The library implements a bytecode interpreter that doesn't support the patented operations of the TrueType virtual machine.</p>
-<p>Its main use is to load certain Asian fonts which position and scale glyph components with bytecode instructions. It produces bad output for most other fonts.</p>
-</td></tr>
-<tr valign=top><td colspan=0><b>FT_TRUETYPE_ENGINE_TYPE_PATENTED</b></td></tr>
-<tr valign=top><td></td><td>
-<p>The library implements a bytecode interpreter that covers the full instruction set of the TrueType virtual machine. See the file &lsquo;docs/PATENTS&rsquo; for legal aspects.</p>
-</td></tr>
-</table>
-</td></tr></table>
-<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>since</b></em></td></tr><tr><td>
-<p>2.2</p>
-</td></tr></table>
-</td></tr></table>
-<hr width="75%">
-<table align=center width="75%"><tr><td><font size=-2>[<a href="
-ft2-index.html">Index</a>]</font></td>
-<td width="100%"></td>
-<td><font size=-2>[<a href="
-ft2-toc.html">TOC</a>]</font></td></tr></table>
-
-<table align=center width="75%"><tr><td>
-<h4><a name="FT_Get_TrueType_Engine_Type">FT_Get_TrueType_Engine_Type</a></h4>
-<table align=center width="87%"><tr bgcolor="#D6E8FF"><td><pre>
-
- FT_EXPORT( <a href="ft2-ttengine.html#FT_TrueTypeEngineType">FT_TrueTypeEngineType</a> )
- <b>FT_Get_TrueType_Engine_Type</b>( <a href="ft2-base_interface.html#FT_Library">FT_Library</a> library );
-
-</pre></table><br>
-<table align=center width="87%"><tr><td>
-<p>Return a <a href="ft2-ttengine.html#FT_TrueTypeEngineType">FT_TrueTypeEngineType</a> value to indicate which level of the TrueType virtual machine a given library instance supports.</p>
-</td></tr></table><br>
-<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>input</b></em></td></tr><tr><td>
-<table cellpadding=3 border=0>
-<tr valign=top><td><b>library</b></td><td>
-<p>A library instance.</p>
-</td></tr>
-</table>
-</td></tr></table>
-<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>return</b></em></td></tr><tr><td>
-<p>A value indicating which level is supported.</p>
-</td></tr></table>
-<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>since</b></em></td></tr><tr><td>
-<p>2.2</p>
-</td></tr></table>
-</td></tr></table>
-<hr width="75%">
-<table align=center width="75%"><tr><td><font size=-2>[<a href="
-ft2-index.html">Index</a>]</font></td>
-<td width="100%"></td>
-<td><font size=-2>[<a href="
-ft2-toc.html">TOC</a>]</font></td></tr></table>
-
-</body>
-</html>
diff --git a/lib/freetype/include/freetype/config/ftoption.h b/lib/freetype/include/freetype/config/ftoption.h
index 5d72e8293..8ad5c7ea7 100644
--- a/lib/freetype/include/freetype/config/ftoption.h
+++ b/lib/freetype/include/freetype/config/ftoption.h
@@ -4,7 +4,7 @@
/* */
/* User-selectable configuration macros (specification only). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -77,6 +77,26 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
+ /* Uncomment the line below if you want to activate sub-pixel rendering */
+ /* (a.k.a. LCD rendering, or ClearType) in this build of the library. */
+ /* */
+ /* Note that this feature is covered by several Microsoft patents */
+ /* and should not be activated in any default build of the library. */
+ /* */
+ /* This macro has no impact on the FreeType API, only on its */
+ /* _implementation_. For example, using FT_RENDER_MODE_LCD when calling */
+ /* FT_Render_Glyph still generates a bitmap that is 3 times larger than */
+ /* the original size; the difference will be that each triplet of */
+ /* subpixels has R=G=B. */
+ /* */
+ /* This is done to allow FreeType clients to run unmodified, forcing */
+ /* them to display normal gray-level anti-aliased glyphs. */
+ /* */
+/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
+
+
+ /*************************************************************************/
+ /* */
/* Many compilers provide a non-ANSI 64-bit data type that can be used */
/* by FreeType to speed up some computations. However, this will create */
/* some problems when compiling the library in strict ANSI mode. */
@@ -282,7 +302,9 @@ FT_BEGIN_HEADER
/* The size in bytes of the render pool used by the scan-line converter */
/* to do all of its work. */
/* */
- /* This must be greater than 4KByte. */
+ /* This must be greater than 4KByte if you use FreeType to rasterize */
+ /* glyphs; otherwise, you may set it to zero to avoid unnecessary */
+ /* allocation of the render pool. */
/* */
#define FT_RENDER_POOL_SIZE 16384L
@@ -441,12 +463,47 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
- /* Define TT_CONFIG_OPTION_UNPATENTED_HINTING (in addition to */
- /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER) to compile the unpatented */
- /* work-around hinting system. Note that for the moment, the algorithm */
- /* is only used when selected at runtime through the parameter tag */
- /* FT_PARAM_TAG_UNPATENTED_HINTING; or when the debug hook */
- /* FT_DEBUG_HOOK_UNPATENTED_HINTING is globally activated. */
+ /* If you define TT_CONFIG_OPTION_UNPATENTED_HINTING, a special version */
+ /* of the TrueType bytecode interpreter is used that doesn't implement */
+ /* any of the patented opcodes and algorithms. Note that the */
+ /* the TT_CONFIG_OPTION_UNPATENTED_HINTING macro is *ignored* if you */
+ /* define TT_CONFIG_OPTION_BYTECODE_INTERPRETER; with other words, */
+ /* either define TT_CONFIG_OPTION_BYTECODE_INTERPRETER or */
+ /* TT_CONFIG_OPTION_UNPATENTED_HINTING but not both at the same time. */
+ /* */
+ /* This macro is only useful for a small number of font files (mostly */
+ /* for Asian scripts) that require bytecode interpretation to properly */
+ /* load glyphs. For all other fonts, this produces unpleasant results, */
+ /* thus the unpatented interpreter is never used to load glyphs from */
+ /* TrueType fonts unless one of the following two options is used. */
+ /* */
+ /* - The unpatented interpreter is explicitly activated by the user */
+ /* through the FT_PARAM_TAG_UNPATENTED_HINTING parameter tag */
+ /* when opening the FT_Face. */
+ /* */
+ /* - FreeType detects that the FT_Face corresponds to one of the */
+ /* `trick' fonts (e.g., `Mingliu') it knows about. The font engine */
+ /* contains a hard-coded list of font names and other matching */
+ /* parameters (see function `tt_face_init' in file */
+ /* `src/truetype/ttobjs.c'). */
+ /* */
+ /* Here a sample code snippet for using FT_PARAM_TAG_UNPATENTED_HINTING. */
+ /* */
+ /* { */
+ /* FT_Parameter parameter; */
+ /* FT_Open_Args open_args; */
+ /* */
+ /* */
+ /* parameter.tag = FT_PARAM_TAG_UNPATENTED_HINTING; */
+ /* */
+ /* open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS; */
+ /* open_args.pathname = my_font_pathname; */
+ /* open_args.num_params = 1; */
+ /* open_args.params = &parameter; */
+ /* */
+ /* error = FT_Open_Face( library, &open_args, index, &face ); */
+ /* ... */
+ /* } */
/* */
#define TT_CONFIG_OPTION_UNPATENTED_HINTING
@@ -571,14 +628,13 @@ FT_BEGIN_HEADER
/* */
#define AF_CONFIG_OPTION_CJK
+ /*************************************************************************/
+ /* */
+ /* Compile autofit module with Indic script support. */
+ /* */
+#define AF_CONFIG_OPTION_INDIC
- /* */
-
- /*
- * This temporary macro is used to control various optimizations for
- * reducing the heap footprint of memory-mapped TrueType files.
- */
-#define FT_OPTIMIZE_MEMORY
+ /* */
/*
@@ -594,6 +650,16 @@ FT_BEGIN_HEADER
#define FT_CONFIG_OPTION_OLD_INTERNALS
+ /*
+ * This variable is defined if either unpatented or native TrueType
+ * hinting is requested by the definitions above.
+ */
+#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+#define TT_USE_BYTECODE_INTERPRETER
+#elif defined TT_CONFIG_OPTION_UNPATENTED_HINTING
+#define TT_USE_BYTECODE_INTERPRETER
+#endif
+
FT_END_HEADER
diff --git a/lib/freetype/shlib_version b/lib/freetype/shlib_version
index d85251eba..779132204 100644
--- a/lib/freetype/shlib_version
+++ b/lib/freetype/shlib_version
@@ -1,2 +1,2 @@
-major=14
+major=15
minor=0
diff --git a/lib/freetype/src/bdf/bdflib.c b/lib/freetype/src/bdf/bdflib.c
index 743c9c677..512cd62c3 100644
--- a/lib/freetype/src/bdf/bdflib.c
+++ b/lib/freetype/src/bdf/bdflib.c
@@ -1,6 +1,7 @@
/*
* Copyright 2000 Computing Research Labs, New Mexico State University
- * Copyright 2001, 2002, 2003, 2004, 2005, 2006 Francesco Zappa Nardelli
+ * Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ * Francesco Zappa Nardelli
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -1262,7 +1263,6 @@
{
unsigned long propid;
hashnode hn;
- int len;
bdf_property_t *prop, *fp;
FT_Memory memory = font->memory;
FT_Error error = BDF_Err_Ok;
@@ -1281,19 +1281,11 @@
/* Delete the current atom if it exists. */
FT_FREE( fp->value.atom );
- if ( value == 0 )
- len = 1;
- else
- len = ft_strlen( value ) + 1;
-
- if ( len > 1 )
+ if ( value && value[0] != 0 )
{
- if ( FT_NEW_ARRAY( fp->value.atom, len ) )
+ if ( FT_STRDUP( fp->value.atom, value ) )
goto Exit;
- FT_MEM_COPY( fp->value.atom, value, len );
}
- else
- fp->value.atom = 0;
break;
case BDF_INTEGER:
@@ -1358,19 +1350,12 @@
switch ( prop->format )
{
case BDF_ATOM:
- if ( value == 0 )
- len = 1;
- else
- len = ft_strlen( value ) + 1;
-
- if ( len > 1 )
+ fp->value.atom = 0;
+ if ( value != 0 && value[0] )
{
- if ( FT_NEW_ARRAY( fp->value.atom, len ) )
+ if ( FT_STRDUP( fp->value.atom, value ) )
goto Exit;
- FT_MEM_COPY( fp->value.atom, value, len );
}
- else
- fp->value.atom = 0;
break;
case BDF_INTEGER:
@@ -1552,6 +1537,12 @@
s = _bdf_list_join( &p->list, ' ', &slen );
+ if ( !s )
+ {
+ error = BDF_Err_Invalid_File_Format;
+ goto Exit;
+ }
+
if ( FT_NEW_ARRAY( p->glyph_name, slen + 1 ) )
goto Exit;
@@ -2132,6 +2123,13 @@
_bdf_list_shift( &p->list, 1 );
s = _bdf_list_join( &p->list, ' ', &slen );
+
+ if ( !s )
+ {
+ error = BDF_Err_Invalid_File_Format;
+ goto Exit;
+ }
+
if ( FT_NEW_ARRAY( p->font->name, slen + 1 ) )
goto Exit;
FT_MEM_COPY( p->font->name, s, slen + 1 );
@@ -2221,7 +2219,7 @@
bdf_options_t* opts,
bdf_font_t* *font )
{
- unsigned long lineno;
+ unsigned long lineno = 0; /* make compiler happy */
_bdf_parse_t *p;
FT_Memory memory = extmemory;
@@ -2241,7 +2239,7 @@
error = _bdf_readstream( stream, _bdf_parse_start,
(void *)p, &lineno );
if ( error )
- goto Exit;
+ goto Fail;
if ( p->font != 0 )
{
@@ -2316,11 +2314,19 @@
{
/* The ENDFONT field was never reached or did not exist. */
if ( !( p->flags & _BDF_GLYPHS ) )
+ {
/* Error happened while parsing header. */
FT_ERROR(( "bdf_load_font: " ERRMSG2, lineno ));
+ error = BDF_Err_Corrupted_Font_Header;
+ goto Exit;
+ }
else
+ {
/* Error happened when parsing glyphs. */
FT_ERROR(( "bdf_load_font: " ERRMSG3, lineno ));
+ error = BDF_Err_Corrupted_Font_Glyphs;
+ goto Exit;
+ }
}
}
@@ -2333,7 +2339,7 @@
if ( FT_RENEW_ARRAY( p->font->comments,
p->font->comments_len,
p->font->comments_len + 1 ) )
- goto Exit;
+ goto Fail;
p->font->comments[p->font->comments_len] = 0;
}
@@ -2354,6 +2360,15 @@
}
return error;
+
+ Fail:
+ bdf_free_font( p->font );
+
+ memory = extmemory;
+
+ FT_FREE( p->font );
+
+ goto Exit;
}
diff --git a/lib/freetype/src/sfnt/ttsbit0.h b/lib/freetype/src/sfnt/ttsbit0.h
deleted file mode 100644
index 396ddc555..000000000
--- a/lib/freetype/src/sfnt/ttsbit0.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * ttsbit0.h
- *
- * This is a dummy file, used to please the build system. It is never
- * included by the sfnt sources.
- *
- */
diff --git a/lib/freetype/src/truetype/ttgload.c b/lib/freetype/src/truetype/ttgload.c
index deb6b978b..d41b2ee82 100644
--- a/lib/freetype/src/truetype/ttgload.c
+++ b/lib/freetype/src/truetype/ttgload.c
@@ -4,7 +4,7 @@
/* */
/* TrueType Glyph Loader (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -108,7 +108,7 @@
if ( face->vertical_info )
( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah );
-#if 1 /* Emperically determined, at variance with what MS said */
+#if 1 /* Empirically determined, at variance with what MS said */
else
{
@@ -188,6 +188,9 @@
if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( byte_count ) )
return error;
+ loader->cursor = stream->cursor;
+ loader->limit = stream->limit;
+
return TT_Err_Ok;
}
@@ -205,26 +208,26 @@
FT_CALLBACK_DEF( FT_Error )
TT_Load_Glyph_Header( TT_Loader loader )
{
- FT_Stream stream = loader->stream;
- FT_Int byte_len = loader->byte_len - 10;
+ FT_Byte* p = loader->cursor;
+ FT_Byte* limit = loader->limit;
- if ( byte_len < 0 )
+ if ( p + 10 > limit )
return TT_Err_Invalid_Outline;
- loader->n_contours = FT_GET_SHORT();
+ loader->n_contours = FT_NEXT_SHORT( p );
- loader->bbox.xMin = FT_GET_SHORT();
- loader->bbox.yMin = FT_GET_SHORT();
- loader->bbox.xMax = FT_GET_SHORT();
- loader->bbox.yMax = FT_GET_SHORT();
+ loader->bbox.xMin = FT_NEXT_SHORT( p );
+ loader->bbox.yMin = FT_NEXT_SHORT( p );
+ loader->bbox.xMax = FT_NEXT_SHORT( p );
+ loader->bbox.yMax = FT_NEXT_SHORT( p );
FT_TRACE5(( " # of contours: %d\n", loader->n_contours ));
FT_TRACE5(( " xMin: %4d xMax: %4d\n", loader->bbox.xMin,
loader->bbox.xMax ));
FT_TRACE5(( " yMin: %4d yMax: %4d\n", loader->bbox.yMin,
loader->bbox.yMax ));
- loader->byte_len = byte_len;
+ loader->cursor = p;
return TT_Err_Ok;
}
@@ -234,20 +237,21 @@
TT_Load_Simple_Glyph( TT_Loader load )
{
FT_Error error;
- FT_Stream stream = load->stream;
+ FT_Byte* p = load->cursor;
+ FT_Byte* limit = load->limit;
FT_GlyphLoader gloader = load->gloader;
FT_Int n_contours = load->n_contours;
FT_Outline* outline;
TT_Face face = (TT_Face)load->face;
FT_UShort n_ins;
- FT_Int n, n_points;
- FT_Int byte_len = load->byte_len;
+ FT_Int n_points;
FT_Byte *flag, *flag_limit;
FT_Byte c, count;
FT_Vector *vec, *vec_limit;
FT_Pos x;
- FT_Short *cont, *cont_limit;
+ FT_Short *cont, *cont_limit, prev_cont;
+ FT_Int xy_size = 0;
/* check that we can add the contours to the glyph */
@@ -260,12 +264,21 @@
cont_limit = cont + n_contours;
/* check space for contours array + instructions count */
- byte_len -= 2 * ( n_contours + 1 );
- if ( byte_len < 0 )
+ if ( n_contours >= 0xFFF || p + ( n_contours + 1 ) * 2 > limit )
goto Invalid_Outline;
- for ( ; cont < cont_limit; cont++ )
- cont[0] = FT_GET_USHORT();
+ cont[0] = prev_cont = FT_NEXT_USHORT( p );
+ for ( cont++; cont < cont_limit; cont++ )
+ {
+ cont[0] = FT_NEXT_USHORT( p );
+ if ( cont[0] <= prev_cont )
+ {
+ /* unordered contours: this is invalid */
+ error = FT_Err_Invalid_Table;
+ goto Fail;
+ }
+ prev_cont = cont[0];
+ }
n_points = 0;
if ( n_contours > 0 )
@@ -291,38 +304,41 @@
load->glyph->control_len = 0;
load->glyph->control_data = 0;
- n_ins = FT_GET_USHORT();
+ if ( p + 2 > limit )
+ goto Invalid_Outline;
+
+ n_ins = FT_NEXT_USHORT( p );
FT_TRACE5(( " Instructions size: %u\n", n_ins ));
if ( n_ins > face->max_profile.maxSizeOfInstructions )
{
- FT_TRACE0(( "TT_Load_Simple_Glyph: Too many instructions!\n" ));
+ FT_TRACE0(( "TT_Load_Simple_Glyph: Too many instructions (%d)\n",
+ n_ins ));
error = TT_Err_Too_Many_Hints;
goto Fail;
}
- byte_len -= (FT_Int)n_ins;
- if ( byte_len < 0 )
+ if ( ( limit - p ) < n_ins )
{
FT_TRACE0(( "TT_Load_Simple_Glyph: Instruction count mismatch!\n" ));
error = TT_Err_Too_Many_Hints;
goto Fail;
}
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+#ifdef TT_USE_BYTECODE_INTERPRETER
if ( IS_HINTED( load->load_flags ) )
{
load->glyph->control_len = n_ins;
load->glyph->control_data = load->exec->glyphIns;
- FT_MEM_COPY( load->exec->glyphIns, stream->cursor, (FT_Long)n_ins );
+ FT_MEM_COPY( load->exec->glyphIns, p, (FT_Long)n_ins );
}
-#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
+#endif /* TT_USE_BYTECODE_INTERPRETER */
- stream->cursor += (FT_Int)n_ins;
+ p += n_ins;
/* reading the point tags */
flag = (FT_Byte*)outline->tags;
@@ -332,16 +348,16 @@
while ( flag < flag_limit )
{
- if ( --byte_len < 0 )
+ if ( p + 1 > limit )
goto Invalid_Outline;
- *flag++ = c = FT_GET_BYTE();
+ *flag++ = c = FT_NEXT_BYTE( p );
if ( c & 8 )
{
- if ( --byte_len < 0 )
+ if ( p + 1 > limit )
goto Invalid_Outline;
- count = FT_GET_BYTE();
+ count = FT_NEXT_BYTE( p );
if ( flag + (FT_Int)count > flag_limit )
goto Invalid_Outline;
@@ -350,23 +366,6 @@
}
}
- /* check that there is enough room to load the coordinates */
- for ( flag = (FT_Byte*)outline->tags; flag < flag_limit; flag++ )
- {
- if ( *flag & 2 )
- byte_len -= 1;
- else if ( ( *flag & 16 ) == 0 )
- byte_len -= 2;
-
- if ( *flag & 4 )
- byte_len -= 1;
- else if ( ( *flag & 32 ) == 0 )
- byte_len -= 2;
- }
-
- if ( byte_len < 0 )
- goto Invalid_Outline;
-
/* reading the X coordinates */
vec = outline->points;
@@ -374,22 +373,35 @@
flag = (FT_Byte*)outline->tags;
x = 0;
+ if ( p + xy_size > limit )
+ goto Invalid_Outline;
+
for ( ; vec < vec_limit; vec++, flag++ )
{
FT_Pos y = 0;
+ FT_Byte f = *flag;
- if ( *flag & 2 )
+ if ( f & 2 )
{
- y = (FT_Pos)FT_GET_BYTE();
- if ( ( *flag & 16 ) == 0 )
+ if ( p + 1 > limit )
+ goto Invalid_Outline;
+
+ y = (FT_Pos)FT_NEXT_BYTE( p );
+ if ( ( f & 16 ) == 0 )
y = -y;
}
- else if ( ( *flag & 16 ) == 0 )
- y = (FT_Pos)FT_GET_SHORT();
+ else if ( ( f & 16 ) == 0 )
+ {
+ if ( p + 2 > limit )
+ goto Invalid_Outline;
+
+ y = (FT_Pos)FT_NEXT_SHORT( p );
+ }
x += y;
vec->x = x;
+ *flag = f & ~( 2 | 16 );
}
/* reading the Y coordinates */
@@ -402,29 +414,35 @@
for ( ; vec < vec_limit; vec++, flag++ )
{
FT_Pos y = 0;
+ FT_Byte f = *flag;
- if ( *flag & 4 )
+ if ( f & 4 )
{
- y = (FT_Pos)FT_GET_BYTE();
- if ( ( *flag & 32 ) == 0 )
+ if ( p + 1 > limit )
+ goto Invalid_Outline;
+
+ y = (FT_Pos)FT_NEXT_BYTE( p );
+ if ( ( f & 32 ) == 0 )
y = -y;
}
- else if ( ( *flag & 32 ) == 0 )
- y = (FT_Pos)FT_GET_SHORT();
+ else if ( ( f & 32 ) == 0 )
+ {
+ if ( p + 2 > limit )
+ goto Invalid_Outline;
+
+ y = (FT_Pos)FT_NEXT_SHORT( p );
+ }
x += y;
vec->y = x;
+ *flag = f & FT_CURVE_TAG_ON;
}
- /* clear the touch tags */
- for ( n = 0; n < n_points; n++ )
- outline->tags[n] &= FT_CURVE_TAG_ON;
-
outline->n_points = (FT_UShort)n_points;
outline->n_contours = (FT_Short) n_contours;
- load->byte_len = byte_len;
+ load->cursor = p;
Fail:
return error;
@@ -439,11 +457,11 @@
TT_Load_Composite_Glyph( TT_Loader loader )
{
FT_Error error;
- FT_Stream stream = loader->stream;
+ FT_Byte* p = loader->cursor;
+ FT_Byte* limit = loader->limit;
FT_GlyphLoader gloader = loader->gloader;
FT_SubGlyph subglyph;
FT_UInt num_subglyphs;
- FT_Int byte_len = loader->byte_len;
num_subglyphs = 0;
@@ -451,6 +469,7 @@
do
{
FT_Fixed xx, xy, yy, yx;
+ FT_UInt count;
/* check that we can load a new subglyph */
@@ -459,41 +478,40 @@
goto Fail;
/* check space */
- byte_len -= 4;
- if ( byte_len < 0 )
+ if ( p + 4 > limit )
goto Invalid_Composite;
subglyph = gloader->current.subglyphs + num_subglyphs;
subglyph->arg1 = subglyph->arg2 = 0;
- subglyph->flags = FT_GET_USHORT();
- subglyph->index = FT_GET_USHORT();
+ subglyph->flags = FT_NEXT_USHORT( p );
+ subglyph->index = FT_NEXT_USHORT( p );
/* check space */
- byte_len -= 2;
+ count = 2;
if ( subglyph->flags & ARGS_ARE_WORDS )
- byte_len -= 2;
+ count += 2;
if ( subglyph->flags & WE_HAVE_A_SCALE )
- byte_len -= 2;
+ count += 2;
else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
- byte_len -= 4;
+ count += 4;
else if ( subglyph->flags & WE_HAVE_A_2X2 )
- byte_len -= 8;
+ count += 8;
- if ( byte_len < 0 )
+ if ( p + count > limit )
goto Invalid_Composite;
/* read arguments */
if ( subglyph->flags & ARGS_ARE_WORDS )
{
- subglyph->arg1 = FT_GET_SHORT();
- subglyph->arg2 = FT_GET_SHORT();
+ subglyph->arg1 = FT_NEXT_SHORT( p );
+ subglyph->arg2 = FT_NEXT_SHORT( p );
}
else
{
- subglyph->arg1 = FT_GET_CHAR();
- subglyph->arg2 = FT_GET_CHAR();
+ subglyph->arg1 = FT_NEXT_CHAR( p );
+ subglyph->arg2 = FT_NEXT_CHAR( p );
}
/* read transform */
@@ -502,20 +520,20 @@
if ( subglyph->flags & WE_HAVE_A_SCALE )
{
- xx = (FT_Fixed)FT_GET_SHORT() << 2;
+ xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
yy = xx;
}
else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
{
- xx = (FT_Fixed)FT_GET_SHORT() << 2;
- yy = (FT_Fixed)FT_GET_SHORT() << 2;
+ xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
+ yy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
}
else if ( subglyph->flags & WE_HAVE_A_2X2 )
{
- xx = (FT_Fixed)FT_GET_SHORT() << 2;
- yx = (FT_Fixed)FT_GET_SHORT() << 2;
- xy = (FT_Fixed)FT_GET_SHORT() << 2;
- yy = (FT_Fixed)FT_GET_SHORT() << 2;
+ xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
+ yx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
+ xy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
+ yy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
}
subglyph->transform.xx = xx;
@@ -529,20 +547,23 @@
gloader->current.num_subglyphs = num_subglyphs;
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+#ifdef TT_USE_BYTECODE_INTERPRETER
{
+ FT_Stream stream = loader->stream;
+
+
/* we must undo the FT_FRAME_ENTER in order to point to the */
/* composite instructions, if we find some. */
/* we will process them later... */
/* */
loader->ins_pos = (FT_ULong)( FT_STREAM_POS() +
- stream->cursor - stream->limit );
+ p - limit );
}
#endif
- loader->byte_len = byte_len;
+ loader->cursor = p;
Fail:
return error;
@@ -570,12 +591,15 @@
FT_UInt start_point,
FT_UInt start_contour )
{
- zone->n_points = (FT_UShort)( load->outline.n_points - start_point );
- zone->n_contours = (FT_Short) ( load->outline.n_contours - start_contour );
- zone->org = load->extra_points + start_point;
- zone->cur = load->outline.points + start_point;
- zone->tags = (FT_Byte*)load->outline.tags + start_point;
- zone->contours = (FT_UShort*)load->outline.contours + start_contour;
+ zone->n_points = (FT_UShort)( load->outline.n_points - start_point );
+ zone->n_contours = (FT_Short) ( load->outline.n_contours -
+ start_contour );
+ zone->org = load->extra_points + start_point;
+ zone->cur = load->outline.points + start_point;
+ zone->orus = load->extra_points2 + start_point;
+ zone->tags = (FT_Byte*)load->outline.tags + start_point;
+ zone->contours = (FT_UShort*)load->outline.contours + start_contour;
+ zone->first_point = (FT_UShort)start_point;
}
@@ -588,9 +612,6 @@
/* Hint the glyph using the zone prepared by the caller. Note that */
/* the zone is supposed to include four phantom points. */
/* */
-#define cur_to_org( n, zone ) \
- FT_ARRAY_COPY( (zone)->org, (zone)->cur, (n) )
-
static FT_Error
TT_Hint_Glyph( TT_Loader loader,
FT_Bool is_composite )
@@ -598,14 +619,14 @@
TT_GlyphZone zone = &loader->zone;
FT_Pos origin;
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+#ifdef TT_USE_BYTECODE_INTERPRETER
FT_UInt n_ins;
#else
FT_UNUSED( is_composite );
#endif
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+#ifdef TT_USE_BYTECODE_INTERPRETER
n_ins = loader->glyph->control_len;
#endif
@@ -614,10 +635,10 @@
if ( origin )
translate_array( zone->n_points, zone->cur, origin, 0 );
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
- /* save original point positioin in org */
+#ifdef TT_USE_BYTECODE_INTERPRETER
+ /* save original point position in org */
if ( n_ins > 0 )
- cur_to_org( zone->n_points, zone );
+ FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points );
#endif
/* round pp2 and pp4 */
@@ -626,7 +647,7 @@
zone->cur[zone->n_points - 1].y =
FT_PIX_ROUND( zone->cur[zone->n_points - 1].y );
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+#ifdef TT_USE_BYTECODE_INTERPRETER
if ( n_ins > 0 )
{
@@ -642,8 +663,8 @@
loader->exec->is_composite = is_composite;
loader->exec->pts = *zone;
- debug = !( loader->load_flags & FT_LOAD_NO_SCALE ) &&
- ( (TT_Size)loader->size )->debug;
+ debug = FT_BOOL( !( loader->load_flags & FT_LOAD_NO_SCALE ) &&
+ ((TT_Size)loader->size)->debug );
error = TT_Run_Context( loader->exec, debug );
if ( error && loader->exec->pedantic_hinting )
@@ -729,6 +750,14 @@
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
+ if ( IS_HINTED( loader->load_flags ) )
+ {
+ tt_prepare_zone( &loader->zone, &gloader->current, 0, 0 );
+
+ FT_ARRAY_COPY( loader->zone.orus, loader->zone.cur,
+ loader->zone.n_points + 4 );
+ }
+
/* scale the glyph */
if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
{
@@ -752,7 +781,6 @@
if ( IS_HINTED( loader->load_flags ) )
{
- tt_prepare_zone( &loader->zone, &gloader->current, 0, 0 );
loader->zone.n_points += 4;
error = TT_Hint_Glyph( loader, 0 );
@@ -926,7 +954,7 @@
/* */
/* <Description> */
/* This is slightly different from TT_Process_Simple_Glyph, in that */
- /* it's sole purpose is to hint the glyph. Thus this function is */
+ /* its sole purpose is to hint the glyph. Thus this function is */
/* only available when bytecode interpreter is enabled. */
/* */
static FT_Error
@@ -936,6 +964,7 @@
{
FT_Error error;
FT_Outline* outline;
+ FT_UInt i;
outline = &loader->gloader->base.outline;
@@ -957,7 +986,7 @@
outline->tags[outline->n_points + 2] = 0;
outline->tags[outline->n_points + 3] = 0;
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+#ifdef TT_USE_BYTECODE_INTERPRETER
{
FT_Stream stream = loader->stream;
@@ -975,7 +1004,8 @@
/* check it */
if ( n_ins > ((TT_Face)loader->face)->max_profile.maxSizeOfInstructions )
{
- FT_TRACE0(( "Too many instructions (%d)\n", n_ins ));
+ FT_TRACE0(( "TT_Process_Composite_Glyph: Too many instructions (%d)\n",
+ n_ins ));
return TT_Err_Too_Many_Hints;
}
@@ -993,6 +1023,13 @@
tt_prepare_zone( &loader->zone, &loader->gloader->base,
start_point, start_contour );
+
+ /* Some points are likely touched during execution of */
+ /* instructions on components. So let's untouch them. */
+ for ( i = start_point; i < loader->zone.n_points; i++ )
+ loader->zone.tags[i] &= ~( FT_CURVE_TAG_TOUCH_X |
+ FT_CURVE_TAG_TOUCH_Y );
+
loader->zone.n_points += 4;
return TT_Hint_Glyph( loader, 1 );
@@ -1268,9 +1305,9 @@
/* otherwise, load a composite! */
else if ( loader->n_contours == -1 )
{
- FT_UInt start_point;
- FT_UInt start_contour;
- FT_ULong ins_pos; /* position of composite instructions, if any */
+ FT_UInt start_point;
+ FT_UInt start_contour;
+ FT_ULong ins_pos; /* position of composite instructions, if any */
start_point = gloader->base.outline.n_points;
@@ -1300,11 +1337,11 @@
/* this provides additional offsets */
/* for each component's translation */
- if ( (error = TT_Vary_Get_Glyph_Deltas(
- face,
- glyph_index,
- &deltas,
- gloader->current.num_subglyphs + 4 )) != 0 )
+ if ( ( error = TT_Vary_Get_Glyph_Deltas(
+ face,
+ glyph_index,
+ &deltas,
+ gloader->current.num_subglyphs + 4 )) != 0 )
goto Exit;
subglyph = gloader->current.subglyphs + gloader->base.num_subglyphs;
@@ -1340,7 +1377,6 @@
/* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */
/* `as is' in the glyph slot (the client application will be */
/* responsible for interpreting these data)... */
- /* */
if ( loader->load_flags & FT_LOAD_NO_RECURSE )
{
FT_GlyphLoader_Add( gloader );
@@ -1354,14 +1390,21 @@
/*********************************************************************/
{
- FT_UInt n, num_base_points;
- FT_SubGlyph subglyph = 0;
+ FT_UInt n, num_base_points;
+ FT_SubGlyph subglyph = 0;
+
+ FT_UInt num_points = start_point;
+ FT_UInt num_subglyphs = gloader->current.num_subglyphs;
+ FT_UInt num_base_subgs = gloader->base.num_subglyphs;
+
+ FT_Stream old_stream = loader->stream;
- FT_UInt num_points = start_point;
- FT_UInt num_subglyphs = gloader->current.num_subglyphs;
- FT_UInt num_base_subgs = gloader->base.num_subglyphs;
+ TT_GraphicsState saved_GS;
+ if ( loader->exec )
+ saved_GS = loader->exec->GS;
+
FT_GlyphLoader_Add( gloader );
/* read each subglyph independently */
@@ -1370,6 +1413,10 @@
FT_Vector pp[4];
+ /* reinitialize graphics state */
+ if ( loader->exec )
+ loader->exec->GS = saved_GS;
+
/* Each time we call load_truetype_glyph in this loop, the */
/* value of `gloader.base.subglyphs' can change due to table */
/* reallocations. We thus need to recompute the subglyph */
@@ -1404,22 +1451,23 @@
if ( num_points == num_base_points )
continue;
- /* gloader->base.outline consists of three part: */
- /* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */
- /* */
- /* (1): exist from the beginning */
- /* (2): components that have been loaded so far */
- /* (3): the newly loaded component */
+ /* gloader->base.outline consists of three parts: */
+ /* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */
+ /* */
+ /* (1): exists from the beginning */
+ /* (2): components that have been loaded so far */
+ /* (3): the newly loaded component */
TT_Process_Composite_Component( loader, subglyph, start_point,
num_base_points );
}
+ loader->stream = old_stream;
/* process the glyph */
loader->ins_pos = ins_pos;
if ( IS_HINTED( loader->load_flags ) &&
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+#ifdef TT_USE_BYTECODE_INTERPRETER
subglyph->flags & WE_HAVE_INSTR &&
@@ -1432,7 +1480,7 @@
}
else
{
- /* invalid composite count ( negative but not -1 ) */
+ /* invalid composite count (negative but not -1) */
error = TT_Err_Invalid_Outline;
goto Exit;
}
@@ -1460,8 +1508,8 @@
static FT_Error
- compute_glyph_metrics( TT_Loader loader,
- FT_UInt glyph_index )
+ compute_glyph_metrics( TT_Loader loader,
+ FT_UInt glyph_index )
{
FT_BBox bbox;
TT_Face face = (TT_Face)loader->face;
@@ -1479,8 +1527,8 @@
else
bbox = loader->bbox;
- /* get the device-independent horizontal advance. It is scaled later */
- /* by the base layer. */
+ /* get the device-independent horizontal advance; it is scaled later */
+ /* by the base layer. */
{
FT_Pos advance = loader->linear;
@@ -1699,40 +1747,63 @@
FT_MEM_ZERO( loader, sizeof ( TT_LoaderRec ) );
-#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+#ifdef TT_USE_BYTECODE_INTERPRETER
/* load execution context */
+ if ( IS_HINTED( load_flags ) )
{
TT_ExecContext exec;
+ FT_Bool grayscale;
+ if ( !size->cvt_ready )
+ {
+ FT_Error error = tt_size_ready_bytecode( size );
+ if ( error )
+ return error;
+ }
+
/* query new execution context */
exec = size->debug ? size->context
: ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
if ( !exec )
return TT_Err_Could_Not_Find_Context;
+ grayscale =
+ FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != FT_RENDER_MODE_MONO );
+
TT_Load_Context( exec, face, size );
- /* see if the cvt program has disabled hinting */
+ /* a change from mono to grayscale rendering (and vice versa) */
+ /* requires a re-execution of the CVT program */
+ if ( grayscale != exec->grayscale )
+ {
+ FT_UInt i;
+
+
+ exec->grayscale = grayscale;
+
+ for ( i = 0; i < size->cvt_size; i++ )
+ size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
+ tt_size_run_prep( size );
+ }
+
+ /* see whether the cvt program has disabled hinting */
if ( exec->GS.instruct_control & 1 )
load_flags |= FT_LOAD_NO_HINTING;
- /* load default graphics state - if needed */
+ /* load default graphics state -- if needed */
if ( exec->GS.instruct_control & 2 )
exec->GS = tt_default_graphics_state;
exec->pedantic_hinting = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
- exec->grayscale =
- FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != FT_LOAD_TARGET_MONO );
-
loader->exec = exec;
loader->instructions = exec->glyphIns;
}
-#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
+#endif /* TT_USE_BYTECODE_INTERPRETER */
- /* seek to the beginning of the glyph table. For Type 42 fonts */
+ /* seek to the beginning of the glyph table -- for Type 42 fonts */
/* the table might be accessed from a Postscript stream or something */
/* else... */
@@ -1810,13 +1881,11 @@
FT_Int32 load_flags )
{
TT_Face face;
- FT_Stream stream;
FT_Error error;
TT_LoaderRec loader;
face = (TT_Face)glyph->face;
- stream = face->root.stream;
error = TT_Err_Ok;
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
@@ -1850,7 +1919,7 @@
glyph->num_subglyphs = 0;
glyph->outline.flags = 0;
- /* Main loading loop */
+ /* main loading loop */
error = load_truetype_glyph( &loader, glyph_index, 0 );
if ( !error )
{