[autofit] Move declaration of scripts into separate file.

This has the benefit that we don't need to duplicate the data at
different places.

* src/autofit/afscript.h: New file.

* src/autofit/aftypes.h (AF_Script): Include `afscript.h' to define
the enumeration values.

* src/autofit/afglobal.c: Include `afscript.h' to get the script
specific header files.
(af_script_classes): Include `afscript.h' to fill this array.

* src/autofit/afpic.c: Include `afscript.h' to get the script
specific header files.
(autofit_module_class_pic_init): Include `afscript.h' for
initialization.
* src/autofit/afpic.h (AF_SCRIPT_CLASSES_COUNT,
AF_SCRIPT_CLASSES_REC_COUNT): Removed.  Use `AF_SCRIPT_MAX' instead.

* src/autofit/rules.mk (AUTOF_DRV_H): Updated.
This commit is contained in:
Werner Lemberg 2013-08-02 20:25:21 +02:00
parent 773601da12
commit 456cc440ca
8 changed files with 87 additions and 52 deletions

View File

@ -1,3 +1,28 @@
2013-08-02 Werner Lemberg <wl@gnu.org>
[autofit] Move declaration of scripts into separate file.
This has the benefit that we don't need to duplicate the data at
different places.
* src/autofit/afscript.h: New file.
* src/autofit/aftypes.h (AF_Script): Include `afscript.h' to define
the enumeration values.
* src/autofit/afglobal.c: Include `afscript.h' to get the script
specific header files.
(af_script_classes): Include `afscript.h' to fill this array.
* src/autofit/afpic.c: Include `afscript.h' to get the script
specific header files.
(autofit_module_class_pic_init): Include `afscript.h' for
initialization.
* src/autofit/afpic.h (AF_SCRIPT_CLASSES_COUNT,
AF_SCRIPT_CLASSES_REC_COUNT): Removed. Use `AF_SCRIPT_MAX' instead.
* src/autofit/rules.mk (AUTOF_DRV_H): Updated.
2013-08-02 Werner Lemberg <wl@gnu.org>
[autofit] Move declaration of writing systems into separate file.

View File

@ -50,20 +50,16 @@
};
/* when updating this table, don't forget to update */
/* AF_SCRIPT_CLASSES_COUNT and autofit_module_class_pic_init */
#undef SCRIPT
#define SCRIPT( s, S ) \
&af_ ## s ## _script_class,
/* populate this list when you add new scripts */
FT_LOCAL_ARRAY_DEF( AF_ScriptClass )
af_script_classes[] =
{
&af_dflt_script_class, /* XXX */
&af_latn_script_class,
&af_hani_script_class,
&af_deva_script_class,
#ifdef FT_OPTION_AUTOFIT2
&af_ltn2_script_class,
#endif
#include "afscript.h"
NULL /* do not remove */
};

View File

@ -42,9 +42,9 @@ FT_BEGIN_HEADER
/* index of fallback script in `af_script_classes' */
#ifdef AF_CONFIG_OPTION_CJK
#define AF_SCRIPT_FALLBACK 2 /* hani */
#define AF_SCRIPT_FALLBACK AF_SCRIPT_HANI
#else
#define AF_SCRIPT_FALLBACK 0 /* dflt */
#define AF_SCRIPT_FALLBACK AF_SCRIPT_DFLT
#endif
/* a bit mask indicating an uncovered glyph */
#define AF_SCRIPT_NONE 0x7F

View File

