shithub: freetype+ttf2subf

Download patch

ref: 84c6f8811734faab5516216526aeba69d5541e63
parent: 33db39e2923516e52975a13ccfd0cd129d3507ab
author: David Turner <[email protected]>
date: Sun Jun 10 16:51:04 EDT 2007

* include/freetype/config/ftoption.h: clarify documentation regarding
	unpatented hinting

	* include/freetype/freetype.h, src/base/ftpatent.c, src/truetype/ttdriver.c,
	include/freetype/internal/services/svttglyf.h, modules.cfg,:
	include/freetype/internal/ftserv.h,:
	Fonts without a cmap must be handled correctly by FreeType (anything
	Adding the FT_Face_CheckTrueTypePatents API to FT_FREETYPE_H, it is
	implemented by the optional src/base/ftpatent.c

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,18 @@
+2007-06-10  David Turner  <[email protected]>
+
+	* include/freetype/config/ftoption.h: clarify documentation regarding
+	unpatented hinting
+
+	* include/freetype/freetype.h, src/base/ftpatent.c, src/truetype/ttdriver.c,
+	include/freetype/internal/services/svttglyf.h, modules.cfg,:
+	include/freetype/internal/ftserv.h,:
+	Fonts without a cmap must be handled correctly by FreeType (anything
+	Adding the FT_Face_CheckTrueTypePatents API to FT_FREETYPE_H, it is
+	implemented by the optional src/base/ftpatent.c
+
 2007-06-08  Werner Lemberg  <[email protected]>
 
-	* src/sfnt/sfobjs.c (sfnt_load_face): Undo change from 2007-04-28. 
+	* src/sfnt/sfobjs.c (sfnt_load_face): Undo change from 2007-04-28.
 	Fonts without a cmap must be handled correctly by FreeType (anything
 	else would be a bug).
 
@@ -399,7 +411,7 @@
 	computation.
 
 	* src/autofit/afloader.c (af_loader_load_g): In the case of
-	monospaced fonts, always set `rsb_delta' and `lsb_delta' to 0. 
+	monospaced fonts, always set `rsb_delta' and `lsb_delta' to 0.
 	Otherwise code that uses them will most certainly ruin the fixed
 	advance property.
 
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -463,12 +463,26 @@
 
   /*************************************************************************/
   /*                                                                       */
-  /* Define TT_CONFIG_OPTION_UNPATENTED_HINTING (in addition to            */
-  /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER) to compile the unpatented      */
-  /* work-around hinting system.  Note that for the moment, the algorithm  */
-  /* is only used when selected at runtime through the parameter tag       */
-  /* FT_PARAM_TAG_UNPATENTED_HINTING; or when the debug hook               */
-  /* FT_DEBUG_HOOK_UNPATENTED_HINTING is globally activated.               */
+  /* The TT_CONFIG_OPTION_UNPATENTED_HINTING macro is *ignored* if you     */
+  /* have defined TT_CONFIG_OPTION_BYTECODE_INTERPRETER. If not, it will   */
+  /* compile a special work-around TrueType bytecode interpreter that      */
+  /* doesn't implement any of the patented opcodes/algorithms.             */
+  /*                                                                       */
+  /* this is only useful for a small number of font files (mostly Asian)   */
+  /* that require bytecode interpretation to properly load glyphs. For all */
+  /* other fonts, this will produce unpleasant results.                    */
+  /*                                                                       */
+  /* for this reason, the unpatented interpreter is never used by to load  */
+  /* glyphs from TrueType fonts, unless one of the following happens:      */
+  /*                                                                       */
+  /*   - the unpatented interpreter is explicitely activated by the        */
+  /*     user through the FT_PARAM_TAG_UNPATENTED_HINTING parameter tag    */
+  /*     when opening the FT_Face                                          */
+  /*                                                                       */
+  /*   - FreeType detects that the FT_Face corresponds to one of the       */
+  /*     'trick' fonts (e.g. Mingliu) it knows about. The font engine      */
+  /*     contains a hard-coded list of font names and other matching       */
+  /*     parameters.                                                       */
   /*                                                                       */
 #define TT_CONFIG_OPTION_UNPATENTED_HINTING
 
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -3368,6 +3368,31 @@
                       FT_Int      *aminor,
                       FT_Int      *apatch );
 
