[meego-commits] 6235: Changes to Trunk/freetype

Peter Zhu peter.j.zhu at intel.com
Wed Aug 4 03:24:40 UTC 2010


Hi,
I have made the following changes to freetype in project Trunk. Please review and accept ASAP.

Thank You,
Peter Zhu

[This message was auto-generated]

---

Request #6235:

  submit:   Trunk:Testing/freetype(r3) -> Trunk/freetype


Message:
    Move to Trunk

State:   new          2010-08-03T15:16:55 peter
Comment: None



changes files:
--------------
--- freetype.changes
+++ freetype.changes
@@ -0,0 +1,10 @@
+* Fri Jul 23 2010 Ling Yue <ling.yue at intel.com> - 2.4.1
+- Upgrade to 2.4.1: the TrueType bytecode interpreter is now 
+  enabled by default.
+- Drop freetype-2.1.10-enable-ft2-bci.patch
+- Drop freetype-2.2.1-memcpy-fix.patch
+- Drop freetype-2.3.5-CVE-2009-0946.patch
+- Drop freetype-2.3.5-CVEs.patch
+- Drop ft2demos-2.1.9-mathlib.patch
+- Use spectacle
+

old:
----
  freetype-2.1.10-enable-ft2-bci.patch
  freetype-2.2.1-memcpy-fix.patch
  freetype-2.3.5-CVE-2009-0946.patch
  freetype-2.3.5-CVEs.patch
  freetype-2.3.5.tar.bz2
  freetype-doc-2.3.5.tar.bz2
  ft2demos-2.1.9-mathlib.patch
  ft2demos-2.3.5.tar.bz2

new:
----
  freetype-2.4.1.tar.bz2
  freetype-doc-2.4.1.tar.bz2
  freetype.yaml
  ft2demos-2.4.1.tar.bz2

spec files:
-----------
--- freetype.spec
+++ freetype.spec
@@ -1,43 +1,26 @@
-#specfile originally created for Fedora, modified for Moblin Linux
-# Patented bytecode interpreter and patented subpixel rendering disabled by default.
-# Pass '--with bytecode_interpreter' and '--with subpixel_rendering' on rpmbuild
-# command-line to enable them.
-%{!?_with_bytecode_interpreter: %{!?_without_bytecode_interpreter: %define _without_bytecode_interpreter --without-bytecode_interpreter}}
-%{!?_with_subpixel_rendering: %{!?_without_subpixel_rendering: %define _without_subpixel_rendering --without-subpixel_rendering}}
+# 
+# Do not Edit! Generated by:
+# spectacle version 0.18
+# 
+# >> macros
+# << macros
 
-%{!?with_xfree86:%define with_xfree86 1}
-
-Summary: A free and portable font rendering engine
 Name: freetype
-Version: 2.3.5
-Release: 6
-License: BSD/GPL dual license
+Summary:    A free and portable font rendering engine
+Version:    2.4.1
+Release:    1
 Group: System/Libraries
+License:    FTL or GPLv2+
 URL: http://www.freetype.org
-Source:  http://download.savannah.gnu.org/releases-noredirect/freetype/freetype-%{version}.tar.bz2
+Source0:    http://download.savannah.gnu.org/releases-noredirect/freetype/freetype-%{version}.tar.bz2
 Source1: http://download.savannah.gnu.org/releases-noredirect/freetype/freetype-doc-%{version}.tar.bz2
+Source100:  freetype.yaml
+Patch0:     freetype-2.2.1-enable-valid.patch
+Patch1:     freetype-multilib.patch
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+Provides:   %{name}-bytecode
 
-Patch20:  freetype-2.1.10-enable-ft2-bci.patch
-Patch21:  freetype-2.3.0-enable-spr.patch
-
-# Enable otvalid and gxvalid modules
-Patch46:  freetype-2.2.1-enable-valid.patch
-
-# Fix multilib conflicts
-Patch88:  freetype-multilib.patch
-
-# Fix crash https://bugs.freedesktop.org/show_bug.cgi?id=6841
-Patch89:  freetype-2.2.1-memcpy-fix.patch
-
-# Upstream patches
-
-Patch90:  freetype-2.3.5-CVEs.patch
-
-Patch91:  freetype-2.3.5-CVE-2009-0946.patch
-
-Buildroot: %{_tmppath}/%{name}-%{version}-root-%(%{__id_u} -n)
-
-#BuildRequires: libX11-devel
 
 %description
 The FreeType engine is a free and portable font rendering
@@ -64,35 +47,45 @@
 FreeType.
 
 
+
 %prep
 %setup -q -b 1 
 
-%if %{?_with_bytecode_interpreter:1}%{!?_with_bytecode_interpreter:0}
-%patch20  -p1 -b .enable-ft2-bci
-%endif
+# freetype-2.2.1-enable-valid.patch
+%patch0 -p1
+# freetype-multilib.patch
+%patch1 -p1
+# >> setup
+# << setup
 
-%if %{?_with_subpixel_rendering:1}%{!?_with_subpixel_rendering:0}
-%patch21  -p1 -b .enable-spr
-%endif
-
-%patch46  -p1 -b .enable-valid
+%build
+# >> build pre
+# << build pre
 
-%patch88 -p1 -b .multilib
-%patch89 -p1 -b .memcpy
 
-%patch90 -p1 -b .CVEs
-%patch91 -p1 -b .CVE-2009-0946
 
-%build
+# >> build post
 
 %configure --disable-static
 sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' builds/unix/libtool
 sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' builds/unix/libtool
 make %{?_smp_mflags}
 
+# Convert FTL.txt to UTF-8
+pushd docs
+iconv -f latin1 -t utf-8 < FTL.TXT > FTL.TXT.tmp && \
+touch -r FTL.TXT FTL.TXT.tmp && \
+mv FTL.TXT.tmp FTL.TXT
+popd
+
 
+# << build post
 %install
-rm -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
+# >> install pre
+# << install pre
+
+# >> install post
 
 
 %makeinstall gnulocaledir=$RPM_BUILD_ROOT%{_datadir}/locale
@@ -106,7 +99,7 @@
 %endif
 
 mv $RPM_BUILD_ROOT%{_includedir}/freetype2/freetype/config/ftconfig.h \
-   $RPM_BUILD_ROOT%{_includedir}/freetype2/freetype/config/ftconfig-%{wordsize}.h
+$RPM_BUILD_ROOT%{_includedir}/freetype2/freetype/config/ftconfig-%{wordsize}.h
 cat >$RPM_BUILD_ROOT%{_includedir}/freetype2/freetype/config/ftconfig.h <<EOF
 #ifndef __FTCONFIG_H__MULTILIB
 #define __FTCONFIG_H__MULTILIB
@@ -127,30 +120,30 @@
 # Don't package static a or .la files
 rm -f $RPM_BUILD_ROOT%{_libdir}/*.{a,la}
 
-%clean
-rm -rf $RPM_BUILD_ROOT
+# << install post
+
 
-%triggerpostun -- freetype < 2.0.5-3
-{
-  # ttmkfdir updated - as of 2.0.5-3, on upgrades we need xfs to regenerate
-  # things to get the iso10646-1 encoding listed.
-  for I in %{_datadir}/fonts/*/TrueType /usr/share/X11/fonts/TTF; do
-      [ -d $I ] && [ -f $I/fonts.scale ] && [ -f $I/fonts.dir ] && touch $I/fonts.scale
-  done
-  exit 0
-}
 
 %post -p /sbin/ldconfig
 
 %postun -p /sbin/ldconfig
 
+
+
+
+
 %files
-%defattr(-,root,root)
+%defattr(-,root,root,-)
+# >> files
 %{_libdir}/libfreetype.so.*
 %doc ChangeLog README
+%doc docs/LICENSE.TXT docs/FTL.TXT docs/GPL.TXT
+# << files
+
 
 %files devel