@ -100,14 +100,12 @@
for ( ss = 0; ss < AF_WRITING_SYSTEM_MAX - 1; ss++ )
container->af_writing_system_classes[ss] =
&container->af_writing_system_classes_rec[ss];
container->af_writing_system_classes
[AF_WRITING_SYSTEM_MAX - 1] = NULL;
container->af_writing_system_classes[AF_WRITING_SYSTEM_MAX - 1] = NULL;
for ( ss = 0; ss < AF_SCRIPT_CLASSES_REC_COUNT; ss++ )
for ( ss = 0; ss < AF_SCRIPT_MAX - 1; ss++ )
container->af_script_classes[ss] =
&container->af_script_classes_rec[ss];
container->af_script_classes
[AF_SCRIPT_CLASSES_COUNT - 1] = NULL;
container->af_script_classes[AF_SCRIPT_MAX - 1] = NULL;
#undef WRITING_SYSTEM
#define WRITING_SYSTEM( ws, WS ) \
@ -115,22 +113,15 @@
&container->af_writing_system_classes_rec[ss++] );
ss = 0;
#include "afwrtsys.h"
#undef SCRIPT
#define SCRIPT( s, S ) \
FT_Init_Class_af_ ## s ## _script_class( \
&container->af_script_classes_rec[ss++] );
ss = 0;
FT_Init_Class_af_dflt_script_class(
&container->af_script_classes_rec[ss++] );
FT_Init_Class_af_latn_script_class(
&container->af_script_classes_rec[ss++] );
FT_Init_Class_af_hani_script_class(
&container->af_script_classes_rec[ss++] );
FT_Init_Class_af_deva_script_class(
&container->af_script_classes_rec[ss++] );
#ifdef FT_OPTION_AUTOFIT2
FT_Init_Class_af_ltn2_script_class(
&container->af_script_classes_rec[ss++] );
#endif
#include "afscript.h"
FT_Init_Class_af_autofitter_interface(
library, &container->af_autofitter_interface );

View File

@ -41,15 +41,6 @@ FT_BEGIN_HEADER
#include "aftypes.h"
#ifdef FT_OPTION_AUTOFIT2
#define AF_SCRIPT_CLASSES_COUNT 6
#else
#define AF_SCRIPT_CLASSES_COUNT 5
#endif
#define AF_SCRIPT_CLASSES_REC_COUNT \
( AF_SCRIPT_CLASSES_COUNT - 1 )
typedef struct AFModulePIC_
{
@ -62,9 +53,9 @@ FT_BEGIN_HEADER
[AF_WRITING_SYSTEM_MAX - 1];
AF_ScriptClass af_script_classes
[AF_SCRIPT_CLASSES_COUNT];
[AF_SCRIPT_MAX];
AF_ScriptClassRec af_script_classes_rec
[AF_SCRIPT_CLASSES_REC_COUNT];
[AF_SCRIPT_MAX - 1];
FT_AutoHinter_InterfaceRec af_autofitter_interface;

34
src/autofit/afscript.h Normal file
View File

@ -0,0 +1,34 @@
/***************************************************************************/
/* */
/* afscript.h */
/* */
/* Auto-fitter scripts (specification only). */
/* */
/* Copyright 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
/* The following part can be included multiple times. */
/* Define `SCRIPT' as needed. */
/* Add new scripts here. */
SCRIPT( dflt, DFLT )
SCRIPT( latn, LATN )
SCRIPT( hani, HANI )
SCRIPT( deva, DEVA )
#ifdef FT_OPTION_AUTOFIT2
SCRIPT( ltn2, LTN2 )
#endif
/* END */

View File

@ -322,19 +322,15 @@ extern void* _af_debug_hints;
* We use four-letter script tags from the OpenType specification.
*/
#undef SCRIPT
#define SCRIPT(s, S ) \
AF_SCRIPT_ ## S,
/* The list of known scripts. */
typedef enum AF_Script_
{
AF_SCRIPT_DFLT = 0,
AF_SCRIPT_LATN = 1,
AF_SCRIPT_HANI = 2,
AF_SCRIPT_DEVA = 3,
#ifdef FT_OPTION_AUTOFIT2
AF_SCRIPT_LTN2 = 4,
#endif
/* Add new scripts here. Don't forget to update */
/* the list in `afglobal.c'. */
#include "afscript.h"
AF_SCRIPT_MAX /* do not remove */

View File

@ -3,7 +3,7 @@
#
# Copyright 2003, 2004, 2005, 2006, 2007, 2011 by
# Copyright 2003-2007, 2011, 2013 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@ -41,7 +41,9 @@ AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \
#
AUTOF_DRV_H := $(AUTOF_DRV_SRC:%c=%h) \
$(AUTOF_DIR)/aferrors.h \
$(AUTOF_DIR)/aftypes.h
$(AUTOF_DIR)/afscript.h \
$(AUTOF_DIR)/aftypes.h \
$(AUTOF_DIR)/afwrtsys.h
# AUTOF driver object(s)