2018-06-03 09:01:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* afindic.c
|
|
|
|
*
|
|
|
|
* Auto-fitter hinting routines for Indic writing system (body).
|
|
|
|
*
|
2020-01-19 17:05:19 +01:00
|
|
|
* Copyright (C) 2007-2020 by
|
2018-06-03 09:01:17 +02:00
|
|
|
* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
2007-06-26 06:44:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
#include "aftypes.h"
|
|
|
|
#include "aflatin.h"
|
2017-03-17 21:47:54 +01:00
|
|
|
#include "afcjk.h"
|
2007-06-26 06:44:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef AF_CONFIG_OPTION_INDIC
|
|
|
|
|
|
|
|
#include "afindic.h"
|
|
|
|
#include "aferrors.h"
|
|
|
|
|
|
|
|
|
2011-03-02 03:52:36 +01:00
|
|
|
#ifdef AF_CONFIG_OPTION_USE_WARPER
|
2007-06-26 06:44:35 +02:00
|
|
|
#include "afwarp.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
2011-05-09 09:48:49 +02:00
|
|
|
af_indic_metrics_init( AF_CJKMetrics metrics,
|
|
|
|
FT_Face face )
|
2007-06-26 06:44:35 +02:00
|
|
|
{
|
[autofit] Add bluezones for CJK Ideographs.
To remove extremas of vertical strokes of CJK Ideographs at
low resolution and make the top and bottom horizontal stems
aligned, bluezones for CJK Ideographs are calculated from
sample glyphs. At present, vertical bluezones (bluezones
to align vertical stems) are disabled by default. For detail, see
http://lists.gnu.org/archive/html/freetype-devel/2011-04/msg00070.html
http://lists.gnu.org/archive/html/freetype-devel/2011-04/msg00092.html
http://lists.gnu.org/archive/html/freetype-devel/2011-05/msg00001.html
* include/freetype/internal/fttrace.h: New trace component `afcjk'.
* src/autofit/afcjk.h (AF_CJK{Blue,Axis,Metric}Rec): Add CJK version
for AF_Latin{Blue,Axis,Metric}Rec.
(af_cjk_metrics_check_digits): Ditto, shared with Indic module.
(af_cjk_metrics_init_widths): Ditto.
(af_cjk_metrics_init): Take AF_CJKMetric instead of AF_LatinMetric.
(af_cjk_metrics_scale): Ditto (declaration).
(af_cjk_hints_init): Ditto (declaration).
(af_cjk_hints_apply): Ditto (declaration).
* src/autofit/afcjk.c (af_cjk_metrics_scale): Ditto (body).
(af_cjk_hints_init): Ditto (body).
(af_cjk_hints_apply): Ditto (body).
(af_cjk_metrics_init_widths): Duplicate af_latin_metrics_init_widths.
(af_cjk_metrics_check_digits): Duplicate af_latin_metrics_check_digits.
(af_cjk_metrics_init): Call CJK bluezone initializer.
(af_cjk_metrics_scale_dim): Add code to scale bluezones.
(af_cjk_hints_compute_blue_edges): New function, CJK version of
af_latin_hints_compute_blue_edges.
(af_cjk_metrics_init_blues): New function, CJK version of
af_latin_metrics_init_blues.
(af_cjk_hints_edges): Add code to align the edge stems to blue zones.
* src/autofit/afindic.c (af_indic_metrics_init): Take AF_CJKMetric
instead of AF_LatinMetric, and initialize as af_cjk_metrics_init.
However bluezones are not initialized.
(af_indic_metrics_scale): Take AF_CJKMetric instead of AF_LatinMetric.
(af_indic_hints_init): Ditto.
(af_indic_hints_apply): Ditto.
* docs/CHANGES: Note about CJK bluezone support.
2011-05-08 12:07:13 +02:00
|
|
|
/* skip blue zone init in CJK routines */
|
|
|
|
FT_CharMap oldmap = face->charmap;
|
|
|
|
|
|
|
|
|
|
|
|
metrics->units_per_em = face->units_per_EM;
|
|
|
|
|
|
|
|
if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
|
|
|
|
face->charmap = NULL;
|
|
|
|
else
|
|
|
|
{
|
2012-10-24 14:22:14 +02:00
|
|
|
af_cjk_metrics_init_widths( metrics, face );
|
[autofit] Add bluezones for CJK Ideographs.
To remove extremas of vertical strokes of CJK Ideographs at
low resolution and make the top and bottom horizontal stems
aligned, bluezones for CJK Ideographs are calculated from
sample glyphs. At present, vertical bluezones (bluezones
to align vertical stems) are disabled by default. For detail, see
http://lists.gnu.org/archive/html/freetype-devel/2011-04/msg00070.html
http://lists.gnu.org/archive/html/freetype-devel/2011-04/msg00092.html
http://lists.gnu.org/archive/html/freetype-devel/2011-05/msg00001.html
* include/freetype/internal/fttrace.h: New trace component `afcjk'.
* src/autofit/afcjk.h (AF_CJK{Blue,Axis,Metric}Rec): Add CJK version
for AF_Latin{Blue,Axis,Metric}Rec.
(af_cjk_metrics_check_digits): Ditto, shared with Indic module.
(af_cjk_metrics_init_widths): Ditto.
(af_cjk_metrics_init): Take AF_CJKMetric instead of AF_LatinMetric.
(af_cjk_metrics_scale): Ditto (declaration).
(af_cjk_hints_init): Ditto (declaration).
(af_cjk_hints_apply): Ditto (declaration).
* src/autofit/afcjk.c (af_cjk_metrics_scale): Ditto (body).
(af_cjk_hints_init): Ditto (body).
(af_cjk_hints_apply): Ditto (body).
(af_cjk_metrics_init_widths): Duplicate af_latin_metrics_init_widths.
(af_cjk_metrics_check_digits): Duplicate af_latin_metrics_check_digits.
(af_cjk_metrics_init): Call CJK bluezone initializer.
(af_cjk_metrics_scale_dim): Add code to scale bluezones.
(af_cjk_hints_compute_blue_edges): New function, CJK version of
af_latin_hints_compute_blue_edges.
(af_cjk_metrics_init_blues): New function, CJK version of
af_latin_metrics_init_blues.
(af_cjk_hints_edges): Add code to align the edge stems to blue zones.
* src/autofit/afindic.c (af_indic_metrics_init): Take AF_CJKMetric
instead of AF_LatinMetric, and initialize as af_cjk_metrics_init.
However bluezones are not initialized.
(af_indic_metrics_scale): Take AF_CJKMetric instead of AF_LatinMetric.
(af_indic_hints_init): Ditto.
(af_indic_hints_apply): Ditto.
* docs/CHANGES: Note about CJK bluezone support.
2011-05-08 12:07:13 +02:00
|
|
|
#if 0
|
2011-05-09 09:48:49 +02:00
|
|
|
/* either need indic specific blue_chars[] or just skip blue zones */
|
[autofit] Add bluezones for CJK Ideographs.
To remove extremas of vertical strokes of CJK Ideographs at
low resolution and make the top and bottom horizontal stems
aligned, bluezones for CJK Ideographs are calculated from
sample glyphs. At present, vertical bluezones (bluezones
to align vertical stems) are disabled by default. For detail, see
http://lists.gnu.org/archive/html/freetype-devel/2011-04/msg00070.html
http://lists.gnu.org/archive/html/freetype-devel/2011-04/msg00092.html
http://lists.gnu.org/archive/html/freetype-devel/2011-05/msg00001.html
* include/freetype/internal/fttrace.h: New trace component `afcjk'.
* src/autofit/afcjk.h (AF_CJK{Blue,Axis,Metric}Rec): Add CJK version
for AF_Latin{Blue,Axis,Metric}Rec.
(af_cjk_metrics_check_digits): Ditto, shared with Indic module.
(af_cjk_metrics_init_widths): Ditto.
(af_cjk_metrics_init): Take AF_CJKMetric instead of AF_LatinMetric.
(af_cjk_metrics_scale): Ditto (declaration).
(af_cjk_hints_init): Ditto (declaration).
(af_cjk_hints_apply): Ditto (declaration).
* src/autofit/afcjk.c (af_cjk_metrics_scale): Ditto (body).
(af_cjk_hints_init): Ditto (body).
(af_cjk_hints_apply): Ditto (body).
(af_cjk_metrics_init_widths): Duplicate af_latin_metrics_init_widths.
(af_cjk_metrics_check_digits): Duplicate af_latin_metrics_check_digits.
(af_cjk_metrics_init): Call CJK bluezone initializer.
(af_cjk_metrics_scale_dim): Add code to scale bluezones.
(af_cjk_hints_compute_blue_edges): New function, CJK version of
af_latin_hints_compute_blue_edges.
(af_cjk_metrics_init_blues): New function, CJK version of
af_latin_metrics_init_blues.
(af_cjk_hints_edges): Add code to align the edge stems to blue zones.
* src/autofit/afindic.c (af_indic_metrics_init): Take AF_CJKMetric
instead of AF_LatinMetric, and initialize as af_cjk_metrics_init.
However bluezones are not initialized.
(af_indic_metrics_scale): Take AF_CJKMetric instead of AF_LatinMetric.
(af_indic_hints_init): Ditto.
(af_indic_hints_apply): Ditto.
* docs/CHANGES: Note about CJK bluezone support.
2011-05-08 12:07:13 +02:00
|
|
|
af_cjk_metrics_init_blues( metrics, face, af_cjk_blue_chars );
|
|
|
|
#endif
|
|
|
|
af_cjk_metrics_check_digits( metrics, face );
|
|
|
|
}
|
|
|
|
|
|
|
|
FT_Set_Charmap( face, oldmap );
|
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
return FT_Err_Ok;
|
2007-06-26 06:44:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2011-05-09 09:48:49 +02:00
|
|
|
af_indic_metrics_scale( AF_CJKMetrics metrics,
|
|
|
|
AF_Scaler scaler )
|
2007-06-26 06:44:35 +02:00
|
|
|
{
|
|
|
|
/* use CJK routines */
|
|
|
|
af_cjk_metrics_scale( metrics, scaler );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
2011-05-09 09:48:49 +02:00
|
|
|
af_indic_hints_init( AF_GlyphHints hints,
|
|
|
|
AF_CJKMetrics metrics )
|
2007-06-26 06:44:35 +02:00
|
|
|
{
|
|
|
|
/* use CJK routines */
|
|
|
|
return af_cjk_hints_init( hints, metrics );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
2015-09-03 06:47:30 +02:00
|
|
|
af_indic_hints_apply( FT_UInt glyph_index,
|
|
|
|
AF_GlyphHints hints,
|
2011-05-09 09:48:49 +02:00
|
|
|
FT_Outline* outline,
|
|
|
|
AF_CJKMetrics metrics )
|
2007-06-26 06:44:35 +02:00
|
|
|
{
|
|
|
|
/* use CJK routines */
|
2015-09-03 06:47:30 +02:00
|
|
|
return af_cjk_hints_apply( glyph_index, hints, outline, metrics );
|
2007-06-26 06:44:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-02 09:32:26 +01:00
|
|
|
/* Extract standard_width from writing system/script specific */
|
|
|
|
/* metrics class. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
af_indic_get_standard_widths( AF_CJKMetrics metrics,
|
|
|
|
FT_Pos* stdHW,
|
|
|
|
FT_Pos* stdVW )
|
|
|
|
{
|
|
|
|
if ( stdHW )
|
|
|
|
*stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width;
|
|
|
|
|
|
|
|
if ( stdVW )
|
|
|
|
*stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-26 06:44:35 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** I N D I C S C R I P T C L A S S *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
2013-07-31 22:49:29 +02:00
|
|
|
AF_DEFINE_WRITING_SYSTEM_CLASS(
|
|
|
|
af_indic_writing_system_class,
|
2007-06-26 06:44:35 +02:00
|
|
|
|
2013-07-31 22:49:29 +02:00
|
|
|
AF_WRITING_SYSTEM_INDIC,
|
2007-06-26 06:44:35 +02:00
|
|
|
|
2011-11-30 10:46:53 +01:00
|
|
|
sizeof ( AF_CJKMetricsRec ),
|
2007-06-26 06:44:35 +02:00
|
|
|
|
2016-09-17 17:12:50 +02:00
|
|
|
(AF_WritingSystem_InitMetricsFunc) af_indic_metrics_init, /* style_metrics_init */
|
|
|
|
(AF_WritingSystem_ScaleMetricsFunc)af_indic_metrics_scale, /* style_metrics_scale */
|
|
|
|
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
|
|
|
|
(AF_WritingSystem_GetStdWidthsFunc)af_indic_get_standard_widths, /* style_metrics_getstdw */
|
2007-06-26 06:44:35 +02:00
|
|
|
|
2016-09-17 17:12:50 +02:00
|
|
|
(AF_WritingSystem_InitHintsFunc) af_indic_hints_init, /* style_hints_init */
|
|
|
|
(AF_WritingSystem_ApplyHintsFunc) af_indic_hints_apply /* style_hints_apply */
|
2009-04-05 17:23:38 +02:00
|
|
|
)
|
2007-06-26 06:44:35 +02:00
|
|
|
|
|
|
|
|
2013-07-31 22:49:29 +02:00
|
|
|
#else /* !AF_CONFIG_OPTION_INDIC */
|
|
|
|
|
2013-12-19 15:45:24 +01:00
|
|
|
|
2013-07-31 22:49:29 +02:00
|
|
|
AF_DEFINE_WRITING_SYSTEM_CLASS(
|
|
|
|
af_indic_writing_system_class,
|
|
|
|
|
|
|
|
AF_WRITING_SYSTEM_INDIC,
|
2007-06-26 06:44:35 +02:00
|
|
|
|
2011-11-30 10:46:53 +01:00
|
|
|
sizeof ( AF_CJKMetricsRec ),
|
2007-06-26 06:44:35 +02:00
|
|
|
|
2016-09-17 17:12:50 +02:00
|
|
|
(AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */
|
|
|
|
(AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */
|
|
|
|
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
|
|
|
|
(AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */
|
2007-06-26 06:44:35 +02:00
|
|
|
|
2016-09-17 17:12:50 +02:00
|
|
|
(AF_WritingSystem_InitHintsFunc) NULL, /* style_hints_init */
|
|
|
|
(AF_WritingSystem_ApplyHintsFunc) NULL /* style_hints_apply */
|
2009-04-05 17:23:38 +02:00
|
|
|
)
|
2007-06-26 06:44:35 +02:00
|
|
|
|
2013-07-31 22:49:29 +02:00
|
|
|
|
2007-06-26 06:44:35 +02:00
|
|
|
#endif /* !AF_CONFIG_OPTION_INDIC */
|
|
|
|
|
|
|
|
|
|
|
|
/* END */
|