-%defattr(-,root,root)
+%defattr(-,root,root,-)
+# >> files devel
 %dir %{_includedir}/freetype2
 %{_datadir}/aclocal/freetype2.m4
 %{_includedir}/freetype2/*
@@ -158,4 +151,5 @@
 %{_libdir}/libfreetype.so
 %{_bindir}/freetype-config
 %{_libdir}/pkgconfig/
+# << files devel
 

other changes:
--------------

++++++ freetype-2.3.5.tar.bz2 -> freetype-2.4.1.tar.bz2
197632 lines of diff (skipped)

++++++ freetype-doc-2.3.5.tar.bz2 -> freetype-doc-2.4.1.tar.bz2
327623 lines of diff (skipped)

++++++ freetype-multilib.patch
--- freetype-multilib.patch
+++ freetype-multilib.patch
@@ -13,6 +13,6 @@
 -libdir=@libdir@
 +includedir=`pkg-config --variable includedir freetype2`
 +libdir=`pkg-config --variable libdir freetype2`
- enable_shared=@enable_shared@
+ enable_shared=@build_libtool_libs@
  wl=@wl@
  hardcode_libdir_flag_spec='@hardcode_libdir_flag_spec@'

++++++ freetype.yaml (new)
--- freetype.yaml
+++ freetype.yaml
+Name: freetype
+Summary: A free and portable font rendering engine
+Version: 2.4.1
+Release: 1
+Group: System/Libraries
+License: FTL or GPLv2+
+URL: http://www.freetype.org
+Sources:
+    - http://download.savannah.gnu.org/releases-noredirect/freetype/freetype-%{version}.tar.bz2
+    - http://download.savannah.gnu.org/releases-noredirect/freetype/freetype-doc-%{version}.tar.bz2
+Patches:
+# Patented subpixel rendering disabled by default.
+# Pass '--with subpixel_rendering' on rpmbuild command-line to enable.
+#%{!?_with_subpixel_rendering: %{!?_without_subpixel_rendering: %define _without_subpixel_rendering --without-subpixel_rendering}}
+#%if %{?_with_subpixel_rendering:1}%{!?_with_subpixel_rendering:0}
+#    - freetype-2.3.0-enable-spr.patch
+#%endif
+    - freetype-2.2.1-enable-valid.patch
+    - freetype-multilib.patch
+Description: |
+    The FreeType engine is a free and portable font rendering
+    engine, developed to provide advanced font support for a variety of
+    platforms and environments. FreeType is a library which can open and
+    manages font files as well as efficiently load, hint and render
+    individual glyphs. FreeType is not a font server or a complete
+    text-rendering library.
+
+Provides:
+    - "%{name}-bytecode"
+#%if %{?_with_subpixel_rendering:1}%{!?_with_subpixel_rendering:0}
+#    - "%{name}-subpixel"
+#%endif
+#Can't use yaml configure and builder because of some scripts between configure and make
+Configure: none
+Builder: none
+SubPackages:
+    - Name: devel
+      Summary: FreeType development libraries and header files
+      Group: Development/Libraries
+      Description: |
+          The freetype-devel package includes the static libraries and header files
+          for the FreeType font rendering engine.
+          
+          Install freetype-devel if you want to develop programs which will use
+          FreeType.
+      Requires:
+          - zlib-devel
+          - pkgconfig
+

++++++ ft2demos-2.3.5.tar.bz2 -> ft2demos-2.4.1.tar.bz2
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,313 @@
+2010-07-19  Werner Lemberg  <wl at gnu.org>
+
+	* Version 2.4.1 released.
+	==========================
+
+
+	Tag sources with `VER-2-4-1'.
+
+	* README: Updated.
+
+2010-07-17  Werner Lemberg  <wl at gnu.org>
+
+	ftmulti: Fix possible buffer overflow.
+	Based on a patch from Marek Kašík <mkasik at redhat.com>.
+
+	* src/ftmulti.c (main): Limit axis name length in `Header'.
+
+2010-07-13  suzuki toshiya  <mpsuzuki at hiroshima-u.ac.jp>
+
+	ftdump: Show language ID for all cmap subtables.
+
+	* src/ftdump.c (Print_Charmaps): Print the language IDs obtained by
+	FT_Get_CMap_Language_ID().  The language IDs is cast to FT_UInt, so
+	broken IDs (> 0xFFFF) will not be shown correctly.
+
+2010-07-12  Werner Lemberg  <wl at gnu.org>
+
+	* Version 2.4.0 released.
+	==========================
+
+
+	Tag sources with `VER-2-4-0'.
+
+	* README: Updated.
+
+2010-06-28  Werner Lemberg  <wl at gnu.org>
+
+	ftbench: Fix suboptions of `-b'.
+
+	* src/ftbench.c (bench_desc): Add missing description for
+	FT_BENCH_LOAD_ADVANCES.
+
+2010-06-07  Werner Lemberg  <wl at gnu.org>
+
+	Fix Savannah bug #30054.
+
+	* src/ftdiff.c, src/ftgrid.c, src/ftmulti.c, src/ftstring.c,
+	src/ftview.c: Use precision for `%s' where appropriate to avoid
+	buffer overflows.
+
+2010-04-14  Werner Lemberg  <wl at gnu.org>
+
+	ftdiff: Add support for LCD filter control.
+
+	Key `l' cycles through the filter modes, `[' and `]' select the
+	custom filter weight, `-' and `+' (or `=') adjust the selected
+	filter weight.
+
+	This is based on code written by Lifter
+	<http://unixforum.org/index.php?showuser=11691>.
+
+	* src/ftdiff.c (ColumnStateRec): Add members for LCD filter control.
+	(render_state_init): Updated.
+	(render_state_draw): Add support for custom LCD filter.
+	(event_help): Document new keys.
+	Make help screen more compact.
+	(process_event): Handle new keys.
+
+2010-04-14  Werner Lemberg  <wl at gnu.org>
+
+	ftview: Add support for LCD filter control.
+
+	Key `F' toggles custom LCD filter mode, `[' and `]' select the
+	custom filter weight, `-' and `+' (or `=') adjust the selected
+	filter weight.
+
+	This is based on code written by Lifter
+	<http://unixforum.org/index.php?showuser=11691>.
+
+	* src/ftview.c (INIT_SIZE, Render_Waterfall): Add space for a third
+	header line.
+	(status_): Add members for LCD filter control.
+	(event_help): Document new keys.
+	Make help screen more compact.
+	(Process_Event): Handle new keys.  Use FTC_Manager_RemoveFaceID to
+	flush the bitmap caches, forcing a redraw.  I'm not sure whether
+	this is the right thing, but it seems to work...
+	(write_header): Display custom filter weights.
+
+2010-02-11  Werner Lemberg  <wl at gnu.org>
+
+	* Version 2.3.12 released.
+	==========================
+
+
+	Tag sources with `VER-2-3-12'.
+
+	* README: Updated.
+
+2009-10-10  Werner Lemberg  <wl at gnu.org>
+
+	* Version 2.3.11 released.
+	==========================
+
+
+	Tag sources with `VER-2-3-11'.
+
+	* README: Updated.
+
+2009-10-06  Werner Lemberg  <wl at gnu.org>
+
+	* Version 2.3.10 released.
+	==========================
+
+
+	Tag sources with `VER-2-3-10'.
+
+	* README: Updated.
+
+	* Makefile (major, minor, patch): Fix regexp to allow more
+	than a single digit.
+	(dist): We now use git.
+
+2009-07-30  Boris Letocha  <b.letocha at gmc.net>
+
+	[graph] Fix rendering on Windows.
+
+	* graph/win32/grwin32.c (gr_win32_surface_refresh_rectangle):
+	Handle `gr_pixel_mode_gray' correctly.
+
+2009-06-17  Werner Lemberg  <wl at gnu.org>
+
+	Reduce number of automatically compiled programs.
+	Many GNU/Linux distributions install those programs, and most of
+	them are completely useless or very specialized.
+
+	* Makefile (LINK): Define.
+	(EXES): Reduce list to retain only generally useful programs.
+	(ftsbit): Comment out.  Program doesn't compile (but may be useful).
+	(ttdebug.o): Make it compile again.
+
+2009-06-17  Werner Lemberg  <wl at gnu.org>
+
+	* Makefile: Handle `EXTRAFLAGS' for platform `unixdev' also.
+
+2009-04-30  Werner Lemberg  <wl at gnu.org>
+
+	ftview: Make slant and boldness controllable.
+
+	Keys `e' and `E' adjust emboldening, keys `s' and `S' the slant.
+
+	* src/ftview.c (status): Add `bold_factor' and `slant' members.
+	(Render_Slanted): Use `status.slant'.
+	(Render_Embolden): Copy code from `FT_GlyphSlot_Embolden' and use
+	`status.bold_factor'.
+	(event_bold_change, event_slant_change): New functions.
+	(Process_Event): Handle keys `s', `S', `e', and `E'.
+	(event_help): Updated.
+
+2009-04-26  Werner Lemberg  <wl at gnu.org>
+
+	* graph/grblit.c (blit_lcd8_to_24): Fix typo.
+	Reported by suyu at cooee.cn.
+
+2009-04-22  Werner Lemberg  <wl at gnu.org>
+
+	Fix crash in ftgrid.
+
+	* src/ftgrid.c (grid_status_draw_outline): Handle return value of
+	FT_Load_Glyph.
+
+2009-03-12  Werner Lemberg  <wl at gnu.org>
+
+	* Version 2.3.9 released.
+	=========================
+
+
+	Tag sources with `VER-2-3-9'.
+
+	* README: Updated.
+
+2009-03-10  Werner Lemberg  <wl at gnu.org>
+
+	* src/common.c (CONST): New macro, defined depending on __STDC__.
+	Use it where necessary.
+
+2009-03-10  Werner Lemberg  <wl at gnu.org>
+
+	Fix C++ compilation.
+
+	* src/ftbench.c (test_load_advances): Use cast.
+	* src/ftgrid.c: Protect `extern' declarations with `extern "C"'.
+
+2009-03-03  Werner Lemberg  <wl at gnu.org>
+
+	Fix signedness issues.
+
+	* src/ftcommon.c (FTDemo_String_Set): Fix signedness.
+	Update callers.
+	Include `common.h'.
+	Use __STDC__ macro.
+	* src/ftcommon.h (FTDemo_String_Set): Fix signedness.
+
+	* src/common.h, src/common.c: Use __STDC__ macro.
+
+2009-03-03  David Turner  <david at freetype.org>
+
+	Add utf-8 support to ftview.  Fixes Savannah BUG #18225.
+
+	* src/common.h, src/common.c: Add `utf8_next' function.
+	* src/ftcommon.c (FTDemo_String_Set), src/ftview.c (Render_Text):
+	Use `utf8_next'.
+
+2009-01-14  Werner Lemberg  <wl at gnu.org>
+
+
+	* Version 2.3.8 released.
+	=========================
+
+
+	Tag sources with `VER-2-3-8'.
+
+	* README: Updated.
+
+2009-01-07  Werner Lemberg  <wl at gnu.org>
+
+	ftdiff: Add `a' key to toggle global advance width.
+
+	* src/ftdiff.c (ColumnStateRec): Add `use_global_advance_width'
+	field.
+	(render_state_init): Updated.
+	(render_state_draw): Control FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH.
+	Update screen output.
+	(event_help): Document `a' key.
+	Sort output.
+	(process_keys): Handle `a' key.
+	Sort entries in `case' block.
+
+2008-12-05  Werner Lemberg  <wl at gnu.org>
+
+	* src/ftbench.c: Remove #if FT_ADVANCES_H ... conditionals.
+
+2008-09-02  David Turner  <david at freetype.org>
+
+	* src/ftbench.c: Include FT_ADVANCES_H.
+	(FT_BENCH_LOAD_ADVANCES): New enumeration value.
+	(test_load_advances): New function.
+	(main) <FT_BENCH_LOAD_ADVANCES>: New case.
+
+2008-06-29  Werner Lemberg  <wl at gnu.org>
+
+
+	* Version 2.3.7 released.
+	=========================
+
+
+	Tag sources with `VER-2-3-7'.
+
+	* README: Updated.
+
+2008-06-10  Werner Lemberg  <wl at gnu.org>
+
+
+	* Version 2.3.6 released.
+	=========================
+
+
+	Tag sources with `VER-2-3-6'.
+
+	* README: Updated.
+
+2008-05-18  Werner Lemberg  <wl at gnu.org>
+
+	* src/ftdiff.c (render_mode_names): Use better strings.
+
+2008-05-13  Werner Lemberg  <wl at gnu.org>
+
+	* src/ftcommon.c (string_render_prepare): Always set extent in last
+	slot.
+
+2008-01-10  Allan Yang, Jian Hua - SH  <Allan.Yang at fmc.fujitsu.com>
+
+	* graph/grfill.c: Include <stdlib.h>.
+
+2007-12-29  Allan Yang, Jian Hua - SH  <Allan.Yang at fmc.fujitsu.com>
+	    Werner Lemberg  <wl at gnu.org>
+
+	* src/ftview.c: Implement slanting.
+
+2007-08-08  Werner Lemberg  <wl at gnu.org>
+
+	* src/ftvalid.c (print_usage): Add option `-f'.
+
+2007-08-08  George Williams  <gww at silcom.com>
+
+	* src/ftvalid.c (ot_table_spec): Handle `MATH' table also.
+	(main): Add option `-f' to select font index.
+
+2007-07-07  Werner Lemberg  <wl at gnu.org>
+
+	* src/ftview.c (parse_cmdline): Remove C++ compiler warning.
+
+	* src/ftcommon.c (my_file_requester), src/ftgrid.c
+	(grid_status_draw_grid, ft_outline_draw, ft_outline_new_circle,
+	grid_status_draw_outline, _af_debug_hints), src/ftdiff.c
+	(_render_state_rescale, render_state_set_files,
+	render_state_set_file, adisplay_draw_glyph, adisplay_draw_text,
+	event_help, event_change_gamma, process_event, write_message, main):
+	Fix compilation with C++ compiler.
+
 2007-07-02  Werner Lemberg  <wl at gnu.org>
 
 
--- Makefile
+++ Makefile
@@ -161,6 +161,9 @@
     endif
   endif
 
+  LINK        = $(LINK_CMD) \
+                $(LINK_ITEMS) \
+                $(LINK_LIBS)
   LINK_COMMON = $(LINK_CMD) \
                 $(LINK_ITEMS) $(subst /,$(COMPILER_SEP),$(COMMON_OBJ)) \
                 $(LINK_LIBS)
@@ -242,14 +245,34 @@
   endif
 
 
+  ####################################################################
+  #
+  # POSIX TERMIOS: Do not define if you use OLD U*ix like 4.2BSD.
+  #
+  ifeq ($(PLATFORM),unix)
+    EXTRAFLAGS = $DUNIX $DHAVE_POSIX_TERMIOS
+  endif
+
+  ifeq ($(PLATFORM),unixdev)
+    EXTRAFLAGS = $DUNIX $DHAVE_POSIX_TERMIOS
+  endif
+
+
   ###################################################################
   #
   # The list of demonstration programs to build.
   #
-  EXES := ftlint ftmemchk ftdump testname fttimer ftbench ftchkwd ftpatchk
+  EXES := ftbench \
+          ftdump  \
+          ftlint
 
   # Comment out the next line if you don't have a graphics subsystem.
-  EXES += ftview ftmulti ftstring ftgamma ftgrid ftdiff
+  EXES += ftdiff   \
+          ftgamma  \
+          ftgrid   \
+          ftmulti  \
+          ftstring \
+          ftview
 
   # ftvalid requires ftgxval.c and ftotval.c
   #
@@ -259,12 +282,18 @@
     endif
   endif
 
-  # Only uncomment the following lines if the truetype driver was
-  # compiled with TT_CONFIG_OPTION_BYTECODE_INTERPRETER defined.
+  # The following programs are not compiled automatically; either comment
+  # out the affected line or use the program name as a Makefile target.
   #
-  #  ifneq ($(findstring $(PLATFORM),os2 unix win32),)
-  #    EXES += ttdebug
-  #  endif
+  # Note that ttdebug only works if the FreeType's `truetype' driver has
+  # been compiled with TT_CONFIG_OPTION_BYTECODE_INTERPRETER defined.
+  #
+  # EXES += ftchkwd
+  # EXES += ftmemchk
+  # EXES += ftpatchk
+  # EXES += fttimer
+  # EXES += testname
+  # EXES += ttdebug
 
   exes: $(EXES:%=$(BIN_DIR_2)/%$E)
 
@@ -320,6 +349,9 @@
   $(OBJ_DIR_2)/testname.$(SO): $(SRC_DIR)/testname.c
 	  $(COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
 
+#  $(OBJ_DIR_2)/ftsbit.$(SO): $(SRC_DIR)/ftsbit.c
+#	  $(COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
+
 
   # We simplify the dependencies on the graphics library by using
   # $(GRAPH_LIB) directly.
@@ -345,10 +377,6 @@
                      $T$(subst /,$(COMPILER_SEP),$@ $<)
 
 
-# $(OBJ_DIR_2)/ftsbit.$(SO): $(SRC_DIR)/ftsbit.c $(GRAPH_LIB)
-#	 $(COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
-
-
   ####################################################################
   #
   # Special rule to compile the `ftdump' program as it includes
@@ -403,18 +431,10 @@
   # the TrueType source path and needs extra flags for correct keyboard
   # handling on Unix.
 
-  # POSIX TERMIOS: Do not define if you use OLD U*ix like 4.2BSD.
-  #
-  # detect a Unix system
-  #
-  ifeq ($(PLATFORM),unix)
-    EXTRAFLAGS = $DUNIX $DHAVE_POSIX_TERMIOS
-  endif
-
   $(OBJ_DIR_2)/ttdebug.$(SO): $(SRC_DIR)/ttdebug.c
 	  $(COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) \
                      $I$(subst /,$(COMPILER_SEP),$(TOP_DIR)/src/truetype) \
-                     $(EXTRAFLAGS)
+                     $(EXTRAFLAGS) $DFT2_BUILD_LIBRARY
 
 
   ####################################################################
@@ -452,8 +472,8 @@
   $(BIN_DIR_2)/fttry$E: $(OBJ_DIR_2)/fttry.$(SO) $(FTLIB)
 	  $(LINK)
 
-  $(BIN_DIR_2)/ftsbit$E: $(OBJ_DIR_2)/ftsbit.$(SO) $(FTLIB)
-	  $(LINK)
+#  $(BIN_DIR_2)/ftsbit$E: $(OBJ_DIR_2)/ftsbit.$(SO) $(FTLIB)
+#	  $(LINK)
 
   $(BIN_DIR_2)/t1dump$E: $(OBJ_DIR_2)/t1dump.$(SO) $(FTLIB)
 	  $(LINK)
@@ -502,9 +522,9 @@
 ifneq ($(findstring distx,$(MAKECMDGOALS)x),)
   FT_H := ../freetype2/include/freetype/freetype.h
 
-  major := $(shell sed -n 's/.*FREETYPE_MAJOR.*\([0-9]\+\)/\1/p' < $(FT_H))
-  minor := $(shell sed -n 's/.*FREETYPE_MINOR.*\([0-9]\+\)/\1/p' < $(FT_H))
-  patch := $(shell sed -n 's/.*FREETYPE_PATCH.*\([0-9]\+\)/\1/p' < $(FT_H))
+  major := $(shell sed -n 's/.*FREETYPE_MAJOR[^0-9]*\([0-9]\+\)/\1/p' < $(FT_H))
+  minor := $(shell sed -n 's/.*FREETYPE_MINOR[^0-9]*\([0-9]\+\)/\1/p' < $(FT_H))
+  patch := $(shell sed -n 's/.*FREETYPE_PATCH[^0-9]*\([0-9]\+\)/\1/p' < $(FT_H))
 
   version    := $(major).$(minor).$(patch)
   winversion := $(major)$(minor)$(patch)
@@ -516,14 +536,14 @@
 	rm -f ft2demos-$(version).tar.bz2
 	rm -f ftdmo$(winversion).zip
 
-	for d in `find . -wholename '*/CVS' -prune \
+	for d in `find . -wholename '*/.git' -prune \
 	                 -o -type f \
 	                 -o -print` ; do \
 	  mkdir -p tmp/$$d ; \
 	done ;
 
 	currdir=`pwd` ; \
