2005-03-03 18:09:08 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* afmodule.c */
|
|
|
|
/* */
|
|
|
|
/* Auto-fitter module implementation (body). */
|
|
|
|
/* */
|
2015-01-17 20:41:43 +01:00
|
|
|
/* Copyright 2003-2015 by */
|
2005-03-03 18:09:08 +01:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
|
|
|
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
|
|
/* this file you indicate that you have read the license and */
|
|
|
|
/* understand and accept it fully. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
2012-10-20 08:34:57 +02:00
|
|
|
#include "afglobal.h"
|
2004-01-16 10:51:00 +01:00
|
|
|
#include "afmodule.h"
|
2004-02-01 17:59:06 +01:00
|
|
|
#include "afloader.h"
|
2012-10-20 08:34:57 +02:00
|
|
|
#include "aferrors.h"
|
2009-04-05 17:23:38 +02:00
|
|
|
#include "afpic.h"
|
2005-03-03 18:09:08 +01:00
|
|
|
|
2011-04-18 19:05:28 +02:00
|
|
|
#ifdef FT_DEBUG_AUTOFIT
|
* Version 2.6 released.
=======================
Tag sources with `VER-2-6'.
* docs/VERSION.DLL: Update documentation and bump version number to
2.6.
* README, Jamfile (RefDoc), builds/windows/vc2005/freetype.vcproj,
builds/windows/vc2005/index.html,
builds/windows/vc2008/freetype.vcproj,
builds/windows/vc2008/index.html,
builds/windows/vc2010/freetype.vcxproj,
builds/windows/vc2010/index.html,
builds/windows/visualc/freetype.dsp,
builds/windows/visualc/freetype.vcproj,
builds/windows/visualc/index.html,
builds/windows/visualce/freetype.dsp,
builds/windows/visualce/freetype.vcproj,
builds/windows/visualce/index.html,
builds/wince/vc2005-ce/freetype.vcproj,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/freetype.vcproj,
builds/wince/vc2008-ce/index.html: s/2.5.5/2.6/, s/255/26/.
* include/freetype/freetype.h (FREETYPE_MINOR): Set to 6.
(FREETYPE_PATCH): Set to 0.
* builds/unix/configure.raw (version_info): Set to 18:0:12.
* CMakeLists.txt (VERSION_MINOR): Set to 0.
(VERSION_PATCH): Set to 6.
* src/autofit/afmodule.c [!FT_MAKE_OPTION_SINGLE_OBJECT]: Add
declarations for dumping functions.
* src/truetype/ttinterp.c (TT_New_Context): Pacify compiler.
* builds/toplevel.mk: Use `freetype.mk's code to compute the version
string.
Don't include a zero patch level in version string.
* builds/freetype.mk: Remove code for computing the version string.
2015-06-07 16:11:18 +02:00
|
|
|
|
|
|
|
#ifndef FT_MAKE_OPTION_SINGLE_OBJECT
|
* Version 2.6.1 released.
=========================
Tag sources with `VER-2-6-1'.
* docs/VERSION.DLL: Update documentation and bump version number to
2.6.1.
* README, Jamfile (RefDoc), builds/windows/vc2005/freetype.vcproj,
builds/windows/vc2005/index.html,
builds/windows/vc2008/freetype.vcproj,
builds/windows/vc2008/index.html,
builds/windows/vc2010/freetype.vcxproj,
builds/windows/vc2010/index.html,
builds/windows/visualc/freetype.dsp,
builds/windows/visualc/freetype.vcproj,
builds/windows/visualc/index.html,
builds/windows/visualce/freetype.dsp,
builds/windows/visualce/freetype.vcproj,
builds/windows/visualce/index.html,
builds/wince/vc2005-ce/freetype.vcproj,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/freetype.vcproj,
builds/wince/vc2008-ce/index.html: s/2.6/2.6.1/, s/26/261/.
* include/freetype/freetype.h (FREETYPE_PATCH): Set to 1.
* builds/unix/configure.raw (version_info): Set to 18:1:12.
* CMakeLists.txt (VERSION_PATCH): Set to 1.
* src/autofit/afmodule.c [AF_DEBUG_AUTOFIT]: Ensure C linking for
dumping functions.
2015-10-04 08:18:01 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
* Version 2.6 released.
=======================
Tag sources with `VER-2-6'.
* docs/VERSION.DLL: Update documentation and bump version number to
2.6.
* README, Jamfile (RefDoc), builds/windows/vc2005/freetype.vcproj,
builds/windows/vc2005/index.html,
builds/windows/vc2008/freetype.vcproj,
builds/windows/vc2008/index.html,
builds/windows/vc2010/freetype.vcxproj,
builds/windows/vc2010/index.html,
builds/windows/visualc/freetype.dsp,
builds/windows/visualc/freetype.vcproj,
builds/windows/visualc/index.html,
builds/windows/visualce/freetype.dsp,
builds/windows/visualce/freetype.vcproj,
builds/windows/visualce/index.html,
builds/wince/vc2005-ce/freetype.vcproj,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/freetype.vcproj,
builds/wince/vc2008-ce/index.html: s/2.5.5/2.6/, s/255/26/.
* include/freetype/freetype.h (FREETYPE_MINOR): Set to 6.
(FREETYPE_PATCH): Set to 0.
* builds/unix/configure.raw (version_info): Set to 18:0:12.
* CMakeLists.txt (VERSION_MINOR): Set to 0.
(VERSION_PATCH): Set to 6.
* src/autofit/afmodule.c [!FT_MAKE_OPTION_SINGLE_OBJECT]: Add
declarations for dumping functions.
* src/truetype/ttinterp.c (TT_New_Context): Pacify compiler.
* builds/toplevel.mk: Use `freetype.mk's code to compute the version
string.
Don't include a zero patch level in version string.
* builds/freetype.mk: Remove code for computing the version string.
2015-06-07 16:11:18 +02:00
|
|
|
extern void
|
|
|
|
af_glyph_hints_dump_segments( AF_GlyphHints hints,
|
|
|
|
FT_Bool to_stdout );
|
|
|
|
extern void
|
|
|
|
af_glyph_hints_dump_points( AF_GlyphHints hints,
|
|
|
|
FT_Bool to_stdout );
|
|
|
|
extern void
|
|
|
|
af_glyph_hints_dump_edges( AF_GlyphHints hints,
|
|
|
|
FT_Bool to_stdout );
|
* Version 2.6.1 released.
=========================
Tag sources with `VER-2-6-1'.
* docs/VERSION.DLL: Update documentation and bump version number to
2.6.1.
* README, Jamfile (RefDoc), builds/windows/vc2005/freetype.vcproj,
builds/windows/vc2005/index.html,
builds/windows/vc2008/freetype.vcproj,
builds/windows/vc2008/index.html,
builds/windows/vc2010/freetype.vcxproj,
builds/windows/vc2010/index.html,
builds/windows/visualc/freetype.dsp,
builds/windows/visualc/freetype.vcproj,
builds/windows/visualc/index.html,
builds/windows/visualce/freetype.dsp,
builds/windows/visualce/freetype.vcproj,
builds/windows/visualce/index.html,
builds/wince/vc2005-ce/freetype.vcproj,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/freetype.vcproj,
builds/wince/vc2008-ce/index.html: s/2.6/2.6.1/, s/26/261/.
* include/freetype/freetype.h (FREETYPE_PATCH): Set to 1.
* builds/unix/configure.raw (version_info): Set to 18:1:12.
* CMakeLists.txt (VERSION_PATCH): Set to 1.
* src/autofit/afmodule.c [AF_DEBUG_AUTOFIT]: Ensure C linking for
dumping functions.
2015-10-04 08:18:01 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
* Version 2.6 released.
=======================
Tag sources with `VER-2-6'.
* docs/VERSION.DLL: Update documentation and bump version number to
2.6.
* README, Jamfile (RefDoc), builds/windows/vc2005/freetype.vcproj,
builds/windows/vc2005/index.html,
builds/windows/vc2008/freetype.vcproj,
builds/windows/vc2008/index.html,
builds/windows/vc2010/freetype.vcxproj,
builds/windows/vc2010/index.html,
builds/windows/visualc/freetype.dsp,
builds/windows/visualc/freetype.vcproj,
builds/windows/visualc/index.html,
builds/windows/visualce/freetype.dsp,
builds/windows/visualce/freetype.vcproj,
builds/windows/visualce/index.html,
builds/wince/vc2005-ce/freetype.vcproj,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/freetype.vcproj,
builds/wince/vc2008-ce/index.html: s/2.5.5/2.6/, s/255/26/.
* include/freetype/freetype.h (FREETYPE_MINOR): Set to 6.
(FREETYPE_PATCH): Set to 0.
* builds/unix/configure.raw (version_info): Set to 18:0:12.
* CMakeLists.txt (VERSION_MINOR): Set to 0.
(VERSION_PATCH): Set to 6.
* src/autofit/afmodule.c [!FT_MAKE_OPTION_SINGLE_OBJECT]: Add
declarations for dumping functions.
* src/truetype/ttinterp.c (TT_New_Context): Pacify compiler.
* builds/toplevel.mk: Use `freetype.mk's code to compute the version
string.
Don't include a zero patch level in version string.
* builds/freetype.mk: Remove code for computing the version string.
2015-06-07 16:11:18 +02:00
|
|
|
#endif
|
|
|
|
|
2015-04-01 13:30:55 +02:00
|
|
|
int _af_debug_disable_horz_hints;
|
|
|
|
int _af_debug_disable_vert_hints;
|
|
|
|
int _af_debug_disable_blue_hints;
|
|
|
|
|
|
|
|
/* we use a global object instead of a local one for debugging */
|
|
|
|
AF_GlyphHintsRec _af_debug_hints_rec[1];
|
|
|
|
|
|
|
|
void* _af_debug_hints = _af_debug_hints_rec;
|
2006-09-26 17:42:44 +02:00
|
|
|
#endif
|
|
|
|
|
2004-02-01 17:59:06 +01:00
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
2012-09-14 11:57:36 +02:00
|
|
|
#include FT_INTERNAL_DEBUG_H
|
2012-09-01 22:31:43 +02:00
|
|
|
#include FT_AUTOHINTER_H
|
2012-08-31 00:20:29 +02:00
|
|
|
#include FT_SERVICE_PROPERTIES_H
|
|
|
|
|
|
|
|
|
2012-09-14 11:57:36 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
|
|
|
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
|
|
|
/* messages during execution. */
|
|
|
|
/* */
|
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_afmodule
|
|
|
|
|
|
|
|
|
Fix clang static analyzer and compiler warnings.
* src/autofit/afhints.c (af_glyph_hints_align_weak_points),
src/autofit/afloader (af_loader_load_g) <FT_GLYPH_FORMAT_COMPOSITE>,
src/base/ftcalc.c (FT_MSB), src/base/ftoutln.c
(FT_Outline_Decompose), src/bdf/bdfdrivr.c (bdf_interpret_style),
src/cff/cffparse.c (cff_parse_integer), src/cid/cidparse.c
(cid_parser_new), src/pfr/pfrload.c (pfr_phy_font_load),
src/raster/ftraster.c (Decompose_Curve), src/sfnt/sfdriver.c
(sfnt_get_ps_name), src/sfnt/ttcmap.c (tt_cmap12_next,
tt_cmap13_next), src/smooth/ftgrays.c (gray_hline): Remove dead
code.
* src/autofit/afmodule.c (af_property_get_face_globals,
af_property_set, af_property_get), src/base/ftbitmap.c
(ft_gray_for_premultiplied_srgb_bgra): Make functions static.
* src/base/ftobjs.c (ft_remove_renderer): Protect against
library == NULL.
(ft_property_do): Make function static.
* src/base/ftrfork.c: Include `ftbase.h'.
* src/sfnt/ttsbit.c (tt_face_load_sbix_image)
[!FT_CONFIG_OPTION_USE_PNG], src/type1/t1gload.c
(T1_Compute_Max_Advance): Avoid compiler warning.
* src/truetype/ttinterp.c (TT_New_Context): Reduce scope of
variable.
2014-02-08 13:55:38 +01:00
|
|
|
static FT_Error
|
2012-09-18 23:31:05 +02:00
|
|
|
af_property_get_face_globals( FT_Face face,
|
|
|
|
AF_FaceGlobals* aglobals,
|
|
|
|
AF_Module module )
|
|
|
|
{
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2012-09-18 23:31:05 +02:00
|
|
|
AF_FaceGlobals globals;
|
|
|
|
|
|
|
|
|
|
|
|
if ( !face )
|
2014-11-25 10:21:13 +01:00
|
|
|
return FT_THROW( Invalid_Face_Handle );
|
2012-09-18 23:31:05 +02:00
|
|
|
|
|
|
|
globals = (AF_FaceGlobals)face->autohint.data;
|
|
|
|
if ( !globals )
|
|
|
|
{
|
[autofit] Introduce `styles'.
This is the new top-level structure for handling glyph input data;
scripts are now defined separately.
* src/autofit/aftypes.h (SCRIPT): Updated.
(AF_ScriptClassRec): Move `blue_stringset' and `writing_system'
members to ...
(AF_Style_ClassRec): ... this new structure.
(AF_Style): New enumeration.
(AF_StyleMetricsRec): Replace `script' enumeration with
`style_class' pointer.
(AF_DEFINE_SCRIPT_CLASS, AF_DECLARE_SCRIPT_CLASS): Updated.
(AF_DEFINE_STYLE_CLASS, AF_DECLARE_STYLE_CLASS): New macros.
* src/autofit/afstyles.h: New file, using data from `afscript.h'.
* src/autofit/afscript.h: Updated.
* src/autofit/afcjk.c (af_cjk_metrics_init_widths,
af_cjk_metrics_init_blues, af_cjk_hint_edges): Updated.
* src/autofit/afglobal.c (SCRIPT): Updated.
(STYLE): Redefine macro to load `afstyles.h'.
(af_script_names) [FT_DEBUG_LEVEL_TRACE]: Replace with...
(af_style_names): ... this array.
(af_face_globals_compute_script_coverage): Renamed to...
(af_face_globals_compute_style_coverage): ... this.
Updated.
(af_face_globals_new, af_face_globals_free,
af_face_globals_get_metrics): Updated.
* src/autofit/afglobal.h (SCRIPT): Updated.
(STYLE): Redefine macro to load `afstyles.h'.
(AF_SCRIPT_FALLBACK): Update definition. This will get more
refinements with later on.
(AF_SCRIPT_UNASSIGNED): Replace with...
(AF_STYLE_UNASSIGNED): ... this macro.
(AF_FaceGlobalsRec): Updated.
* src/autofit/aflatin.c (af_latin_metrics_init_widths,
af_latin_metrics_init_blues, af_latin_metrics_scale_dim,
af_latin_hint_edges): Updated.
* src/autofit/aflatin2.c (af_latin2_metrics_init_widths): Updated.
(af_ltn2_uniranges): Removed.
* src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph):
Updated.
* src/autofit/afpic.c (autofit_module_class_pic_init): Updated.
* src/autofit/afpic.h (AF_STYLE_CLASSES_GET): New macro.
(AFModulePIC): Add `af_style_classes' and `af_style_classes_rec'
members.
* src/autofit/afranges.h: Updated.
* src/autofit/rules.mk (AUTOF_DRV_H): Add `afstyles.h'.
2013-12-20 17:26:26 +01:00
|
|
|
/* trigger computation of the global style data */
|
|
|
|
/* in case it hasn't been done yet */
|
2012-09-18 23:31:05 +02:00
|
|
|
error = af_face_globals_new( face, &globals, module );
|
|
|
|
if ( !error )
|
|
|
|
{
|
|
|
|
face->autohint.data =
|
|
|
|
(FT_Pointer)globals;
|
|
|
|
face->autohint.finalizer =
|
|
|
|
(FT_Generic_Finalizer)af_face_globals_free;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !error )
|
|
|
|
*aglobals = globals;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Fix clang static analyzer and compiler warnings.
* src/autofit/afhints.c (af_glyph_hints_align_weak_points),
src/autofit/afloader (af_loader_load_g) <FT_GLYPH_FORMAT_COMPOSITE>,
src/base/ftcalc.c (FT_MSB), src/base/ftoutln.c
(FT_Outline_Decompose), src/bdf/bdfdrivr.c (bdf_interpret_style),
src/cff/cffparse.c (cff_parse_integer), src/cid/cidparse.c
(cid_parser_new), src/pfr/pfrload.c (pfr_phy_font_load),
src/raster/ftraster.c (Decompose_Curve), src/sfnt/sfdriver.c
(sfnt_get_ps_name), src/sfnt/ttcmap.c (tt_cmap12_next,
tt_cmap13_next), src/smooth/ftgrays.c (gray_hline): Remove dead
code.
* src/autofit/afmodule.c (af_property_get_face_globals,
af_property_set, af_property_get), src/base/ftbitmap.c
(ft_gray_for_premultiplied_srgb_bgra): Make functions static.
* src/base/ftobjs.c (ft_remove_renderer): Protect against
library == NULL.
(ft_property_do): Make function static.
* src/base/ftrfork.c: Include `ftbase.h'.
* src/sfnt/ttsbit.c (tt_face_load_sbix_image)
[!FT_CONFIG_OPTION_USE_PNG], src/type1/t1gload.c
(T1_Compute_Max_Advance): Avoid compiler warning.
* src/truetype/ttinterp.c (TT_New_Context): Reduce scope of
variable.
2014-02-08 13:55:38 +01:00
|
|
|
static FT_Error
|
2012-09-18 15:23:41 +02:00
|
|
|
af_property_set( FT_Module ft_module,
|
2012-08-31 00:20:29 +02:00
|
|
|
const char* property_name,
|
|
|
|
const void* value )
|
|
|
|
{
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2012-09-18 15:23:41 +02:00
|
|
|
AF_Module module = (AF_Module)ft_module;
|
2012-09-15 18:26:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
if ( !ft_strcmp( property_name, "fallback-script" ) )
|
|
|
|
{
|
|
|
|
FT_UInt* fallback_script = (FT_UInt*)value;
|
|
|
|
|
2013-12-21 21:31:38 +01:00
|
|
|
FT_UInt ss;
|
2012-09-15 18:26:28 +02:00
|
|
|
|
2013-12-21 21:31:38 +01:00
|
|
|
|
|
|
|
/* We translate the fallback script to a fallback style that uses */
|
|
|
|
/* `fallback-script' as its script and `AF_COVERAGE_NONE' as its */
|
|
|
|
/* coverage value. */
|
|
|
|
for ( ss = 0; AF_STYLE_CLASSES_GET[ss]; ss++ )
|
|
|
|
{
|
|
|
|
AF_StyleClass style_class = AF_STYLE_CLASSES_GET[ss];
|
|
|
|
|
|
|
|
|
2014-06-13 09:28:00 +02:00
|
|
|
if ( (FT_UInt)style_class->script == *fallback_script &&
|
|
|
|
style_class->coverage == AF_COVERAGE_DEFAULT )
|
2013-12-21 21:31:38 +01:00
|
|
|
{
|
|
|
|
module->fallback_style = ss;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !AF_STYLE_CLASSES_GET[ss] )
|
|
|
|
{
|
|
|
|
FT_TRACE0(( "af_property_set: Invalid value %d for property `%s'\n",
|
|
|
|
fallback_script, property_name ));
|
|
|
|
return FT_THROW( Invalid_Argument );
|
|
|
|
}
|
2012-09-15 18:26:28 +02:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
2013-12-27 19:26:04 +01:00
|
|
|
else if ( !ft_strcmp( property_name, "default-script" ) )
|
|
|
|
{
|
|
|
|
FT_UInt* default_script = (FT_UInt*)value;
|
|
|
|
|
|
|
|
|
|
|
|
module->default_script = *default_script;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
2012-09-18 23:31:05 +02:00
|
|
|
else if ( !ft_strcmp( property_name, "increase-x-height" ) )
|
|
|
|
{
|
|
|
|
FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value;
|
|
|
|
AF_FaceGlobals globals;
|
|
|
|
|
|
|
|
|
|
|
|
error = af_property_get_face_globals( prop->face, &globals, module );
|
|
|
|
if ( !error )
|
|
|
|
globals->increase_x_height = prop->limit;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
2015-04-21 07:13:59 +02:00
|
|
|
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
|
|
|
else if ( !ft_strcmp( property_name, "warping" ) )
|
|
|
|
{
|
|
|
|
FT_Bool* warping = (FT_Bool*)value;
|
|
|
|
|
|
|
|
|
|
|
|
module->warping = *warping;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
#endif /* AF_CONFIG_OPTION_USE_WARPER */
|
2015-11-02 09:06:36 +01:00
|
|
|
else if ( !ft_strcmp( property_name, "darkening-parameters" ) )
|
|
|
|
{
|
|
|
|
FT_Int* darken_params = (FT_Int*)value;
|
|
|
|
|
|
|
|
FT_Int x1 = darken_params[0];
|
|
|
|
FT_Int y1 = darken_params[1];
|
|
|
|
FT_Int x2 = darken_params[2];
|
|
|
|
FT_Int y2 = darken_params[3];
|
|
|
|
FT_Int x3 = darken_params[4];
|
|
|
|
FT_Int y3 = darken_params[5];
|
|
|
|
FT_Int x4 = darken_params[6];
|
|
|
|
FT_Int y4 = darken_params[7];
|
|
|
|
|
|
|
|
|
|
|
|
if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 ||
|
|
|
|
y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 ||
|
|
|
|
x1 > x2 || x2 > x3 || x3 > x4 ||
|
|
|
|
y1 > 500 || y2 > 500 || y3 > 500 || y4 > 500 )
|
|
|
|
return FT_THROW( Invalid_Argument );
|
|
|
|
|
|
|
|
module->darken_params[0] = x1;
|
|
|
|
module->darken_params[1] = y1;
|
|
|
|
module->darken_params[2] = x2;
|
|
|
|
module->darken_params[3] = y2;
|
|
|
|
module->darken_params[4] = x3;
|
|
|
|
module->darken_params[5] = y3;
|
|
|
|
module->darken_params[6] = x4;
|
|
|
|
module->darken_params[7] = y4;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
|
|
|
|
{
|
|
|
|
FT_Bool* no_stem_darkening = (FT_Bool*)value;
|
|
|
|
|
|
|
|
|
|
|
|
module->no_stem_darkening = *no_stem_darkening;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
2012-08-31 00:20:29 +02:00
|
|
|
|
2013-03-23 14:06:54 +01:00
|
|
|
FT_TRACE0(( "af_property_set: missing property `%s'\n",
|
2012-08-31 00:20:29 +02:00
|
|
|
property_name ));
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Missing_Property );
|
2012-08-31 00:20:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Fix clang static analyzer and compiler warnings.
* src/autofit/afhints.c (af_glyph_hints_align_weak_points),
src/autofit/afloader (af_loader_load_g) <FT_GLYPH_FORMAT_COMPOSITE>,
src/base/ftcalc.c (FT_MSB), src/base/ftoutln.c
(FT_Outline_Decompose), src/bdf/bdfdrivr.c (bdf_interpret_style),
src/cff/cffparse.c (cff_parse_integer), src/cid/cidparse.c
(cid_parser_new), src/pfr/pfrload.c (pfr_phy_font_load),
src/raster/ftraster.c (Decompose_Curve), src/sfnt/sfdriver.c
(sfnt_get_ps_name), src/sfnt/ttcmap.c (tt_cmap12_next,
tt_cmap13_next), src/smooth/ftgrays.c (gray_hline): Remove dead
code.
* src/autofit/afmodule.c (af_property_get_face_globals,
af_property_set, af_property_get), src/base/ftbitmap.c
(ft_gray_for_premultiplied_srgb_bgra): Make functions static.
* src/base/ftobjs.c (ft_remove_renderer): Protect against
library == NULL.
(ft_property_do): Make function static.
* src/base/ftrfork.c: Include `ftbase.h'.
* src/sfnt/ttsbit.c (tt_face_load_sbix_image)
[!FT_CONFIG_OPTION_USE_PNG], src/type1/t1gload.c
(T1_Compute_Max_Advance): Avoid compiler warning.
* src/truetype/ttinterp.c (TT_New_Context): Reduce scope of
variable.
2014-02-08 13:55:38 +01:00
|
|
|
static FT_Error
|
2012-09-18 15:23:41 +02:00
|
|
|
af_property_get( FT_Module ft_module,
|
2012-08-31 00:20:29 +02:00
|
|
|
const char* property_name,
|
|
|
|
void* value )
|
|
|
|
{
|
2013-12-21 21:31:38 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
|
|
|
AF_Module module = (AF_Module)ft_module;
|
|
|
|
FT_UInt fallback_style = module->fallback_style;
|
2013-12-27 19:26:04 +01:00
|
|
|
FT_UInt default_script = module->default_script;
|
2015-04-21 07:13:59 +02:00
|
|
|
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
|
|
|
FT_Bool warping = module->warping;
|
|
|
|
#endif
|
2012-09-01 22:31:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
if ( !ft_strcmp( property_name, "glyph-to-script-map" ) )
|
|
|
|
{
|
|
|
|
FT_Prop_GlyphToScriptMap* prop = (FT_Prop_GlyphToScriptMap*)value;
|
|
|
|
AF_FaceGlobals globals;
|
|
|
|
|
|
|
|
|
2012-09-18 23:31:05 +02:00
|
|
|
error = af_property_get_face_globals( prop->face, &globals, module );
|
2012-09-01 22:31:43 +02:00
|
|
|
if ( !error )
|
2013-12-18 10:36:06 +01:00
|
|
|
prop->map = globals->glyph_styles;
|
2012-09-01 22:31:43 +02:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
2012-09-15 18:26:28 +02:00
|
|
|
else if ( !ft_strcmp( property_name, "fallback-script" ) )
|
|
|
|
{
|
|
|
|
FT_UInt* val = (FT_UInt*)value;
|
|
|
|
|
2013-12-21 21:31:38 +01:00
|
|
|
AF_StyleClass style_class = AF_STYLE_CLASSES_GET[fallback_style];
|
|
|
|
|
2012-09-15 18:26:28 +02:00
|
|
|
|
2013-12-21 21:31:38 +01:00
|
|
|
*val = style_class->script;
|
2012-09-15 18:26:28 +02:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
2013-12-27 19:26:04 +01:00
|
|
|
else if ( !ft_strcmp( property_name, "default-script" ) )
|
|
|
|
{
|
|
|
|
FT_UInt* val = (FT_UInt*)value;
|
|
|
|
|
|
|
|
|
|
|
|
*val = default_script;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
2012-09-18 23:31:05 +02:00
|
|
|
else if ( !ft_strcmp( property_name, "increase-x-height" ) )
|
|
|
|
{
|
|
|
|
FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value;
|
|
|
|
AF_FaceGlobals globals;
|
|
|
|
|
|
|
|
|
|
|
|
error = af_property_get_face_globals( prop->face, &globals, module );
|
|
|
|
if ( !error )
|
|
|
|
prop->limit = globals->increase_x_height;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
2015-04-21 07:13:59 +02:00
|
|
|
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
|
|
|
else if ( !ft_strcmp( property_name, "warping" ) )
|
|
|
|
{
|
|
|
|
FT_Bool* val = (FT_Bool*)value;
|
|
|
|
|
|
|
|
|
|
|
|
*val = warping;
|
2012-09-18 23:31:05 +02:00
|
|
|
|
2015-04-21 07:13:59 +02:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
#endif /* AF_CONFIG_OPTION_USE_WARPER */
|
2015-11-02 09:06:36 +01:00
|
|
|
else if ( !ft_strcmp( property_name, "darkening-parameters" ) )
|
|
|
|
{
|
|
|
|
FT_Int* darken_params = module->darken_params;
|
|
|
|
FT_Int* val = (FT_Int*)value;
|
|
|
|
|
|
|
|
|
|
|
|
val[0] = darken_params[0];
|
|
|
|
val[1] = darken_params[1];
|
|
|
|
val[2] = darken_params[2];
|
|
|
|
val[3] = darken_params[3];
|
|
|
|
val[4] = darken_params[4];
|
|
|
|
val[5] = darken_params[5];
|
|
|
|
val[6] = darken_params[6];
|
|
|
|
val[7] = darken_params[7];
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
|
|
|
|
{
|
|
|
|
FT_Bool no_stem_darkening = module->no_stem_darkening;
|
|
|
|
FT_Bool* val = (FT_Bool*)value;
|
|
|
|
|
|
|
|
|
|
|
|
*val = no_stem_darkening;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
2012-08-31 00:20:29 +02:00
|
|
|
|
|
|
|
FT_TRACE0(( "af_property_get: missing property `%s'\n",
|
|
|
|
property_name ));
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Missing_Property );
|
2012-08-31 00:20:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_DEFINE_SERVICE_PROPERTIESREC(
|
|
|
|
af_service_properties,
|
2015-10-30 08:07:56 +01:00
|
|
|
(FT_Properties_SetFunc)af_property_set, /* set_property */
|
|
|
|
(FT_Properties_GetFunc)af_property_get ) /* get_property */
|
2012-08-31 00:20:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
FT_DEFINE_SERVICEDESCREC1(
|
|
|
|
af_services,
|
|
|
|
FT_SERVICE_ID_PROPERTIES, &AF_SERVICE_PROPERTIES_GET )
|
|
|
|
|
|
|
|
|
|
|
|
FT_CALLBACK_DEF( FT_Module_Interface )
|
|
|
|
af_get_interface( FT_Module module,
|
|
|
|
const char* module_interface )
|
|
|
|
{
|
2014-12-07 08:17:12 +01:00
|
|
|
/* AF_SERVICES_GET dereferences `library' in PIC mode */
|
2012-08-31 00:20:29 +02:00
|
|
|
#ifdef FT_CONFIG_OPTION_PIC
|
|
|
|
FT_Library library;
|
|
|
|
|
|
|
|
|
|
|
|
if ( !module )
|
|
|
|
return NULL;
|
|
|
|
library = module->library;
|
|
|
|
if ( !library )
|
|
|
|
return NULL;
|
|
|
|
#else
|
|
|
|
FT_UNUSED( module );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ft_service_list_lookup( AF_SERVICES_GET, module_interface );
|
|
|
|
}
|
2004-01-16 10:51:00 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
|
2004-02-01 17:59:06 +01:00
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
2013-03-23 14:06:54 +01:00
|
|
|
af_autofitter_init( FT_Module ft_module ) /* AF_Module */
|
2004-02-01 17:59:06 +01:00
|
|
|
{
|
2013-03-23 14:06:54 +01:00
|
|
|
AF_Module module = (AF_Module)ft_module;
|
|
|
|
|
|
|
|
|
2015-11-02 09:06:36 +01:00
|
|
|
module->fallback_style = AF_STYLE_FALLBACK;
|
|
|
|
module->default_script = AF_SCRIPT_DEFAULT;
|
2015-04-21 07:13:59 +02:00
|
|
|
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
2015-11-02 09:06:36 +01:00
|
|
|
module->warping = 0;
|
2015-04-21 07:13:59 +02:00
|
|
|
#endif
|
2015-11-11 09:55:16 +01:00
|
|
|
module->no_stem_darkening = TRUE;
|
2015-11-02 09:06:36 +01:00
|
|
|
|
|
|
|
module->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
|
|
|
|
module->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
|
|
|
|
module->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
|
|
|
|
module->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
|
|
|
|
module->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
|
|
|
|
module->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
|
|
|
|
module->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
|
|
|
|
module->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
|
2012-09-15 10:33:43 +02:00
|
|
|
|
2015-01-14 16:01:19 +01:00
|
|
|
return FT_Err_Ok;
|
2004-01-16 10:51:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-01 17:59:06 +01:00
|
|
|
FT_CALLBACK_DEF( void )
|
2013-03-23 14:06:54 +01:00
|
|
|
af_autofitter_done( FT_Module ft_module ) /* AF_Module */
|
2004-01-16 10:51:00 +01:00
|
|
|
{
|
2015-01-14 19:38:36 +01:00
|
|
|
FT_UNUSED( ft_module );
|
2015-04-01 13:30:55 +02:00
|
|
|
|
|
|
|
#ifdef FT_DEBUG_AUTOFIT
|
|
|
|
if ( _af_debug_hints_rec->memory )
|
|
|
|
af_glyph_hints_done( _af_debug_hints_rec );
|
|
|
|
#endif
|
2004-02-01 17:59:06 +01:00
|
|
|
}
|
2004-01-16 10:51:00 +01:00
|
|
|
|
|
|
|
|
2004-02-01 17:59:06 +01:00
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
2012-09-14 07:55:15 +02:00
|
|
|
af_autofitter_load_glyph( AF_Module module,
|
|
|
|
FT_GlyphSlot slot,
|
|
|
|
FT_Size size,
|
|
|
|
FT_UInt glyph_index,
|
|
|
|
FT_Int32 load_flags )
|
2004-02-01 17:59:06 +01:00
|
|
|
{
|
2015-01-14 19:16:12 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
|
|
|
FT_Memory memory = module->root.library->memory;
|
|
|
|
|
2015-04-01 13:30:55 +02:00
|
|
|
#ifdef FT_DEBUG_AUTOFIT
|
|
|
|
|
|
|
|
/* in debug mode, we use a global object that survives this routine */
|
|
|
|
|
|
|
|
AF_GlyphHints hints = _af_debug_hints_rec;
|
|
|
|
AF_LoaderRec loader[1];
|
|
|
|
|
|
|
|
FT_UNUSED( size );
|
|
|
|
|
|
|
|
|
|
|
|
if ( hints->memory )
|
|
|
|
af_glyph_hints_done( hints );
|
|
|
|
|
|
|
|
af_glyph_hints_init( hints, memory );
|
|
|
|
af_loader_init( loader, hints );
|
|
|
|
|
|
|
|
error = af_loader_load_glyph( loader, module, slot->face,
|
|
|
|
glyph_index, load_flags );
|
|
|
|
|
2015-04-01 15:55:41 +02:00
|
|
|
af_glyph_hints_dump_points( hints, 0 );
|
|
|
|
af_glyph_hints_dump_segments( hints, 0 );
|
|
|
|
af_glyph_hints_dump_edges( hints, 0 );
|
|
|
|
|
2015-04-01 13:30:55 +02:00
|
|
|
af_loader_done( loader );
|
|
|
|
|
|
|
|
return error;
|
|
|
|
|
|
|
|
#else /* !FT_DEBUG_AUTOFIT */
|
|
|
|
|
2015-01-14 19:16:12 +01:00
|
|
|
AF_GlyphHintsRec hints[1];
|
|
|
|
AF_LoaderRec loader[1];
|
2015-01-14 16:01:19 +01:00
|
|
|
|
2004-04-22 00:27:11 +02:00
|
|
|
FT_UNUSED( size );
|
2004-04-21 16:30:37 +02:00
|
|
|
|
2015-01-14 16:01:19 +01:00
|
|
|
|
2015-01-14 19:16:12 +01:00
|
|
|
af_glyph_hints_init( hints, memory );
|
|
|
|
af_loader_init( loader, hints );
|
2015-01-14 16:01:19 +01:00
|
|
|
|
|
|
|
error = af_loader_load_glyph( loader, module, slot->face,
|
|
|
|
glyph_index, load_flags );
|
|
|
|
|
|
|
|
af_loader_done( loader );
|
2015-01-14 19:16:12 +01:00
|
|
|
af_glyph_hints_done( hints );
|
2015-01-14 16:01:19 +01:00
|
|
|
|
|
|
|
return error;
|
2015-04-01 13:30:55 +02:00
|
|
|
|
|
|
|
#endif /* !FT_DEBUG_AUTOFIT */
|
2004-02-01 17:59:06 +01:00
|
|
|
}
|
2004-01-16 10:51:00 +01:00
|
|
|
|
|
|
|
|
2012-08-27 06:57:05 +02:00
|
|
|
FT_DEFINE_AUTOHINTER_INTERFACE(
|
|
|
|
af_autofitter_interface,
|
2012-08-23 13:34:26 +02:00
|
|
|
NULL, /* reset_face */
|
|
|
|
NULL, /* get_global_hints */
|
|
|
|
NULL, /* done_global_hints */
|
|
|
|
(FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph ) /* load_glyph */
|
2004-01-16 10:51:00 +01:00
|
|
|
|
2012-08-27 06:57:05 +02:00
|
|
|
|
2011-02-26 17:32:38 +01:00
|
|
|
FT_DEFINE_MODULE(
|
|
|
|
autofit_module_class,
|
2004-01-16 10:51:00 +01:00
|
|
|
|
2004-02-01 17:59:06 +01:00
|
|
|
FT_MODULE_HINTER,
|
2012-09-14 07:55:15 +02:00
|
|
|
sizeof ( AF_ModuleRec ),
|
2004-01-16 10:51:00 +01:00
|
|
|
|
2004-02-01 17:59:06 +01:00
|
|
|
"autofitter",
|
|
|
|
0x10000L, /* version 1.0 of the autofitter */
|
|
|
|
0x20000L, /* requires FreeType 2.0 or above */
|
2004-01-16 10:51:00 +01:00
|
|
|
|
2012-08-27 08:41:43 +02:00
|
|
|
(const void*)&AF_INTERFACE_GET,
|
2004-01-16 10:51:00 +01:00
|
|
|
|
2005-03-03 18:09:08 +01:00
|
|
|
(FT_Module_Constructor)af_autofitter_init,
|
|
|
|
(FT_Module_Destructor) af_autofitter_done,
|
2012-08-31 00:20:29 +02:00
|
|
|
(FT_Module_Requester) af_get_interface )
|
2004-01-16 10:51:00 +01:00
|
|
|
|
|
|
|
|
2004-02-01 17:59:06 +01:00
|
|
|
/* END */
|