+
+  /*************************************************************************/
+  /*                                                                       */
+  /* <Function>                                                            */
+  /*    FT_Face_CheckTrueTypePatents                                       */
+  /*                                                                       */
+  /* <Description>                                                         */
+  /*    Parses the whole content of a TrueType font file and returns       */
+  /*    true if it uses any of the patented opcodes. this is only useful   */
+  /*    if you want to be able to use the unpatented hinter with           */
+  /*    fonts that do *not* use these opcodes.                             */
+  /*                                                                       */
+  /*    note that this function parses *all* glyph instructions in the     */
+  /*    font file, and may be *slow*                                       */
+  /*                                                                       */
+  /* <Input>                                                               */
+  /*    face :: a face handle                                              */
+  /*                                                                       */
+  /* <Return>                                                              */
+  /*    TRUE if this is a TrueType font that uses one of the patented       */
+  /*    opcodes. FALSE otherwise                                           */
+  /*                                                                       */
+  FT_EXPORT( FT_Bool )
+  FT_Face_CheckTrueTypePatents( FT_Face   face );
+
   /* */
 
 
--- a/include/freetype/internal/ftserv.h
+++ b/include/freetype/internal/ftserv.h
@@ -315,6 +315,7 @@
 #define FT_SERVICE_TT_CMAP_H            <freetype/internal/services/svttcmap.h>
 #define FT_SERVICE_WINFNT_H             <freetype/internal/services/svwinfnt.h>
 #define FT_SERVICE_XFREE86_NAME_H       <freetype/internal/services/svxf86nm.h>
+#define FT_SERVICE_TRUETYPE_GLYF_H      <freetype/internal/services/svttglyf.h>
 
  /* */
 
--- /dev/null
+++ b/include/freetype/internal/services/svttglyf.h
@@ -1,0 +1,48 @@
+/***************************************************************************/
+/*                                                                         */
+/*  svsttglyf.h                                                            */
+/*                                                                         */
+/*    The FreeType TrueType glyph service.                                 */
+/*                                                                         */
+/*  Copyright 2007 by David Turner.                                        */
+/*                                                                         */
+/*  This file is part of the FreeType project, and may only be used,       */
+/*  modified, and distributed under the terms of the FreeType project      */
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
+/*  this file you indicate that you have read the license and              */
+/*  understand and accept it fully.                                        */
+/*                                                                         */
+/***************************************************************************/
+
+#ifndef __SVTTGLYF_H__
+#define __SVTTGLYF_H__
+
+#include FT_INTERNAL_SERVICE_H
+#include FT_TRUETYPE_TABLES_H
+
+
+FT_BEGIN_HEADER
+
+
+#define FT_SERVICE_ID_TT_GLYF "tt-glyf"
+
+
+  typedef FT_ULong
+  (*TT_Glyf_GetLocationFunc)( FT_Face    face,
+                              FT_UInt    gindex,
+                              FT_ULong  *psize );
+
+  FT_DEFINE_SERVICE( TTGlyf )
+  {
+    TT_Glyf_GetLocationFunc  get_location;
+  };
+
+  /* */
+
+
+FT_END_HEADER
+
+#endif /* __SVTTCMAP_H__ */
+
+
+/* END */
--- a/modules.cfg
+++ b/modules.cfg
@@ -220,6 +220,11 @@
 # See include/freetype/ftgasp.h for the API.
 BASE_EXTENSIONS += ftgasp.c
 
+# Support for FT_Face_CheckTrueTypePatents
+#
+# See include/freetype.h for the API.
+BASE_EXTENSIONS += ftpatent.c
+
 ####
 #### The components `ftsystem.c' (for memory allocation and stream I/O
 #### management) and `ftdebug.c' (for emitting debug messages to the user)
--- a/src/base/Jamfile
+++ b/src/base/Jamfile
@@ -34,7 +34,7 @@
   local  _sources =  system  init    glyph  mm      bdf
                      bbox    debug   xf86   type1   pfr
                      stroke  winfnt  otval  bitmap  synth
-                     gxval   lcdfil  gasp
+                     gxval   lcdfil  gasp   patent
                      ;
 
   Library  $(FT2_LIB) : ft$(_sources).c ;
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -29,9 +29,11 @@
 #endif
 
 #include FT_SERVICE_TRUETYPE_ENGINE_H
+#include FT_SERVICE_TRUETYPE_GLYF_H
 
 #include "ttdriver.h"
 #include "ttgload.h"
+#include "ttpload.h"
 
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
 #include "ttgxvar.h"
@@ -313,6 +315,11 @@
 #endif /* TT_USE_BYTECODE_INTERPRETER */
   };
 
+  static const FT_Service_TTGlyfRec  tt_service_truetype_glyf =
+  {
+    (TT_Glyf_GetLocationFunc)     tt_face_get_location
+  };
+
   static const FT_ServiceDescRec  tt_services[] =
   {
     { FT_SERVICE_ID_XF86_NAME,       FT_XF86_FORMAT_TRUETYPE },
@@ -320,6 +327,7 @@
     { FT_SERVICE_ID_MULTI_MASTERS,   &tt_service_gx_multi_masters },
 #endif
     { FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine },
+    { FT_SERVICE_ID_TT_GLYF,         &tt_service_truetype_glyf },
     { NULL, NULL }
   };