-	for f in `find . -wholename '*/CVS' -prune \
+	for f in `find . -wholename '*/.git' -prune \
 	                 -o -name .cvsignore \
 	                 -o -type d \
 	                 -o -print` ; do \
--- README
+++ README
@@ -8,8 +8,8 @@
   downloaded one  of the  stable FreeType 2  source packages  from our
   server, you most probably have to rename its directory, for example:
 
-    mv freetype-2.3.5 freetype2       on Unix
-    rename freetype-2.3.5 freetype2   on Windows
+    mv freetype-2.4.1 freetype2       on Unix
+    rename freetype-2.4.1 freetype2   on Windows
 
 WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
 
--- graph/grblit.c
+++ graph/grblit.c
@@ -2,7 +2,7 @@
 /*                                                                          */
 /*  The FreeType project -- a free and portable quality TrueType renderer.  */
 /*                                                                          */
-/*  Copyright 1996-1999, 2000, 2001, 2002 by                                */
+/*  Copyright 1996-1999, 2000, 2001, 2002, 2009 by                          */
 /*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
 /*                                                                          */
 /*  grblit.c: Support for blitting of bitmaps with various depth.           */
@@ -1395,7 +1395,7 @@
             dg  = _write[1];
             dg += (sg-dg)*val1 >> 8;
 
-            db  = _write[1];
+            db  = _write[2];
             db += (sb-db)*val2 >> 8;
 
             _write[0] = dr;
--- graph/grfill.c
+++ graph/grfill.c
@@ -1,4 +1,5 @@
 #include "graph.h"
+#include <stdlib.h>
 #include <memory.h>
 
 static void
--- graph/win32/grwin32.c
+++ graph/win32/grwin32.c
@@ -191,10 +191,11 @@
 
   /* now, perform the blit */
   row_bytes = surface->root.bitmap.pitch;
-  if (row_bytes < 0) row_bytes = -row_bytes;
+  if ( row_bytes < 0 )
+    row_bytes = -row_bytes;
 
-  if ( row_bytes*8 != pbmi->bmiHeader.biWidth * pbmi->bmiHeader.biBitCount )
-    pbmi->bmiHeader.biWidth  = row_bytes * 8 / pbmi->bmiHeader.biBitCount;
+  if ( row_bytes * 8 != pbmi->bmiHeader.biWidth * pbmi->bmiHeader.biBitCount )
+    pbmi->bmiHeader.biWidth = row_bytes * 8 / pbmi->bmiHeader.biBitCount;
 
 #ifdef SWIZZLE
   {
@@ -219,27 +220,45 @@
     int             height      = bitmap->rows;
     int             width       = bitmap->width;
 
-    if (read_pitch < 0)
-      read_line -= (height-1)*read_pitch;
+    if ( read_pitch < 0 )
+      read_line -= ( height - 1 ) * read_pitch;
 
-    if (write_pitch < 0)
-      write_line -= (height-1)*write_pitch;
+    if ( write_pitch < 0 )
+      write_line -= ( height - 1 ) * write_pitch;
 
-    for ( ; height > 0; height-- )
+    if ( bitmap->mode == gr_pixel_mode_gray )
     {
-      unsigned char*  read       = read_line;
-      unsigned char*  read_limit = read + 3*width;
-      unsigned char*  write      = write_line;
-
-      for ( ; read < read_limit; read += 3, write += 3 )
+      for ( ; height > 0; height-- )
       {
-        write[0] = read[2];
-        write[1] = read[1];
-        write[2] = read[0];
+        unsigned char*  read       = read_line;
+        unsigned char*  read_limit = read + width;
+        unsigned char*  write      = write_line;
+
+        for ( ; read < read_limit; read++, write++ )
+          *write = *read;
+
+        read_line  += read_pitch;
+        write_line += write_pitch;
       }
+    }
+    else
+    {
+      for ( ; height > 0; height-- )
+      {
+        unsigned char*  read       = read_line;
+        unsigned char*  read_limit = read + 3 * width;
+        unsigned char*  write      = write_line;
+
+        for ( ; read < read_limit; read += 3, write += 3 )
+        {
+          write[0] = read[2];
+          write[1] = read[1];
+          write[2] = read[0];
+        }
 
-      read_line  += read_pitch;
-      write_line += write_pitch;
+        read_line  += read_pitch;
+        write_line += write_pitch;
+      }
     }
   }
 
--- src/common.c
+++ src/common.c
@@ -8,7 +8,7 @@
  *  mleisher at crl.nmsu.edu (Mark Leisher)
  *  10 October 1997
  *
- *  Last update 2005-11-30.
+ *  Last update 2009-03-11.
  */
 
 #include "common.h"
@@ -18,6 +18,12 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef __STDC__
+#define CONST  const
+#else
+#define CONST
+#endif
+
   /*
    *  Externals visible to programs.
    */
@@ -32,13 +38,8 @@
    */
 
   static int  cmdac;
-#ifdef __STDC__
-  static const char*   cmdname;
-  static char* const*  cmdav;
-#else
-  static char*   cmdname;
-  static char**  cmdav;
-#endif
+  static CONST char*   cmdname;
+  static char* CONST*  cmdav;
 
   int
 #ifdef __STDC__
@@ -51,13 +52,8 @@
 #endif
   {
     int  opt;
-#ifdef __STDC__
-    const char*  p;
-    const char*  pp;
-#else
-    char*  p;
-    char*  pp;
-#endif
+    CONST char*  p;
+    CONST char*  pp;
 
     /*
      *  If there is no pattern, indicate the parsing is done.
@@ -190,13 +186,8 @@
     char* name;
 #endif
   {
-#ifdef __STDC__
-    const char*  base;
-    const char*  current;
-#else
-    char*        base;
-    char*        current;
-#endif
+    CONST char*  base;
+    CONST char*  current;
     char         c;
 
     base    = name;
@@ -221,11 +212,12 @@
   }
 
 
+  void
 #ifdef __STDC__
-  void Panic( const char*  fmt, ... )
+  Panic( const char*  fmt, ... )
 #else
-  void Panic( fmt )
-    const char* fmt;
+  Panic( fmt )
+    char* fmt;
 #endif
   {
     va_list  ap;
@@ -239,4 +231,63 @@
   }
 
 
+  extern int
+#ifdef __STDC__
+  utf8_next( const char** pcursor,
+             const char*  end )
+#else
+  utf8_next( pcursor, end )
+    char** pcursor;
+    char*  end;
+#endif
+  {
+    CONST unsigned char*  p = (CONST unsigned char*)*pcursor;
+    int                   ch;
+
+
+    if ( (CONST char*)p >= end ) /* end of stream */
+      return -1;
+
+    ch = *p++;
+    if ( ch >= 0x80 )
+    {
+      int  len;
+
+
+      if ( ch < 0xc0 )  /* malformed data */
+        goto BAD_DATA;
+      else if ( ch < 0xe0 )
+      {
+        len = 1;
+        ch &= 0x1f;
+      }
+      else if ( ch < 0xf0 )
+      {
+        len = 2;
+        ch &= 0x0f;
+      }
+      else
+      {
+        len = 3;
+        ch &= 0x07;
+      }
+
+      while ( len > 0 )
+      {
+        if ( (CONST char*)p >= end || ( p[0] & 0xc0 ) != 0x80 )
+          goto BAD_DATA;
+
+        ch   = ( ch << 6 ) | ( p[0] & 0x3f );
+        p   += 1;
+        len -= 1;
+      }
+    }
+
+    *pcursor = (CONST char*) p;
+    return ch;
+
+  BAD_DATA:
+    return -1;
+  }
+
 /* End */
--- src/common.h
+++ src/common.h
@@ -42,12 +42,25 @@
   );
 
   /* print a message and exit */
-  extern  void  Panic  (
+  extern void  Panic(
 #ifdef __STDC__
     const char*  fmt, ...
 #endif
   );
 
+  /* read the next UTF-8 code from `*pcursor' and
+   * returns its value. `end' is the limit of the
+   * input string.
+   *
+   * return -1 if the end of the input string is
+   * reached, or in case of malformed data
+   */
+  extern int  utf8_next(
+#ifdef __STDC__
+    const char** pcursor,
+    const char*  end
+#endif
+  );
 
 #ifdef __cplusplus
   }
--- src/ftbench.c
+++ src/ftbench.c
@@ -2,7 +2,7 @@
 /*                                                                          */
 /*  The FreeType project -- a free and portable quality TrueType renderer.  */
 /*                                                                          */
-/*  Copyright 2002, 2003, 2004, 2005, 2006 by                               */
+/*  Copyright 2002, 2003, 2004, 2005, 2006, 2009, 2010 by                   */
 /*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
 /*                                                                          */
 /*  ftbench: bench some common FreeType call paths                          */
@@ -21,7 +21,7 @@
 #include FT_CACHE_IMAGE_H
 #include FT_CACHE_SMALL_BITMAPS_H
 #include FT_SYNTHESIS_H
-
+#include FT_ADVANCES_H
 
 #ifdef UNIX
 #include <sys/time.h>
@@ -74,6 +74,7 @@
 
 enum {
   FT_BENCH_LOAD_GLYPH,
+  FT_BENCH_LOAD_ADVANCES,
   FT_BENCH_RENDER,
   FT_BENCH_GET_GLYPH,
   FT_BENCH_GET_CBOX,
@@ -86,6 +87,7 @@
 
 const char* bench_desc[] = {
   "Load a glyph",
+  "Load advance widths",
   "Render a glyph",
   "Get FT_Glyph",
   "Get glyph cbox",
@@ -225,6 +227,31 @@
 
 
 int
+test_load_advances( btimer_t*  timer,
+                    FT_Face    face,
+                    void*      user_data )
+{
+  int        done = 0;
+  FT_Fixed*  advances;
+  FT_ULong   flags = *((FT_ULong*)user_data);
+
+
+  advances = (FT_Fixed *)calloc( sizeof ( FT_Fixed ), face->num_glyphs );
+
+  TIMER_START( timer );
+
+  FT_Get_Advances( face, 0, face->num_glyphs, flags, advances );
+  done += face->num_glyphs;
+
+  TIMER_STOP( timer );
+
+  free( advances );
+
+  return done;
+}
+
+
+int
 test_render( btimer_t*  timer,
              FT_Face    face,
              void*      user_data )
@@ -735,7 +762,8 @@
 
   for ( i = 0; i < N_FT_BENCH; i++ )
   {
-    btest_t  test;
+    btest_t   test;
+    FT_ULong  flags;
 
 
     if ( !TEST( 'a' + i ) )
@@ -766,6 +794,19 @@
         benchmark( face, &test, max_iter, max_time );
       }
       break;
+    case FT_BENCH_LOAD_ADVANCES:
+      test.user_data = &flags;
+
+      test.title = "Load_Advances (Normal)";
+      test.bench = test_load_advances;
+      flags      = FT_LOAD_DEFAULT;
+      benchmark( face, &test, max_iter, max_time );
+
+      test.title  = "Load_Advances (Fast)";
+      test.bench  = test_load_advances;
+      flags       = FT_LOAD_TARGET_LIGHT;
+      benchmark( face, &test, max_iter, max_time );
+      break;
     case FT_BENCH_RENDER:
       test.title = "Render";
       test.bench = test_render;
--- src/ftcommon.c
+++ src/ftcommon.c
@@ -2,7 +2,7 @@
 /*                                                                          */
 /*  The FreeType project -- a free and portable quality TrueType renderer.  */
 /*                                                                          */
-/*  Copyright 2005, 2006 by                                                 */
+/*  Copyright 2005, 2006, 2007, 2008, 2009 by                               */
 /*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
 /*                                                                          */
 /*                                                                          */
@@ -19,6 +19,7 @@
 
 #include FT_BITMAP_H
 
+#include "common.h"
 #include "ftcommon.h"
 
 #include <stdio.h>
@@ -209,8 +210,11 @@
     FT_UNUSED( request_data );
 
     if ( font->file_address != NULL )
-      error = FT_New_Memory_Face( lib, font->file_address, font->file_size,
-                                  font->face_index, aface );
+      error = FT_New_Memory_Face( lib,
+                                  (const FT_Byte*)font->file_address,
+                                  font->file_size,
+                                  font->face_index,
+                                  aface );
     else
       error = FT_New_Face( lib,
                            font->filepathname,
@@ -1015,58 +1019,27 @@
 
 
   void
-  FTDemo_String_Set( FTDemo_Handle*        handle,
-                     const unsigned char*  string )
+  FTDemo_String_Set( FTDemo_Handle*  handle,
+                     const char*     string )
   {
-    const unsigned char*  p = string;
-    unsigned long         codepoint;
-    unsigned char         in_code;
-    int                   expect;
-    PGlyph                glyph = handle->string;
+    const char*     p = string;
+    const char*     end = p + strlen( string );
+    unsigned long   codepoint;
+    int             ch;
+    int             expect;
+    PGlyph          glyph = handle->string;
 
 
     handle->string_length = 0;
     codepoint = expect = 0;
 
-    while ( *p )
+    for (;;)
     {
-      in_code = *p++ ;
-
-      if ( in_code >= 0xC0 )
-      {
-        if ( in_code < 0xE0 )           /*  U+0080 - U+07FF   */
-        {
-          expect = 1;
-          codepoint = in_code & 0x1F;
-        }
-        else if ( in_code < 0xF0 )      /*  U+0800 - U+FFFF   */
-        {
-          expect = 2;
-          codepoint = in_code & 0x0F;
-        }
-        else if ( in_code < 0xF8 )      /* U+10000 - U+10FFFF */
-        {
-          expect = 3;
-          codepoint = in_code & 0x07;
-        }
-        continue;
-      }
-      else if ( in_code >= 0x80 )
-      {
-        --expect;
-
-        if ( expect >= 0 )
-        {
-          codepoint <<= 6;
-          codepoint  += in_code & 0x3F;
-        }
-        if ( expect >  0 )
-          continue;
+      ch = utf8_next( &p, end );
+      if ( ch < 0 )
+        break;
 
-        expect = 0;
-      }
-      else                              /* ASCII, U+0000 - U+007F */
-        codepoint = in_code;
+      codepoint = ch;
 
       if ( handle->encoding != FT_ENCODING_NONE )
         glyph->glyph_index = FTDemo_Get_Index( handle, codepoint );
@@ -1238,12 +1211,12 @@
 
       extent.x += prev_advance->x;
       extent.y += prev_advance->y;
-
-      /*store the extent in the last slot */
-      i = handle->string_length - 1;
-      advances[i] = extent;
     }
 
+    /* store the extent in the last slot */
+    i = handle->string_length - 1;
+    advances[i] = extent;
+
     return FT_Err_Ok;
   }
 
--- src/ftcommon.h
+++ src/ftcommon.h
@@ -2,7 +2,7 @@
 /*                                                                          */
 /*  The FreeType project -- a free and portable quality TrueType renderer.  */
 /*                                                                          */
-/*  Copyright 2005, 2006 by                                                 */
+/*  Copyright 2005, 2006, 2009 by                                           */
 /*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
 /*                                                                          */
 /*                                                                          */
@@ -309,8 +309,8 @@
 
   /* set the string to be drawn */
   void
-  FTDemo_String_Set( FTDemo_Handle*        handle,
-                     const unsigned char*  string );
+  FTDemo_String_Set( FTDemo_Handle*  handle,
+                     const char*     string );
 
 
   /* draw a string centered at (center_x, center_y) --  */
--- src/ftdiff.c
+++ src/ftdiff.c
@@ -2,7 +2,7 @@
 /*                                                                          */
 /*  The FreeType project -- a free and portable quality TrueType renderer.  */
 /*                                                                          */
-/*  Copyright 2007 by                                                       */
+/*  Copyright 2007, 2008, 2009, 2010 by                                     */
 /*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
 /*                                                                          */
 /*                                                                          */
@@ -132,22 +132,27 @@
 
   static const char* const  render_mode_names[HINT_MODE_MAX] =
   {
-      "unhinted",
-      "autohint",
-      "light autohint",
-      "bytecode hinted"
+    "unhinted",
+    "auto hinter",
+    "light auto hinter",
+    "native hinter"
   };
 
   /** RENDER STATE **/
 
   typedef struct  _ColumnStateRec
   {
-    int           use_kerning;
-    int           use_deltas;
-    int           use_lcd_filter;
-    FT_LcdFilter  lcd_filter;
-    HintMode      hint_mode;
-    DisplayMode   disp_mode;
+    int            use_kerning;
+    int            use_deltas;
+    int            use_lcd_filter;
+    int            use_global_advance_width;
+    FT_LcdFilter   lcd_filter;
+    HintMode       hint_mode;
+    DisplayMode    disp_mode;
+
+    int            use_custom_lcd_filter;
+    unsigned char  filter_weights[5];
+    int            fw_index;
 
   } ColumnStateRec, *ColumnState;
 
@@ -197,19 +202,25 @@
     state->char_size    = 16;
     state->display      = display[0];
 
-    state->columns[0].use_kerning    = 1;
-    state->columns[0].use_deltas     = 1;
-    state->columns[0].use_lcd_filter = 1;
-    state->columns[0].lcd_filter     = FT_LCD_FILTER_DEFAULT;
-    state->columns[0].hint_mode      = HINT_MODE_BYTECODE;
+    state->columns[0].use_kerning              = 1;
+    state->columns[0].use_deltas               = 1;
+    state->columns[0].use_lcd_filter           = 1;
+    state->columns[0].use_global_advance_width = 1;
+    state->columns[0].lcd_filter               = FT_LCD_FILTER_DEFAULT;
+    state->columns[0].hint_mode                = HINT_MODE_BYTECODE;
+    state->columns[0].use_custom_lcd_filter    = 0;
+    state->columns[0].fw_index                 = 2;
+    /* freetype default filter weights */
+    memcpy( state->columns[0].filter_weights, "\x10\x40\x70\x40\x10", 5);
+
+    state->columns[1]                       = state->columns[0];
+    state->columns[1].hint_mode             = HINT_MODE_AUTOHINT;
+    state->columns[1].use_custom_lcd_filter = 1;
 
-    state->columns[1] = state->columns[0];
-    state->columns[1].hint_mode = HINT_MODE_AUTOHINT;
-
-    state->columns[2] = state->columns[0];
+    state->columns[2]           = state->columns[0];
     state->columns[2].hint_mode = HINT_MODE_UNHINTED;
 
-    state->col = 2;
+    state->col = 1;
 
     if ( FT_Init_FreeType( &state->library ) != 0 )
       panic( "could not initialize FreeType library. Check your code\n" );
@@ -265,7 +276,8 @@
   {
     if ( state->need_rescale && state->size )
     {
-      FT_Set_Char_Size( state->face, 0, state->char_size * 64,
+      FT_Set_Char_Size( state->face, 0,
+                        (FT_F26Dot6)( state->char_size * 64.0 ),
                         0, state->resolution );
       state->need_rescale = 0;
     }
@@ -301,7 +313,8 @@
         if ( num_faces >= max_faces )
         {
           max_faces += ( max_faces >> 1 ) + 8;
-          faces = realloc( faces, max_faces * sizeof ( faces[0] ) );
+          faces = (FontFace)realloc( faces,
+                                     max_faces * sizeof ( faces[0] ) );
           if ( faces == NULL )
             panic("ftdiff: not enough memory\n");
         }
@@ -370,7 +383,7 @@
 
         if ( len + 1 > sizeof ( state->filepath0 ) )
         {
-          state->filepath = malloc( len + 1 );
+          state->filepath = (const char*)malloc( len + 1 );
           if ( state->filepath == NULL )
           {
             state->filepath = state->filepath0;
@@ -426,6 +439,10 @@
     if ( column->use_lcd_filter )
       FT_Library_SetLcdFilter( face->glyph->library, column->lcd_filter );
 
+    if ( column->use_custom_lcd_filter )
+      FT_Library_SetLcdFilterWeights( face->glyph->library,
+                                      column->filter_weights );
+
     y          += state->size->metrics.ascender / 64;
     line_height = state->size->metrics.height / 64;
 
@@ -438,6 +455,9 @@
     if ( rmode == HINT_MODE_UNHINTED )
       load_flags |= FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP;
 
+    if ( !column->use_global_advance_width )
+      load_flags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
+
     for ( ; *p; p++ )
     {
       FT_UInt       gindex;
@@ -571,26 +591,52 @@
 
       if ( !column->use_lcd_filter )
         msg = "gray rendering";
+      else if ( column->use_custom_lcd_filter )
+      {
+        int             fwi = column->fw_index;
+        unsigned char  *fw  = column->filter_weights;
+
+
+        msg = "";
+
+        sprintf( temp,
+                 "%s0x%02X%s0x%02X%s0x%02X%s0x%02X%s0x%02X%s",
+                 fwi == 0 ? "[" : " ",
+                   fw[0],
+                 fwi == 0 ? "]" : ( fwi == 1 ? "[" : " " ),
+                   fw[1],
+                 fwi == 1 ? "]" : ( fwi == 2 ? "[" : " " ),
+                   fw[2],
+                 fwi == 2 ? "]" : ( fwi == 3 ? "[" : " " ),
+                   fw[3],
+                 fwi == 3 ? "]" : ( fwi == 4 ? "[" : " " ),
+                   fw[4],
+                 fwi == 4 ? "]" : " " );
+        state->display.disp_text( disp, left, bottom + 15, temp );
+      }
       else switch ( column->lcd_filter )
       {
       case FT_LCD_FILTER_NONE:
-        msg = "lcd without filtering";
+        msg = "LCD without filtering";
         break;
       case FT_LCD_FILTER_DEFAULT:
-        msg = "default lcd filter";
+        msg = "default LCD filter";
         break;
       case FT_LCD_FILTER_LIGHT:
-        msg = "light lcd filter";
+        msg = "light LCD filter";
         break;
       default:
-        msg = "legacy lcd filter";
+        msg = "legacy LCD filter";
       }
       state->display.disp_text( disp, left, bottom + 15, msg );
 
-      sprintf(temp, "%s / %s",
-              column->use_kerning ? "kerning" : "no kerning",
-              column->use_deltas  ? "deltas"  : "no deltas" );
-      msg = column->use_kerning ? "use kerning" : "no kerning";
+      sprintf(temp, "%s %s %s",
+              column->use_kerning ? "+kern"
+                                  : "-kern",
+              column->use_deltas ? "+delta"
+                                 : "-delta",
+              column->use_global_advance_width ? "+advance"
+                                               : "-advance" );
       state->display.disp_text( disp, left, bottom + 25, temp );
 
       if ( state->col == idx )
@@ -714,14 +760,14 @@
                        int          pitch,
                        void*        buffer )
   {
-    ADisplay  display = _display;
+    ADisplay  display = (ADisplay)_display;
     grBitmap  glyph;
 
 
     glyph.width  = width;
     glyph.rows   = height;
     glyph.pitch  = pitch;
-    glyph.buffer = buffer;
+    glyph.buffer = (unsigned char*)buffer;
     glyph.grays  = 256;
     glyph.mode   = gr_pixel_mode_mono;
 
@@ -741,7 +787,7 @@
                       int          y,
                       const char*  msg )
   {
-    ADisplay  adisplay = _display;
+    ADisplay  adisplay = (ADisplay)_display;
 
 
     grWriteCellString( adisplay->bitmap, x, y, msg,
@@ -766,7 +812,7 @@
   static void
   event_help( RenderState  state )
   {
-    ADisplay  display = state->display.disp;
+    ADisplay  display = (ADisplay)state->display.disp;
     grEvent   dummy_event;
 
 
@@ -784,24 +830,24 @@
     grLn();
     grWriteln( "Use the following keys:" );
     grLn();
-    grWriteln( "  F1 or ?    : display this help screen" );
+    grWriteln( "  F1, ?       display this help screen" );
+    grLn();
+    grWriteln( "  n, p        select previous/next font" );
     grLn();
-    grWriteln( "  n          : jump to next font file in arguments list" );
-    grWriteln( "  p          : jump to previous font file in arguments list" );
+    grWriteln( "  1, 2, 3     select left, middle, or right column" );
+    grWriteln( "  a           toggle `ignore global advance width flag'" );
+    grWriteln( "  d           toggle lsb/rsb deltas" );
+    grWriteln( "  h           toggle hinting mode" );
+    grWriteln( "  k           toggle kerning" );
+    grWriteln( "  g, v        adjust gamma value" );
+    grWriteln( "  r           toggle rendering mode" );
     grLn();
-    grWriteln( "  g          : increase gamma by 0.1" );
-    grWriteln( "  v          : decrease gamma by 0.1" );
+    grWriteln( "  l           change LCD filter type" );
+    grWriteln( "  [, ]        select custom LCD filter weight" );
+    grWriteln( "  -, +(=)     adjust selected custom LCD filter weight");
     grLn();
-    grWriteln( "  1-3        : change currently selected column" );
-    grWriteln( "  k          : toggle kerning" );
-    grWriteln( "  d          : toggle lsb/rsb deltas" );
-    grWriteln( "  h          : toggle hinting mode" );
-    grWriteln( "  r          : toggle rendering mode" );
-    grWriteln( "  l          : change LCD filter type" );
-    grWriteln( "  Up         : increase pointsize by 0.5 unit" );
-    grWriteln( "  Down       : decrease pointsize by 0.5 unit" );
-    grWriteln( "  Page Up    : increase pointsize by 5 units" );
-    grWriteln( "  Page Down  : decrease pointsize by 5 units" );
+    grWriteln( "  Up, Down    adjust pointsize by 0.5 unit" );
+    grWriteln( "  PgUp, PgDn  adjust pointsize by 5 units" );
     grLn();
     grWriteln( "press any key to exit this help screen" );
 
@@ -814,7 +860,7 @@
   event_change_gamma( RenderState  state,
                       double       delta )
   {
-    ADisplay  display = state->display.disp;
+    ADisplay  display = (ADisplay)state->display.disp;
 
 
     adisplay_change_gamma( display, delta );
@@ -878,11 +924,43 @@
       sprintf( state->message0, "column %d selected", state->col + 1 );
       break;
 
-    case grKEY( 'k' ):
-      column->use_kerning = !column->use_kerning;
-      state->message      = column->use_kerning
-                              ? (char *)"using kerning"
-                              : (char *)"ignoring kerning";
+    case grKeyUp:
+      event_change_size( state, +0.5 );
+      break;
+
+    case grKeyDown:
+      event_change_size( state, -0.5 );
+      break;
+
+    case grKeyPageUp:
+      event_change_size( state, +5. );
+      break;
+
+    case grKeyPageDown:
+      event_change_size( state, -5. );
+      break;
+
+    case grKEY( '1' ):
+      state->col     = 0;
+      state->message = (char *)"column 1 selected";
+      break;
+
+    case grKEY( '2' ):
+      state->col     = 1;
+      state->message = (char *)"column 2 selected";
+      break;
+
+    case grKEY( '3' ):
+      state->col     = 2;
+      state->message = (char *)"column 3 selected";
+      break;
+
+    case grKEY( 'a' ):
+      column->use_global_advance_width
+                     = !column->use_global_advance_width;
+      state->message = column->use_global_advance_width
+                         ? (char *)"using global advance width"
+                         : (char *)"ignoring global advance width";
       break;
 
     case grKEY( 'd' ):
@@ -892,6 +970,25 @@
                              : (char *)"ignoring rsb/lsb deltas";
       break;
 
+    case grKEY( 'g' ):
+      event_change_gamma( state, +0.1 );
+      break;
+
+    case grKEY( 'h' ):
+      column->hint_mode =
+        (HintMode)( ( column->hint_mode + 1 ) % HINT_MODE_MAX );
+      state->message = state->message0;
+      sprintf( state->message0, "column %d is %s",
+               state->col + 1, render_mode_names[column->hint_mode] );
+      break;
+
+    case grKEY( 'k' ):
+      column->use_kerning = !column->use_kerning;
+      state->message      = column->use_kerning
+                              ? (char *)"using kerning"
+                              : (char *)"ignoring kerning";
+      break;
+
     case grKEY( 'l' ):
       switch ( column->lcd_filter )
       {
@@ -901,8 +998,17 @@
         break;
 
       case FT_LCD_FILTER_DEFAULT:
-        column->lcd_filter = FT_LCD_FILTER_LIGHT;
-        state->message     = (char *)"using light LCD filter";
+        if ( !column->use_custom_lcd_filter )
+        {
+          column->use_custom_lcd_filter = 1;
+          state->message                = (char*)"using custom LCD filter";
+        }
+        else
+        {
+          column->use_custom_lcd_filter = 0;
+          column->lcd_filter            = FT_LCD_FILTER_LIGHT;
+          state->message                = (char *)"using light LCD filter";
+        }
         break;
 
       case FT_LCD_FILTER_LIGHT:
@@ -920,66 +1026,57 @@
       }
       break;
 
-    case grKEY( '1' ):
-      state->col     = 0;
-      state->message = (char *)"column 1 selected";
-      break;
-
-    case grKEY( '2' ):
-      state->col     = 1;
-      state->message = (char *)"column 2 selected";
-      break;
-
-    case grKEY( '3' ):
-      state->col     = 2;
-      state->message = (char *)"column 3 selected";
+    case grKEY( 'n' ):
+      render_state_set_file( state, state->face_index + 1 );
       break;
 
-    case grKEY( 'h' ):
-      column->hint_mode = ( column->hint_mode + 1 ) % HINT_MODE_MAX;
-      state->message    = state->message0;
-      sprintf( state->message0, "column %d is %s",
-               state->col + 1, render_mode_names[column->hint_mode] );
+    case grKEY( 'p' ):
+      render_state_set_file( state, state->face_index - 1 );
       break;
 
     case grKEY( 'r' ):
       column->use_lcd_filter = !column->use_lcd_filter;
       state->message         = state->message0;
       sprintf( state->message0, "column %d is using %s",
-               state->col + 1, column->use_lcd_filter ? "lcd filtering"
+               state->col + 1, column->use_lcd_filter ? "LCD filtering"
                                                       : "gray rendering" );
       break;
 
-    case grKEY( 'n' ):
-      render_state_set_file( state, state->face_index + 1 );
+    case grKEY( 'v' ):
+      event_change_gamma( state, -0.1 );
       break;
 
-    case grKEY( 'p' ):
-      render_state_set_file( state, state->face_index - 1 );
-      break;
+    case grKEY( '[' ):
+      if ( !column->use_custom_lcd_filter )
+        break;
 
-    case grKEY( 'g' ):
-      event_change_gamma( state, +0.1 );
+      column->fw_index--;
+      if ( column->fw_index < 0 )
+        column->fw_index = 4;
       break;
 
-    case grKEY( 'v' ):
-      event_change_gamma( state, -0.1 );
-      break;
+    case grKEY( ']' ):
+      if ( !column->use_custom_lcd_filter )
+        break;
 
-    case grKeyUp:
-      event_change_size( state, +0.5 );
+      column->fw_index++;
+      if ( column->fw_index > 4 )
+        column->fw_index = 0;
       break;
 
-    case grKeyDown:
-      event_change_size( state, -0.5 );
-      break;
+    case grKEY( '-' ):
+      if ( !column->use_custom_lcd_filter )
+        break;
 
-    case grKeyPageUp:
-      event_change_size( state, +5. );
+      column->filter_weights[column->fw_index]--;
       break;
 
-    case grKeyPageDown:
-      event_change_size( state, -5. );
+    case grKEY( '+' ):
+    case grKEY( '=' ):
+      if ( !column->use_custom_lcd_filter )
+        break;
+
+      column->filter_weights[column->fw_index]++;
       break;
 
     default:
@@ -1015,7 +1112,7 @@
   static void
   write_message( RenderState  state )
   {
-    ADisplay  adisplay = state->display.disp;
+    ADisplay  adisplay = (ADisplay)state->display.disp;
 
 
     if ( state->message == NULL )
@@ -1034,11 +1131,11 @@
 
       state->message = state->message0;
       if ( total > 1 )
-        sprintf( state->message0, "%s %d/%d @ %5.1fpt",
+        sprintf( state->message0, "%.100s %d/%d @ %5.1fpt",
                  state->filename, idx + 1, total,
                  state->char_size );
       else
-        sprintf( state->message0, "%s @ %5.1fpt",
+        sprintf( state->message0, "%.100s @ %5.1fpt",
                  state->filename,
                  state->char_size );
     }
@@ -1114,7 +1211,7 @@
         tsize = ftell( tfile );
 
         fseek( tfile, 0, SEEK_SET );
-        text = malloc( tsize + 1 );
+        text = (unsigned char*)malloc( tsize + 1 );
 
         if ( text != NULL )
         {
--- src/ftdump.c
+++ src/ftdump.c
@@ -12,6 +12,7 @@
 #include FT_FREETYPE_H
 #include FT_SFNT_NAMES_H
 #include FT_TRUETYPE_IDS_H
+#include FT_TRUETYPE_TABLES_H
 
   /* the following header shouldn't be used in normal programs */
 #include FT_INTERNAL_DEBUG_H
@@ -508,10 +509,11 @@
 
     for( i = 0; i < face->num_charmaps; i++ )
     {
-      printf( "   %d: platform %d, encoding %d",
+      printf( "   %d: platform %d, encoding %d, language %d",
               i,
               face->charmaps[i]->platform_id,
-              face->charmaps[i]->encoding_id );
+              face->charmaps[i]->encoding_id,
+              (FT_UInt)FT_Get_CMap_Language_ID( face->charmaps[i] ) );
       if ( i == active )
         printf( " (active)" );
       printf ( "\n" );
--- src/ftgrid.c
+++ src/ftgrid.c
@@ -2,7 +2,7 @@
 /*                                                                          */
 /*  The FreeType project -- a free and portable quality TrueType renderer.  */
 /*                                                                          */
-/*  Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007 by                    */
+/*  Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by        */
 /*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
 /*                                                                          */
 /*                                                                          */
@@ -40,15 +40,27 @@
 #endif
 
 
-int   _af_debug;
-int   _af_debug_disable_horz_hints;
-int   _af_debug_disable_vert_hints;
-int   _af_debug_disable_blue_hints;
-void* _af_debug_hints;
-
-extern void af_glyph_hints_dump_segments( void*  hints );
-extern void af_glyph_hints_dump_points( void*  hints );
-extern void af_glyph_hints_dump_edges( void*  hints );
+/* these variables, structures and declarations  are for  */
+/* communication with the debugger in the autofit module; */
+/* normal programs don't need this                        */
+struct  AF_GlyphHintsRec_;
+typedef struct AF_GlyphHintsRec_*  AF_GlyphHints;
+
+int            _af_debug;
+int            _af_debug_disable_horz_hints;
+int            _af_debug_disable_vert_hints;
+int            _af_debug_disable_blue_hints;
+AF_GlyphHints  _af_debug_hints;
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+extern void af_glyph_hints_dump_segments( AF_GlyphHints  hints );
+extern void af_glyph_hints_dump_points( AF_GlyphHints  hints );
+extern void af_glyph_hints_dump_edges( AF_GlyphHints  hints );
+#ifdef __cplusplus
+  }
+#endif
 
 typedef struct  status_
 {
@@ -177,8 +189,8 @@
 static void
 grid_status_draw_grid( GridStatus  st )
 {
-  int     x_org   = st->x_origin;
-  int     y_org   = st->y_origin;
+  int     x_org   = (int)st->x_origin;
+  int     y_org   = (int)st->y_origin;
   double  xy_incr = 64.0 * st->scale;
 
   if ( xy_incr >= 2. )
@@ -295,7 +307,7 @@
   bitm.pitch      = bitm.width;
   bitm.num_grays  = 256;
   bitm.pixel_mode = FT_PIXEL_MODE_GRAY;
-  bitm.buffer     = calloc( bitm.pitch, bitm.rows );
+  bitm.buffer     = (unsigned char*)calloc( bitm.pitch, bitm.rows );
 
   FT_Outline_Translate( &transformed, -cbox.xMin, -cbox.yMin );
   FT_Outline_Get_Bitmap( handle->library, &transformed, &bitm );
@@ -318,7 +330,7 @@
 {
   char*       tag;
   FT_Vector*  vec;
-  FT_F26Dot6  disp = radius*0.6781;
+  FT_F26Dot6  disp = (FT_F26Dot6)( radius * 0.6781 );
 
   FT_Outline_New( handle->library, 12, 1, outline );
   outline->n_points   = 12;
@@ -371,8 +383,8 @@
   FT_Size            size;
   FT_GlyphSlot       slot;
   double             scale = 64.0 * st->scale;
-  int                ox    = st->x_origin;
-  int                oy    = st->y_origin;
+  int                ox    = (int)st->x_origin;
+  int                oy    = (int)st->y_origin;
 
 
   if ( stroker == NULL )
@@ -388,8 +400,9 @@
   _af_debug_disable_horz_hints = !st->do_horz_hints;
   _af_debug_disable_vert_hints = !st->do_vert_hints;
 
-  FT_Load_Glyph( size->face, st->Num,
-                 handle->load_flags | FT_LOAD_NO_BITMAP );
+  if ( FT_Load_Glyph( size->face, st->Num,
+                      handle->load_flags | FT_LOAD_NO_BITMAP ) )
+    return;
 
   slot = size->face->glyph;
   if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
@@ -424,8 +437,8 @@
     if ( st->do_dots )
     {
       for (nn = 0; nn < gimage->n_points; nn++)
-        circle_draw( st->x_origin * 64 + gimage->points[nn].x,
-                     st->y_origin * 64 - gimage->points[nn].y,
+        circle_draw( (FT_F26Dot6)( st->x_origin * 64 + gimage->points[nn].x ),
+                     (FT_F26Dot6)( st->y_origin * 64 - gimage->points[nn].y ),
                      128,
                      handle,
                      display,
@@ -774,22 +787,22 @@
       switch ( error_code )
       {
       case FT_Err_Ok:
-        sprintf( status.header_buffer, "%s %s (file `%s')",
+        sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')",
                  face->family_name, face->style_name, basename );
         break;
 
       case FT_Err_Invalid_Pixel_Size:
-        sprintf( status.header_buffer, "Invalid pixel size (file `%s')",
+        sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')",
                  basename );
         break;
 
       case FT_Err_Invalid_PPem:
-        sprintf( status.header_buffer, "Invalid ppem value (file `%s')",
+        sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')",
                  basename );
         break;
 
       default:
-        sprintf( status.header_buffer, "File `%s': error 0x%04x",
+        sprintf( status.header_buffer, "File `%.100s': error 0x%04x",
                  basename, (FT_UShort)error_code );
         break;
       }
--- src/ftmulti.c
+++ src/ftmulti.c
@@ -2,7 +2,7 @@
 /*                                                                          */
 /*  The FreeType project -- a free and portable quality TrueType renderer.  */
 /*                                                                          */
-/*  Copyright 1996-2000, 2003, 2004, 2005 by                                */
+/*  Copyright 1996-2000, 2003, 2004, 2005, 2010 by                          */
 /*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
 /*                                                                          */
 /*                                                                          */
@@ -34,7 +34,7 @@
 
 #define  MAXPTSIZE  500                 /* dtp */
 
-  char  Header[128];
+  char  Header[256];
   char* new_header = 0;
 
   const unsigned char*  Text = (unsigned char*)
@@ -795,7 +795,7 @@
           Render_All( Num, ptsize );
         }
 
-        sprintf( Header, "%s %s (file %s)",
+        sprintf( Header, "%.50s %.50s (file %.100s)",
                          face->family_name,
                          face->style_name,
                          ft_basename( argv[file] ) );
@@ -816,10 +816,10 @@
             char  temp[32];
 
 
-            sprintf( temp, "  %s:%g",
+            sprintf( temp, "  %50s:%g",
                            multimaster->axis[n].name,
-                           design_pos[n]/65536. );
-            strcat( Header, temp );
+                           design_pos[n] / 65536.0 );
+            strncat( Header, temp, sizeof( Header ) - 1 );
           }
         }
         grWriteCellString( &bit, 0, 16, Header, fore_color );
@@ -830,7 +830,7 @@
       }
       else
       {
-        sprintf( Header, "%s: not an MM font file, or could not be opened",
+        sprintf( Header, "%.100s: not an MM font file, or could not be opened",
                          ft_basename( argv[file] ) );
       }
 
--- src/ftstring.c
+++ src/ftstring.c
@@ -2,7 +2,7 @@
 /*                                                                          */
 /*  The FreeType project -- a free and portable quality TrueType renderer.  */
 /*                                                                          */
-/*  Copyright 1996-2002, 2003, 2004, 2005, 2006, 2007 by                    */
+/*  Copyright 1996-2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by        */
 /*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
 /*                                                                          */
 /*                                                                          */
@@ -135,7 +135,7 @@
     FTDemo_Set_Current_Charsize( handle, status.ptsize, status.res );
     FTDemo_Update_Current_Flags( handle );
 
-    FTDemo_String_Set( handle, (unsigned char*)Text );
+    FTDemo_String_Set( handle, Text );
   }
 
 
@@ -413,19 +413,20 @@
       switch ( error_code )
       {
       case FT_Err_Ok:
-        sprintf( status.header_buffer, "%s %s (file `%s')", face->family_name,
+        sprintf( status.header_buffer,
+                 "%.50s %.50s (file `%.100s')", face->family_name,
                  face->style_name, basename );
         break;
       case FT_Err_Invalid_Pixel_Size:
-        sprintf( status.header_buffer, "Invalid pixel size (file `%s')",
+        sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')",
                  basename );
         break;
       case FT_Err_Invalid_PPem:
-        sprintf( status.header_buffer, "Invalid ppem value (file `%s')",
+        sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')",
                  basename );
         break;
       default:
-        sprintf( status.header_buffer, "File `%s': error 0x%04x", basename,
+        sprintf( status.header_buffer, "File `%.100s': error 0x%04x", basename,
             (FT_UShort)error_code );
         break;
       }
--- src/ftvalid.c
+++ src/ftvalid.c
@@ -67,6 +67,7 @@
     MAKE_TABLE_SPEC( GPOS ),
     MAKE_TABLE_SPEC( GSUB ),
     MAKE_TABLE_SPEC( JSTF ),
+    MAKE_TABLE_SPEC( MATH ),
   };
 #define N_OT_TABLE_SPEC  ( sizeof ( ot_table_spec ) / sizeof ( TableSpecRec ) )
 
@@ -222,17 +223,21 @@
     fprintf( stderr, "\n" );
     fprintf( stderr, "Usage: %s [options] fontfile\n", execname );
     fprintf( stderr, "\n" );
-    fprintf( stderr, "  -t validator              select validator. \n");
-    fprintf( stderr, "                            Available validators: ");
+    fprintf( stderr, "  -f index                  Select font index (default: 0).\n" );
+    fprintf( stderr, "\n" );
+    fprintf( stderr, "  -t validator              Select validator.\n" );
+    fprintf( stderr, "                            Available validators: " );
     for ( i = 0; i < LAST_VALIDATE; i++ )
     {
       v = &validators[i];
-      fprintf( stderr, "\"%s\"%s ", v->symbol, v->is_implemented( library )? "": "(NOT IMPLEMENTED)");
+      fprintf( stderr, "\"%s\"%s ",
+               v->symbol, v->is_implemented( library )? ""
+                                                      : "(NOT IMPLEMENTED)" );
     }
     fprintf( stderr, "\n");
 
     fprintf( stderr, "\n" );
-    fprintf( stderr, "  -T \"sfnt:tabl:enam:es  \"  select snft table names to be \n" );
+    fprintf( stderr, "  -T \"sfnt:tabl:enam:es  \"  Select snft table names to be\n" );
     fprintf( stderr, "                            validated. `:' is for separating table names.\n" );
     fprintf( stderr, "\n" );
 
@@ -255,10 +260,10 @@
       fprintf( stderr, "\n" );
     }
 
-    fprintf( stderr, "  -T \"ms:apple\"             [ckern] select (a) classic kern dialect(s) for \n" );
+    fprintf( stderr, "  -T \"ms:apple\"             [ckern] Select (a) classic kern dialect(s) for\n" );
     fprintf( stderr, "                            validation. `:' is for separating dialect names.\n" );
     fprintf( stderr, "                            If more than one dialects is specified, all\n" );
-    fprintf( stderr, "                            dialects are accepted when validating. \n" );
+    fprintf( stderr, "                            dialects are accepted when validating.\n" );
 
     fprintf( stderr, "\n" );
     fprintf( stderr, "                            Supported dialects in ckern validator are:\n" );
@@ -266,16 +271,16 @@
 
     fprintf( stderr, "\n" );
     fprintf( stderr, "\n" );
-    fprintf( stderr, "  -L                        list the layout related SFNT tables\n" );
+    fprintf( stderr, "  -L                        List the layout related SFNT tables\n" );
     fprintf( stderr, "                            available in the font file. Choice of\n" );
     fprintf( stderr, "                            validator with -t option affects on the\n" );
     fprintf( stderr, "                            listing.\n" );
     fprintf( stderr, "\n" );
     fprintf( stderr, "                            ckern is applicable to kern table. -L lists\n");
-    fprintf( stderr, "                            dialects supported in ckern validator only if \n" );
+    fprintf( stderr, "                            dialects supported in ckern validator only if\n" );
     fprintf( stderr, "                            kern table is available in the font file.\n" );
     fprintf( stderr, "\n" );
-    fprintf( stderr, "  -v validation_level       validation level. \n" );
+    fprintf( stderr, "  -v validation_level       Validation level.\n" );
     fprintf( stderr, "                            validation_level = 0...2\n" );
     fprintf( stderr, "                            (0: default, 1: tight, 2: paranoid)\n" );
 
@@ -493,9 +498,9 @@
     {
       printf( "[%s:%s] layout tables are invalid.\n",
               execname, validators[validator].symbol );
-      printf( "[%s:%s] set FT2_DEBUG environment variable to \n",
+      printf( "[%s:%s] set FT2_DEBUG environment variable to\n",
               execname, validators[validator].symbol );
-      printf( "[%s:%s] know the validation detail. \n",
+      printf( "[%s:%s] know the validation detail.\n",
               execname, validators[validator].symbol );
     }
   }
@@ -715,6 +720,7 @@
 #if 0
     int  trace_level;
 #endif  /* 0 */
+    int  font_index = 0;
 
     execname = ft_basename( argv[0] );
 
@@ -739,7 +745,7 @@
 
     while ( 1 )
     {
-      option = getopt( argc, argv, "t:T:Lv:l:" );
+      option = getopt( argc, argv, "t:T:Lv:l:f:" );
 
       if ( option == -1 )
         break;
@@ -785,6 +791,10 @@
         }
         break;
 
+      case 'f':
+        font_index = atoi( optarg );
+        break;
+
       default:
         print_usage( NULL );
         break;
@@ -839,7 +849,7 @@
 
 
       /* TODO: Multiple faces in a font file? */
-      error = FT_New_Face( library, fontfile, 0, &face );
+      error = FT_New_Face( library, fontfile, font_index, &face );
       if ( error )
         panic( error, "Could not open face." );
 
--- src/ftview.c
+++ src/ftview.c
@@ -2,7 +2,7 @@
 /*                                                                          */
 /*  The FreeType project -- a free and portable quality TrueType renderer.  */
 /*                                                                          */
-/*  Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007 by                    */
+/*  Copyright 1996-2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by        */
 /*  D. Turner, R.Wilhelm, and W. Lemberg                                    */
 /*                                                                          */
 /*                                                                          */
@@ -33,23 +33,24 @@
 #ifdef CEIL
 #undef CEIL
 #endif
-#define CEIL( x )   ( ( (x) + 63 ) >> 6 )
+#define CEIL( x )  ( ( (x) + 63 ) >> 6 )
 
-#define INIT_SIZE( size, start_x, start_y, step_x, step_y, x, y )        \
-          do {                                                           \
-            start_x = 4;                                                 \
-            start_y = CEIL( size->metrics.height ) + 2 * HEADER_HEIGHT;  \
-            step_x  = CEIL( size->metrics.max_advance );                 \
-            step_y  = CEIL( size->metrics.height ) + 4;                  \
-                                                                         \
-            x = start_x;                                                 \
-            y = start_y;                                                 \
+#define INIT_SIZE( size, start_x, start_y, step_x, step_y, x, y )       \
+          do {                                                          \
+            start_x = 4;                                                \
+            start_y = CEIL( size->metrics.height ) + 3 * HEADER_HEIGHT; \
+            step_x  = CEIL( size->metrics.max_advance );                \
+            step_y  = CEIL( size->metrics.height ) + 4;                 \
+                                                                        \
+            x = start_x;                                                \
+            y = start_y;                                                \
           } while ( 0 )
 
-#define X_TOO_LONG( x, size, display) \
-          ( ( x ) + ( ( size )->metrics.max_advance >> 6 ) > ( display )->bitmap->width )
-#define Y_TOO_LONG( y, size, display) \
-          ( ( y ) >= ( display )->bitmap->rows )
+#define X_TOO_LONG( x, size, display )                   \
+          ( (x) + ( (size)->metrics.max_advance >> 6 ) > \
+            (display)->bitmap->width )
+#define Y_TOO_LONG( y, size, display )       \
+          ( (y) >= (display)->bitmap->rows )
 
 #ifdef _WIN32
 #define snprintf  _snprintf
@@ -60,6 +61,7 @@
   {
     RENDER_MODE_ALL = 0,
     RENDER_MODE_EMBOLDEN,
+    RENDER_MODE_SLANTED,
     RENDER_MODE_STROKE,
     RENDER_MODE_TEXT,
     RENDER_MODE_WATERFALL,
@@ -68,24 +70,33 @@
 
   static struct  status_
   {
-    int          render_mode;
-    FT_Encoding  encoding;
-    int          res;
-    int          ptsize;            /* current point size, 26.6 format */
-    int          lcd_mode;
-    double       gamma;
-
-    int          debug;
-    int          trace_level;
-    int          font_index;
-    int          dump_cache_stats;  /* do we need to dump cache statistics? */
-    int          Num;               /* current first index */
-    char*        header;
-    char         header_buffer[256];
-    int          Fail;
-    int          preload;
-
-  } status = { RENDER_MODE_ALL, FT_ENCODING_NONE, 72, 48, -1, 1.0, 0, 0, 0, 0, 0, NULL, { 0 }, 0, 0 };
+    int            render_mode;
+    FT_Encoding    encoding;
+    int            res;
+    int            ptsize;            /* current point size, 26.6 format */
+    int            lcd_mode;
+    double         gamma;
+    double         bold_factor;
+    double         slant;
+
+    int            debug;
+    int            trace_level;
+    int            font_index;
+    int            dump_cache_stats;  /* do we need to dump cache statistics? */
+    int            Num;               /* current first index */
+    char*          header;
+    char           header_buffer[256];
+    int            Fail;
+    int            preload;
+
+    int            use_custom_lcd_filter;
+    unsigned char  filter_weights[5];
+    int            fw_index;
+
+  } status = { RENDER_MODE_ALL, FT_ENCODING_NONE, 72, 48, -1,
+               1.0, 0.04, 0.22,
+               0, 0, 0, 0, 0, NULL, { 0 }, 0, 0,
+               0, "\x10\x40\x70\x40\x10", 2 };
 
 
   static FTDemo_Display*  display;
@@ -93,15 +104,15 @@
 
 
   static const unsigned char*  Text = (unsigned char*)
-    "The quick brown fox jumps over the lazy dog 0123456789 "
-    "\342\352\356\373\364\344\353\357\366\374\377\340\371\351\350\347 "
-    "&#~\"\'(-`_^@)=+\260 ABCDEFGHIJKLMNOPQRSTUVWXYZ "
-    "$\243^\250*\265\371%!\247:/;.,?<>";
+    "The quick brown fox jumps over the lazy dog 0123456789"
+    " \342\352\356\373\364\344\353\357\366\374\377\340\371\351\350\347"
+    " &#~\"\'(-`_^@)=+\260 ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+    " $\243^\250*\265\371%!\247:/;.,?<>";
 
 
 
   static void
-  Fatal( const char* message )
+  Fatal( const char*  message )
   {
     FTDemo_Display_Done( display );
     FTDemo_Done( handle );
@@ -159,6 +170,7 @@
       {
         FT_Glyph  glyph;
 
+
         error = FT_Get_Glyph( slot, &glyph );
         if ( error )
           goto Next;
@@ -186,7 +198,7 @@
       }
       else
       {
-Next:
+    Next:
         status.Fail++;
       }
 
@@ -202,12 +214,12 @@
 
 
   static FT_Error
-  Render_Embolden( int  num_indices,
-                   int  first_index )
+  Render_Slanted( int  num_indices,
+                  int  first_index )
   {
-    int       start_x, start_y, step_x, step_y, x, y;
-    int       i;
-    FT_Size   size;
+    int      start_x, start_y, step_x, step_y, x, y;
+    int      i;
+    FT_Size  size;
 
 
     error = FTDemo_Get_Size( handle, &size );
@@ -224,8 +236,9 @@
 
     while ( i < num_indices )
     {
-      int           gindex;
-      FT_Face       face = size->face;
+      int      gindex;
+      FT_Face  face = size->face;
+
 
       if ( handle->encoding == FT_ENCODING_NONE )
         gindex = i;
@@ -235,7 +248,32 @@
       error = FT_Load_Glyph( face, gindex, handle->load_flags );
       if ( !error )
       {
-        FT_GlyphSlot_Embolden( face->glyph );
+        FT_Matrix    shear;
+        FT_Outline*  outline;
+
+
+        /***************************************************************/
+        /*                                                             */
+        /*  2*2 affine transformation matrix, 16.16 fixed float format */
+        /*                                                             */
+        /*  Shear matrix:                                              */
+        /*                                                             */
+        /*         | x' |     | 1  k |   | x |          x' = x + ky    */
+        /*         |    |  =  |      | * |   |   <==>                  */
+        /*         | y' |     | 0  1 |   | y |          y' = y         */
+        /*                                                             */
+        /*        outline'     shear    outline                        */
+        /*                                                             */
+        /***************************************************************/
+
+        shear.xx = 1 << 16;
+        shear.xy = (FT_Fixed)( status.slant * ( 1 << 16 ) );
+        shear.yx = 0;
+        shear.yy = 1 << 16;
+
+        outline = &(face->glyph)->outline;
+
+        FT_Outline_Transform( outline, &shear );
 
         error = FTDemo_Draw_Slot( handle, display, face->glyph, &x, &y );
 
@@ -261,12 +299,128 @@
 
 
   static FT_Error
+  Render_Embolden( int  num_indices,
+                   int  first_index )
+  {
+    int      start_x, start_y, step_x, step_y, x, y;
+    int      i;
+    FT_Size  size;
+
+
+    error = FTDemo_Get_Size( handle, &size );
+
+    if ( error )
+    {
+      /* probably a non-existent bitmap font size */
+      return error;
+    }
+
+    INIT_SIZE( size, start_x, start_y, step_x, step_y, x, y );
+
+    i = first_index;
+
+    while ( i < num_indices )
+    {
+      int      gindex;
+      FT_Face  face = size->face;
+
+
+      if ( handle->encoding == FT_ENCODING_NONE )
+        gindex = i;
+      else
+        gindex = FTDemo_Get_Index( handle, i );
+
+      error = FT_Load_Glyph( face, gindex, handle->load_flags );
+      if ( !error )
+      {
+        /* this is essentially the code of function */
+        /* `FT_GlyphSlot_Embolden'                  */
+
+        FT_GlyphSlot  slot    = face->glyph;
+        FT_Library    library = slot->library;
+        FT_Pos        xstr, ystr;
+
+
+        if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
+             slot->format != FT_GLYPH_FORMAT_BITMAP )
+          goto Next;
+
+        xstr = FT_MulFix( face->units_per_EM,
+                          face->size->metrics.y_scale );
+        xstr = (FT_Fixed)( xstr * status.bold_factor );
+        ystr = xstr;
+
+        if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
+        {
+          error = FT_Outline_Embolden( &slot->outline, xstr );
+          /* ignore error */
+
+          xstr = xstr * 2;
+          ystr = xstr;
+        }
+        else if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
+        {
+          /* round to full pixels */
+          xstr &= ~63;
+          ystr &= ~63;
+
+          error = FT_GlyphSlot_Own_Bitmap( slot );
+          if ( error )
+            goto Next;
+
+          error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr );
+          if ( error )
+            goto Next;
+        }
+
+        if ( slot->advance.x )
+          slot->advance.x += xstr;
+
+        if ( slot->advance.y )
+          slot->advance.y += ystr;
+
+        slot->metrics.width        += xstr;
+        slot->metrics.height       += ystr;
+        slot->metrics.horiBearingY += ystr;
+        slot->metrics.horiAdvance  += xstr;
+        slot->metrics.vertBearingX -= xstr / 2;
+        slot->metrics.vertBearingY += ystr;
+        slot->metrics.vertAdvance  += ystr;
+
+        if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
+          slot->bitmap_top += ystr >> 6;
+
+        error = FTDemo_Draw_Slot( handle, display, slot, &x, &y );
+
+        if ( error )
+          goto Next;
+        else if ( X_TOO_LONG( x, size, display ) )
+        {
+          x  = start_x;
+          y += step_y;
+
+          if ( Y_TOO_LONG( y, size, display ) )
+            break;
+        }
+      }
+      else
+    Next:
+        status.Fail++;
+
+      i++;
+    }
+
+    return error;
+  }
+
+
+  static FT_Error
   Render_All( int  num_indices,
               int  first_index )
   {
-    int         start_x, start_y, step_x, step_y, x, y;
-    int         i;
-    FT_Size     size;
+    int      start_x, start_y, step_x, step_y, x, y;
+    int      i;
+    FT_Size  size;
 
 
     error = FTDemo_Get_Size( handle, &size );
@@ -296,7 +450,7 @@
         status.Fail++;
       else if ( X_TOO_LONG( x, size, display ) )
       {
-        x  = start_x;
+        x = start_x;
         y += step_y;
 
         if ( Y_TOO_LONG( y, size, display ) )
@@ -318,7 +472,8 @@
     int      i;
     FT_Size  size;
 
-    const unsigned char*  p;
+    const char*  p;
+    const char*  pEnd;
 
 
     num_indices = num_indices;  /* pacify compiler */
@@ -334,20 +489,26 @@
 
     i = first_index;
 
-    p = Text;
+    p    = (const char*)Text;
+    pEnd = p + strlen( (const char*)Text );
 
-    while ( i > 0 && *p )
+    while ( i > 0 )
     {
-      p++;
+      utf8_next( &p, pEnd );
       i--;
     }
 
-    while ( *p && num_indices != 0 )
+    while ( num_indices != 0 )
     {
       FT_UInt  gindex;
+      int      ch;
+
 
+      ch = utf8_next( &p, pEnd );
+      if ( ch < 0 )
+        break;
 
-      gindex = FTDemo_Get_Index( handle, *p );
+      gindex = FTDemo_Get_Index( handle, ch );
 
       error = FTDemo_Draw_Index( handle, display, gindex, &x, &y );
       if ( error )
@@ -367,8 +528,6 @@
         }
       }
 
-      p++;
-
       if ( num_indices > 0 )
         num_indices -= 1;
     }
@@ -380,45 +539,44 @@
   static FT_Error
   Render_Waterfall( int  first_size )
   {
-    int         start_x, start_y, step_x, step_y, x, y;
-    int         pt_size, max_size = 100000;
-    FT_Size     size;
-    FT_Face     face;
+    int      start_x, start_y, step_x, step_y, x, y;
+    int      pt_size, max_size = 100000;
+    FT_Size  size;
+    FT_Face  face;
 
     unsigned char         text[256];
     const unsigned char*  p;
 
 
+    error = FTC_Manager_LookupFace( handle->cache_manager,
+                                    handle->scaler.face_id, &face );
+    if ( error )
     {
-      error = FTC_Manager_LookupFace( handle->cache_manager,
-                                      handle->scaler.face_id, &face );
-      if ( error )
-      {
-        /* can't access the font file. do not render anything */
-        fprintf( stderr, "can't access font file %p\n", (void*)handle->scaler.face_id );
-        return 0;
-      }
+      /* can't access the font file: do not render anything */
+      fprintf( stderr, "can't access font file %p\n",
+               (void*)handle->scaler.face_id );
+      return 0;
+    }
 
-      if ( !FT_IS_SCALABLE( face ) )
-      {
-        int  i;
+    if ( !FT_IS_SCALABLE( face ) )
+    {
+      int  i;
 
 
-        max_size = 0;
-        for ( i = 0; i < face->num_fixed_sizes; i++ )
-          if ( face->available_sizes[i].height >= max_size/64 )
-            max_size = face->available_sizes[i].height*64;
-      }
+      max_size = 0;
+      for ( i = 0; i < face->num_fixed_sizes; i++ )
+        if ( face->available_sizes[i].height >= max_size / 64 )
+          max_size = face->available_sizes[i].height * 64;
     }
 
     start_x = 4;
-    start_y = 2 * HEADER_HEIGHT;
+    start_y = 3 * HEADER_HEIGHT;
 
     for ( pt_size = first_size; pt_size < max_size; pt_size += 64 )
     {
       sprintf( (char*)text,
-                "%g: the quick brown fox jumps over the lazy dog "
-                "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", pt_size/64.0 );
+               "%g: the quick brown fox jumps over the lazy dog"
+               " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", pt_size / 64.0 );
 
       p = text;
 
@@ -491,40 +649,38 @@
     grLn();
     grWriteln( "Use the following keys:" );
     grLn();
-    grWriteln( "  F1 or ?    : display this help screen" );
+    grWriteln( "  F1, ?       display this help screen" );
+    grLn();
+    grWriteln( "  a           toggle anti-aliasing" );
+    grWriteln( "  b           toggle embedded bitmaps" );
+    grWriteln( "  c           toggle between cache modes" );
+    grWriteln( "  f           toggle forced auto-hinting" );
+    grWriteln( "  h           toggle outline hinting" );
+    grWriteln( "  l           toggle low precision rendering" );
     grLn();
-    grWriteln( "  a          : toggle anti-aliasing" );
-    grWriteln( "  b          : toggle embedded bitmaps" );
-    grWriteln( "  c          : toggle between cache modes" );
-    grWriteln( "  f          : toggle forced auto-hinting" );
-    grWriteln( "  h          : toggle outline hinting" );
-    grWriteln( "  l          : toggle low precision rendering" );
+    grWriteln( "  L           cycle through LCD modes" );
+    grWriteln( "  space       cycle through rendering modes" );
+    grWriteln( "  1-6         select rendering mode" );
     grLn();
-    grWriteln( "  L          : cycle through LCD modes" );
-    grWriteln( "  space      : toggle rendering mode" );
-    grWriteln( "  1-5        : select rendering mode" );
+    grWriteln( "  e, E        adjust emboldening" );
+    grWriteln( "  s, S        adjust slanting" );
     grLn();
-    grWriteln( "  G          : show gamma ramp" );
-    grWriteln( "  g          : increase gamma by 0.1" );
-    grWriteln( "  v          : decrease gamma by 0.1" );
+    grWriteln( "  F           toggle custom LCD filter mode" );
+    grWriteln( "  [, ]        select custom LCD filter weight" );
+    grWriteln( "  -, +(=)     adjust selected custom LCD filter weight" );
     grLn();
-    grWriteln( "  n          : next font" );
-    grWriteln( "  p          : previous font" );
+    grWriteln( "  G           show gamma ramp" );
+    grWriteln( "  g, v        adjust gamma value" );
     grLn();
-    grWriteln( "  Up         : increase pointsize by 1 unit" );
-    grWriteln( "  Down       : decrease pointsize by 1 unit" );
-    grWriteln( "  Page Up    : increase pointsize by 10 units" );
-    grWriteln( "  Page Down  : decrease pointsize by 10 units" );
+    grWriteln( "  p, n        select previous/next font" );
     grLn();
-    grWriteln( "  Right      : increment index" );
-    grWriteln( "  Left       : decrement index" );
+    grWriteln( "  Up, Down    adjust pointsize by 1 unit" );
+    grWriteln( "  PgUp, PgDn  adjust pointsize by 10 units" );
     grLn();
-    grWriteln( "  F7         : decrement index by 10" );
-    grWriteln( "  F8         : increment index by 10" );
-    grWriteln( "  F9         : decrement index by 100" );
-    grWriteln( "  F10        : increment index by 100" );
-    grWriteln( "  F11        : decrement index by 1000" );
-    grWriteln( "  F12        : increment index by 1000" );
+    grWriteln( "  Left, Right adjust index by 1" );
+    grWriteln( "  F7, F8      adjust index by 10" );
+    grWriteln( "  F9, F10     adjust index by 100" );
+    grWriteln( "  F11, F12    adjust index by 1000" );
     grLn();
     grWriteln( "press any key to exit this help screen" );
 
@@ -542,8 +698,8 @@
     int      xside  = 10;
     int      levels = 17;
     int      gammas = 30;
-    int      x_0    = (display->bitmap->width - levels*xside)/2;
-    int      y_0    = (display->bitmap->rows  - gammas*(yside+1))/2;
+    int      x_0    = ( display->bitmap->width - levels * xside ) / 2;
+    int      y_0    = ( display->bitmap->rows - gammas * ( yside + 1 ) ) / 2;
     int      pitch  = display->bitmap->pitch;
 
 
@@ -553,18 +709,21 @@
     if ( pitch < 0 )
       pitch = -pitch;
 
-    memset( display->bitmap->buffer, 100, pitch*display->bitmap->rows );
+    memset( display->bitmap->buffer, 100, pitch * display->bitmap->rows );
 
-    grWriteCellString( display->bitmap, 0, 0, "Gamma grid", display->fore_color );
+    grWriteCellString( display->bitmap, 0, 0, "Gamma grid",
+                       display->fore_color );
 
     for ( g = 1; g <= gammas; g += 1 )
     {
-      double ggamma = g / 10.0;
-      char   temp[6];
-      int    y = y_0 + ( yside + 1 ) * ( g - 1 );
-      int    nx, ny;
+      double  ggamma = g / 10.0;
+      char    temp[6];
+      int     y = y_0 + ( yside + 1 ) * ( g - 1 );
+      int     nx, ny;
+
+      unsigned char*  line = display->bitmap->buffer +
+                             y * display->bitmap->pitch;
 
-      unsigned char*  line = display->bitmap->buffer + y * display->bitmap->pitch;
 
       if ( display->bitmap->pitch < 0 )
         line -= display->bitmap->pitch * ( display->bitmap->rows - 1 );
@@ -581,24 +740,25 @@
       {
         unsigned char*  dst = line;
 
+
         for ( nx = 0; nx < levels; nx++, dst += 3 * xside )
         {
-          double  p   = nx/(double)(levels - 1);
+          double  p   = nx / (double)( levels - 1 );
           int     gm  = (int)( 255.0 * pow( p, ggamma ) );
 
+
           memset( dst, gm, xside * 3 );
         }
       }
     }
 
-
     grRefreshSurface( display->surface );
     grListenSurface( display->surface, gr_event_key, &dummy_event );
   }
 
 
   static void
-  event_gamma_change( double delta )
+  event_gamma_change( double  delta )
   {
     status.gamma += delta;
 
@@ -617,23 +777,57 @@
 
 
   static void
-  event_size_change( int delta )
+  event_bold_change( double  delta )
+  {
+    status.bold_factor += delta;
+
+    if ( status.bold_factor > 0.1 )
+      status.bold_factor = 0.1;
+    else if ( status.bold_factor < -0.1 )
+      status.bold_factor = -0.1;
+
+    sprintf( status.header_buffer, "embolding factor changed to %.3f",
+             status.bold_factor );
+
+    status.header = status.header_buffer;
+  }
+
+
+  static void
+  event_slant_change( double  delta )
+  {
+    status.slant += delta;
+
+    if ( status.slant > 1.0 )
+      status.slant = 1.0;
+    else if ( status.slant < -1.0 )
+      status.slant = -1.0;
+
+    sprintf( status.header_buffer, "slanting changed to %.3f",
+             status.slant );
+
+    status.header = status.header_buffer;
+  }
+
+
+  static void
+  event_size_change( int  delta )
   {
     status.ptsize += delta;
 
-    if ( status.ptsize < 64*1 )
-      status.ptsize = 1*64;
-    else if ( status.ptsize > MAXPTSIZE*64 )
-      status.ptsize = MAXPTSIZE*64;
+    if ( status.ptsize < 64 * 1 )
+      status.ptsize = 1 * 64;
+    else if ( status.ptsize > MAXPTSIZE * 64 )
+      status.ptsize = MAXPTSIZE * 64;
 
     FTDemo_Set_Current_Charsize( handle, status.ptsize, status.res );
   }
 
 
   static void
-  event_index_change( int delta )
+  event_index_change( int  delta )
   {
-    int num_indices = handle->current_font->num_indices;
+    int  num_indices = handle->current_font->num_indices;
 
 
     status.Num += delta;
@@ -646,7 +840,7 @@
 
 
   static void
-  event_render_mode_change( int delta )
+  event_render_mode_change( int  delta )
   {
 
     if ( delta )
@@ -665,6 +859,9 @@
     case RENDER_MODE_EMBOLDEN:
       status.header = (char *)"rendering emboldened text";
       break;
+    case RENDER_MODE_SLANTED:
+      status.header = (char *)"rendering slanted text";
+      break;
     case RENDER_MODE_STROKE:
       status.header = (char *)"rendering stroked text";
       break;
@@ -681,11 +878,11 @@
   static void
   event_font_change( int  delta )
   {
-    int      num_indices;
+    int  num_indices;
 
 
     if ( status.font_index + delta >= handle->num_fonts ||
-         status.font_index + delta < 0 )
+         status.font_index + delta < 0                  )
       return;
 
     status.font_index += delta;
@@ -706,6 +903,7 @@
   {
     int  ret = 0;
 
+
     if ( event->key >= '1' && event->key < '1' + N_RENDER_MODES )
     {
       status.render_mode = event->key - '1';
@@ -738,8 +936,8 @@
     case grKEY( 'b' ):
       handle->use_sbits = !handle->use_sbits;
       status.header     = handle->use_sbits
-                           ? (char *)"embedded bitmaps are now used when available"
-                           : (char *)"embedded bitmaps are now ignored";
+                           ? (char *)"now using embedded bitmaps (if available)"
+                           : (char *)"now ignoring embedded bitmaps";
 
       FTDemo_Update_Current_Flags( handle );
       break;
@@ -784,22 +982,22 @@
       switch ( handle->lcd_mode )
       {
       case LCD_MODE_AA:
-        status.header = (char *)"normal anti-aliased rendering on";
+        status.header = (char *)"use normal anti-aliased rendering";
         break;
       case LCD_MODE_LIGHT:
-        status.header = (char *)"light anti-aliased rendering on";
+        status.header = (char *)"use light anti-aliased rendering";
         break;
       case LCD_MODE_RGB:
-        status.header = (char *)"horizontal LCD-optimized rendering on (RGB)";
+        status.header = (char *)"use horizontal LCD-optimized rendering (RGB)";
         break;
       case LCD_MODE_BGR:
-        status.header = (char *)"horizontal LCD-optimized rendering on (BGR)";
+        status.header = (char *)"use horizontal LCD-optimized rendering (BGR)";
         break;
       case LCD_MODE_VRGB:
-        status.header = (char *)"vertical LCD-optimized rendering on (RGB)";
+        status.header = (char *)"use vertical LCD-optimized rendering (RGB)";
         break;
       case LCD_MODE_VBGR:
-        status.header = (char *)"vertical LCD-optimized rendering on (BGR)";
+        status.header = (char *)"use vertical LCD-optimized rendering (BGR)";
         break;
       }
 
@@ -814,6 +1012,22 @@
       event_gamma_grid();
       break;
 
+    case grKEY( 's' ):
+      event_slant_change( 0.02 );
+      break;
+
+    case grKEY( 'S' ):
+      event_slant_change( -0.02 );
+      break;
+
+    case grKEY( 'e' ):
+      event_bold_change( 0.002 );
+      break;
+
+    case grKEY( 'E' ):
+      event_bold_change( -0.002 );
+      break;
+
     case grKEY( 'g' ):
       event_gamma_change( 0.1 );
       break;
@@ -844,8 +1058,67 @@
     case grKeyF11:   event_index_change( -1000 ); break;
     case grKeyF12:   event_index_change(  1000 ); break;
 
+    case grKEY( 'F' ):
+      FTC_Manager_RemoveFaceID( handle->cache_manager,
+                                handle->scaler.face_id );
+
+      status.use_custom_lcd_filter = !status.use_custom_lcd_filter;
+      if ( status.use_custom_lcd_filter )
+        FT_Library_SetLcdFilterWeights( handle->library,
+                                        status.filter_weights );
+      else
+        FT_Library_SetLcdFilterWeights( handle->library,
+                                        (unsigned char*)"\x10\x40\x70\x40\x10" );
+      status.header = status.use_custom_lcd_filter
+                      ? (char *)"using custom LCD filter weights"
+                      : (char *)"using default LCD filter";
+      break;
+
+    case grKEY( '[' ):
+      if ( !status.use_custom_lcd_filter )
+        break;
+
+      status.fw_index--;
+      if ( status.fw_index < 0 )
+        status.fw_index = 4;
+      break;
+
+    case grKEY( ']' ):
+      if ( !status.use_custom_lcd_filter )
+        break;
+
+      status.fw_index++;
+      if ( status.fw_index > 4 )
+        status.fw_index = 0;
+      break;
+
+    case grKEY( '-' ):
+      if ( !status.use_custom_lcd_filter )
+        break;
+
+      FTC_Manager_RemoveFaceID( handle->cache_manager,
+                                handle->scaler.face_id );
+
+      status.filter_weights[status.fw_index]--;
+      FT_Library_SetLcdFilterWeights( handle->library,
+                                      status.filter_weights );
+      break;
+
+    case grKEY( '+' ):
+    case grKEY( '=' ):
+      if ( !status.use_custom_lcd_filter )
+        break;
+
+      FTC_Manager_RemoveFaceID( handle->cache_manager,
+                                handle->scaler.face_id );
+
+      status.filter_weights[status.fw_index]++;
+      FT_Library_SetLcdFilterWeights( handle->library,
+                                      status.filter_weights );
+      break;
+
     default:
-      ;
+      break;
     }
 
     return ret;
@@ -853,7 +1126,7 @@
 
 
   static void
-  write_header( FT_Error error_code )
+  write_header( FT_Error  error_code )
   {
     FT_Face      face;
     const char*  basename;
@@ -872,31 +1145,35 @@
       switch ( error_code )
       {
       case FT_Err_Ok:
-        sprintf( status.header_buffer, "%s %s (file `%s')", face->family_name,
-                 face->style_name, basename );
+        sprintf( status.header_buffer, "%.50s %.50s (file `%.100s')",
+                 face->family_name, face->style_name, basename );
         break;
       case FT_Err_Invalid_Pixel_Size:
-        sprintf( status.header_buffer, "Invalid pixel size (file `%s')", basename );
+        sprintf( status.header_buffer, "Invalid pixel size (file `%.100s')",
+                 basename );
         break;
       case FT_Err_Invalid_PPem:
-        sprintf( status.header_buffer, "Invalid ppem value (file `%s')", basename );
+        sprintf( status.header_buffer, "Invalid ppem value (file `%.100s')",
+                 basename );
         break;
       default:
-        sprintf( status.header_buffer, "File `%s': error 0x%04x", basename,
-                 (FT_UShort)error_code );
+        sprintf( status.header_buffer, "File `%.100s': error 0x%04x",
+                 basename, (FT_UShort)error_code );
         break;
       }
 
       status.header = status.header_buffer;
     }
 
-    grWriteCellString( display->bitmap, 0, 0, status.header, display->fore_color );
+    grWriteCellString( display->bitmap, 0, 0,
+                       status.header, display->fore_color );
 
-    format = ( status.encoding != FT_ENCODING_NONE )
+    format = status.encoding != FT_ENCODING_NONE
              ? "at %g points, first char code = 0x%x"
              : "at %g points, first glyph index = %d";
 
-    snprintf( status.header_buffer, 256, format, status.ptsize/64.0, status.Num );
+    snprintf( status.header_buffer, 256, format,
+              status.ptsize / 64.0, status.Num );
 
     if ( FT_HAS_GLYPH_NAMES( face ) )
     {
@@ -918,14 +1195,32 @@
           gindex = FTDemo_Get_Index( handle, status.Num );
 
         strcpy( p, format );
-        if ( FT_Get_Glyph_Name( face, gindex, p + format_len, size - format_len ) )
+        if ( FT_Get_Glyph_Name( face, gindex,
+                                p + format_len, size - format_len ) )
           *p = '\0';
       }
     }
 
     status.header = status.header_buffer;
-    grWriteCellString( display->bitmap, 0, HEADER_HEIGHT, status.header_buffer,
-                       display->fore_color );
+    grWriteCellString( display->bitmap, 0, HEADER_HEIGHT,
+                       status.header_buffer, display->fore_color );
+
+    if ( status.use_custom_lcd_filter )
+    {
+      int             fwi = status.fw_index;
+      unsigned char  *fw  = status.filter_weights;
+
+
+      sprintf( status.header_buffer,
+               "%s0x%02X%s%s0x%02X%s%s0x%02X%s%s0x%02X%s%s0x%02X%s",
+               fwi == 0 ? "[" : " ", fw[0], fwi == 0 ? "]" : " ",
+               fwi == 1 ? "[" : " ", fw[1], fwi == 1 ? "]" : " ",
+               fwi == 2 ? "[" : " ", fw[2], fwi == 2 ? "]" : " ",
+               fwi == 3 ? "[" : " ", fw[3], fwi == 3 ? "]" : " ",
+               fwi == 4 ? "[" : " ", fw[4], fwi == 4 ? "]" : " " );
+      grWriteCellString( display->bitmap, 0, 2 * HEADER_HEIGHT,
+                         status.header_buffer, display->fore_color );
+    }
 
     grRefreshSurface( display->surface );
   }
@@ -1043,9 +1338,9 @@
     if ( *argc <= 1 )
       usage( execname );
 
-    status.ptsize = atof( *argv[0] ) * 64.0;
+    status.ptsize = (int)( atof( *argv[0] ) * 64.0 );
     if ( status.ptsize == 0 )
-      status.ptsize = 64*10;
+      status.ptsize = 64 * 10;
 
     (*argc)--;
     (*argv)++;
@@ -1064,15 +1359,15 @@
 #if FREETYPE_MAJOR == 2 && FREETYPE_MINOR == 0 && FREETYPE_PATCH <= 8
     if ( status.debug )
     {
-#  ifdef FT_DEBUG_LEVEL_TRACE
+#ifdef FT_DEBUG_LEVEL_TRACE
       FT_SetTraceLevel( trace_any, (FT_Byte)status.trace_level );
-#  else
+#else
       status.trace_level = 0;
-#  endif
+#endif
     }
 #elif 0
-       /* "setenv/putenv" is not ANSI and I don't want to mess */
-       /* with this portability issue right now..              */
+       /* `setenv' and `putenv' is not ANSI and I don't want to mess */
+       /* with this portability issue right now...                   */
     if ( status.debug )
     {
       char  temp[32];
@@ -1102,7 +1397,8 @@
 
     memset( display->fore_color.chroma, 0, 4 );
     memset( display->back_color.chroma, 0xff, 4 );
-    grSetTitle( display->surface, "FreeType Glyph Viewer - press F1 for help" );
+    grSetTitle( display->surface,
+                "FreeType Glyph Viewer - press F1 for help" );
 
     status.Fail = 0;
 
@@ -1120,15 +1416,23 @@
       switch ( status.render_mode )
       {
       case RENDER_MODE_ALL:
-        error = Render_All( handle->current_font->num_indices, status.Num );
+        error = Render_All( handle->current_font->num_indices,
+                            status.Num );
         break;
 
       case RENDER_MODE_EMBOLDEN:
-        error = Render_Embolden( handle->current_font->num_indices, status.Num );
+        error = Render_Embolden( handle->current_font->num_indices,
+                                 status.Num );
+        break;
+
+      case RENDER_MODE_SLANTED:
+        error = Render_Slanted( handle->current_font->num_indices,
+                                status.Num );
         break;
 
       case RENDER_MODE_STROKE:
-        error = Render_Stroke( handle->current_font->num_indices, status.Num );
+        error = Render_Stroke( handle->current_font->num_indices,
+                               status.Num );
         break;
 
       case RENDER_MODE_TEXT:

++++++ deleted files:
--- freetype-2.1.10-enable-ft2-bci.patch
--- freetype-2.2.1-memcpy-fix.patch
--- freetype-2.3.5-CVE-2009-0946.patch
--- freetype-2.3.5-CVEs.patch
--- ft2demos-2.1.9-mathlib.patch


More information about the MeeGo-commits mailing list