[Scummvm-git-logs] scummvm master -> d117a48aaff513408e6bea2ec955d11026dd54f8
sev-
noreply at scummvm.org
Sun Sep 3 20:27:56 UTC 2023
This automated email contains information about 25 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1856e56202 GRAPHICS: Add Init/Done_FreeType_With_Mem to common freetype
e4548cf1d7 AGS: Import autohinter module from freetype2.1.3
63fd2b928a AGS: Import glyph loader and some helpers from freetype2.1.3
4c020ac290 AGS: Freetype: Add minimal fterrors and cleanup ftutil
365e74d51f AGS: Freetype: Clean up ftgloadr.h/cpp
c2ee3b8b34 AGS: Freetype: Add required FT_SubGlyph type to ftgloadr
5ea6b4c048 AGS: Freetype: Fix includes/declarations in ahangles / ahglobal
7b39ad094a AGS: Freetype: Fix includes in ahtypes
35b82f7c8f AGS: Freetype: Cleanup ahglyph/ahhint/ahloader headers
b318122139 AGS: Freetype: Fix headers/declarations ahglyph
a0211934db AGS: Freetype: Fix headers/declarations ahhint
4843b18fb2 AGS: Freetype: Use FT_Memory in ah_hinter_new
cc168a16dd AGS: Freetype: Disable uncompilable code in ahhint
cee11c1b99 AGS: Freetype: Update alfont and enable compilation
d2e445fc49 AGS: Freetype: apply autohinting in alfont glyph loader
1698b26bcb AGS: Freetype: remove unneeded files
1d7b009638 AGS: Freetype: Remove newline from warnings
c08d7492c4 AGS: Freetype: Remove unneeded debugging directives
ccf816a83a AGS: Freetype: Use scummvm debug logging
4a33374939 AGS: Freetype: Use scummvm logging in autohint debug functions
85db570098 AGS: Freetype: Remove unused variable
7279c8a540 AGS: Freetype: Trim include paths
ab6b7b0360 DISTS: Add Catharon license and include in builds
892f46f382 AGS: Freetype: Build autohint sources only if freetype2 is enabled
d117a48aaf DISTS: Keep Catharon license original naming
Commit: 1856e56202d4a05ceaee3b90cf61409cb963e933
https://github.com/scummvm/scummvm/commit/1856e56202d4a05ceaee3b90cf61409cb963e933
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
GRAPHICS: Add Init/Done_FreeType_With_Mem to common freetype
These are needed for the new alfont implementation in AGS
Changed paths:
graphics/fonts/freetype.cpp
graphics/fonts/freetype.h
diff --git a/graphics/fonts/freetype.cpp b/graphics/fonts/freetype.cpp
index 4c2453690f0..755751c2ac2 100644
--- a/graphics/fonts/freetype.cpp
+++ b/graphics/fonts/freetype.cpp
@@ -30,10 +30,43 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
+#include FT_MODULE_H
namespace Graphics {
namespace FreeType {
+void *Alloc_Callback(FT_Memory memory, long size) {
+ return realloc(nullptr, static_cast<size_t>(size));
+}
+
+void Free_Callback(FT_Memory memory, void *block) {
+ realloc(block, 0);
+}
+
+void *Realloc_Callback(FT_Memory memory, long cur_size, long new_size, void *block) {
+ return realloc(block, static_cast<size_t>(new_size));
+}
+
+FT_Error Init_FreeType_With_Mem(FT_Library *alibrary, FT_Memory *amem) {
+ // It seems FT_New_Memory isn't part of the public API in 2.10.4
+ FT_Memory mem = static_cast<FT_Memory>(malloc(sizeof(FT_MemoryRec_)));
+ if (!mem)
+ return FT_Err_Out_Of_Memory;
+
+ mem->alloc = Alloc_Callback;
+ mem->free = Free_Callback;
+ mem->realloc = Realloc_Callback;
+ mem->user = nullptr;
+
+ FT_Error error = FT_New_Library(mem, alibrary);
+ if (!error) {
+ FT_Add_Default_Modules(*alibrary);
+ *amem = mem;
+ }
+
+ return error;
+}
+
FT_Error Init_FreeType(FT_Library *alibrary) {
return FT_Init_FreeType(alibrary);
}
@@ -42,6 +75,12 @@ FT_Error Done_FreeType(FT_Library library) {
return FT_Done_FreeType(library);
}
+FT_Error Done_FreeType_With_Mem(FT_Library library, FT_Memory mem) {
+ FT_Error error = FT_Done_Library(library);
+ free(mem);
+ return error;
+}
+
FT_Error Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags) {
return FT_Load_Glyph(face, glyph_index, load_flags);
}
diff --git a/graphics/fonts/freetype.h b/graphics/fonts/freetype.h
index 2d588256980..abf11495403 100644
--- a/graphics/fonts/freetype.h
+++ b/graphics/fonts/freetype.h
@@ -33,7 +33,9 @@ namespace Graphics {
namespace FreeType {
extern FT_Error Init_FreeType(FT_Library *alibrary);
+extern FT_Error Init_FreeType_With_Mem(FT_Library *alibrary, FT_Memory *amem);
extern FT_Error Done_FreeType(FT_Library library);
+extern FT_Error Done_FreeType_With_Mem(FT_Library library, FT_Memory mem);
extern FT_Error Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags);
extern FT_Error Get_Glyph(FT_GlyphSlot slot, FT_Glyph *aglyph);
extern FT_Error Glyph_Copy(FT_Glyph source, FT_Glyph *target);
Commit: e4548cf1d7523c91873bcb6d43379aa6994a4dc2
https://github.com/scummvm/scummvm/commit/e4548cf1d7523c91873bcb6d43379aa6994a4dc2
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Import autohinter module from freetype2.1.3
Changed paths:
A engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp
A engines/ags/lib/freetype-2.1.3/autohint/ahangles.h
A engines/ags/lib/freetype-2.1.3/autohint/aherrors.h
A engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
A engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h
A engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
A engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h
A engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
A engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
A engines/ags/lib/freetype-2.1.3/autohint/ahloader.h
A engines/ags/lib/freetype-2.1.3/autohint/ahmodule.cpp
A engines/ags/lib/freetype-2.1.3/autohint/ahmodule.h
A engines/ags/lib/freetype-2.1.3/autohint/ahoptim.cpp
A engines/ags/lib/freetype-2.1.3/autohint/ahoptim.h
A engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
A engines/ags/lib/freetype-2.1.3/autohint/autohint.h
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp
new file mode 100644
index 00000000000..a3f990f151e
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp
@@ -0,0 +1,157 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahangles.c */
+/* */
+/* A routine used to compute vector angles with limited accuracy */
+/* and very high speed (body). */
+/* */
+/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahangles.h"
+
+namespace AGS3 {
+namespace FreeType213 {
+
+/* the following table has been automatically generated with */
+/* the `mather.py' Python script */
+
+const AH_Angle ah_arctan[1L << AH_ATAN_BITS] = {
+ 0, 0, 1, 1, 1, 2, 2, 2,
+ 3, 3, 3, 3, 4, 4, 4, 5,
+ 5, 5, 6, 6, 6, 7, 7, 7,
+ 8, 8, 8, 9, 9, 9, 10, 10,
+ 10, 10, 11, 11, 11, 12, 12, 12,
+ 13, 13, 13, 14, 14, 14, 14, 15,
+ 15, 15, 16, 16, 16, 17, 17, 17,
+ 18, 18, 18, 18, 19, 19, 19, 20,
+ 20, 20, 21, 21, 21, 21, 22, 22,
+ 22, 23, 23, 23, 24, 24, 24, 24,
+ 25, 25, 25, 26, 26, 26, 26, 27,
+ 27, 27, 28, 28, 28, 28, 29, 29,
+ 29, 30, 30, 30, 30, 31, 31, 31,
+ 31, 32, 32, 32, 33, 33, 33, 33,
+ 34, 34, 34, 34, 35, 35, 35, 35,
+ 36, 36, 36, 36, 37, 37, 37, 38,
+ 38, 38, 38, 39, 39, 39, 39, 40,
+ 40, 40, 40, 41, 41, 41, 41, 42,
+ 42, 42, 42, 42, 43, 43, 43, 43,
+ 44, 44, 44, 44, 45, 45, 45, 45,
+ 46, 46, 46, 46, 46, 47, 47, 47,
+ 47, 48, 48, 48, 48, 48, 49, 49,
+ 49, 49, 50, 50, 50, 50, 50, 51,
+ 51, 51, 51, 51, 52, 52, 52, 52,
+ 52, 53, 53, 53, 53, 53, 54, 54,
+ 54, 54, 54, 55, 55, 55, 55, 55,
+ 56, 56, 56, 56, 56, 57, 57, 57,
+ 57, 57, 57, 58, 58, 58, 58, 58,
+ 59, 59, 59, 59, 59, 59, 60, 60,
+ 60, 60, 60, 61, 61, 61, 61, 61,
+ 61, 62, 62, 62, 62, 62, 62, 63,
+ 63, 63, 63, 63, 63, 64, 64, 64
+};
+
+FT_LOCAL_DEF(AH_Angle)
+ah_angle(FT_Vector *v) {
+ FT_Pos dx, dy;
+ AH_Angle angle;
+
+ dx = v->x;
+ dy = v->y;
+
+ /* check trivial cases */
+ if (dy == 0) {
+ angle = 0;
+ if (dx < 0)
+ angle = AH_PI;
+ return angle;
+ } else if (dx == 0) {
+ angle = AH_HALF_PI;
+ if (dy < 0)
+ angle = -AH_HALF_PI;
+ return angle;
+ }
+
+ angle = 0;
+ if (dx < 0) {
+ dx = -v->x;
+ dy = -v->y;
+ angle = AH_PI;
+ }
+
+ if (dy < 0) {
+ FT_Pos tmp;
+
+ tmp = dx;
+ dx = -dy;
+ dy = tmp;
+ angle -= AH_HALF_PI;
+ }
+
+ if (dx == 0 && dy == 0)
+ return 0;
+
+ if (dx == dy)
+ angle += AH_PI / 4;
+ else if (dx > dy)
+ angle += ah_arctan[FT_DivFix(dy, dx) >> (16 - AH_ATAN_BITS)];
+ else
+ angle += AH_HALF_PI - ah_arctan[FT_DivFix(dx, dy) >> (16 - AH_ATAN_BITS)];
+
+ if (angle > AH_PI)
+ angle -= AH_2PI;
+
+ return angle;
+}
+
+
+FT_LOCAL_DEF(AH_Angle)
+ah_angle_diff(AH_Angle angle1, AH_Angle angle2) {
+ AH_Angle delta;
+
+ delta = (angle2 - angle1);
+ if (delta < 0)
+ delta += AH_2PI;
+
+ if (delta > AH_PI)
+ delta -= AH_2PI;
+
+ return delta;
+}
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahangles.h b/engines/ags/lib/freetype-2.1.3/autohint/ahangles.h
new file mode 100644
index 00000000000..8be06c48138
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahangles.h
@@ -0,0 +1,83 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahangles.h */
+/* */
+/* A routine used to compute vector angles with limited accuracy */
+/* and very high speed (specification). */
+/* */
+/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+#ifndef AGS_LIB_FREETYPE_AHANGLES_H
+#define AGS_LIB_FREETYPE_AHANGLES_H
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/ftobjs.h"
+#include "ahtypes.h"
+
+namespace AGS3 {
+namespace FreeType213 {
+
+// FT_BEGIN_HEADER
+
+
+/* PI expressed in ah_angles -- we don't really need an important */
+/* precision, so 256 should be enough */
+#define AH_PI 256
+#define AH_2PI (AH_PI * 2)
+#define AH_HALF_PI (AH_PI / 2)
+#define AH_2PIMASK (AH_2PI - 1)
+
+/* the number of bits used to express an arc tangent; */
+/* see the structure of the lookup table */
+#define AH_ATAN_BITS 8
+
+extern const AH_Angle ah_arctan[1L << AH_ATAN_BITS];
+
+FT_LOCAL(AH_Angle)
+ah_angle(FT_Vector *v);
+
+FT_LOCAL(AH_Angle)
+ah_angle_diff(AH_Angle angle1, AH_Angle angle2);
+
+
+// FT_END_HEADER
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
+
+#endif /* AGS_LIB_FREETYPE_AHANGLES_H */
\ No newline at end of file
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/aherrors.h b/engines/ags/lib/freetype-2.1.3/autohint/aherrors.h
new file mode 100644
index 00000000000..640096f2347
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/aherrors.h
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* aherrors.h */
+/* */
+/* Autohinter error codes (specification only). */
+/* */
+/* Copyright 2001 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. */
+/* */
+/***************************************************************************/
+
+
+/*************************************************************************/
+/* */
+/* This file is used to define the Autohinter error enumeration */
+/* constants. */
+/* */
+/*************************************************************************/
+
+#ifndef AGS_LIB_FREETYPE_AHERRORS_H
+#define AGS_LIB_FREETYPE_AHERRORS_H
+
+#include "engines/ags/lib/freetype-2.1.3/ftmoderr.h"
+
+#undef AGS_LIB_FREETYPE_FTERRORS_H
+
+#define FT_ERR_PREFIX AH_Err_
+#define FT_ERR_BASE FT_Mod_Err_Autohint
+
+#include "engines/ags/lib/freetype-2.1.3/fterrors.h"
+
+#endif /* AGS_LIB_FREETYPE_AHERRORS_H */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
new file mode 100644
index 00000000000..9ef5ef35fa9
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
@@ -0,0 +1,372 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahglobal.c */
+/* */
+/* Routines used to compute global metrics automatically (body). */
+/* */
+/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/ftdebug.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahglobal.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahglyph.h"
+
+
+#define MAX_TEST_CHARACTERS 12
+
+namespace AGS3 {
+namespace FreeType213 {
+
+
+static const char* blue_chars[AH_BLUE_MAX] = {
+ "THEZOCQS",
+ "HEZLOCUS",
+ "xzroesc",
+ "xzroesc",
+ "pqgjy"
+};
+
+/* simple insertion sort */
+static void sort_values(FT_Int count, FT_Pos *table) {
+ FT_Int i, j;
+ FT_Pos swap;
+
+ for (i = 1; i < count; i++) {
+ for (j = i; j > 0; j--) {
+ if (table[j] > table[j - 1])
+ break;
+
+ swap = table[j];
+ table[j] = table[j - 1];
+ table[j - 1] = swap;
+ }
+ }
+}
+
+static FT_Error ah_hinter_compute_blues(AH_Hinter hinter) {
+ AH_Blue blue;
+ AH_Globals globals = &hinter->globals->design;
+ FT_Pos flats[MAX_TEST_CHARACTERS];
+ FT_Pos rounds[MAX_TEST_CHARACTERS];
+ FT_Int num_flats;
+ FT_Int num_rounds;
+
+ FT_Face face;
+ FT_GlyphSlot glyph;
+ FT_Error error;
+ FT_CharMap charmap;
+
+ face = hinter->face;
+ glyph = face->glyph;
+
+ /* save current charmap */
+ charmap = face->charmap;
+
+ /* do we have a Unicode charmap in there? */
+ error = FT_Select_Charmap(face, FT_ENCODING_UNICODE);
+ if (error)
+ goto Exit;
+
+ /* we compute the blues simply by loading each character from the */
+ /* 'blue_chars[blues]' string, then compute its top-most and */
+ /* bottom-most points */
+
+ AH_LOG(("blue zones computation\n"));
+ AH_LOG(("------------------------------------------------\n"));
+
+ for (blue = AH_BLUE_CAPITAL_TOP; blue < AH_BLUE_MAX; blue++) {
+ const char *p = blue_chars[blue];
+ const char *limit = p + MAX_TEST_CHARACTERS;
+ FT_Pos *blue_ref, *blue_shoot;
+
+ AH_LOG(("blue %3d: ", blue));
+
+ num_flats = 0;
+ num_rounds = 0;
+
+ for (; p < limit; p++) {
+ FT_UInt glyph_index;
+ FT_Vector *extremum;
+ FT_Vector *points;
+ FT_Vector *point_limit;
+ FT_Vector *point;
+ FT_Bool round;
+
+ /* exit if we reach the end of the string */
+ if (!*p)
+ break;
+
+ AH_LOG(("`%c'", *p));
+
+ /* load the character in the face -- skip unknown or empty ones */
+ glyph_index = FT_Get_Char_Index(face, (FT_UInt)*p);
+ if (glyph_index == 0)
+ continue;
+
+ error = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE);
+ if (error || glyph->outline.n_points <= 0)
+ continue;
+
+ /* now compute min or max point indices and coordinates */
+ points = glyph->outline.points;
+ point_limit = points + glyph->outline.n_points;
+ point = points;
+ extremum = point;
+ point++;
+
+ if (AH_IS_TOP_BLUE(blue)) {
+ for (; point < point_limit; point++)
+ if (point->y > extremum->y)
+ extremum = point;
+ } else {
+ for (; point < point_limit; point++)
+ if (point->y < extremum->y)
+ extremum = point;
+ }
+
+ AH_LOG(("%5d", (int)extremum->y));
+
+ /* now, check whether the point belongs to a straight or round */
+ /* segment; we first need to find in which contour the extremum */
+ /* lies, then see its previous and next points */
+ {
+ FT_Int idx = (FT_Int)(extremum - points);
+ FT_Int n;
+ FT_Int first, last, prev, next, end;
+ FT_Pos dist;
+
+ last = -1;
+ first = 0;
+
+ for (n = 0; n < glyph->outline.n_contours; n++) {
+ end = glyph->outline.contours[n];
+ if (end >= idx) {
+ last = end;
+ break;
+ }
+ first = end + 1;
+ }
+
+ /* XXX: should never happen! */
+ if (last < 0)
+ continue;
+
+ /* now look for the previous and next points that are not on the */
+ /* same Y coordinate. Threshold the `closeness'... */
+
+ prev = idx;
+ next = prev;
+
+ do {
+ if (prev > first)
+ prev--;
+ else
+ prev = last;
+
+ dist = points[prev].y - extremum->y;
+ if (dist < -5 || dist > 5)
+ break;
+
+ } while (prev != idx);
+
+ do {
+ if (next < last)
+ next++;
+ else
+ next = first;
+
+ dist = points[next].y - extremum->y;
+ if (dist < -5 || dist > 5)
+ break;
+
+ } while (next != idx);
+
+ /* now, set the `round' flag depending on the segment's kind */
+ round = FT_BOOL(
+ FT_CURVE_TAG(glyph->outline.tags[prev]) != FT_CURVE_TAG_ON ||
+ FT_CURVE_TAG(glyph->outline.tags[next]) != FT_CURVE_TAG_ON);
+
+ AH_LOG(("%c ", round ? 'r' : 'f'));
+ }
+
+ if (round)
+ rounds[num_rounds++] = extremum->y;
+ else
+ flats[num_flats++] = extremum->y;
+ }
+
+ AH_LOG(("\n"));
+
+ /* we have computed the contents of the `rounds' and `flats' tables, */
+ /* now determine the reference and overshoot position of the blue; */
+ /* we simply take the median value after a simple short */
+ sort_values(num_rounds, rounds);
+ sort_values(num_flats, flats);
+
+ blue_ref = globals->blue_refs + blue;
+ blue_shoot = globals->blue_shoots + blue;
+ if (num_flats == 0 && num_rounds == 0) {
+ *blue_ref = -10000;
+ *blue_shoot = -10000;
+ } else if (num_flats == 0) {
+ *blue_ref = *blue_shoot = rounds[num_rounds / 2];
+ } else if (num_rounds == 0) {
+ *blue_ref = *blue_shoot = flats[num_flats / 2];
+ } else {
+ *blue_ref = flats[num_flats / 2];
+ *blue_shoot = rounds[num_rounds / 2];
+ }
+
+ /* there are sometimes problems: if the overshoot position of top */
+ /* zones is under its reference position, or the opposite for bottom */
+ /* zones. We must thus check everything there and correct the errors */
+ if (*blue_shoot != *blue_ref) {
+ FT_Pos ref = *blue_ref;
+ FT_Pos shoot = *blue_shoot;
+ FT_Bool over_ref = FT_BOOL(shoot > ref);
+
+ if (AH_IS_TOP_BLUE(blue) ^ over_ref)
+ *blue_shoot = *blue_ref = (shoot + ref) / 2;
+ }
+
+ AH_LOG(("-- ref = %ld, shoot = %ld\n", *blue_ref, *blue_shoot));
+ }
+
+ /* reset original face charmap */
+ FT_Set_Charmap(face, charmap);
+ error = 0;
+
+Exit:
+ return error;
+}
+
+static FT_Error ah_hinter_compute_widths(AH_Hinter hinter) {
+ /* scan the array of segments in each direction */
+ AH_Outline outline = hinter->glyph;
+ AH_Segment segments;
+ AH_Segment limit;
+ AH_Globals globals = &hinter->globals->design;
+ FT_Pos *widths;
+ FT_Int dimension;
+ FT_Int *p_num_widths;
+ FT_Error error = 0;
+ FT_Pos edge_distance_threshold = 32000;
+
+ globals->num_widths = 0;
+ globals->num_heights = 0;
+
+ /* For now, compute the standard width and height from the `o' */
+ /* character. I started computing the stem width of the `i' and the */
+ /* stem height of the "-", but it wasn't too good. Moreover, we now */
+ /* have a single character that gives us standard width and height. */
+ {
+ FT_UInt glyph_index;
+
+ glyph_index = FT_Get_Char_Index(hinter->face, 'o');
+ if (glyph_index == 0)
+ return 0;
+
+ error = FT_Load_Glyph(hinter->face, glyph_index, FT_LOAD_NO_SCALE);
+ if (error)
+ goto Exit;
+
+ error = ah_outline_load(hinter->glyph, hinter->face);
+ if (error)
+ goto Exit;
+
+ ah_outline_compute_segments(hinter->glyph);
+ ah_outline_link_segments(hinter->glyph);
+ }
+
+ segments = outline->horz_segments;
+ limit = segments + outline->num_hsegments;
+ widths = globals->heights;
+ p_num_widths = &globals->num_heights;
+
+ for (dimension = 1; dimension >= 0; dimension--) {
+ AH_Segment seg = segments;
+ AH_Segment link;
+ FT_Int num_widths = 0;
+
+ for (; seg < limit; seg++) {
+ link = seg->link;
+ /* we only consider stem segments there! */
+ if (link && link->link == seg && link > seg) {
+ FT_Pos dist;
+
+ dist = seg->pos - link->pos;
+ if (dist < 0)
+ dist = -dist;
+
+ if (num_widths < AH_MAX_WIDTHS)
+ widths[num_widths++] = dist;
+ }
+ }
+
+ sort_values(num_widths, widths);
+ *p_num_widths = num_widths;
+
+ /* we will now try to find the smallest width */
+ if (num_widths > 0 && widths[0] < edge_distance_threshold)
+ edge_distance_threshold = widths[0];
+
+ segments = outline->vert_segments;
+ limit = segments + outline->num_vsegments;
+ widths = globals->widths;
+ p_num_widths = &globals->num_widths;
+ }
+
+ /* Now, compute the edge distance threshold as a fraction of the */
+ /* smallest width in the font. Set it in `hinter.glyph' too! */
+ if (edge_distance_threshold == 32000)
+ edge_distance_threshold = 50;
+
+ /* let's try 20% */
+ hinter->glyph->edge_distance_threshold = edge_distance_threshold / 5;
+
+Exit:
+ return error;
+}
+
+FT_LOCAL_DEF(FT_Error)
+ah_hinter_compute_globals(AH_Hinter hinter) {
+ return ah_hinter_compute_widths(hinter) || ah_hinter_compute_blues(hinter);
+}
+
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h
new file mode 100644
index 00000000000..1cc0e20963d
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h
@@ -0,0 +1,70 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahglobal.h */
+/* */
+/* Routines used to compute global metrics automatically */
+/* (specification). */
+/* */
+/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+#ifndef AGS_LIB_FREETYPE_AHGLOBAL_H
+#define AGS_LIB_FREETYPE_AHGLOBAL_H
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahtypes.h"
+#include "engines/ags/lib/freetype-2.1.3/ftobjs.h"
+
+namespace AGS3 {
+namespace FreeType213 {
+
+// FT_BEGIN_HEADER
+
+
+#define AH_IS_TOP_BLUE(b) ((b) == AH_BLUE_CAPITAL_TOP || (b) == AH_BLUE_SMALL_TOP)
+
+/* compute global metrics automatically */
+FT_LOCAL(FT_Error)
+ah_hinter_compute_globals(AH_Hinter hinter);
+
+
+// FT_END_HEADER
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
+
+#endif /* AGS_LIB_FREETYPE_AHGLOBAL_H */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
new file mode 100644
index 00000000000..30b3f76458b
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
@@ -0,0 +1,1333 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahglyph.c */
+/* */
+/* Routines used to load and analyze a given glyph before hinting */
+/* (body). */
+/* */
+/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahglyph.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahangles.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahglobal.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/aherrors.h"
+
+namespace AGS3 {
+namespace FreeType213 {
+
+#ifdef AH_DEBUG
+
+#include <stdio.h>
+
+void ah_dump_edges(AH_Outline outline) {
+ AH_Edge edges;
+ AH_Edge edge_limit;
+ AH_Segment segments;
+ FT_Int dimension;
+
+ edges = outline->horz_edges;
+ edge_limit = edges + outline->num_hedges;
+ segments = outline->horz_segments;
+
+ for (dimension = 1; dimension >= 0; dimension--) {
+ AH_Edge edge;
+
+ printf("Table of %s edges:\n", !dimension ? "vertical" : "horizontal");
+ printf(" [ index | pos | dir | link |"
+ " serif | blue | opos | pos ]\n");
+
+ for (edge = edges; edge < edge_limit; edge++) {
+ printf(" [ %5d | %4d | %5s | %4d | %5d | %c | %5.2f | %5.2f ]\n",
+ edge - edges,
+ (int)edge->fpos,
+ edge->dir == AH_DIR_UP
+ ? "up"
+ : (edge->dir == AH_DIR_DOWN
+ ? "down"
+ : (edge->dir == AH_DIR_LEFT
+ ? "left"
+ : (edge->dir == AH_DIR_RIGHT
+ ? "right"
+ : "none"))),
+ edge->link ? (edge->link - edges) : -1,
+ edge->serif ? (edge->serif - edges) : -1,
+ edge->blue_edge ? 'y' : 'n',
+ edge->opos / 64.0,
+ edge->pos / 64.0);
+ }
+
+ edges = outline->vert_edges;
+ edge_limit = edges + outline->num_vedges;
+ segments = outline->vert_segments;
+ }
+}
+
+/* A function used to dump the array of linked segments */
+void ah_dump_segments(AH_Outline outline) {
+ AH_Segment segments;
+ AH_Segment segment_limit;
+ AH_Point points;
+ FT_Int dimension;
+
+ points = outline->points;
+ segments = outline->horz_segments;
+ segment_limit = segments + outline->num_hsegments;
+
+ for (dimension = 1; dimension >= 0; dimension--) {
+ AH_Segment seg;
+
+ printf("Table of %s segments:\n",
+ !dimension ? "vertical" : "horizontal");
+ printf(" [ index | pos | dir | link | serif |"
+ " numl | first | start ]\n");
+
+ for (seg = segments; seg < segment_limit; seg++) {
+ printf(" [ %5d | %4d | %5s | %4d | %5d | %4d | %5d | %5d ]\n",
+ seg - segments,
+ (int)seg->pos,
+ seg->dir == AH_DIR_UP
+ ? "up"
+ : (seg->dir == AH_DIR_DOWN
+ ? "down"
+ : (seg->dir == AH_DIR_LEFT
+ ? "left"
+ : (seg->dir == AH_DIR_RIGHT
+ ? "right"
+ : "none"))),
+ seg->link ? (seg->link - segments) : -1,
+ seg->serif ? (seg->serif - segments) : -1,
+ (int)seg->num_linked,
+ seg->first - points,
+ seg->last - points);
+ }
+
+ segments = outline->vert_segments;
+ segment_limit = segments + outline->num_vsegments;
+ }
+}
+
+#endif /* AH_DEBUG */
+
+/* compute the direction value of a given vector.. */
+static AH_Direction ah_compute_direction(FT_Pos dx, FT_Pos dy) {
+ AH_Direction dir;
+ FT_Pos ax = ABS(dx);
+ FT_Pos ay = ABS(dy);
+
+ dir = AH_DIR_NONE;
+
+ /* test for vertical direction */
+ if (ax * 12 < ay) {
+ dir = dy > 0 ? AH_DIR_UP : AH_DIR_DOWN;
+ }
+ /* test for horizontal direction */
+ else if (ay * 12 < ax) {
+ dir = dx > 0 ? AH_DIR_RIGHT : AH_DIR_LEFT;
+ }
+
+ return dir;
+}
+
+/* this function is used by ah_get_orientation (see below) to test */
+/* the fill direction of a given bbox extrema */
+static FT_Int ah_test_extrema(FT_Outline *outline, FT_Int n) {
+ FT_Vector *prev, *cur, *next;
+ FT_Pos product;
+ FT_Int first, last, c;
+ FT_Int retval;
+
+ /* we need to compute the `previous' and `next' point */
+ /* for these extrema */
+ cur = outline->points + n;
+ prev = cur - 1;
+ next = cur + 1;
+
+ first = 0;
+ for (c = 0; c < outline->n_contours; c++) {
+ last = outline->contours[c];
+
+ if (n == first)
+ prev = outline->points + last;
+
+ if (n == last)
+ next = outline->points + first;
+
+ first = last + 1;
+ }
+
+ product = FT_MulDiv(cur->x - prev->x, /* in.x */
+ next->y - cur->y, /* out.y */
+ 0x40) -
+ FT_MulDiv(cur->y - prev->y, /* in.y */
+ next->x - cur->x, /* out.x */
+ 0x40);
+
+ retval = 0;
+ if (product)
+ retval = product > 0 ? 2 : 1;
+
+ return retval;
+}
+
+/* Compute the orientation of path filling. It differs between TrueType */
+/* and Type1 formats */
+static FT_Int ah_get_orientation(FT_Outline *outline) {
+ FT_BBox box;
+ FT_Int indices_xMin, indices_yMin, indices_xMax, indices_yMax;
+ FT_Int n, last;
+
+ indices_xMin = -1;
+ indices_yMin = -1;
+ indices_xMax = -1;
+ indices_yMax = -1;
+
+ box.xMin = box.yMin = 32767L;
+ box.xMax = box.yMax = -32768L;
+
+ /* is it empty? */
+ if (outline->n_contours < 1)
+ return 1;
+
+ last = outline->contours[outline->n_contours - 1];
+
+ for (n = 0; n <= last; n++) {
+ FT_Pos x, y;
+
+ x = outline->points[n].x;
+ if (x < box.xMin) {
+ box.xMin = x;
+ indices_xMin = n;
+ }
+ if (x > box.xMax) {
+ box.xMax = x;
+ indices_xMax = n;
+ }
+
+ y = outline->points[n].y;
+ if (y < box.yMin) {
+ box.yMin = y;
+ indices_yMin = n;
+ }
+ if (y > box.yMax) {
+ box.yMax = y;
+ indices_yMax = n;
+ }
+ }
+
+ /* test orientation of the xmin */
+ n = ah_test_extrema(outline, indices_xMin);
+ if (n)
+ goto Exit;
+
+ n = ah_test_extrema(outline, indices_yMin);
+ if (n)
+ goto Exit;
+
+ n = ah_test_extrema(outline, indices_xMax);
+ if (n)
+ goto Exit;
+
+ n = ah_test_extrema(outline, indices_yMax);
+ if (!n)
+ n = 1;
+
+Exit:
+ return n;
+}
+
+FT_LOCAL_DEF(FT_Error)
+ah_outline_new(FT_Memory memory, AH_Outline *aoutline) {
+ FT_Error error;
+ AH_Outline outline;
+
+ if (!FT_NEW(outline)) {
+ outline->memory = memory;
+ *aoutline = outline;
+ }
+
+ return error;
+}
+
+FT_LOCAL_DEF(void)
+ah_outline_done(AH_Outline outline) {
+ FT_Memory memory = outline->memory;
+
+ FT_FREE(outline->horz_edges);
+ FT_FREE(outline->horz_segments);
+ FT_FREE(outline->contours);
+ FT_FREE(outline->points);
+
+ FT_FREE(outline);
+}
+
+FT_LOCAL_DEF(void)
+ah_outline_save(AH_Outline outline, AH_Loader gloader) {
+ AH_Point point = outline->points;
+ AH_Point point_limit = point + outline->num_points;
+ FT_Vector *vec = gloader->current.outline.points;
+ char *tag = gloader->current.outline.tags;
+
+ /* we assume that the glyph loader has already been checked for storage */
+ for (; point < point_limit; point++, vec++, tag++) {
+ vec->x = point->x;
+ vec->y = point->y;
+
+ if (point->flags & AH_FLAG_CONIC)
+ tag[0] = FT_CURVE_TAG_CONIC;
+ else if (point->flags & AH_FLAG_CUBIC)
+ tag[0] = FT_CURVE_TAG_CUBIC;
+ else
+ tag[0] = FT_CURVE_TAG_ON;
+ }
+}
+
+FT_LOCAL_DEF(FT_Error)
+ah_outline_load(AH_Outline outline, FT_Face face) {
+ FT_Memory memory = outline->memory;
+ FT_Error error = FT_Err_Ok;
+ FT_Outline *source = &face->glyph->outline;
+ FT_Int num_points = source->n_points;
+ FT_Int num_contours = source->n_contours;
+ AH_Point points;
+
+ /* check arguments */
+ if (!face ||
+ !face->size ||
+ face->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
+ return FT_Err_Invalid_Argument;
+
+ /* first of all, reallocate the contours array if necessary */
+ if (num_contours > outline->max_contours) {
+ FT_Int new_contours = (num_contours + 3) & -4;
+
+ if (FT_RENEW_ARRAY(outline->contours,
+ outline->max_contours,
+ new_contours))
+ goto Exit;
+
+ outline->max_contours = new_contours;
+ }
+
+ /* then, reallocate the points, segments & edges arrays if needed -- */
+ /* note that we reserved two additional point positions, used to */
+ /* hint metrics appropriately */
+ /* */
+ if (num_points + 2 > outline->max_points) {
+ FT_Int news = (num_points + 2 + 7) & -8;
+ FT_Int max = outline->max_points;
+
+ if (FT_RENEW_ARRAY(outline->points, max, news) ||
+ FT_RENEW_ARRAY(outline->horz_edges, max * 2, news * 2) ||
+ FT_RENEW_ARRAY(outline->horz_segments, max * 2, news * 2))
+ goto Exit;
+
+ /* readjust some pointers */
+ outline->vert_edges = outline->horz_edges + news;
+ outline->vert_segments = outline->horz_segments + news;
+ outline->max_points = news;
+ }
+
+ outline->num_points = num_points;
+ outline->num_contours = num_contours;
+
+ outline->num_hedges = 0;
+ outline->num_vedges = 0;
+ outline->num_hsegments = 0;
+ outline->num_vsegments = 0;
+
+ /* We can't rely on the value of `FT_Outline.flags' to know the fill */
+ /* direction used for a glyph, given that some fonts are broken (e.g. */
+ /* the Arphic ones). We thus recompute it each time we need to. */
+ /* */
+ outline->vert_major_dir = AH_DIR_UP;
+ outline->horz_major_dir = AH_DIR_LEFT;
+
+ if (ah_get_orientation(source) > 1) {
+ outline->vert_major_dir = AH_DIR_DOWN;
+ outline->horz_major_dir = AH_DIR_RIGHT;
+ }
+
+ outline->x_scale = face->size->metrics.x_scale;
+ outline->y_scale = face->size->metrics.y_scale;
+
+ points = outline->points;
+ if (outline->num_points == 0)
+ goto Exit;
+
+ {
+ /* do one thing at a time -- it is easier to understand, and */
+ /* the code is clearer */
+ AH_Point point;
+ AH_Point point_limit = points + outline->num_points;
+
+ /* compute coordinates */
+ {
+ FT_Vector *vec = source->points;
+ FT_Fixed x_scale = outline->x_scale;
+ FT_Fixed y_scale = outline->y_scale;
+
+ for (point = points; point < point_limit; vec++, point++) {
+ point->fx = vec->x;
+ point->fy = vec->y;
+ point->ox = point->x = FT_MulFix(vec->x, x_scale);
+ point->oy = point->y = FT_MulFix(vec->y, y_scale);
+
+ point->flags = 0;
+ }
+ }
+
+ /* compute Bezier flags */
+ {
+ char *tag = source->tags;
+
+ for (point = points; point < point_limit; point++, tag++) {
+ switch (FT_CURVE_TAG(*tag)) {
+ case FT_CURVE_TAG_CONIC:
+ point->flags = AH_FLAG_CONIC;
+ break;
+ case FT_CURVE_TAG_CUBIC:
+ point->flags = AH_FLAG_CUBIC;
+ break;
+ default:;
+ }
+ }
+ }
+
+ /* compute `next' and `prev' */
+ {
+ FT_Int contour_index;
+ AH_Point prev;
+ AH_Point first;
+ AH_Point end;
+
+ contour_index = 0;
+
+ first = points;
+ end = points + source->contours[0];
+ prev = end;
+
+ for (point = points; point < point_limit; point++) {
+ point->prev = prev;
+ if (point < end) {
+ point->next = point + 1;
+ prev = point;
+ } else {
+ point->next = first;
+ contour_index++;
+ if (point + 1 < point_limit) {
+ end = points + source->contours[contour_index];
+ first = point + 1;
+ prev = end;
+ }
+ }
+ }
+ }
+
+ /* set-up the contours array */
+ {
+ AH_Point *contour = outline->contours;
+ AH_Point *contour_limit = contour + outline->num_contours;
+ short *end = source->contours;
+ short idx = 0;
+
+ for (; contour < contour_limit; contour++, end++) {
+ contour[0] = points + idx;
+ idx = (short)(end[0] + 1);
+ }
+ }
+
+ /* compute directions of in & out vectors */
+ {
+ for (point = points; point < point_limit; point++) {
+ AH_Point prev;
+ AH_Point next;
+ FT_Vector ivec, ovec;
+
+ prev = point->prev;
+ ivec.x = point->fx - prev->fx;
+ ivec.y = point->fy - prev->fy;
+
+ point->in_dir = ah_compute_direction(ivec.x, ivec.y);
+
+ next = point->next;
+ ovec.x = next->fx - point->fx;
+ ovec.y = next->fy - point->fy;
+
+ point->out_dir = ah_compute_direction(ovec.x, ovec.y);
+
+#ifndef AH_OPTION_NO_WEAK_INTERPOLATION
+ if (point->flags & (AH_FLAG_CONIC | AH_FLAG_CUBIC)) {
+ Is_Weak_Point:
+ point->flags |= AH_FLAG_WEAK_INTERPOLATION;
+ } else if (point->out_dir == point->in_dir) {
+ AH_Angle angle_in, angle_out, delta;
+
+ if (point->out_dir != AH_DIR_NONE)
+ goto Is_Weak_Point;
+
+ angle_in = ah_angle(&ivec);
+ angle_out = ah_angle(&ovec);
+ delta = angle_in - angle_out;
+
+ if (delta > AH_PI)
+ delta = AH_2PI - delta;
+
+ if (delta < 0)
+ delta = -delta;
+
+ if (delta < 2)
+ goto Is_Weak_Point;
+ } else if (point->in_dir == -point->out_dir)
+ goto Is_Weak_Point;
+#endif
+ }
+ }
+ }
+
+Exit:
+ return error;
+}
+
+FT_LOCAL_DEF(void)
+ah_setup_uv(AH_Outline outline, AH_UV source) {
+ AH_Point point = outline->points;
+ AH_Point point_limit = point + outline->num_points;
+
+ for (; point < point_limit; point++) {
+ FT_Pos u, v;
+
+ switch (source) {
+ case AH_UV_FXY:
+ u = point->fx;
+ v = point->fy;
+ break;
+ case AH_UV_FYX:
+ u = point->fy;
+ v = point->fx;
+ break;
+ case AH_UV_OXY:
+ u = point->ox;
+ v = point->oy;
+ break;
+ case AH_UV_OYX:
+ u = point->oy;
+ v = point->ox;
+ break;
+ case AH_UV_YX:
+ u = point->y;
+ v = point->x;
+ break;
+ case AH_UV_OX:
+ u = point->x;
+ v = point->ox;
+ break;
+ case AH_UV_OY:
+ u = point->y;
+ v = point->oy;
+ break;
+ default:
+ u = point->x;
+ v = point->y;
+ break;
+ }
+ point->u = u;
+ point->v = v;
+ }
+}
+
+/* compute all inflex points in a given glyph */
+static void ah_outline_compute_inflections(AH_Outline outline) {
+ AH_Point *contour = outline->contours;
+ AH_Point *contour_limit = contour + outline->num_contours;
+
+ /* load original coordinates in (u,v) */
+ ah_setup_uv(outline, AH_UV_FXY);
+
+ /* do each contour separately */
+ for (; contour < contour_limit; contour++) {
+ FT_Vector vec;
+ AH_Point point = contour[0];
+ AH_Point first = point;
+ AH_Point start = point;
+ AH_Point end = point;
+ AH_Point before;
+ AH_Point after;
+ AH_Angle angle_in, angle_seg, angle_out;
+ AH_Angle diff_in, diff_out;
+ FT_Int finished = 0;
+
+ /* compute first segment in contour */
+ first = point;
+
+ start = end = first;
+ do {
+ end = end->next;
+ if (end == first)
+ goto Skip;
+
+ } while (end->u == first->u && end->v == first->v);
+
+ vec.x = end->u - start->u;
+ vec.y = end->v - start->v;
+ angle_seg = ah_angle(&vec);
+
+ /* extend the segment start whenever possible */
+ before = start;
+ do {
+ do {
+ start = before;
+ before = before->prev;
+ if (before == first)
+ goto Skip;
+
+ } while (before->u == start->u && before->v == start->v);
+
+ vec.x = start->u - before->u;
+ vec.y = start->v - before->v;
+ angle_in = ah_angle(&vec);
+
+ } while (angle_in == angle_seg);
+
+ first = start;
+ diff_in = ah_angle_diff(angle_in, angle_seg);
+
+ /* now, process all segments in the contour */
+ do {
+ /* first, extend current segment's end whenever possible */
+ after = end;
+ do {
+ do {
+ end = after;
+ after = after->next;
+ if (after == first)
+ finished = 1;
+
+ } while (end->u == after->u && end->v == after->v);
+
+ vec.x = after->u - end->u;
+ vec.y = after->v - end->v;
+ angle_out = ah_angle(&vec);
+
+ } while (angle_out == angle_seg);
+
+ diff_out = ah_angle_diff(angle_seg, angle_out);
+
+ if ((diff_in ^ diff_out) < 0) {
+ /* diff_in and diff_out have different signs, we have */
+ /* inflection points here... */
+
+ do {
+ start->flags |= AH_FLAG_INFLECTION;
+ start = start->next;
+
+ } while (start != end);
+
+ start->flags |= AH_FLAG_INFLECTION;
+ }
+
+ start = end;
+ end = after;
+ angle_seg = angle_out;
+ diff_in = diff_out;
+
+ } while (!finished);
+
+ Skip:;
+ }
+}
+
+FT_LOCAL_DEF(void)
+ah_outline_compute_segments(AH_Outline outline) {
+ int dimension;
+ AH_Segment segments;
+ FT_Int *p_num_segments;
+ AH_Direction segment_dir;
+ AH_Direction major_dir;
+
+ segments = outline->horz_segments;
+ p_num_segments = &outline->num_hsegments;
+ major_dir = AH_DIR_RIGHT; /* This value must be positive! */
+ segment_dir = major_dir;
+
+ /* set up (u,v) in each point */
+ ah_setup_uv(outline, AH_UV_FYX);
+
+ for (dimension = 1; dimension >= 0; dimension--) {
+ AH_Point *contour = outline->contours;
+ AH_Point *contour_limit = contour + outline->num_contours;
+ AH_Segment segment = segments;
+ FT_Int num_segments = 0;
+
+#ifdef AH_HINT_METRICS
+ AH_Point min_point = 0;
+ AH_Point max_point = 0;
+ FT_Pos min_coord = 32000;
+ FT_Pos max_coord = -32000;
+#endif
+
+ /* do each contour separately */
+ for (; contour < contour_limit; contour++) {
+ AH_Point point = contour[0];
+ AH_Point last = point->prev;
+ int on_edge = 0;
+ FT_Pos min_pos = +32000; /* minimum segment pos != min_coord */
+ FT_Pos max_pos = -32000; /* maximum segment pos != max_coord */
+ FT_Bool passed;
+
+#ifdef AH_HINT_METRICS
+ if (point->u < min_coord) {
+ min_coord = point->u;
+ min_point = point;
+ }
+ if (point->u > max_coord) {
+ max_coord = point->u;
+ max_point = point;
+ }
+#endif
+
+ if (point == last) /* skip singletons -- just in case? */
+ continue;
+
+ if (ABS(last->out_dir) == major_dir &&
+ ABS(point->out_dir) == major_dir) {
+ /* we are already on an edge, try to locate its start */
+ last = point;
+
+ for (;;) {
+ point = point->prev;
+ if (ABS(point->out_dir) != major_dir) {
+ point = point->next;
+ break;
+ }
+ if (point == last)
+ break;
+ }
+ }
+
+ last = point;
+ passed = 0;
+
+ for (;;) {
+ FT_Pos u, v;
+
+ if (on_edge) {
+ u = point->u;
+ if (u < min_pos)
+ min_pos = u;
+ if (u > max_pos)
+ max_pos = u;
+
+ if (point->out_dir != segment_dir || point == last) {
+ /* we are just leaving an edge; record a new segment! */
+ segment->last = point;
+ segment->pos = (min_pos + max_pos) >> 1;
+
+ /* a segment is round if either its first or last point */
+ /* is a control point */
+ if ((segment->first->flags | point->flags) &
+ AH_FLAG_CONTROL)
+ segment->flags |= AH_EDGE_ROUND;
+
+ /* compute segment size */
+ min_pos = max_pos = point->v;
+
+ v = segment->first->v;
+ if (v < min_pos)
+ min_pos = v;
+ if (v > max_pos)
+ max_pos = v;
+
+ segment->min_coord = min_pos;
+ segment->max_coord = max_pos;
+
+ on_edge = 0;
+ num_segments++;
+ segment++;
+ /* fallthrough */
+ }
+ }
+
+ /* now exit if we are at the start/end point */
+ if (point == last) {
+ if (passed)
+ break;
+ passed = 1;
+ }
+
+ if (!on_edge && ABS(point->out_dir) == major_dir) {
+ /* this is the start of a new segment! */
+ segment_dir = point->out_dir;
+
+ /* clear all segment fields */
+ FT_ZERO(segment);
+
+ segment->dir = segment_dir;
+ segment->flags = AH_EDGE_NORMAL;
+ min_pos = max_pos = point->u;
+ segment->first = point;
+ segment->last = point;
+ segment->contour = contour;
+ on_edge = 1;
+
+#ifdef AH_HINT_METRICS
+ if (point == max_point)
+ max_point = 0;
+
+ if (point == min_point)
+ min_point = 0;
+#endif
+ }
+
+ point = point->next;
+ }
+
+ } /* contours */
+
+#ifdef AH_HINT_METRICS
+ /* we need to ensure that there are edges on the left-most and */
+ /* right-most points of the glyph in order to hint the metrics; */
+ /* we do this by inserting fake segments when needed */
+ if (dimension == 0) {
+ AH_Point point = outline->points;
+ AH_Point point_limit = point + outline->num_points;
+
+ FT_Pos min_pos = 32000;
+ FT_Pos max_pos = -32000;
+
+ min_point = 0;
+ max_point = 0;
+
+ /* compute minimum and maximum points */
+ for (; point < point_limit; point++) {
+ FT_Pos x = point->fx;
+
+ if (x < min_pos) {
+ min_pos = x;
+ min_point = point;
+ }
+ if (x > max_pos) {
+ max_pos = x;
+ max_point = point;
+ }
+ }
+
+ /* insert minimum segment */
+ if (min_point) {
+ /* clear all segment fields */
+ FT_ZERO(segment);
+
+ segment->dir = segment_dir;
+ segment->flags = AH_EDGE_NORMAL;
+ segment->first = min_point;
+ segment->last = min_point;
+ segment->pos = min_pos;
+
+ num_segments++;
+ segment++;
+ }
+
+ /* insert maximum segment */
+ if (max_point) {
+ /* clear all segment fields */
+ FT_ZERO(segment);
+
+ segment->dir = segment_dir;
+ segment->flags = AH_EDGE_NORMAL;
+ segment->first = max_point;
+ segment->last = max_point;
+ segment->pos = max_pos;
+
+ num_segments++;
+ segment++;
+ }
+ }
+#endif /* AH_HINT_METRICS */
+
+ *p_num_segments = num_segments;
+
+ segments = outline->vert_segments;
+ major_dir = AH_DIR_UP;
+ p_num_segments = &outline->num_vsegments;
+ ah_setup_uv(outline, AH_UV_FXY);
+ }
+}
+
+FT_LOCAL_DEF(void)
+ah_outline_link_segments(AH_Outline outline) {
+ AH_Segment segments;
+ AH_Segment segment_limit;
+ int dimension;
+
+ ah_setup_uv(outline, AH_UV_FYX);
+
+ segments = outline->horz_segments;
+ segment_limit = segments + outline->num_hsegments;
+
+ for (dimension = 1; dimension >= 0; dimension--) {
+ AH_Segment seg1;
+ AH_Segment seg2;
+
+ /* now compare each segment to the others */
+ for (seg1 = segments; seg1 < segment_limit; seg1++) {
+ FT_Pos best_score;
+ AH_Segment best_segment;
+
+ /* the fake segments are introduced to hint the metrics -- */
+ /* we must never link them to anything */
+ if (seg1->first == seg1->last)
+ continue;
+
+ best_segment = seg1->link;
+ if (best_segment)
+ best_score = seg1->score;
+ else
+ best_score = 32000;
+
+ for (seg2 = segments; seg2 < segment_limit; seg2++)
+ if (seg1 != seg2 && seg1->dir + seg2->dir == 0) {
+ FT_Pos pos1 = seg1->pos;
+ FT_Pos pos2 = seg2->pos;
+ FT_Bool is_dir;
+ FT_Bool is_pos;
+
+ /* check that the segments are correctly oriented and */
+ /* positioned to form a black distance */
+
+ is_dir = (FT_Bool)(seg1->dir == outline->horz_major_dir ||
+ seg1->dir == outline->vert_major_dir);
+ is_pos = (FT_Bool)(pos1 > pos2);
+
+ if (pos1 == pos2 || !(is_dir ^ is_pos))
+ continue;
+
+ {
+ FT_Pos min = seg1->min_coord;
+ FT_Pos max = seg1->max_coord;
+ FT_Pos len, dist, score;
+
+ if (min < seg2->min_coord)
+ min = seg2->min_coord;
+
+ if (max > seg2->max_coord)
+ max = seg2->max_coord;
+
+ len = max - min;
+ if (len >= 8) {
+ dist = seg2->pos - seg1->pos;
+ if (dist < 0)
+ dist = -dist;
+
+ score = dist + 3000 / len;
+
+ if (score < best_score) {
+ best_score = score;
+ best_segment = seg2;
+ }
+ }
+ }
+ }
+
+ if (best_segment) {
+ seg1->link = best_segment;
+ seg1->score = best_score;
+
+ best_segment->num_linked++;
+ }
+
+ } /* edges 1 */
+
+ /* now, compute the `serif' segments */
+ for (seg1 = segments; seg1 < segment_limit; seg1++) {
+ seg2 = seg1->link;
+
+ if (seg2 && seg2->link != seg1) {
+ seg1->link = 0;
+ seg1->serif = seg2->link;
+ }
+ }
+
+ ah_setup_uv(outline, AH_UV_FXY);
+
+ segments = outline->vert_segments;
+ segment_limit = segments + outline->num_vsegments;
+ }
+}
+
+static void ah_outline_compute_edges(AH_Outline outline) {
+ AH_Edge edges;
+ AH_Segment segments;
+ AH_Segment segment_limit;
+ AH_Direction up_dir;
+ FT_Int *p_num_edges;
+ FT_Int dimension;
+ FT_Fixed scale;
+ FT_Pos edge_distance_threshold;
+
+ edges = outline->horz_edges;
+ segments = outline->horz_segments;
+ segment_limit = segments + outline->num_hsegments;
+ p_num_edges = &outline->num_hedges;
+ up_dir = AH_DIR_RIGHT;
+ scale = outline->y_scale;
+
+ for (dimension = 1; dimension >= 0; dimension--) {
+ AH_Edge edge;
+ AH_Edge edge_limit; /* really == edge + num_edges */
+ AH_Segment seg;
+
+ /*********************************************************************/
+ /* */
+ /* We will begin by generating a sorted table of edges for the */
+ /* current direction. To do so, we simply scan each segment and try */
+ /* to find an edge in our table that corresponds to its position. */
+ /* */
+ /* If no edge is found, we create and insert a new edge in the */
+ /* sorted table. Otherwise, we simply add the segment to the edge's */
+ /* list which will be processed in the second step to compute the */
+ /* edge's properties. */
+ /* */
+ /* Note that the edges table is sorted along the segment/edge */
+ /* position. */
+ /* */
+ /*********************************************************************/
+
+ edge_distance_threshold = FT_MulFix(outline->edge_distance_threshold, scale);
+ if (edge_distance_threshold > 64 / 4)
+ edge_distance_threshold = 64 / 4;
+
+ edge_limit = edges;
+ for (seg = segments; seg < segment_limit; seg++) {
+ AH_Edge found = 0;
+
+ /* look for an edge corresponding to the segment */
+ for (edge = edges; edge < edge_limit; edge++) {
+ FT_Pos dist;
+
+ dist = seg->pos - edge->fpos;
+ if (dist < 0)
+ dist = -dist;
+
+ dist = FT_MulFix(dist, scale);
+ if (dist < edge_distance_threshold) {
+ found = edge;
+ break;
+ }
+ }
+
+ if (!found) {
+ /* insert a new edge in the list and */
+ /* sort according to the position */
+ while (edge > edges && edge[-1].fpos > seg->pos) {
+ edge[0] = edge[-1];
+ edge--;
+ }
+ edge_limit++;
+
+ /* clear all edge fields */
+ FT_MEM_ZERO(edge, sizeof(*edge));
+
+ /* add the segment to the new edge's list */
+ edge->first = seg;
+ edge->last = seg;
+ edge->fpos = seg->pos;
+ edge->opos = edge->pos = FT_MulFix(seg->pos, scale);
+ seg->edge_next = seg;
+ } else {
+ /* if an edge was found, simply add the segment to the edge's */
+ /* list */
+ seg->edge_next = edge->first;
+ edge->last->edge_next = seg;
+ edge->last = seg;
+ }
+ }
+
+ *p_num_edges = (FT_Int)(edge_limit - edges);
+
+ /*********************************************************************/
+ /* */
+ /* Good, we will now compute each edge's properties according to */
+ /* segments found on its position. Basically, these are: */
+ /* */
+ /* - edge's main direction */
+ /* - stem edge, serif edge or both (which defaults to stem then) */
+ /* - rounded edge, straigth or both (which defaults to straight) */
+ /* - link for edge */
+ /* */
+ /*********************************************************************/
+
+ /* first of all, set the `edge' field in each segment -- this is */
+ /* required in order to compute edge links */
+ for (edge = edges; edge < edge_limit; edge++) {
+ seg = edge->first;
+ if (seg)
+ do {
+ seg->edge = edge;
+ seg = seg->edge_next;
+ } while (seg != edge->first);
+ }
+
+ /* now, compute each edge properties */
+ for (edge = edges; edge < edge_limit; edge++) {
+ FT_Int is_round = 0; /* does it contain round segments? */
+ FT_Int is_straight = 0; /* does it contain straight segments? */
+ FT_Pos ups = 0; /* number of upwards segments */
+ FT_Pos downs = 0; /* number of downwards segments */
+
+ seg = edge->first;
+
+ do {
+ FT_Bool is_serif;
+
+ /* check for roundness of segment */
+ if (seg->flags & AH_EDGE_ROUND)
+ is_round++;
+ else
+ is_straight++;
+
+ /* check for segment direction */
+ if (seg->dir == up_dir)
+ ups += seg->max_coord - seg->min_coord;
+ else
+ downs += seg->max_coord - seg->min_coord;
+
+ /* check for links -- if seg->serif is set, then seg->link must */
+ /* be ignored */
+ is_serif = (FT_Bool)(seg->serif && seg->serif->edge != edge);
+
+ if (seg->link || is_serif) {
+ AH_Edge edge2;
+ AH_Segment seg2;
+
+ edge2 = edge->link;
+ seg2 = seg->link;
+
+ if (is_serif) {
+ seg2 = seg->serif;
+ edge2 = edge->serif;
+ }
+
+ if (edge2) {
+ FT_Pos edge_delta;
+ FT_Pos seg_delta;
+
+ edge_delta = edge->fpos - edge2->fpos;
+ if (edge_delta < 0)
+ edge_delta = -edge_delta;
+
+ seg_delta = seg->pos - seg2->pos;
+ if (seg_delta < 0)
+ seg_delta = -seg_delta;
+
+ if (seg_delta < edge_delta)
+ edge2 = seg2->edge;
+ } else
+ edge2 = seg2->edge;
+
+ if (is_serif)
+ edge->serif = edge2;
+ else
+ edge->link = edge2;
+ }
+
+ seg = seg->edge_next;
+
+ } while (seg != edge->first);
+
+ /* set the round/straight flags */
+ edge->flags = AH_EDGE_NORMAL;
+
+ if (is_round > 0 && is_round >= is_straight)
+ edge->flags |= AH_EDGE_ROUND;
+
+ /* set the edge's main direction */
+ edge->dir = AH_DIR_NONE;
+
+ if (ups > downs)
+ edge->dir = up_dir;
+
+ else if (ups < downs)
+ edge->dir = -up_dir;
+
+ else if (ups == downs)
+ edge->dir = 0; /* both up and down !! */
+
+ /* gets rid of serifs if link is set */
+ /* XXX: This gets rid of many unpleasant artefacts! */
+ /* Example: the `c' in cour.pfa at size 13 */
+
+ if (edge->serif && edge->link)
+ edge->serif = 0;
+ }
+
+ edges = outline->vert_edges;
+ segments = outline->vert_segments;
+ segment_limit = segments + outline->num_vsegments;
+ p_num_edges = &outline->num_vedges;
+ up_dir = AH_DIR_UP;
+ scale = outline->x_scale;
+ }
+}
+
+FT_LOCAL_DEF(void)
+ah_outline_detect_features(AH_Outline outline) {
+ ah_outline_compute_segments(outline);
+ ah_outline_link_segments(outline);
+ ah_outline_compute_edges(outline);
+ ah_outline_compute_inflections(outline);
+}
+
+FT_LOCAL_DEF(void)
+ah_outline_compute_blue_edges(AH_Outline outline, AH_Face_Globals face_globals) {
+ AH_Edge edge = outline->horz_edges;
+ AH_Edge edge_limit = edge + outline->num_hedges;
+ AH_Globals globals = &face_globals->design;
+ FT_Fixed y_scale = outline->y_scale;
+
+ FT_Bool blue_active[AH_BLUE_MAX];
+
+ /* compute which blue zones are active, i.e. have their scaled */
+ /* size < 3/4 pixels */
+ {
+ AH_Blue blue;
+ FT_Bool check = 0;
+
+ for (blue = AH_BLUE_CAPITAL_TOP; blue < AH_BLUE_MAX; blue++) {
+ FT_Pos ref, shoot, dist;
+
+ ref = globals->blue_refs[blue];
+ shoot = globals->blue_shoots[blue];
+ dist = ref - shoot;
+ if (dist < 0)
+ dist = -dist;
+
+ blue_active[blue] = 0;
+
+ if (FT_MulFix(dist, y_scale) < 48) {
+ blue_active[blue] = 1;
+ check = 1;
+ }
+ }
+
+ /* return immediately if no blue zone is active */
+ if (!check)
+ return;
+ }
+
+ /* compute for each horizontal edge, which blue zone is closer */
+ for (; edge < edge_limit; edge++) {
+ AH_Blue blue;
+ FT_Pos *best_blue = 0;
+ FT_Pos best_dist; /* initial threshold */
+
+ /* compute the initial threshold as a fraction of the EM size */
+ best_dist = FT_MulFix(face_globals->face->units_per_EM / 40, y_scale);
+ if (best_dist > 64 / 4)
+ best_dist = 64 / 4;
+
+ for (blue = AH_BLUE_CAPITAL_TOP; blue < AH_BLUE_MAX; blue++) {
+ /* if it is a top zone, check for right edges -- if it is a bottom */
+ /* zone, check for left edges */
+ /* */
+ /* of course, that's for TrueType XXX */
+ FT_Bool is_top_blue = FT_BOOL(AH_IS_TOP_BLUE(blue));
+ FT_Bool is_major_dir = FT_BOOL(edge->dir == outline->horz_major_dir);
+
+ if (!blue_active[blue])
+ continue;
+
+ /* if it is a top zone, the edge must be against the major */
+ /* direction; if it is a bottom zone, it must be in the major */
+ /* direction */
+ if (is_top_blue ^ is_major_dir) {
+ FT_Pos dist;
+ FT_Pos *blue_pos = globals->blue_refs + blue;
+
+ /* first of all, compare it to the reference position */
+ dist = edge->fpos - *blue_pos;
+ if (dist < 0)
+ dist = -dist;
+
+ dist = FT_MulFix(dist, y_scale);
+ if (dist < best_dist) {
+ best_dist = dist;
+ best_blue = blue_pos;
+ }
+
+ /* now, compare it to the overshoot position if the edge is */
+ /* rounded, and if the edge is over the reference position of a */
+ /* top zone, or under the reference position of a bottom zone */
+ if (edge->flags & AH_EDGE_ROUND && dist != 0) {
+ FT_Bool is_under_ref = FT_BOOL(edge->fpos < *blue_pos);
+
+ if (is_top_blue ^ is_under_ref) {
+ blue_pos = globals->blue_shoots + blue;
+ dist = edge->fpos - *blue_pos;
+ if (dist < 0)
+ dist = -dist;
+
+ dist = FT_MulFix(dist, y_scale);
+ if (dist < best_dist) {
+ best_dist = dist;
+ best_blue = blue_pos;
+ }
+ }
+ }
+ }
+ }
+
+ if (best_blue)
+ edge->blue_edge = best_blue;
+ }
+}
+
+FT_LOCAL_DEF(void)
+ah_outline_scale_blue_edges(AH_Outline outline, AH_Face_Globals globals) {
+ AH_Edge edge = outline->horz_edges;
+ AH_Edge edge_limit = edge + outline->num_hedges;
+ FT_Pos delta;
+
+ delta = globals->scaled.blue_refs - globals->design.blue_refs;
+
+ for (; edge < edge_limit; edge++) {
+ if (edge->blue_edge)
+ edge->blue_edge += delta;
+ }
+}
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h
new file mode 100644
index 00000000000..1911eabc36a
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h
@@ -0,0 +1,107 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahglyph.h */
+/* */
+/* Routines used to load and analyze a given glyph before hinting */
+/* (specification). */
+/* */
+/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+#ifndef AGS_LIB_FREETYPE_AHGLYPH_H
+#define AGS_LIB_FREETYPE_AHGLYPH_H
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahtypes.h"
+
+namespace AGS3 {
+namespace FreeType213 {
+
+// FT_BEGIN_HEADER
+
+
+typedef enum AH_UV_ {
+ AH_UV_FXY,
+ AH_UV_FYX,
+ AH_UV_OXY,
+ AH_UV_OYX,
+ AH_UV_OX,
+ AH_UV_OY,
+ AH_UV_YX,
+ AH_UV_XY /* should always be last! */
+} AH_UV;
+
+
+FT_LOCAL(void)
+ah_setup_uv(AH_Outline outline, AH_UV source);
+
+/* AH_OutlineRec functions - they should be typically called in this order */
+
+FT_LOCAL(FT_Error)
+ah_outline_new(FT_Memory memory, AH_Outline *aoutline);
+
+FT_LOCAL(FT_Error)
+ah_outline_load(AH_Outline outline, FT_Face face);
+
+FT_LOCAL(void)
+ah_outline_compute_segments(AH_Outline outline);
+
+FT_LOCAL(void)
+ah_outline_link_segments(AH_Outline outline);
+
+FT_LOCAL(void)
+ah_outline_detect_features(AH_Outline outline);
+
+FT_LOCAL(void)
+ah_outline_compute_blue_edges(AH_Outline outline, AH_Face_Globals globals);
+
+FT_LOCAL(void)
+ah_outline_scale_blue_edges(AH_Outline outline, AH_Face_Globals globals);
+
+FT_LOCAL(void)
+ah_outline_save(AH_Outline outline, AH_Loader loader);
+
+FT_LOCAL(void)
+ah_outline_done(AH_Outline outline);
+
+
+// FT_END_HEADER
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
+
+#endif /* AGS_LIB_FREETYPE_AHGLYPH_H */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
new file mode 100644
index 00000000000..b8e1d538313
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
@@ -0,0 +1,1239 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahhint.c */
+/* */
+/* Glyph hinter (body). */
+/* */
+/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahhint.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahglyph.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahangles.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/aherrors.h"
+#include "engines/ags/lib/freetype-2.1.3/ftoutln.h"
+
+#define FACE_GLOBALS(face) ((AH_Face_Globals)(face)->autohint.data)
+
+#define AH_USE_IUP
+#define OPTIM_STEM_SNAP
+
+namespace AGS3 {
+namespace FreeType213 {
+
+
+/**** Hinting routines ****/
+
+/* snap a given width in scaled coordinates to one of the */
+/* current standard widths */
+static FT_Pos ah_snap_width(FT_Pos *widths, FT_Int count, FT_Pos width) {
+ int n;
+ FT_Pos best = 64 + 32 + 2;
+ FT_Pos reference = width;
+ FT_Pos scaled;
+
+ for (n = 0; n < count; n++) {
+ FT_Pos w;
+ FT_Pos dist;
+
+ w = widths[n];
+ dist = width - w;
+ if (dist < 0)
+ dist = -dist;
+ if (dist < best) {
+ best = dist;
+ reference = w;
+ }
+ }
+
+ scaled = (reference + 32) & -64;
+
+ if (width >= reference) {
+ if (width < scaled + 48)
+ width = reference;
+ } else {
+ if (width > scaled - 48)
+ width = reference;
+ }
+
+ return width;
+}
+
+
+/* compute the snapped width of a given stem */
+static FT_Pos ah_compute_stem_width(AH_Hinter hinter, int vertical, FT_Pos width) {
+ AH_Globals globals = &hinter->globals->scaled;
+ FT_Pos dist = width;
+ FT_Int sign = 0;
+
+ if (dist < 0) {
+ dist = -width;
+ sign = 1;
+ }
+
+ if ((vertical && !hinter->do_vert_snapping) || (!vertical && !hinter->do_horz_snapping)) {
+ /* smooth hinting process, very lightly quantize the stem width */
+ /* */
+ if (dist < 64)
+ dist = 64;
+
+ {
+ FT_Pos delta = dist - globals->stds[vertical];
+
+ if (delta < 0)
+ delta = -delta;
+
+ if (delta < 40) {
+ dist = globals->stds[vertical];
+ if (dist < 48)
+ dist = 48;
+ }
+
+ if (dist < 3 * 64) {
+ delta = (dist & 63);
+ dist &= -64;
+
+ if (delta < 10)
+ dist += delta;
+
+ else if (delta < 32)
+ dist += 10;
+
+ else if (delta < 54)
+ dist += 54;
+
+ else
+ dist += delta;
+ } else
+ dist = (dist + 32) & -64;
+ }
+ } else {
+ /* strong hinting process, snap the stem width to integer pixels */
+ /* */
+ if (vertical) {
+ dist = ah_snap_width(globals->heights, globals->num_heights, dist);
+
+ /* in the case of vertical hinting, always round */
+ /* the stem heights to integer pixels */
+ if (dist >= 64)
+ dist = (dist + 16) & -64;
+ else
+ dist = 64;
+ } else {
+ dist = ah_snap_width(globals->widths, globals->num_widths, dist);
+
+ if (hinter->flags & AH_HINTER_MONOCHROME) {
+ /* monochrome horizontal hinting: snap widths to integer pixels */
+ /* with a different threshold */
+ if (dist < 64)
+ dist = 64;
+ else
+ dist = (dist + 32) & -64;
+ } else {
+ /* for horizontal anti-aliased hinting, we adopt a more subtle */
+ /* approach: we strengthen small stems, round stems whose size */
+ /* is between 1 and 2 pixels to an integer, otherwise nothing */
+ if (dist < 48)
+ dist = (dist + 64) >> 1;
+
+ else if (dist < 128)
+ dist = (dist + 22) & -64;
+ else
+ /* XXX: round otherwise, prevent color fringes in LCD mode */
+ dist = (dist + 32) & -64;
+ }
+ }
+ }
+
+ if (sign)
+ dist = -dist;
+
+ return dist;
+}
+
+/* align one stem edge relative to the previous stem edge */
+static void ah_align_linked_edge(AH_Hinter hinter, AH_Edge base_edge, AH_Edge stem_edge, int vertical) {
+ FT_Pos dist = stem_edge->opos - base_edge->opos;
+
+ stem_edge->pos = base_edge->pos + ah_compute_stem_width(hinter, vertical, dist);
+}
+
+static void ah_align_serif_edge(AH_Hinter hinter, AH_Edge base, AH_Edge serif, int vertical) {
+ FT_Pos dist;
+ FT_Pos sign = 1;
+
+ FT_UNUSED(hinter);
+
+ dist = serif->opos - base->opos;
+ if (dist < 0) {
+ dist = -dist;
+ sign = -1;
+ }
+
+ /* do not touch serifs widths !! */
+#if 0
+ if ( base->flags & AH_EDGE_DONE ) {
+ if ( dist >= 64 )
+ dist = (dist+8) & -64;
+
+ else if ( dist <= 32 && !vertical )
+ dist = ( dist + 33 ) >> 1;
+ else
+ dist = 0;
+ }
+#endif
+
+ serif->pos = base->pos + sign * dist;
+}
+
+
+/**** EDGE HINTING ****/
+
+/* Another alternative edge hinting algorithm */
+static void ah_hint_edges_3(AH_Hinter hinter) {
+ AH_Edge edges;
+ AH_Edge edge_limit;
+ AH_Outline outline = hinter->glyph;
+ FT_Int dimension;
+
+ edges = outline->horz_edges;
+ edge_limit = edges + outline->num_hedges;
+
+ for (dimension = 1; dimension >= 0; dimension--) {
+ AH_Edge edge;
+ AH_Edge anchor = 0;
+ int has_serifs = 0;
+
+ if (!hinter->do_horz_hints && !dimension)
+ goto Next_Dimension;
+
+ if (!hinter->do_vert_hints && dimension)
+ goto Next_Dimension;
+
+ /* we begin by aligning all stems relative to the blue zone */
+ /* if needed -- that's only for horizontal edges */
+ if (dimension) {
+ for (edge = edges; edge < edge_limit; edge++) {
+ FT_Pos *blue;
+ AH_EdgeRec *edge1, *edge2;
+
+ if (edge->flags & AH_EDGE_DONE)
+ continue;
+
+ blue = edge->blue_edge;
+ edge1 = 0;
+ edge2 = edge->link;
+
+ if (blue) {
+ edge1 = edge;
+ } else if (edge2 && edge2->blue_edge) {
+ blue = edge2->blue_edge;
+ edge1 = edge2;
+ edge2 = edge;
+ }
+
+ if (!edge1)
+ continue;
+
+ edge1->pos = blue[0];
+ edge1->flags |= AH_EDGE_DONE;
+
+ if (edge2 && !edge2->blue_edge) {
+ ah_align_linked_edge(hinter, edge1, edge2, dimension);
+ edge2->flags |= AH_EDGE_DONE;
+ }
+
+ if (!anchor)
+ anchor = edge;
+ }
+ }
+
+ /* now, we will align all stem edges, trying to maintain the */
+ /* relative order of stems in the glyph.. */
+ for (edge = edges; edge < edge_limit; edge++) {
+ AH_EdgeRec *edge2;
+
+ if (edge->flags & AH_EDGE_DONE)
+ continue;
+
+ /* skip all non-stem edges */
+ edge2 = edge->link;
+ if (!edge2) {
+ has_serifs++;
+ continue;
+ }
+
+ /* now, align the stem */
+
+ /* this should not happen, but it's better to be safe. */
+ if (edge2->blue_edge || edge2 < edge) {
+
+ ah_align_linked_edge(hinter, edge2, edge, dimension);
+ edge->flags |= AH_EDGE_DONE;
+ continue;
+ }
+
+ if (!anchor) {
+ edge->pos = (edge->opos + 32) & -64;
+ anchor = edge;
+
+ edge->flags |= AH_EDGE_DONE;
+
+ ah_align_linked_edge(hinter, edge, edge2, dimension);
+ } else {
+ FT_Pos org_pos, org_len, org_center, cur_len;
+ FT_Pos cur_pos1, cur_pos2, delta1, delta2;
+
+ org_pos = anchor->pos + (edge->opos - anchor->opos);
+ org_len = edge2->opos - edge->opos;
+ org_center = org_pos + (org_len >> 1);
+
+ cur_len = ah_compute_stem_width(hinter, dimension, org_len);
+
+ cur_pos1 = (org_pos + 32) & -64;
+ delta1 = (cur_pos1 + (cur_len >> 1) - org_center);
+ if (delta1 < 0)
+ delta1 = -delta1;
+
+ cur_pos2 = ((org_pos + org_len + 32) & -64) - cur_len;
+ delta2 = (cur_pos2 + (cur_len >> 1) - org_center);
+ if (delta2 < 0)
+ delta2 = -delta2;
+
+ edge->pos = (delta1 <= delta2) ? cur_pos1 : cur_pos2;
+ edge2->pos = edge->pos + cur_len;
+
+ edge->flags |= AH_EDGE_DONE;
+ edge2->flags |= AH_EDGE_DONE;
+
+ if (edge > edges && edge->pos < edge[-1].pos)
+ edge->pos = edge[-1].pos;
+ }
+ }
+
+ if (!has_serifs)
+ goto Next_Dimension;
+
+ /* now, hint the remaining edges (serifs and single) in order */
+ /* to complete our processing */
+ for (edge = edges; edge < edge_limit; edge++) {
+ if (edge->flags & AH_EDGE_DONE)
+ continue;
+
+ if (edge->serif)
+ ah_align_serif_edge(hinter, edge->serif, edge, dimension);
+ else if (!anchor) {
+ edge->pos = (edge->opos + 32) & -64;
+ anchor = edge;
+ } else
+ edge->pos = anchor->pos + ((edge->opos - anchor->opos + 32) & -64);
+
+ edge->flags |= AH_EDGE_DONE;
+
+ if (edge > edges && edge->pos < edge[-1].pos)
+ edge->pos = edge[-1].pos;
+
+ if (edge + 1 < edge_limit && edge[1].flags & AH_EDGE_DONE && edge->pos > edge[1].pos)
+ edge->pos = edge[1].pos;
+ }
+
+ Next_Dimension:
+ edges = outline->vert_edges;
+ edge_limit = edges + outline->num_vedges;
+ }
+}
+
+FT_LOCAL_DEF(void)
+ah_hinter_hint_edges(AH_Hinter hinter) {
+ /* AH_Interpolate_Blue_Edges( hinter ); -- doesn't seem to help */
+ /* reduce the problem of the disappearing eye in the `e' of Times... */
+ /* also, creates some artifacts near the blue zones? */
+ {
+ ah_hint_edges_3(hinter);
+ }
+}
+
+
+/**** POINT HINTING ****/
+
+static void ah_hinter_align_edge_points(AH_Hinter hinter) {
+ AH_Outline outline = hinter->glyph;
+ AH_Edge edges;
+ AH_Edge edge_limit;
+ FT_Int dimension;
+
+ edges = outline->horz_edges;
+ edge_limit = edges + outline->num_hedges;
+
+ for (dimension = 1; dimension >= 0; dimension--) {
+ AH_Edge edge;
+
+ edge = edges;
+ for (; edge < edge_limit; edge++) {
+ /* move the points of each segment */
+ /* in each edge to the edge's position */
+ AH_Segment seg = edge->first;
+
+ do {
+ AH_Point point = seg->first;
+
+ for (;;) {
+ if (dimension) {
+ point->y = edge->pos;
+ point->flags |= AH_FLAG_TOUCH_Y;
+ } else {
+ point->x = edge->pos;
+ point->flags |= AH_FLAG_TOUCH_X;
+ }
+
+ if (point == seg->last)
+ break;
+
+ point = point->next;
+ }
+
+ seg = seg->edge_next;
+
+ } while (seg != edge->first);
+ }
+
+ edges = outline->vert_edges;
+ edge_limit = edges + outline->num_vedges;
+ }
+}
+
+/* hint the strong points -- this is equivalent to the TrueType `IP' */
+static void ah_hinter_align_strong_points(AH_Hinter hinter) {
+ AH_Outline outline = hinter->glyph;
+ FT_Int dimension;
+ AH_Edge edges;
+ AH_Edge edge_limit;
+ AH_Point points;
+ AH_Point point_limit;
+ AH_Flags touch_flag;
+
+ points = outline->points;
+ point_limit = points + outline->num_points;
+
+ edges = outline->horz_edges;
+ edge_limit = edges + outline->num_hedges;
+ touch_flag = AH_FLAG_TOUCH_Y;
+
+ for (dimension = 1; dimension >= 0; dimension--) {
+ AH_Point point;
+ AH_Edge edge;
+
+ if (edges < edge_limit)
+ for (point = points; point < point_limit; point++) {
+ FT_Pos u, ou, fu; /* point position */
+ FT_Pos delta;
+
+ if (point->flags & touch_flag)
+ continue;
+
+#ifndef AH_OPTION_NO_WEAK_INTERPOLATION
+ /* if this point is candidate to weak interpolation, we will */
+ /* interpolate it after all strong points have been processed */
+ if ((point->flags & AH_FLAG_WEAK_INTERPOLATION) &&
+ !(point->flags & AH_FLAG_INFLECTION))
+ continue;
+#endif
+
+ if (dimension) {
+ u = point->fy;
+ ou = point->oy;
+ } else {
+ u = point->fx;
+ ou = point->ox;
+ }
+
+ fu = u;
+
+ /* is the point before the first edge? */
+ edge = edges;
+ delta = edge->fpos - u;
+ if (delta >= 0) {
+ u = edge->pos - (edge->opos - ou);
+ goto Store_Point;
+ }
+
+ /* is the point after the last edge ? */
+ edge = edge_limit - 1;
+ delta = u - edge->fpos;
+ if (delta >= 0) {
+ u = edge->pos + (ou - edge->opos);
+ goto Store_Point;
+ }
+
+ /* otherwise, interpolate the point in between */
+ {
+ AH_Edge before = 0;
+ AH_Edge after = 0;
+
+ for (edge = edges; edge < edge_limit; edge++) {
+ if (u == edge->fpos) {
+ u = edge->pos;
+ goto Store_Point;
+ }
+ if (u < edge->fpos)
+ break;
+ before = edge;
+ }
+
+ for (edge = edge_limit - 1; edge >= edges; edge--) {
+ if (u == edge->fpos) {
+ u = edge->pos;
+ goto Store_Point;
+ }
+ if (u > edge->fpos)
+ break;
+ after = edge;
+ }
+
+ /* assert( before && after && before != after ) */
+ u = before->pos + FT_MulDiv(fu - before->fpos,
+ after->pos - before->pos,
+ after->fpos - before->fpos);
+ }
+
+ Store_Point:
+
+ /* save the point position */
+ if (dimension)
+ point->y = u;
+ else
+ point->x = u;
+
+ point->flags |= touch_flag;
+ }
+
+ edges = outline->vert_edges;
+ edge_limit = edges + outline->num_vedges;
+ touch_flag = AH_FLAG_TOUCH_X;
+ }
+}
+
+#ifndef AH_OPTION_NO_WEAK_INTERPOLATION
+
+static void ah_iup_shift(AH_Point p1, AH_Point p2, AH_Point ref) {
+ AH_Point p;
+ FT_Pos delta = ref->u - ref->v;
+
+ for (p = p1; p < ref; p++)
+ p->u = p->v + delta;
+
+ for (p = ref + 1; p <= p2; p++)
+ p->u = p->v + delta;
+}
+
+static void ah_iup_interp(AH_Point p1, AH_Point p2, AH_Point ref1, AH_Point ref2) {
+ AH_Point p;
+ FT_Pos u;
+ FT_Pos v1 = ref1->v;
+ FT_Pos v2 = ref2->v;
+ FT_Pos d1 = ref1->u - v1;
+ FT_Pos d2 = ref2->u - v2;
+
+ if (p1 > p2)
+ return;
+
+ if (v1 == v2) {
+ for (p = p1; p <= p2; p++) {
+ u = p->v;
+
+ if (u <= v1)
+ u += d1;
+ else
+ u += d2;
+
+ p->u = u;
+ }
+ return;
+ }
+
+ if (v1 < v2) {
+ for (p = p1; p <= p2; p++) {
+ u = p->v;
+
+ if (u <= v1)
+ u += d1;
+ else if (u >= v2)
+ u += d2;
+ else
+ u = ref1->u + FT_MulDiv(u - v1, ref2->u - ref1->u, v2 - v1);
+
+ p->u = u;
+ }
+ } else {
+ for (p = p1; p <= p2; p++) {
+ u = p->v;
+
+ if (u <= v2)
+ u += d2;
+ else if (u >= v1)
+ u += d1;
+ else
+ u = ref1->u + FT_MulDiv(u - v1, ref2->u - ref1->u, v2 - v1);
+
+ p->u = u;
+ }
+ }
+}
+
+/* interpolate weak points -- this is equivalent to the TrueType `IUP' */
+static void ah_hinter_align_weak_points(AH_Hinter hinter) {
+ AH_Outline outline = hinter->glyph;
+ FT_Int dimension;
+ AH_Point points;
+ AH_Point point_limit;
+ AH_Point *contour_limit;
+ AH_Flags touch_flag;
+
+ points = outline->points;
+ point_limit = points + outline->num_points;
+
+ /* PASS 1: Move segment points to edge positions */
+
+ touch_flag = AH_FLAG_TOUCH_Y;
+
+ contour_limit = outline->contours + outline->num_contours;
+
+ ah_setup_uv(outline, AH_UV_OY);
+
+ for (dimension = 1; dimension >= 0; dimension--) {
+ AH_Point point;
+ AH_Point end_point;
+ AH_Point first_point;
+ AH_Point *contour;
+
+ point = points;
+ contour = outline->contours;
+
+ for (; contour < contour_limit; contour++) {
+ point = *contour;
+ end_point = point->prev;
+ first_point = point;
+
+ while (point <= end_point && !(point->flags & touch_flag))
+ point++;
+
+ if (point <= end_point) {
+ AH_Point first_touched = point;
+ AH_Point cur_touched = point;
+
+ point++;
+ while (point <= end_point) {
+ if (point->flags & touch_flag) {
+ /* we found two successive touched points; we interpolate */
+ /* all contour points between them */
+ ah_iup_interp(cur_touched + 1, point - 1, cur_touched, point);
+ cur_touched = point;
+ }
+ point++;
+ }
+
+ if (cur_touched == first_touched) {
+ /* this is a special case: only one point was touched in the */
+ /* contour; we thus simply shift the whole contour */
+ ah_iup_shift(first_point, end_point, cur_touched);
+ } else {
+ /* now interpolate after the last touched point to the end */
+ /* of the contour */
+ ah_iup_interp(cur_touched + 1, end_point, cur_touched, first_touched);
+
+ /* if the first contour point isn't touched, interpolate */
+ /* from the contour start to the first touched point */
+ if (first_touched > points)
+ ah_iup_interp(first_point, first_touched - 1, cur_touched, first_touched);
+ }
+ }
+ }
+
+ /* now save the interpolated values back to x/y */
+ if (dimension) {
+ for (point = points; point < point_limit; point++)
+ point->y = point->u;
+
+ touch_flag = AH_FLAG_TOUCH_X;
+ ah_setup_uv(outline, AH_UV_OX);
+ } else {
+ for (point = points; point < point_limit; point++)
+ point->x = point->u;
+
+ break; /* exit loop */
+ }
+ }
+}
+
+#endif /* !AH_OPTION_NO_WEAK_INTERPOLATION */
+
+FT_LOCAL_DEF(void)
+ah_hinter_align_points(AH_Hinter hinter) {
+ ah_hinter_align_edge_points(hinter);
+
+#ifndef AH_OPTION_NO_STRONG_INTERPOLATION
+ ah_hinter_align_strong_points(hinter);
+#endif
+
+#ifndef AH_OPTION_NO_WEAK_INTERPOLATION
+ ah_hinter_align_weak_points(hinter);
+#endif
+}
+
+
+/**** HINTER OBJECT METHODS ****/
+
+/* scale and fit the global metrics */
+static void ah_hinter_scale_globals(AH_Hinter hinter, FT_Fixed x_scale, FT_Fixed y_scale) {
+ FT_Int n;
+ AH_Face_Globals globals = hinter->globals;
+ AH_Globals design = &globals->design;
+ AH_Globals scaled = &globals->scaled;
+
+ /* copy content */
+ *scaled = *design;
+
+ /* scale the standard widths & heights */
+ for (n = 0; n < design->num_widths; n++)
+ scaled->widths[n] = FT_MulFix(design->widths[n], x_scale);
+
+ for (n = 0; n < design->num_heights; n++)
+ scaled->heights[n] = FT_MulFix(design->heights[n], y_scale);
+
+ scaled->stds[0] = (design->num_widths > 0) ? scaled->widths[0] : 32000;
+ scaled->stds[1] = (design->num_heights > 0) ? scaled->heights[0] : 32000;
+
+ /* scale the blue zones */
+ for (n = 0; n < AH_BLUE_MAX; n++) {
+ FT_Pos delta, delta2;
+
+ delta = design->blue_shoots[n] - design->blue_refs[n];
+ delta2 = delta;
+ if (delta < 0)
+ delta2 = -delta2;
+ delta2 = FT_MulFix(delta2, y_scale);
+
+ if (delta2 < 32)
+ delta2 = 0;
+ else if (delta2 < 64)
+ delta2 = 32 + (((delta2 - 32) + 16) & -32);
+ else
+ delta2 = (delta2 + 32) & -64;
+
+ if (delta < 0)
+ delta2 = -delta2;
+
+ scaled->blue_refs[n] = (FT_MulFix(design->blue_refs[n], y_scale) + 32) & -64;
+ scaled->blue_shoots[n] = scaled->blue_refs[n] + delta2;
+ }
+
+ globals->x_scale = x_scale;
+ globals->y_scale = y_scale;
+}
+
+static void ah_hinter_align(AH_Hinter hinter) {
+ ah_hinter_align_edge_points(hinter);
+ ah_hinter_align_points(hinter);
+}
+
+/* finalize a hinter object */
+FT_LOCAL_DEF(void)
+ah_hinter_done(AH_Hinter hinter) {
+ if (hinter) {
+ FT_Memory memory = hinter->memory;
+
+ ah_loader_done(hinter->loader);
+ ah_outline_done(hinter->glyph);
+
+ /* note: the `globals' pointer is _not_ owned by the hinter */
+ /* but by the current face object, we don't need to */
+ /* release it */
+ hinter->globals = 0;
+ hinter->face = 0;
+
+ FT_FREE(hinter);
+ }
+}
+
+/* create a new empty hinter object */
+FT_LOCAL_DEF(FT_Error)
+ah_hinter_new(FT_Library library, AH_Hinter *ahinter) {
+ AH_Hinter hinter = 0;
+ FT_Memory memory = library->memory;
+ FT_Error error;
+
+ *ahinter = 0;
+
+ /* allocate object */
+ if (FT_NEW(hinter))
+ goto Exit;
+
+ hinter->memory = memory;
+ hinter->flags = 0;
+
+ /* allocate outline and loader */
+ error = ah_outline_new(memory, &hinter->glyph) ||
+ ah_loader_new(memory, &hinter->loader) ||
+ ah_loader_create_extra(hinter->loader);
+ if (error)
+ goto Exit;
+
+ *ahinter = hinter;
+
+Exit:
+ if (error)
+ ah_hinter_done(hinter);
+
+ return error;
+}
+
+/* create a face's autohint globals */
+FT_LOCAL_DEF(FT_Error)
+ah_hinter_new_face_globals(AH_Hinter hinter, FT_Face face, AH_Globals globals) {
+ FT_Error error;
+ FT_Memory memory = hinter->memory;
+ AH_Face_Globals face_globals;
+
+ if (FT_NEW(face_globals))
+ goto Exit;
+
+ hinter->face = face;
+ hinter->globals = face_globals;
+
+ if (globals)
+ face_globals->design = *globals;
+ else
+ ah_hinter_compute_globals(hinter);
+
+ face->autohint.data = face_globals;
+ face->autohint.finalizer = (FT_Generic_Finalizer)ah_hinter_done_face_globals;
+ face_globals->face = face;
+
+Exit:
+ return error;
+}
+
+/* discard a face's autohint globals */
+FT_LOCAL_DEF(void)
+ah_hinter_done_face_globals(AH_Face_Globals globals) {
+ FT_Face face = globals->face;
+ FT_Memory memory = face->memory;
+
+ FT_FREE(globals);
+}
+
+static FT_Error ah_hinter_load(AH_Hinter hinter, FT_UInt glyph_index, FT_Int32 load_flags, FT_UInt depth) {
+ FT_Face face = hinter->face;
+ FT_GlyphSlot slot = face->glyph;
+ FT_Slot_Internal internal = slot->internal;
+ FT_Fixed x_scale = face->size->metrics.x_scale;
+ FT_Fixed y_scale = face->size->metrics.y_scale;
+ FT_Error error;
+ AH_Outline outline = hinter->glyph;
+ AH_Loader gloader = hinter->loader;
+
+ /* load the glyph */
+ error = FT_Load_Glyph(face, glyph_index, load_flags);
+ if (error)
+ goto Exit;
+
+ /* Set `hinter->transformed' after loading with FT_LOAD_NO_RECURSE. */
+ hinter->transformed = internal->glyph_transformed;
+
+ if (hinter->transformed) {
+ FT_Matrix imatrix;
+
+ imatrix = internal->glyph_matrix;
+ hinter->trans_delta = internal->glyph_delta;
+ hinter->trans_matrix = imatrix;
+
+ FT_Matrix_Invert(&imatrix);
+ FT_Vector_Transform(&hinter->trans_delta, &imatrix);
+ }
+
+ /* set linear horizontal metrics */
+ slot->linearHoriAdvance = slot->metrics.horiAdvance;
+ slot->linearVertAdvance = slot->metrics.vertAdvance;
+
+ switch (slot->format) {
+ case FT_GLYPH_FORMAT_OUTLINE:
+
+ /* translate glyph outline if we need to */
+ if (hinter->transformed) {
+ FT_UInt n = slot->outline.n_points;
+ FT_Vector *point = slot->outline.points;
+
+ for (; n > 0; point++, n--) {
+ point->x += hinter->trans_delta.x;
+ point->y += hinter->trans_delta.y;
+ }
+ }
+
+ /* copy the outline points in the loader's current */
+ /* extra points, which is used to keep original glyph coordinates */
+ error = ah_loader_check_points(gloader, slot->outline.n_points + 2, slot->outline.n_contours);
+ if (error)
+ goto Exit;
+
+ FT_MEM_COPY(gloader->current.extra_points, slot->outline.points, slot->outline.n_points * sizeof(FT_Vector));
+
+ FT_MEM_COPY(gloader->current.outline.contours, slot->outline.contours, slot->outline.n_contours * sizeof(short));
+
+ FT_MEM_COPY(gloader->current.outline.tags, slot->outline.tags, slot->outline.n_points * sizeof(char));
+
+ gloader->current.outline.n_points = slot->outline.n_points;
+ gloader->current.outline.n_contours = slot->outline.n_contours;
+
+ /* compute original phantom points */
+ hinter->pp1.x = 0;
+ hinter->pp1.y = 0;
+ hinter->pp2.x = FT_MulFix(slot->metrics.horiAdvance, x_scale);
+ hinter->pp2.y = 0;
+
+ /* be sure to check for spacing glyphs */
+ if (slot->outline.n_points == 0)
+ goto Hint_Metrics;
+
+ /* now, load the slot image into the auto-outline, and run the */
+ /* automatic hinting process */
+ error = ah_outline_load(outline, face); /* XXX: change to slot */
+ if (error)
+ goto Exit;
+
+ /* perform feature detection */
+ ah_outline_detect_features(outline);
+
+ if (hinter->do_vert_hints) {
+ ah_outline_compute_blue_edges(outline, hinter->globals);
+ ah_outline_scale_blue_edges(outline, hinter->globals);
+ }
+
+ /* perform alignment control */
+ ah_hinter_hint_edges(hinter);
+ ah_hinter_align(hinter);
+
+ /* now save the current outline into the loader's current table */
+ ah_outline_save(outline, gloader);
+
+ /* we now need to hint the metrics according to the change in */
+ /* width/positioning that occured during the hinting process */
+ {
+ FT_Pos old_advance, old_rsb, old_lsb, new_lsb;
+ AH_Edge edge1 = outline->vert_edges; /* leftmost edge */
+ AH_Edge edge2 = edge1 +
+ outline->num_vedges - 1; /* rightmost edge */
+
+ old_advance = hinter->pp2.x;
+ old_rsb = old_advance - edge2->opos;
+ old_lsb = edge1->opos;
+ new_lsb = edge1->pos;
+
+ hinter->pp1.x = ((new_lsb - old_lsb) + 32) & -64;
+ hinter->pp2.x = ((edge2->pos + old_rsb) + 32) & -64;
+
+ /* try to fix certain bad advance computations */
+ if (hinter->pp2.x + hinter->pp1.x == edge2->pos && old_rsb > 4)
+ hinter->pp2.x += 64;
+ }
+
+ /* good, we simply add the glyph to our loader's base */
+ ah_loader_add(gloader);
+ break;
+
+ case FT_GLYPH_FORMAT_COMPOSITE: {
+ FT_UInt nn, num_subglyphs = slot->num_subglyphs;
+ FT_UInt num_base_subgs, start_point;
+ FT_SubGlyph subglyph;
+
+ start_point = gloader->base.outline.n_points;
+
+ /* first of all, copy the subglyph descriptors in the glyph loader */
+ error = ah_loader_check_subglyphs(gloader, num_subglyphs);
+ if (error)
+ goto Exit;
+
+ FT_MEM_COPY(gloader->current.subglyphs, slot->subglyphs,
+ num_subglyphs * sizeof(FT_SubGlyph));
+
+ gloader->current.num_subglyphs = num_subglyphs;
+ num_base_subgs = gloader->base.num_subglyphs;
+
+ /* now, read each subglyph independently */
+ for (nn = 0; nn < num_subglyphs; nn++) {
+ FT_Vector pp1, pp2;
+ FT_Pos x, y;
+ FT_UInt num_points, num_new_points, num_base_points;
+
+ /* gloader.current.subglyphs can change during glyph loading due */
+ /* to re-allocation -- we must recompute the current subglyph on */
+ /* each iteration */
+ subglyph = gloader->base.subglyphs + num_base_subgs + nn;
+
+ pp1 = hinter->pp1;
+ pp2 = hinter->pp2;
+
+ num_base_points = gloader->base.outline.n_points;
+
+ error = ah_hinter_load(hinter, subglyph->index, load_flags, depth + 1);
+ if (error)
+ goto Exit;
+
+ /* recompute subglyph pointer */
+ subglyph = gloader->base.subglyphs + num_base_subgs + nn;
+
+ if (subglyph->flags & FT_SUBGLYPH_FLAG_USE_MY_METRICS) {
+ pp1 = hinter->pp1;
+ pp2 = hinter->pp2;
+ } else {
+ hinter->pp1 = pp1;
+ hinter->pp2 = pp2;
+ }
+
+ num_points = gloader->base.outline.n_points;
+ num_new_points = num_points - num_base_points;
+
+ /* now perform the transform required for this subglyph */
+
+ if (subglyph->flags & (FT_SUBGLYPH_FLAG_SCALE | FT_SUBGLYPH_FLAG_XY_SCALE | FT_SUBGLYPH_FLAG_2X2)) {
+ FT_Vector *cur = gloader->base.outline.points + num_base_points;
+ FT_Vector *org = gloader->base.extra_points + num_base_points;
+ FT_Vector *limit = cur + num_new_points;
+
+ for (; cur < limit; cur++, org++) {
+ FT_Vector_Transform(cur, &subglyph->transform);
+ FT_Vector_Transform(org, &subglyph->transform);
+ }
+ }
+
+ /* apply offset */
+
+ if (!(subglyph->flags & FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES)) {
+ FT_Int k = subglyph->arg1;
+ FT_UInt l = subglyph->arg2;
+ FT_Vector *p1;
+ FT_Vector *p2;
+
+ if (start_point + k >= num_base_points ||
+ l >= (FT_UInt)num_new_points) {
+ error = FT_Err_Invalid_Composite;
+ goto Exit;
+ }
+
+ l += num_base_points;
+
+ /* for now, only use the current point coordinates */
+ /* we may consider another approach in the near future */
+ p1 = gloader->base.outline.points + start_point + k;
+ p2 = gloader->base.outline.points + start_point + l;
+
+ x = p1->x - p2->x;
+ y = p1->y - p2->y;
+ } else {
+ x = FT_MulFix(subglyph->arg1, x_scale);
+ y = FT_MulFix(subglyph->arg2, y_scale);
+
+ x = (x + 32) & -64;
+ y = (y + 32) & -64;
+ }
+
+ {
+ FT_Outline dummy = gloader->base.outline;
+
+ dummy.points += num_base_points;
+ dummy.n_points = (short)num_new_points;
+
+ FT_Outline_Translate(&dummy, x, y);
+ }
+ }
+ } break;
+
+ default:
+ /* we don't support other formats (yet?) */
+ error = FT_Err_Unimplemented_Feature;
+ }
+
+Hint_Metrics:
+ if (depth == 0) {
+ FT_BBox bbox;
+
+ /* transform the hinted outline if needed */
+ if (hinter->transformed)
+ FT_Outline_Transform(&gloader->base.outline, &hinter->trans_matrix);
+
+ /* we must translate our final outline by -pp1.x, and compute */
+ /* the new metrics */
+ if (hinter->pp1.x)
+ FT_Outline_Translate(&gloader->base.outline, -hinter->pp1.x, 0);
+
+ FT_Outline_Get_CBox(&gloader->base.outline, &bbox);
+ bbox.xMin &= -64;
+ bbox.yMin &= -64;
+ bbox.xMax = (bbox.xMax + 63) & -64;
+ bbox.yMax = (bbox.yMax + 63) & -64;
+
+ slot->metrics.width = bbox.xMax - bbox.xMin;
+ slot->metrics.height = bbox.yMax - bbox.yMin;
+ slot->metrics.horiBearingX = bbox.xMin;
+ slot->metrics.horiBearingY = bbox.yMax;
+
+ /* for mono-width fonts (like Andale, Courier, etc.), we need */
+ /* to keep the original rounded advance width */
+ if (!FT_IS_FIXED_WIDTH(slot->face))
+ slot->metrics.horiAdvance = hinter->pp2.x - hinter->pp1.x;
+ else
+ slot->metrics.horiAdvance = FT_MulFix(slot->metrics.horiAdvance, x_scale);
+
+ slot->metrics.horiAdvance = (slot->metrics.horiAdvance + 32) & -64;
+
+ /* now copy outline into glyph slot */
+ ah_loader_rewind(slot->internal->loader);
+ error = ah_loader_copy_points(slot->internal->loader, gloader);
+ if (error)
+ goto Exit;
+
+ slot->outline = slot->internal->loader->base.outline;
+ slot->format = FT_GLYPH_FORMAT_OUTLINE;
+ }
+
+#ifdef DEBUG_HINTER
+ ah_debug_hinter = hinter;
+#endif
+
+Exit:
+ return error;
+}
+
+/* load and hint a given glyph */
+FT_LOCAL_DEF(FT_Error)
+ah_hinter_load_glyph(AH_Hinter hinter, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags) {
+ FT_Face face = slot->face;
+ FT_Error error;
+ FT_Fixed x_scale = size->metrics.x_scale;
+ FT_Fixed y_scale = size->metrics.y_scale;
+ AH_Face_Globals face_globals = FACE_GLOBALS(face);
+ FT_Render_Mode hint_mode = FT_LOAD_TARGET_MODE(load_flags);
+
+ /* first of all, we need to check that we're using the correct face and */
+ /* global hints to load the glyph */
+ if (hinter->face != face || hinter->globals != face_globals) {
+ hinter->face = face;
+ if (!face_globals) {
+ error = ah_hinter_new_face_globals(hinter, face, 0);
+ if (error)
+ goto Exit;
+ }
+ hinter->globals = FACE_GLOBALS(face);
+ face_globals = FACE_GLOBALS(face);
+ }
+
+ /* now, we must check the current character pixel size to see if we */
+ /* need to rescale the global metrics */
+ if (face_globals->x_scale != x_scale || face_globals->y_scale != y_scale)
+ ah_hinter_scale_globals(hinter, x_scale, y_scale);
+
+ ah_loader_rewind(hinter->loader);
+
+ /* reset hinting flags according to load flags and current render target */
+ hinter->do_horz_hints = !FT_BOOL(load_flags & FT_LOAD_NO_AUTOHINT);
+ hinter->do_vert_hints = !FT_BOOL(load_flags & FT_LOAD_NO_AUTOHINT);
+
+#ifdef DEBUG_HINTER
+ hinter->do_horz_hints = !ah_debug_disable_vert; /* not a bug, the meaning */
+ hinter->do_vert_hints = !ah_debug_disable_horz; /* of h/v is inverted! */
+#endif
+
+ /* we snap the width of vertical stems for the monochrome and */
+ /* horizontal LCD rendering targets only. Corresponds to X snapping. */
+ hinter->do_horz_snapping = FT_BOOL(hint_mode == FT_RENDER_MODE_MONO || hint_mode == FT_RENDER_MODE_LCD);
+
+ /* we snap the width of horizontal stems for the monochrome and */
+ /* vertical LCD rendering targets only. Corresponds to Y snapping. */
+ hinter->do_vert_snapping = FT_BOOL(hint_mode == FT_RENDER_MODE_MONO || hint_mode == FT_RENDER_MODE_LCD_V);
+
+#if 1
+ load_flags = FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM;
+#else
+ load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_RECURSE;
+#endif
+
+ error = ah_hinter_load(hinter, glyph_index, load_flags, 0);
+
+Exit:
+ return error;
+}
+
+/* retrieve a face's autohint globals for client applications */
+FT_LOCAL_DEF(void)
+ah_hinter_get_global_hints(AH_Hinter hinter, FT_Face face, void **global_hints, long *global_len) {
+ AH_Globals globals = 0;
+ FT_Memory memory = hinter->memory;
+ FT_Error error;
+
+ /* allocate new master globals */
+ if (FT_NEW(globals))
+ goto Fail;
+
+ /* compute face globals if needed */
+ if (!FACE_GLOBALS(face)) {
+ error = ah_hinter_new_face_globals(hinter, face, 0);
+ if (error)
+ goto Fail;
+ }
+
+ *globals = FACE_GLOBALS(face)->design;
+ *global_hints = globals;
+ *global_len = sizeof(*globals);
+
+ return;
+
+Fail:
+ FT_FREE(globals);
+
+ *global_hints = 0;
+ *global_len = 0;
+}
+
+FT_LOCAL_DEF(void)
+ah_hinter_done_global_hints(AH_Hinter hinter, void *global_hints) {
+ FT_Memory memory = hinter->memory;
+
+ FT_FREE(global_hints);
+}
+
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
new file mode 100644
index 00000000000..95b1659f5e2
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
@@ -0,0 +1,88 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahhint.h */
+/* */
+/* Glyph hinter (declaration). */
+/* */
+/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+#ifndef AGS_LIB_FREETYPE_AHHINT_H
+#define AGS_LIB_FREETYPE_AHHINT_H
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahglobal.h"
+
+namespace AGS3 {
+namespace FreeType213 {
+
+// FT_BEGIN_HEADER
+
+
+#define AH_HINT_DEFAULT 0
+#define AH_HINT_NO_ALIGNMENT 1
+#define AH_HINT_NO_HORZ_EDGES 0x200000L /* temporary hack */
+#define AH_HINT_NO_VERT_EDGES 0x400000L /* temporary hack */
+
+/* create a new empty hinter object */
+FT_LOCAL(FT_Error)
+ah_hinter_new(FT_Library library, AH_Hinter *ahinter);
+
+/* Load a hinted glyph in the hinter */
+FT_LOCAL(FT_Error)
+ah_hinter_load_glyph(AH_Hinter hinter, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags);
+
+/* finalize a hinter object */
+FT_LOCAL(void)
+ah_hinter_done(AH_Hinter hinter);
+
+FT_LOCAL(void)
+ah_hinter_done_face_globals(AH_Face_Globals globals);
+
+FT_LOCAL(void)
+ah_hinter_get_global_hints(AH_Hinter hinter, FT_Face face, void **global_hints, long *global_len);
+
+FT_LOCAL(void)
+ah_hinter_done_global_hints(AH_Hinter hinter, void *global_hints);
+
+
+// FT_END_HEADER
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
+
+#endif /* AGS_LIB_FREETYPE_AHHINT_H */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahloader.h b/engines/ags/lib/freetype-2.1.3/autohint/ahloader.h
new file mode 100644
index 00000000000..2ada4930c43
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahloader.h
@@ -0,0 +1,72 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahloader.h */
+/* */
+/* Glyph loader for the auto-hinting module (declaration only). */
+/* */
+/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+
+#ifndef AGS_LIB_FREETYPE_AHLOADER_H
+#define AGS_LIB_FREETYPE_AHLOADER_H
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+
+
+// FT_BEGIN_HEADER
+
+#include "engines/ags/lib/freetype-2.1.3/ftgloadr.h"
+
+#define AH_Load FT_GlyphLoad
+#define AH_Loader FT_GlyphLoader
+
+#define ah_loader_new FT_GlyphLoader_New
+#define ah_loader_done FT_GlyphLoader_Done
+#define ah_loader_reset FT_GlyphLoader_Reset
+#define ah_loader_rewind FT_GlyphLoader_Rewind
+#define ah_loader_create_extra FT_GlyphLoader_CreateExtra
+#define ah_loader_check_points FT_GlyphLoader_CheckPoints
+#define ah_loader_check_subglyphs FT_GlyphLoader_CheckSubGlyphs
+#define ah_loader_prepare FT_GlyphLoader_Prepare
+#define ah_loader_add FT_GlyphLoader_Add
+#define ah_loader_copy_points FT_GlyphLoader_CopyPoints
+
+
+// FT_END_HEADER
+
+#endif /* AGS_LIB_FREETYPE_AHLOADER_H */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahmodule.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahmodule.cpp
new file mode 100644
index 00000000000..cc3f9fc07a2
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahmodule.cpp
@@ -0,0 +1,130 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahmodule.c */
+/* */
+/* Auto-hinting module implementation (declaration). */
+/* */
+/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/ftmodule.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahhint.h"
+
+namespace AGS3 {
+namespace FreeType213 {
+
+
+#ifdef DEBUG_HINTER
+AH_Hinter ah_debug_hinter = NULL;
+FT_Bool ah_debug_disable_horz = 0;
+FT_Bool ah_debug_disable_vert = 0;
+#endif
+
+typedef struct FT_AutoHinterRec_ {
+ FT_ModuleRec root;
+ AH_Hinter hinter;
+} FT_AutoHinterRec;
+
+FT_CALLBACK_DEF(FT_Error)
+ft_autohinter_init(FT_AutoHinter module) {
+ FT_Error error;
+
+ error = ah_hinter_new(module->root.library, &module->hinter);
+#ifdef DEBUG_HINTER
+ if (!error)
+ ah_debug_hinter = module->hinter;
+#endif
+ return error;
+}
+
+FT_CALLBACK_DEF(void)
+ft_autohinter_done(FT_AutoHinter module) {
+ ah_hinter_done(module->hinter);
+
+#ifdef DEBUG_HINTER
+ ah_debug_hinter = NULL;
+#endif
+}
+
+FT_CALLBACK_DEF(FT_Error)
+ft_autohinter_load_glyph(FT_AutoHinter module, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags) {
+ return ah_hinter_load_glyph(module->hinter, slot, size, glyph_index, load_flags);
+}
+
+FT_CALLBACK_DEF(void)
+ft_autohinter_reset_globals(FT_AutoHinter module, FT_Face face) {
+ FT_UNUSED(module);
+
+ if (face->autohint.data)
+ ah_hinter_done_face_globals((AH_Face_Globals)(face->autohint.data));
+}
+
+FT_CALLBACK_DEF(void)
+ft_autohinter_get_globals(FT_AutoHinter module, FT_Face face, void **global_hints, long *global_len) {
+ ah_hinter_get_global_hints(module->hinter, face, global_hints, global_len);
+}
+
+FT_CALLBACK_DEF(void)
+ft_autohinter_done_globals(FT_AutoHinter module, void *global_hints) {
+ ah_hinter_done_global_hints(module->hinter, global_hints);
+}
+
+FT_CALLBACK_TABLE_DEF
+const FT_AutoHinter_ServiceRec ft_autohinter_service = {
+ ft_autohinter_reset_globals,
+ ft_autohinter_get_globals,
+ ft_autohinter_done_globals,
+ ft_autohinter_load_glyph};
+
+FT_CALLBACK_TABLE_DEF
+const FT_Module_Class autohint_module_class = {
+ ft_module_hinter,
+ sizeof(FT_AutoHinterRec),
+
+ "autohinter",
+ 0x10000L, /* version 1.0 of the autohinter */
+ 0x20000L, /* requires FreeType 2.0 or above */
+
+ (const void *)&ft_autohinter_service,
+
+ (FT_Module_Constructor)ft_autohinter_init,
+ (FT_Module_Destructor)ft_autohinter_done,
+ (FT_Module_Requester)0};
+
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahmodule.h b/engines/ags/lib/freetype-2.1.3/autohint/ahmodule.h
new file mode 100644
index 00000000000..b6701655f15
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahmodule.h
@@ -0,0 +1,65 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahmodule.h */
+/* */
+/* Auto-hinting module (declaration). */
+/* */
+/* Copyright 2000-2001 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+#ifndef AGS_LIB_FREETYPE_AHMODULE_H
+#define AGS_LIB_FREETYPE_AHMODULE_H
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/ftmodule.h"
+
+namespace AGS3 {
+namespace FreeType213 {
+
+// FT_BEGIN_HEADER
+
+
+FT_CALLBACK_TABLE
+const FT_Module_Class autohint_module_class;
+
+
+// FT_END_HEADER
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
+
+#endif /* AGS_LIB_FREETYPE_AHMODULE_H */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahoptim.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahoptim.cpp
new file mode 100644
index 00000000000..66c65463335
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahoptim.cpp
@@ -0,0 +1,848 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahoptim.c */
+/* */
+/* FreeType auto hinting outline optimization (body). */
+/* */
+/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+/*************************************************************************/
+/* */
+/* This module is in charge of optimising the outlines produced by the */
+/* auto-hinter in direct mode. This is required at small pixel sizes in */
+/* order to ensure coherent spacing, among other things.. */
+/* */
+/* The technique used in this module is a simplified simulated */
+/* annealing. */
+/* */
+/*************************************************************************/
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/ftobjs.h" /* for FT_ALLOC_ARRAY() and FT_FREE() */
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahoptim.h"
+
+
+/* define this macro to use brute force optimization -- this is slow, */
+/* but a good way to perfect the distortion function `by hand' through */
+/* tweaking */
+#define AH_BRUTE_FORCE
+
+
+#define xxxAH_DEBUG_OPTIM
+
+
+#undef LOG
+#ifdef AH_DEBUG_OPTIM
+
+#define LOG( x ) optim_log ## x
+
+#else
+
+#define LOG( x )
+
+#endif /* AH_DEBUG_OPTIM */
+
+namespace AGS3 {
+namespace FreeType213 {
+
+#ifdef AH_DEBUG_OPTIM
+
+#include <stdarg.h>
+#include <stdlib.h>
+
+#define FLOAT( x ) ( (float)( (x) / 64.0 ) )
+
+
+static void
+optim_log( const char* fmt, ... ) {
+ va_list ap;
+
+
+ va_start( ap, fmt );
+ vprintf( fmt, ap );
+ va_end( ap );
+}
+
+
+static void
+AH_Dump_Stems( AH_Optimizer* optimizer ) {
+ int n;
+ AH_Stem* stem;
+
+
+ stem = optimizer->stems;
+ for ( n = 0; n < optimizer->num_stems; n++, stem++ ) {
+ LOG(( " %c%2d [%.1f:%.1f]={%.1f:%.1f}="
+ "<%1.f..%1.f> force=%.1f speed=%.1f\n",
+ optimizer->vertical ? 'V' : 'H', n,
+ FLOAT( stem->edge1->opos ), FLOAT( stem->edge2->opos ),
+ FLOAT( stem->edge1->pos ), FLOAT( stem->edge2->pos ),
+ FLOAT( stem->min_pos ), FLOAT( stem->max_pos ),
+ FLOAT( stem->force ), FLOAT( stem->velocity ) ));
+ }
+}
+
+
+static void
+AH_Dump_Stems2( AH_Optimizer* optimizer ) {
+ int n;
+ AH_Stem* stem;
+
+
+ stem = optimizer->stems;
+ for ( n = 0; n < optimizer->num_stems; n++, stem++ ) {
+ LOG(( " %c%2d [%.1f]=<%1.f..%1.f> force=%.1f speed=%.1f\n",
+ optimizer->vertical ? 'V' : 'H', n,
+ FLOAT( stem->pos ),
+ FLOAT( stem->min_pos ), FLOAT( stem->max_pos ),
+ FLOAT( stem->force ), FLOAT( stem->velocity ) ));
+ }
+}
+
+
+static void
+AH_Dump_Springs( AH_Optimizer* optimizer ) {
+ int n;
+ AH_Spring* spring;
+ AH_Stem* stems;
+
+
+ spring = optimizer->springs;
+ stems = optimizer->stems;
+ LOG(( "%cSprings ", optimizer->vertical ? 'V' : 'H' ));
+
+ for ( n = 0; n < optimizer->num_springs; n++, spring++ ) {
+ LOG(( " [%d-%d:%.1f:%1.f:%.1f]",
+ spring->stem1 - stems, spring->stem2 - stems,
+ FLOAT( spring->owidth ),
+ FLOAT( spring->stem2->pos -
+ ( spring->stem1->pos + spring->stem1->width ) ),
+ FLOAT( spring->tension ) ));
+ }
+
+ LOG(( "\n" ));
+}
+
+#endif /* AH_DEBUG_OPTIM */
+
+
+/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
+/**** ****/
+/**** COMPUTE STEMS AND SPRINGS IN AN OUTLINE ****/
+/**** ****/
+/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
+
+
+static int
+valid_stem_segments( AH_Segment seg1,
+ AH_Segment seg2 ) {
+ return seg1->serif == 0 &&
+ seg2 &&
+ seg2->link == seg1 &&
+ seg1->pos < seg2->pos &&
+ seg1->min_coord <= seg2->max_coord &&
+ seg2->min_coord <= seg1->max_coord;
+}
+
+
+/* compute all stems in an outline */
+static int
+optim_compute_stems( AH_Optimizer* optimizer ) {
+ AH_Outline outline = optimizer->outline;
+ FT_Fixed scale;
+ FT_Memory memory = optimizer->memory;
+ FT_Error error = 0;
+ FT_Int dimension;
+ AH_Edge edges;
+ AH_Edge edge_limit;
+ AH_Stem** p_stems;
+ FT_Int* p_num_stems;
+
+
+ edges = outline->horz_edges;
+ edge_limit = edges + outline->num_hedges;
+ scale = outline->y_scale;
+
+ p_stems = &optimizer->horz_stems;
+ p_num_stems = &optimizer->num_hstems;
+
+ for ( dimension = 1; dimension >= 0; dimension-- ) {
+ AH_Stem* stems = 0;
+ FT_Int num_stems = 0;
+ AH_Edge edge;
+
+
+ /* first of all, count the number of stems in this direction */
+ for ( edge = edges; edge < edge_limit; edge++ ) {
+ AH_Segment seg = edge->first;
+
+
+ do {
+ if (valid_stem_segments( seg, seg->link ) )
+ num_stems++;
+
+ seg = seg->edge_next;
+
+ } while ( seg != edge->first );
+ }
+
+ /* now allocate the stems and build their table */
+ if ( num_stems > 0 ) {
+ AH_Stem* stem;
+
+
+ if ( FT_NEW_ARRAY( stems, num_stems ) )
+ goto Exit;
+
+ stem = stems;
+ for ( edge = edges; edge < edge_limit; edge++ ) {
+ AH_Segment seg = edge->first;
+ AH_Segment seg2;
+
+
+ do {
+ seg2 = seg->link;
+ if ( valid_stem_segments( seg, seg2 ) ) {
+ AH_Edge edge1 = seg->edge;
+ AH_Edge edge2 = seg2->edge;
+
+
+ stem->edge1 = edge1;
+ stem->edge2 = edge2;
+ stem->opos = edge1->opos;
+ stem->pos = edge1->pos;
+ stem->owidth = edge2->opos - edge1->opos;
+ stem->width = edge2->pos - edge1->pos;
+
+ /* compute min_coord and max_coord */
+ {
+ FT_Pos min_coord = seg->min_coord;
+ FT_Pos max_coord = seg->max_coord;
+
+
+ if ( seg2->min_coord > min_coord )
+ min_coord = seg2->min_coord;
+
+ if ( seg2->max_coord < max_coord )
+ max_coord = seg2->max_coord;
+
+ stem->min_coord = min_coord;
+ stem->max_coord = max_coord;
+ }
+
+ /* compute minimum and maximum positions for stem -- */
+ /* note that the left-most/bottom-most stem has always */
+ /* a fixed position */
+ if ( stem == stems || edge1->blue_edge || edge2->blue_edge ) {
+ /* this stem cannot move; it is snapped to a blue edge */
+ stem->min_pos = stem->pos;
+ stem->max_pos = stem->pos;
+ } else {
+ /* this edge can move; compute its min and max positions */
+ FT_Pos pos1 = stem->opos;
+ FT_Pos pos2 = pos1 + stem->owidth - stem->width;
+ FT_Pos min1 = pos1 & -64;
+ FT_Pos min2 = pos2 & -64;
+
+
+ stem->min_pos = min1;
+ stem->max_pos = min1 + 64;
+ if ( min2 < min1 )
+ stem->min_pos = min2;
+ else
+ stem->max_pos = min2 + 64;
+
+ /* XXX: just to see what it does */
+ stem->max_pos += 64;
+
+ /* just for the case where direct hinting did some */
+ /* incredible things (e.g. blue edge shifts) */
+ if ( stem->min_pos > stem->pos )
+ stem->min_pos = stem->pos;
+
+ if ( stem->max_pos < stem->pos )
+ stem->max_pos = stem->pos;
+ }
+
+ stem->velocity = 0;
+ stem->force = 0;
+
+ stem++;
+ }
+ seg = seg->edge_next;
+
+ } while ( seg != edge->first );
+ }
+ }
+
+ *p_stems = stems;
+ *p_num_stems = num_stems;
+
+ edges = outline->vert_edges;
+ edge_limit = edges + outline->num_vedges;
+ scale = outline->x_scale;
+
+ p_stems = &optimizer->vert_stems;
+ p_num_stems = &optimizer->num_vstems;
+ }
+
+Exit:
+
+#ifdef AH_DEBUG_OPTIM
+ AH_Dump_Stems( optimizer );
+#endif
+
+ return error;
+}
+
+
+/* returns the spring area between two stems, 0 if none */
+static FT_Pos
+stem_spring_area( AH_Stem* stem1,
+ AH_Stem* stem2 ) {
+ FT_Pos area1 = stem1->max_coord - stem1->min_coord;
+ FT_Pos area2 = stem2->max_coord - stem2->min_coord;
+ FT_Pos min = stem1->min_coord;
+ FT_Pos max = stem1->max_coord;
+ FT_Pos area;
+
+
+ /* order stems */
+ if ( stem2->opos <= stem1->opos + stem1->owidth )
+ return 0;
+
+ if ( min < stem2->min_coord )
+ min = stem2->min_coord;
+
+ if ( max < stem2->max_coord )
+ max = stem2->max_coord;
+
+ area = ( max-min );
+ if ( 2 * area < area1 && 2 * area < area2 )
+ area = 0;
+
+ return area;
+}
+
+
+/* compute all springs in an outline */
+static int
+optim_compute_springs( AH_Optimizer* optimizer ) {
+ /* basically, a spring exists between two stems if most of their */
+ /* surface is aligned */
+ FT_Memory memory = optimizer->memory;
+
+ AH_Stem* stems;
+ AH_Stem* stem_limit;
+ AH_Stem* stem;
+ int dimension;
+ int error = 0;
+
+ FT_Int* p_num_springs;
+ AH_Spring** p_springs;
+
+
+ stems = optimizer->horz_stems;
+ stem_limit = stems + optimizer->num_hstems;
+
+ p_springs = &optimizer->horz_springs;
+ p_num_springs = &optimizer->num_hsprings;
+
+ for ( dimension = 1; dimension >= 0; dimension-- ) {
+ FT_Int num_springs = 0;
+ AH_Spring* springs = 0;
+
+
+ /* first of all, count stem springs */
+ for ( stem = stems; stem + 1 < stem_limit; stem++ ) {
+ AH_Stem* stem2;
+
+
+ for ( stem2 = stem+1; stem2 < stem_limit; stem2++ )
+ if ( stem_spring_area( stem, stem2 ) )
+ num_springs++;
+ }
+
+ /* then allocate and build the springs table */
+ if ( num_springs > 0 ) {
+ AH_Spring* spring;
+
+
+ /* allocate table of springs */
+ if ( FT_NEW_ARRAY( springs, num_springs ) )
+ goto Exit;
+
+ /* fill the springs table */
+ spring = springs;
+ for ( stem = stems; stem+1 < stem_limit; stem++ ) {
+ AH_Stem* stem2;
+ FT_Pos area;
+
+
+ for ( stem2 = stem + 1; stem2 < stem_limit; stem2++ ) {
+ area = stem_spring_area( stem, stem2 );
+ if ( area ) {
+ /* add a new spring here */
+ spring->stem1 = stem;
+ spring->stem2 = stem2;
+ spring->owidth = stem2->opos - ( stem->opos + stem->owidth );
+ spring->tension = 0;
+
+ spring++;
+ }
+ }
+ }
+ }
+ *p_num_springs = num_springs;
+ *p_springs = springs;
+
+ stems = optimizer->vert_stems;
+ stem_limit = stems + optimizer->num_vstems;
+
+ p_springs = &optimizer->vert_springs;
+ p_num_springs = &optimizer->num_vsprings;
+ }
+
+Exit:
+
+#ifdef AH_DEBUG_OPTIM
+ AH_Dump_Springs( optimizer );
+#endif
+
+ return error;
+}
+
+
+/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
+/**** ****/
+/**** OPTIMIZE THROUGH MY STRANGE SIMULATED ANNEALING ALGO ;-) ****/
+/**** ****/
+/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
+
+#ifndef AH_BRUTE_FORCE
+
+/* compute all spring tensions */
+static void
+optim_compute_tensions( AH_Optimizer* optimizer ) {
+ AH_Spring* spring = optimizer->springs;
+ AH_Spring* limit = spring + optimizer->num_springs;
+
+
+ for ( ; spring < limit; spring++ ) {
+ AH_Stem* stem1 = spring->stem1;
+ AH_Stem* stem2 = spring->stem2;
+ FT_Int status;
+
+ FT_Pos width;
+ FT_Pos tension;
+ FT_Pos sign;
+
+
+ /* compute the tension; it simply is -K*(new_width-old_width) */
+ width = stem2->pos - ( stem1->pos + stem1->width );
+ tension = width - spring->owidth;
+
+ sign = 1;
+ if ( tension < 0 ) {
+ sign = -1;
+ tension = -tension;
+ }
+
+ if ( width <= 0 )
+ tension = 32000;
+ else
+ tension = ( tension << 10 ) / width;
+
+ tension = -sign * FT_MulFix( tension, optimizer->tension_scale );
+ spring->tension = tension;
+
+ /* now, distribute tension among the englobing stems, if they */
+ /* are able to move */
+ status = 0;
+ if ( stem1->pos <= stem1->min_pos )
+ status |= 1;
+ if ( stem2->pos >= stem2->max_pos )
+ status |= 2;
+
+ if ( !status )
+ tension /= 2;
+
+ if ( ( status & 1 ) == 0 )
+ stem1->force -= tension;
+
+ if ( ( status & 2 ) == 0 )
+ stem2->force += tension;
+ }
+}
+
+
+/* compute all stem movements -- returns 0 if nothing moved */
+static int
+optim_compute_stem_movements( AH_Optimizer* optimizer ) {
+ AH_Stem* stems = optimizer->stems;
+ AH_Stem* limit = stems + optimizer->num_stems;
+ AH_Stem* stem = stems;
+ int moved = 0;
+
+
+ /* set initial forces to velocity */
+ for ( stem = stems; stem < limit; stem++ ) {
+ stem->force = stem->velocity;
+ stem->velocity /= 2; /* XXX: Heuristics */
+ }
+
+ /* compute the sum of forces applied on each stem */
+ optim_compute_tensions( optimizer );
+
+#ifdef AH_DEBUG_OPTIM
+ AH_Dump_Springs( optimizer );
+ AH_Dump_Stems2( optimizer );
+#endif
+
+ /* now, see whether something can move */
+ for ( stem = stems; stem < limit; stem++ ) {
+ if ( stem->force > optimizer->tension_threshold ) {
+ /* there is enough tension to move the stem to the right */
+ if ( stem->pos < stem->max_pos ) {
+ stem->pos += 64;
+ stem->velocity = stem->force / 2;
+ moved = 1;
+ } else
+ stem->velocity = 0;
+ } else if ( stem->force < optimizer->tension_threshold ) {
+ /* there is enough tension to move the stem to the left */
+ if ( stem->pos > stem->min_pos ) {
+ stem->pos -= 64;
+ stem->velocity = stem->force / 2;
+ moved = 1;
+ } else
+ stem->velocity = 0;
+ }
+ }
+
+ /* return 0 if nothing moved */
+ return moved;
+}
+
+#endif /* AH_BRUTE_FORCE */
+
+
+/* compute current global distortion from springs */
+static FT_Pos
+optim_compute_distortion( AH_Optimizer* optimizer ) {
+ AH_Spring* spring = optimizer->springs;
+ AH_Spring* limit = spring + optimizer->num_springs;
+ FT_Pos distortion = 0;
+
+
+ for ( ; spring < limit; spring++ ) {
+ AH_Stem* stem1 = spring->stem1;
+ AH_Stem* stem2 = spring->stem2;
+ FT_Pos width;
+
+ width = stem2->pos - ( stem1->pos + stem1->width );
+ width -= spring->owidth;
+ if ( width < 0 )
+ width = -width;
+
+ distortion += width;
+ }
+
+ return distortion;
+}
+
+
+/* record stems configuration in `best of' history */
+static void
+optim_record_configuration( AH_Optimizer* optimizer ) {
+ FT_Pos distortion;
+ AH_Configuration* configs = optimizer->configs;
+ AH_Configuration* limit = configs + optimizer->num_configs;
+ AH_Configuration* config;
+
+
+ distortion = optim_compute_distortion( optimizer );
+ LOG(( "config distortion = %.1f ", FLOAT( distortion * 64 ) ));
+
+ /* check that we really need to add this configuration to our */
+ /* sorted history */
+ if ( limit > configs && limit[-1].distortion < distortion ) {
+ LOG(( "ejected\n" ));
+ return;
+ }
+
+ /* add new configuration at the end of the table */
+ {
+ int n;
+
+
+ config = limit;
+ if ( optimizer->num_configs < AH_MAX_CONFIGS )
+ optimizer->num_configs++;
+ else
+ config--;
+
+ config->distortion = distortion;
+
+ for ( n = 0; n < optimizer->num_stems; n++ )
+ config->positions[n] = optimizer->stems[n].pos;
+ }
+
+ /* move the current configuration towards the front of the list */
+ /* when necessary -- yes this is slow bubble sort ;-) */
+ while ( config > configs && config[0].distortion < config[-1].distortion ) {
+ AH_Configuration temp;
+
+
+ config--;
+ temp = config[0];
+ config[0] = config[1];
+ config[1] = temp;
+ }
+ LOG(( "recorded!\n" ));
+}
+
+
+#ifdef AH_BRUTE_FORCE
+
+/* optimize outline in a single direction */
+static void
+optim_compute( AH_Optimizer* optimizer ) {
+ int n;
+ FT_Bool moved;
+
+ AH_Stem* stem = optimizer->stems;
+ AH_Stem* limit = stem + optimizer->num_stems;
+
+
+ /* empty, exit */
+ if ( stem >= limit )
+ return;
+
+ optimizer->num_configs = 0;
+
+ stem = optimizer->stems;
+ for ( ; stem < limit; stem++ )
+ stem->pos = stem->min_pos;
+
+ do {
+ /* record current configuration */
+ optim_record_configuration( optimizer );
+
+ /* now change configuration */
+ moved = 0;
+ for ( stem = optimizer->stems; stem < limit; stem++ ) {
+ if ( stem->pos < stem->max_pos ) {
+ stem->pos += 64;
+ moved = 1;
+ break;
+ }
+
+ stem->pos = stem->min_pos;
+ }
+ } while ( moved );
+
+ /* now, set the best stem positions */
+ for ( n = 0; n < optimizer->num_stems; n++ ) {
+ AH_Stem* stem = optimizer->stems + n;
+ FT_Pos pos = optimizer->configs[0].positions[n];
+
+
+ stem->edge1->pos = pos;
+ stem->edge2->pos = pos + stem->width;
+
+ stem->edge1->flags |= AH_EDGE_DONE;
+ stem->edge2->flags |= AH_EDGE_DONE;
+ }
+}
+
+#else /* AH_BRUTE_FORCE */
+
+/* optimize outline in a single direction */
+static void
+optim_compute( AH_Optimizer* optimizer ) {
+ int n, counter, counter2;
+
+
+ optimizer->num_configs = 0;
+ optimizer->tension_scale = 0x80000L;
+ optimizer->tension_threshold = 64;
+
+ /* record initial configuration threshold */
+ optim_record_configuration( optimizer );
+
+ counter = 0;
+ for ( counter2 = optimizer->num_stems*8; counter2 >= 0; counter2-- ) {
+ if ( counter == 0 )
+ counter = 2 * optimizer->num_stems;
+
+ if ( !optim_compute_stem_movements( optimizer ) )
+ break;
+
+ optim_record_configuration( optimizer );
+
+ counter--;
+ if ( counter == 0 )
+ optimizer->tension_scale /= 2;
+ }
+
+ /* now, set the best stem positions */
+ for ( n = 0; n < optimizer->num_stems; n++ ) {
+ AH_Stem* stem = optimizer->stems + n;
+ FT_Pos pos = optimizer->configs[0].positions[n];
+
+
+ stem->edge1->pos = pos;
+ stem->edge2->pos = pos + stem->width;
+
+ stem->edge1->flags |= AH_EDGE_DONE;
+ stem->edge2->flags |= AH_EDGE_DONE;
+ }
+}
+
+#endif /* AH_BRUTE_FORCE */
+
+
+/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
+/**** ****/
+/**** HIGH-LEVEL OPTIMIZER API ****/
+/**** ****/
+/*************************************************************************/
+/*************************************************************************/
+/*************************************************************************/
+
+
+/* releases the optimization data */
+void
+AH_Optimizer_Done( AH_Optimizer* optimizer ) {
+ if ( optimizer ) {
+ FT_Memory memory = optimizer->memory;
+
+
+ FT_FREE( optimizer->horz_stems );
+ FT_FREE( optimizer->vert_stems );
+ FT_FREE( optimizer->horz_springs );
+ FT_FREE( optimizer->vert_springs );
+ FT_FREE( optimizer->positions );
+ }
+}
+
+
+/* loads the outline into the optimizer */
+int
+AH_Optimizer_Init( AH_Optimizer* optimizer,
+ AH_Outline outline,
+ FT_Memory memory ) {
+ FT_Error error;
+
+
+ FT_MEM_ZERO( optimizer, sizeof ( *optimizer ) );
+ optimizer->outline = outline;
+ optimizer->memory = memory;
+
+ LOG(( "initializing new optimizer\n" ));
+ /* compute stems and springs */
+ error = optim_compute_stems ( optimizer ) ||
+ optim_compute_springs( optimizer );
+ if ( error )
+ goto Fail;
+
+ /* allocate stem positions history and configurations */
+ {
+ int n, max_stems;
+
+
+ max_stems = optimizer->num_hstems;
+ if ( max_stems < optimizer->num_vstems )
+ max_stems = optimizer->num_vstems;
+
+ if ( FT_NEW_ARRAY( optimizer->positions, max_stems * AH_MAX_CONFIGS ) )
+ goto Fail;
+
+ optimizer->num_configs = 0;
+ for ( n = 0; n < AH_MAX_CONFIGS; n++ )
+ optimizer->configs[n].positions = optimizer->positions +
+ n * max_stems;
+ }
+
+ return error;
+
+Fail:
+ AH_Optimizer_Done( optimizer );
+ return error;
+}
+
+
+/* compute optimal outline */
+void
+AH_Optimizer_Compute( AH_Optimizer* optimizer ) {
+ optimizer->num_stems = optimizer->num_hstems;
+ optimizer->stems = optimizer->horz_stems;
+ optimizer->num_springs = optimizer->num_hsprings;
+ optimizer->springs = optimizer->horz_springs;
+
+ if ( optimizer->num_springs > 0 ) {
+ LOG(( "horizontal optimization ------------------------\n" ));
+ optim_compute( optimizer );
+ }
+
+ optimizer->num_stems = optimizer->num_vstems;
+ optimizer->stems = optimizer->vert_stems;
+ optimizer->num_springs = optimizer->num_vsprings;
+ optimizer->springs = optimizer->vert_springs;
+
+ if ( optimizer->num_springs ) {
+ LOG(( "vertical optimization --------------------------\n" ));
+ optim_compute( optimizer );
+ }
+}
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
+
+/* END */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahoptim.h b/engines/ags/lib/freetype-2.1.3/autohint/ahoptim.h
new file mode 100644
index 00000000000..9e1712047b1
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahoptim.h
@@ -0,0 +1,145 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahoptim.h */
+/* */
+/* FreeType auto hinting outline optimization (declaration). */
+/* */
+/* Copyright 2000-2001 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+#ifndef AGS_LIB_FREETYPE_AHOPTIM_H
+#define AGS_LIB_FREETYPE_AHOPTIM_H
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahtypes.h"
+
+namespace AGS3 {
+namespace FreeType213 {
+
+// FT_BEGIN_HEADER
+
+
+/* the maximal number of stem configurations to record */
+/* during optimization */
+#define AH_MAX_CONFIGS 8
+
+
+typedef struct AH_Stem_ {
+ FT_Pos pos; /* current position */
+ FT_Pos velocity; /* current velocity */
+ FT_Pos force; /* sum of current forces */
+ FT_Pos width; /* normalized width */
+
+ FT_Pos min_pos; /* minimum grid position */
+ FT_Pos max_pos; /* maximum grid position */
+
+ AH_Edge edge1; /* left/bottom edge */
+ AH_Edge edge2; /* right/top edge */
+
+ FT_Pos opos; /* original position */
+ FT_Pos owidth; /* original width */
+
+ FT_Pos min_coord; /* minimum coordinate */
+ FT_Pos max_coord; /* maximum coordinate */
+} AH_Stem;
+
+
+/* A spring between two stems */
+typedef struct AH_Spring_ {
+ AH_Stem *stem1;
+ AH_Stem *stem2;
+ FT_Pos owidth; /* original width */
+ FT_Pos tension; /* current tension */
+} AH_Spring;
+
+
+/* A configuration records the position of each stem at a given time */
+/* as well as the associated distortion */
+typedef struct AH_Configuration_ {
+ FT_Pos *positions;
+ FT_Long distortion;
+} AH_Configuration;
+
+
+typedef struct AH_Optimizer_ {
+ FT_Memory memory;
+ AH_Outline outline;
+
+ FT_Int num_hstems;
+ AH_Stem *horz_stems;
+
+ FT_Int num_vstems;
+ AH_Stem *vert_stems;
+
+ FT_Int num_hsprings;
+ FT_Int num_vsprings;
+ AH_Spring *horz_springs;
+ AH_Spring *vert_springs;
+
+ FT_Int num_configs;
+ AH_Configuration configs[AH_MAX_CONFIGS];
+ FT_Pos *positions;
+
+ /* during each pass, use these instead */
+ FT_Int num_stems;
+ AH_Stem *stems;
+
+ FT_Int num_springs;
+ AH_Spring *springs;
+ FT_Bool vertical;
+
+ FT_Fixed tension_scale;
+ FT_Pos tension_threshold;
+} AH_Optimizer;
+
+
+/* loads the outline into the optimizer */
+int AH_Optimizer_Init(AH_Optimizer *optimizer, AH_Outline outline, FT_Memory memory);
+
+/* compute optimal outline */
+void AH_Optimizer_Compute(AH_Optimizer *optimizer);
+
+/* release the optimization data */
+void AH_Optimizer_Done(AH_Optimizer *optimizer);
+
+
+// FT_END_HEADER
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
+
+#endif /* AGS_LIB_FREETYPE_AHOPTIM_H */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h b/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
new file mode 100644
index 00000000000..904e495c76d
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
@@ -0,0 +1,347 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ahtypes.h */
+/* */
+/* General types and definitions for the auto-hint module */
+/* (specification only). */
+/* */
+/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
+/* Author: David Turner */
+/* */
+/* This file is part of the Catharon Typography Project and shall only */
+/* be used, modified, and distributed under the terms of the Catharon */
+/* Open Source License that should come with this file under the name */
+/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/* Note that this license is compatible with the FreeType license. */
+/* */
+/***************************************************************************/
+
+
+#ifndef AGS_LIB_FREETYPE_AHTYPES_H
+#define AGS_LIB_FREETYPE_AHTYPES_H
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/ftobjs.h"
+
+#ifdef DEBUG_HINTER
+#include <../modules/autohint/ahloader.h>
+#else
+#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahloader.h"
+#endif
+
+
+#define xxAH_DEBUG
+
+
+#ifdef AH_DEBUG
+
+#include <stdio.h>
+#define AH_LOG(x) printf##x
+
+#else
+
+#define AH_LOG(x) do ; while(0) /* nothing */
+
+#endif /* AH_DEBUG */
+
+namespace AGS3 {
+namespace FreeType213 {
+
+// FT_BEGIN_HEADER
+
+
+/**** COMPILE-TIME BUILD OPTIONS ****/
+
+/*************************************************************************/
+/* */
+/* If this option is defined, only strong interpolation will be used to */
+/* place the points between edges. Otherwise, `smooth' points are */
+/* detected and later hinted through weak interpolation to correct some */
+/* unpleasant artefacts. */
+/* */
+#undef AH_OPTION_NO_WEAK_INTERPOLATION
+
+/*************************************************************************/
+/* */
+/* If this option is defined, only weak interpolation will be used to */
+/* place the points between edges. Otherwise, `strong' points are */
+/* detected and later hinted through strong interpolation to correct */
+/* some unpleasant artefacts. */
+/* */
+#undef AH_OPTION_NO_STRONG_INTERPOLATION
+
+/*************************************************************************/
+/* */
+/* Undefine this macro if you don't want to hint the metrics. There is */
+/* no reason to do this (at least for non-CJK scripts), except for */
+/* experimentation. */
+/* */
+#undef AH_HINT_METRICS
+
+/*************************************************************************/
+/* */
+/* Define this macro if you do not want to insert extra edges at a */
+/* glyph's x and y extremum (if there isn't one already available). */
+/* This helps to reduce a number of artefacts and allows hinting of */
+/* metrics. */
+/* */
+#undef AH_OPTION_NO_EXTREMUM_EDGES
+
+/* don't touch for now */
+#define AH_MAX_WIDTHS 12
+#define AH_MAX_HEIGHTS 12
+
+
+/**** TYPE DEFINITIONS ****/
+
+/* see agangles.h */
+typedef FT_Int AH_Angle;
+
+/* hint flags */
+#define AH_FLAG_NONE 0
+
+/* bezier control points flags */
+#define AH_FLAG_CONIC 1
+#define AH_FLAG_CUBIC 2
+#define AH_FLAG_CONTROL ( AH_FLAG_CONIC | AH_FLAG_CUBIC )
+
+/* extrema flags */
+#define AH_FLAG_EXTREMA_X 4
+#define AH_FLAG_EXTREMA_Y 8
+
+/* roundness */
+#define AH_FLAG_ROUND_X 16
+#define AH_FLAG_ROUND_Y 32
+
+/* touched */
+#define AH_FLAG_TOUCH_X 64
+#define AH_FLAG_TOUCH_Y 128
+
+/* weak interpolation */
+#define AH_FLAG_WEAK_INTERPOLATION 256
+#define AH_FLAG_INFLECTION 512
+
+typedef FT_Int AH_Flags;
+
+/* edge hint flags */
+#define AH_EDGE_NORMAL 0
+#define AH_EDGE_ROUND 1
+#define AH_EDGE_SERIF 2
+#define AH_EDGE_DONE 4
+
+typedef FT_Int AH_Edge_Flags;
+
+/* hint directions -- the values are computed so that two vectors are */
+/* in opposite directions iff `dir1+dir2 == 0' */
+#define AH_DIR_NONE 4
+#define AH_DIR_RIGHT 1
+#define AH_DIR_LEFT -1
+#define AH_DIR_UP 2
+#define AH_DIR_DOWN -2
+
+typedef FT_Int AH_Direction;
+
+typedef struct AH_PointRec_ *AH_Point;
+typedef struct AH_SegmentRec_ *AH_Segment;
+typedef struct AH_EdgeRec_ *AH_Edge;
+
+typedef struct AH_PointRec_ {
+ AH_Flags flags; /* point flags used by hinter */
+ FT_Pos ox, oy;
+ FT_Pos fx, fy;
+ FT_Pos x, y;
+ FT_Pos u, v;
+
+ AH_Direction in_dir; /* direction of inwards vector */
+ AH_Direction out_dir; /* direction of outwards vector */
+
+ AH_Angle in_angle;
+ AH_Angle out_angle;
+
+ AH_Point next; /* next point in contour */
+ AH_Point prev; /* previous point in contour */
+} AH_PointRec;
+
+
+typedef struct AH_SegmentRec_ {
+ AH_Edge_Flags flags;
+ AH_Direction dir;
+
+ AH_Point first; /* first point in edge segment */
+ AH_Point last; /* last point in edge segment */
+ AH_Point *contour; /* ptr to first point of segment's contour */
+
+ FT_Pos pos; /* position of segment */
+ FT_Pos min_coord; /* minimum coordinate of segment */
+ FT_Pos max_coord; /* maximum coordinate of segment */
+
+ AH_Edge edge;
+ AH_Segment edge_next;
+
+ AH_Segment link; /* link segment */
+ AH_Segment serif; /* primary segment for serifs */
+ FT_Pos num_linked; /* number of linked segments */
+ FT_Pos score;
+} AH_SegmentRec;
+
+
+typedef struct AH_EdgeRec_ {
+ AH_Edge_Flags flags;
+ AH_Direction dir;
+
+ AH_Segment first;
+ AH_Segment last;
+
+ FT_Pos fpos;
+ FT_Pos opos;
+ FT_Pos pos;
+
+ AH_Edge link;
+ AH_Edge serif;
+ FT_Int num_linked;
+
+ FT_Int score;
+ FT_Pos *blue_edge;
+} AH_EdgeRec;
+
+
+/* an outline as seen by the hinter */
+typedef struct AH_OutlineRec_ {
+ FT_Memory memory;
+
+ AH_Direction vert_major_dir; /* vertical major direction */
+ AH_Direction horz_major_dir; /* horizontal major direction */
+
+ FT_Fixed x_scale;
+ FT_Fixed y_scale;
+ FT_Pos edge_distance_threshold;
+
+ FT_Int max_points;
+ FT_Int num_points;
+ AH_Point points;
+
+ FT_Int max_contours;
+ FT_Int num_contours;
+ AH_Point *contours;
+
+ FT_Int num_hedges;
+ AH_Edge horz_edges;
+
+ FT_Int num_vedges;
+ AH_Edge vert_edges;
+
+ FT_Int num_hsegments;
+ AH_Segment horz_segments;
+
+ FT_Int num_vsegments;
+ AH_Segment vert_segments;
+} AH_OutlineRec, *AH_Outline;
+
+
+#define AH_BLUE_CAPITAL_TOP 0 /* THEZOCQS */
+#define AH_BLUE_CAPITAL_BOTTOM ( AH_BLUE_CAPITAL_TOP + 1 ) /* HEZLOCUS */
+#define AH_BLUE_SMALL_TOP ( AH_BLUE_CAPITAL_BOTTOM + 1 ) /* xzroesc */
+#define AH_BLUE_SMALL_BOTTOM ( AH_BLUE_SMALL_TOP + 1 ) /* xzroesc */
+#define AH_BLUE_SMALL_MINOR ( AH_BLUE_SMALL_BOTTOM + 1 ) /* pqgjy */
+#define AH_BLUE_MAX ( AH_BLUE_SMALL_MINOR + 1 )
+
+typedef FT_Int AH_Blue;
+
+
+#define AH_HINTER_MONOCHROME 1
+#define AH_HINTER_OPTIMIZE 2
+
+typedef FT_Int AH_Hinter_Flags;
+
+
+typedef struct AH_GlobalsRec_ {
+ FT_Int num_widths;
+ FT_Int num_heights;
+
+ FT_Pos stds[2];
+
+ FT_Pos widths[AH_MAX_WIDTHS];
+ FT_Pos heights[AH_MAX_HEIGHTS];
+
+ FT_Pos blue_refs[AH_BLUE_MAX];
+ FT_Pos blue_shoots[AH_BLUE_MAX];
+} AH_GlobalsRec, *AH_Globals;
+
+
+typedef struct AH_Face_GlobalsRec_ {
+ FT_Face face;
+ AH_GlobalsRec design;
+ AH_GlobalsRec scaled;
+ FT_Fixed x_scale;
+ FT_Fixed y_scale;
+ FT_Bool control_overshoot;
+} AH_Face_GlobalsRec, *AH_Face_Globals;
+
+
+typedef struct AH_HinterRec {
+ FT_Memory memory;
+ AH_Hinter_Flags flags;
+
+ FT_Int algorithm;
+ FT_Face face;
+
+ AH_Face_Globals globals;
+
+ AH_Outline glyph;
+
+ AH_Loader loader;
+ FT_Vector pp1;
+ FT_Vector pp2;
+
+ FT_Bool transformed;
+ FT_Vector trans_delta;
+ FT_Matrix trans_matrix;
+
+ FT_Bool do_horz_hints; /* disable X hinting */
+ FT_Bool do_vert_hints; /* disable Y hinting */
+ FT_Bool do_horz_snapping; /* disable X stem size snapping */
+ FT_Bool do_vert_snapping; /* disable Y stem size snapping */
+} AH_HinterRec, *AH_Hinter;
+
+
+#ifdef DEBUG_HINTER
+extern AH_Hinter ah_debug_hinter;
+extern FT_Bool ah_debug_disable_horz;
+extern FT_Bool ah_debug_disable_vert;
+#else
+#define ah_debug_disable_horz 0
+#define ah_debug_disable_vert 0
+#endif /* DEBUG_HINTER */
+
+
+// FT_END_HEADER
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
+
+#endif /* AGS_LIB_FREETYPE_AHTYPES_H */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/autohint.h b/engines/ags/lib/freetype-2.1.3/autohint/autohint.h
new file mode 100644
index 00000000000..5b6797f0d7a
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/autohint/autohint.h
@@ -0,0 +1,79 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* autohint.h */
+/* */
+/* High-level `autohint' module-specific interface (specification). */
+/* */
+/* Copyright 1996-2001, 2002 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 auto-hinter is used to load and automatically hint glyphs if a */
+/* format-specific hinter isn't available. */
+/* */
+/*************************************************************************/
+
+
+#ifndef AGS_LIB_FREETYPE_AUTOHINT_H
+#define AGS_LIB_FREETYPE_AUTOHINT_H
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/freetype.h"
+
+namespace AGS3 {
+namespace FreeType213 {
+
+// FT_BEGIN_HEADER
+
+
+typedef struct FT_AutoHinterRec_ *FT_AutoHinter;
+typedef void (*FT_AutoHinter_GlobalGetFunc)(FT_AutoHinter hinter, FT_Face face, void **global_hints, long *global_len);
+typedef void (*FT_AutoHinter_GlobalDoneFunc)(FT_AutoHinter hinter, void *global);
+typedef void (*FT_AutoHinter_GlobalResetFunc)(FT_AutoHinter hinter, FT_Face face);
+typedef FT_Error (*FT_AutoHinter_GlyphLoadFunc)(FT_AutoHinter hinter, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags);
+
+typedef struct FT_AutoHinter_ServiceRec_ {
+ FT_AutoHinter_GlobalResetFunc reset_face;
+ FT_AutoHinter_GlobalGetFunc get_global_hints;
+ FT_AutoHinter_GlobalDoneFunc done_global_hints;
+ FT_AutoHinter_GlyphLoadFunc load_glyph;
+} FT_AutoHinter_ServiceRec, *FT_AutoHinter_Service;
+
+
+// FT_END_HEADER
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
+
+#endif /* AGS_LIB_FREETYPE_AUTOHINT_H */
Commit: 63fd2b928affa09655ff35a519553f7f7593945d
https://github.com/scummvm/scummvm/commit/63fd2b928affa09655ff35a519553f7f7593945d
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Import glyph loader and some helpers from freetype2.1.3
Changed paths:
A engines/ags/lib/freetype-2.1.3/freetype.h
A engines/ags/lib/freetype-2.1.3/ftgloadr.cpp
A engines/ags/lib/freetype-2.1.3/ftgloadr.h
A engines/ags/lib/freetype-2.1.3/ftmemory.h
A engines/ags/lib/freetype-2.1.3/ftutil.cpp
diff --git a/engines/ags/lib/freetype-2.1.3/freetype.h b/engines/ags/lib/freetype-2.1.3/freetype.h
new file mode 100644
index 00000000000..ef152c94ca3
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/freetype.h
@@ -0,0 +1,511 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* freetype.h */
+/* */
+/* FreeType high-level API and common types (specification only). */
+/* */
+/* Copyright 1996-2001, 2002 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. */
+/* */
+/***************************************************************************/
+
+
+#ifndef AGS_LIB_FREETYPE_FREETYPE_H
+#define AGS_LIB_FREETYPE_FREETYPE_H
+
+
+/*************************************************************************/
+/* */
+/* The `raster' component duplicates some of the declarations in */
+/* freetype.h for stand-alone use if _FREETYPE_ isn't defined. */
+/* */
+
+
+/*************************************************************************/
+/* */
+/* The FREETYPE_MAJOR and FREETYPE_MINOR macros are used to version the */
+/* new FreeType design, which is able to host several kinds of font */
+/* drivers. It starts at 2.0. */
+/* */
+#define FREETYPE213_MAJOR 2
+#define FREETYPE213_MINOR 1
+#define FREETYPE213_PATCH 3
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/config/ftconfig.h"
+#include "engines/ags/lib/freetype-2.1.3/fterrors.h"
+#include "engines/ags/lib/freetype-2.1.3/fttypes.h"
+
+namespace AGS3 {
+namespace FreeType213 {
+
+// FT_BEGIN_HEADER
+
+typedef struct FT_Glyph_Metrics_ {
+ FT_Pos width; /* glyph width */
+ FT_Pos height; /* glyph height */
+
+ FT_Pos horiBearingX; /* left side bearing in horizontal layouts */
+ FT_Pos horiBearingY; /* top side bearing in horizontal layouts */
+ FT_Pos horiAdvance; /* advance width for horizontal layout */
+
+ FT_Pos vertBearingX; /* left side bearing in vertical layouts */
+ FT_Pos vertBearingY; /* top side bearing in vertical layouts */
+ FT_Pos vertAdvance; /* advance height for vertical layout */
+} FT_Glyph_Metrics;
+
+typedef struct FT_Bitmap_Size_ {
+ FT_Short height;
+ FT_Short width;
+} FT_Bitmap_Size;
+
+
+typedef struct FT_LibraryRec_ *FT_Library;
+typedef struct FT_ModuleRec_ *FT_Module;
+typedef struct FT_DriverRec_ *FT_Driver;
+typedef struct FT_RendererRec_ *FT_Renderer;
+typedef struct FT_FaceRec_ *FT_Face;
+typedef struct FT_SizeRec_ *FT_Size;
+typedef struct FT_GlyphSlotRec_ *FT_GlyphSlot;
+typedef struct FT_CharMapRec_ *FT_CharMap;
+
+
+#ifndef FT_ENC_TAG
+#define FT_ENC_TAG(value, a, b, c, d) \
+ value = (((FT_UInt32)(a) << 24) | \
+ ((FT_UInt32)(b) << 16) | \
+ ((FT_UInt32)(c) << 8) | \
+ (FT_UInt32)(d))
+#endif
+
+
+typedef enum FT_Encoding_ {
+ FT_ENC_TAG(FT_ENCODING_NONE, 0, 0, 0, 0),
+
+ FT_ENC_TAG(FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b'),
+ FT_ENC_TAG(FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c'),
+
+ FT_ENC_TAG(FT_ENCODING_MS_SJIS, 's', 'j', 'i', 's'),
+ FT_ENC_TAG(FT_ENCODING_MS_GB2312, 'g', 'b', ' ', ' '),
+ FT_ENC_TAG(FT_ENCODING_MS_BIG5, 'b', 'i', 'g', '5'),
+ FT_ENC_TAG(FT_ENCODING_MS_WANSUNG, 'w', 'a', 'n', 's'),
+ FT_ENC_TAG(FT_ENCODING_MS_JOHAB, 'j', 'o', 'h', 'a'),
+
+ FT_ENC_TAG(FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B'),
+ FT_ENC_TAG(FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E'),
+ FT_ENC_TAG(FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C'),
+ FT_ENC_TAG(FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1'),
+
+ FT_ENC_TAG(FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2'),
+
+ FT_ENC_TAG(FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n')
+} FT_Encoding;
+
+/* These constants are deprecated; use the corresponding @FT_Encoding */
+/* values instead. */
+#define ft_encoding_none FT_ENCODING_NONE
+#define ft_encoding_unicode FT_ENCODING_UNICODE
+#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
+#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
+#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
+#define ft_encoding_sjis FT_ENCODING_MS_SJIS
+#define ft_encoding_gb2312 FT_ENCODING_MS_GB2312
+#define ft_encoding_big5 FT_ENCODING_MS_BIG5
+#define ft_encoding_wansung FT_ENCODING_MS_WANSUNG
+#define ft_encoding_johab FT_ENCODING_MS_JOHAB
+
+#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
+#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
+#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
+#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
+
+
+typedef struct FT_CharMapRec_ {
+ FT_Face face;
+ FT_Encoding encoding;
+ FT_UShort platform_id;
+ FT_UShort encoding_id;
+} FT_CharMapRec;
+
+typedef struct FT_Face_InternalRec_ *FT_Face_Internal;
+
+typedef struct FT_FaceRec_ {
+ FT_Long num_faces;
+ FT_Long face_index;
+
+ FT_Long face_flags;
+ FT_Long style_flags;
+
+ FT_Long num_glyphs;
+
+ FT_String *family_name;
+ FT_String *style_name;
+
+ FT_Int num_fixed_sizes;
+ FT_Bitmap_Size *available_sizes;
+
+ FT_Int num_charmaps;
+ FT_CharMap *charmaps;
+
+ FT_Generic generic;
+
+ /*# the following are only relevant to scalable outlines */
+ FT_BBox bbox;
+
+ FT_UShort units_per_EM;
+ FT_Short ascender;
+ FT_Short descender;
+ FT_Short height;
+
+ FT_Short max_advance_width;
+ FT_Short max_advance_height;
+
+ FT_Short underline_position;
+ FT_Short underline_thickness;
+
+ FT_GlyphSlot glyph;
+ FT_Size size;
+ FT_CharMap charmap;
+
+ /*@private begin */
+
+ FT_Driver driver;
+ FT_Memory memory;
+ FT_Stream stream;
+
+ FT_ListRec sizes_list;
+
+ FT_Generic autohint;
+ void *extensions;
+
+ FT_Face_Internal internal;
+
+ /*@private end */
+
+} FT_FaceRec;
+
+
+#define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
+#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
+#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
+#define FT_FACE_FLAG_SFNT ( 1L << 3 )
+#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
+#define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
+#define FT_FACE_FLAG_KERNING ( 1L << 6 )
+#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
+#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
+#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
+#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
+
+#define FT_HAS_HORIZONTAL(face) \
+ (face->face_flags & FT_FACE_FLAG_HORIZONTAL)
+
+#define FT_HAS_VERTICAL(face) \
+ (face->face_flags & FT_FACE_FLAG_VERTICAL)
+
+#define FT_HAS_KERNING(face) \
+ (face->face_flags & FT_FACE_FLAG_KERNING)
+
+#define FT_IS_SCALABLE(face) \
+ (face->face_flags & FT_FACE_FLAG_SCALABLE)
+
+#define FT_IS_SFNT(face) \
+ (face->face_flags & FT_FACE_FLAG_SFNT)
+
+#define FT_IS_FIXED_WIDTH(face) \
+ (face->face_flags & FT_FACE_FLAG_FIXED_WIDTH)
+
+#define FT_HAS_FIXED_SIZES(face) \
+ (face->face_flags & FT_FACE_FLAG_FIXED_SIZES)
+
+#define FT_HAS_FAST_GLYPHS(face) \
+ (face->face_flags & FT_FACE_FLAG_FAST_GLYPHS)
+
+#define FT_HAS_GLYPH_NAMES(face) \
+ (face->face_flags & FT_FACE_FLAG_GLYPH_NAMES)
+
+#define FT_HAS_MULTIPLE_MASTERS(face) \
+ (face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS)
+
+#define FT_STYLE_FLAG_ITALIC (1 << 0)
+#define FT_STYLE_FLAG_BOLD (1 << 1)
+
+
+typedef struct FT_Size_InternalRec_ *FT_Size_Internal;
+
+typedef struct FT_Size_Metrics_ {
+ FT_UShort x_ppem; /* horizontal pixels per EM */
+ FT_UShort y_ppem; /* vertical pixels per EM */
+
+ FT_Fixed x_scale; /* two scales used to convert font units */
+ FT_Fixed y_scale; /* to 26.6 frac. pixel coordinates.. */
+
+ FT_Pos ascender; /* ascender in 26.6 frac. pixels */
+ FT_Pos descender; /* descender in 26.6 frac. pixels */
+ FT_Pos height; /* text height in 26.6 frac. pixels */
+ FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
+} FT_Size_Metrics;
+
+typedef struct FT_SizeRec_ {
+ FT_Face face; /* parent face object */
+ FT_Generic generic; /* generic pointer for client uses */
+ FT_Size_Metrics metrics; /* size metrics */
+ FT_Size_Internal internal;
+} FT_SizeRec;
+
+typedef struct FT_SubGlyphRec_ *FT_SubGlyph;
+typedef struct FT_Slot_InternalRec_ *FT_Slot_Internal;
+
+typedef struct FT_GlyphSlotRec_ {
+ FT_Library library;
+ FT_Face face;
+ FT_GlyphSlot next;
+ FT_UInt flags;
+ FT_Generic generic;
+
+ FT_Glyph_Metrics metrics;
+ FT_Fixed linearHoriAdvance;
+ FT_Fixed linearVertAdvance;
+ FT_Vector advance;
+
+ FT_Glyph_Format format;
+
+ FT_Bitmap bitmap;
+ FT_Int bitmap_left;
+ FT_Int bitmap_top;
+
+ FT_Outline outline;
+
+ FT_UInt num_subglyphs;
+ FT_SubGlyph subglyphs;
+
+ void *control_data;
+ long control_len;
+
+ void *other;
+
+ FT_Slot_Internal internal;
+
+} FT_GlyphSlotRec;
+
+
+/*************************************************************************/
+/* F U N C T I O N S */
+/*************************************************************************/
+
+FT_EXPORT(FT_Error)
+FT_Init_FreeType(FT_Library *alibrary);
+
+FT_EXPORT(void)
+FT_Library_Version(FT_Library library, FT_Int *amajor, FT_Int *aminor, FT_Int *apatch);
+
+FT_EXPORT(FT_Error)
+FT_Done_FreeType(FT_Library library);
+
+
+typedef enum {
+ FT_OPEN_MEMORY = 1,
+ FT_OPEN_STREAM = 2,
+ FT_OPEN_PATHNAME = 4,
+ FT_OPEN_DRIVER = 8,
+ FT_OPEN_PARAMS = 16
+} FT_Open_Flags;
+
+#define FT_OPEN_MEMORY FT_OPEN_MEMORY
+#define FT_OPEN_STREAM FT_OPEN_STREAM
+#define FT_OPEN_PATHNAME FT_OPEN_PATHNAME
+#define FT_OPEN_DRIVER FT_OPEN_DRIVER
+#define FT_OPEN_PARAMS FT_OPEN_PARAMS
+
+typedef struct FT_Parameter_ {
+ FT_ULong tag;
+ FT_Pointer data;
+} FT_Parameter;
+
+typedef struct FT_Open_Args_ {
+ FT_Open_Flags flags;
+ const FT_Byte *memory_base;
+ FT_Long memory_size;
+ FT_String *pathname;
+ FT_Stream stream;
+ FT_Module driver;
+ FT_Int num_params;
+ FT_Parameter *params;
+} FT_Open_Args;
+
+FT_EXPORT(FT_Error)
+FT_New_Face(FT_Library library, const char *filepathname, FT_Long face_index, FT_Face *aface);
+
+FT_EXPORT(FT_Error)
+FT_New_Memory_Face(FT_Library library, const FT_Byte *file_base, FT_Long file_size, FT_Long face_index, FT_Face *aface);
+
+FT_EXPORT(FT_Error)
+FT_Open_Face(FT_Library library, const FT_Open_Args *args, FT_Long face_index, FT_Face *aface);
+
+FT_EXPORT(FT_Error)
+FT_Attach_File(FT_Face face, const char *filepathname);
+
+FT_EXPORT(FT_Error)
+FT_Attach_Stream(FT_Face face, FT_Open_Args *parameters);
+
+FT_EXPORT(FT_Error)
+FT_Done_Face(FT_Face face);
+
+FT_EXPORT(FT_Error)
+FT_Set_Char_Size(FT_Face face, FT_F26Dot6 char_width, FT_F26Dot6 char_height, FT_UInt horz_resolution, FT_UInt vert_resolution);
+
+FT_EXPORT(FT_Error)
+FT_Set_Pixel_Sizes(FT_Face face, FT_UInt pixel_width, FT_UInt pixel_height);
+
+FT_EXPORT(FT_Error)
+FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags);
+
+FT_EXPORT(FT_Error)
+FT_Load_Char(FT_Face face, FT_ULong char_code, FT_Int32 load_flags);
+
+
+#define FT_LOAD_NO_SCALE 0x1
+#define FT_LOAD_NO_HINTING 0x2
+#define FT_LOAD_RENDER 0x4
+#define FT_LOAD_NO_BITMAP 0x8
+#define FT_LOAD_VERTICAL_LAYOUT 0x10
+#define FT_LOAD_FORCE_AUTOHINT 0x20
+#define FT_LOAD_CROP_BITMAP 0x40
+#define FT_LOAD_PEDANTIC 0x80
+#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 0x200
+#define FT_LOAD_NO_RECURSE 0x400
+#define FT_LOAD_IGNORE_TRANSFORM 0x800
+#define FT_LOAD_MONOCHROME 0x1000
+#define FT_LOAD_LINEAR_DESIGN 0x2000
+
+/* temporary hack! */
+#define FT_LOAD_SBITS_ONLY 0x4000
+#define FT_LOAD_NO_AUTOHINT 0x8000U
+
+#define FT_LOAD_TARGET_(x) ((FT_Int32)((x) & 15) << 16)
+#define FT_LOAD_TARGET_MODE(x) ((FT_Render_Mode)(((x) >> 16) & 15))
+
+#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_(FT_RENDER_MODE_NORMAL)
+#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_(FT_RENDER_MODE_LIGHT)
+#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_(FT_RENDER_MODE_MONO)
+#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_(FT_RENDER_MODE_LCD)
+#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_(FT_RENDER_MODE_LCD_V)
+
+#define FT_LOAD_DEFAULT 0x0
+
+FT_EXPORT(void)
+FT_Set_Transform(FT_Face face, FT_Matrix *matrix, FT_Vector *delta);
+
+typedef enum FT_Render_Mode_ {
+ FT_RENDER_MODE_NORMAL = 0,
+ FT_RENDER_MODE_LIGHT,
+ FT_RENDER_MODE_MONO,
+ FT_RENDER_MODE_LCD,
+ FT_RENDER_MODE_LCD_V,
+ FT_RENDER_MODE_MAX
+} FT_Render_Mode;
+
+/* These constats are deprecated. */
+#define ft_render_mode_normal FT_RENDER_MODE_NORMAL
+#define ft_render_mode_mono FT_RENDER_MODE_MONO
+
+FT_EXPORT(FT_Error)
+FT_Render_Glyph(FT_GlyphSlot slot, FT_Render_Mode render_mode);
+
+typedef enum FT_Kerning_Mode_ {
+ FT_KERNING_DEFAULT = 0,
+ FT_KERNING_UNFITTED,
+ FT_KERNING_UNSCALED
+} FT_Kerning_Mode;
+
+/* These constats are deprecated. */
+#define ft_kerning_default FT_KERNING_DEFAULT
+#define ft_kerning_unfitted FT_KERNING_UNFITTED
+#define ft_kerning_unscaled FT_KERNING_UNSCALED
+
+FT_EXPORT(FT_Error)
+FT_Get_Kerning(FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph, FT_UInt kern_mode, FT_Vector *akerning);
+
+FT_EXPORT(FT_Error)
+FT_Get_Glyph_Name(FT_Face face, FT_UInt glyph_index, FT_Pointer buffer, FT_UInt buffer_max);
+
+FT_EXPORT(const char *)
+FT_Get_Postscript_Name(FT_Face face);
+
+FT_EXPORT(FT_Error)
+FT_Select_Charmap(FT_Face face, FT_Encoding encoding);
+
+FT_EXPORT(FT_Error)
+FT_Set_Charmap(FT_Face face, FT_CharMap charmap);
+
+FT_EXPORT(FT_UInt)
+FT_Get_Char_Index(FT_Face face, FT_ULong charcode);
+
+FT_EXPORT(FT_ULong)
+FT_Get_First_Char(FT_Face face, FT_UInt *agindex);
+
+FT_EXPORT(FT_ULong)
+FT_Get_Next_Char(FT_Face face, FT_ULong char_code, FT_UInt *agindex);
+
+FT_EXPORT(FT_UInt)
+FT_Get_Name_Index(FT_Face face, FT_String *glyph_name);
+
+
+/* COMPUTATIONS */
+
+FT_EXPORT(FT_Long)
+FT_MulDiv(FT_Long a, FT_Long b, FT_Long c);
+
+FT_EXPORT(FT_Long)
+FT_MulFix(FT_Long a, FT_Long b);
+
+FT_EXPORT(FT_Long)
+FT_DivFix(FT_Long a, FT_Long b);
+
+FT_EXPORT(FT_Fixed)
+FT_RoundFix(FT_Fixed a);
+
+FT_EXPORT(FT_Fixed)
+FT_CeilFix(FT_Fixed a);
+
+FT_EXPORT(FT_Fixed)
+FT_FloorFix(FT_Fixed a);
+
+FT_EXPORT(void)
+FT_Vector_Transform(FT_Vector *vec, FT_Matrix *matrix);
+
+
+// FT_END_HEADER
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
+
+#endif /* AGS_LIB_FREETYPE_FREETYPE_H */
diff --git a/engines/ags/lib/freetype-2.1.3/ftgloadr.cpp b/engines/ags/lib/freetype-2.1.3/ftgloadr.cpp
new file mode 100644
index 00000000000..d463a6059be
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/ftgloadr.cpp
@@ -0,0 +1,297 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ftgloadr.c */
+/* */
+/* The FreeType glyph loader (body). */
+/* */
+/* Copyright 2002 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. */
+/* */
+/***************************************************************************/
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/ftgloadr.h"
+#include "engines/ags/lib/freetype-2.1.3/ftmemory.h"
+
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_gloader
+
+namespace AGS3 {
+namespace FreeType213 {
+
+
+/* create a new glyph loader */
+FT_BASE_DEF(FT_Error)
+FT_GlyphLoader_New(FT_Memory memory, FT_GlyphLoader *aloader) {
+ FT_GlyphLoader loader;
+ FT_Error error;
+
+ if (!FT_NEW(loader)) {
+ loader->memory = memory;
+ *aloader = loader;
+ }
+ return error;
+}
+
+
+/* rewind the glyph loader - reset counters to 0 */
+FT_BASE_DEF(void)
+FT_GlyphLoader_Rewind(FT_GlyphLoader loader) {
+ FT_GlyphLoad base = &loader->base;
+ FT_GlyphLoad current = &loader->current;
+
+ base->outline.n_points = 0;
+ base->outline.n_contours = 0;
+ base->num_subglyphs = 0;
+
+ *current = *base;
+}
+
+
+/* reset the glyph loader, frees all allocated tables */
+/* and starts from zero */
+FT_BASE_DEF(void)
+FT_GlyphLoader_Reset(FT_GlyphLoader loader) {
+ FT_Memory memory = loader->memory;
+
+ FT_FREE(loader->base.outline.points);
+ FT_FREE(loader->base.outline.tags);
+ FT_FREE(loader->base.outline.contours);
+ FT_FREE(loader->base.extra_points);
+ FT_FREE(loader->base.subglyphs);
+
+ loader->max_points = 0;
+ loader->max_contours = 0;
+ loader->max_subglyphs = 0;
+
+ FT_GlyphLoader_Rewind(loader);
+}
+
+
+/* delete a glyph loader */
+FT_BASE_DEF(void)
+FT_GlyphLoader_Done(FT_GlyphLoader loader) {
+ if (loader) {
+ FT_Memory memory = loader->memory;
+
+ FT_GlyphLoader_Reset(loader);
+ FT_FREE(loader);
+ }
+}
+
+
+/* re-adjust the `current' outline fields */
+static void FT_GlyphLoader_Adjust_Points(FT_GlyphLoader loader) {
+ FT_Outline *base = &loader->base.outline;
+ FT_Outline *current = &loader->current.outline;
+
+ current->points = base->points + base->n_points;
+ current->tags = base->tags + base->n_points;
+ current->contours = base->contours + base->n_contours;
+
+ /* handle extra points table - if any */
+ if (loader->use_extra)
+ loader->current.extra_points = loader->base.extra_points + base->n_points;
+}
+
+
+FT_BASE_DEF(FT_Error)
+FT_GlyphLoader_CreateExtra(FT_GlyphLoader loader) {
+ FT_Error error;
+ FT_Memory memory = loader->memory;
+
+ if (!FT_NEW_ARRAY(loader->base.extra_points, loader->max_points)) {
+ loader->use_extra = 1;
+ FT_GlyphLoader_Adjust_Points(loader);
+ }
+ return error;
+}
+
+
+/* re-adjust the `current' subglyphs field */
+static void FT_GlyphLoader_Adjust_Subglyphs(FT_GlyphLoader loader) {
+ FT_GlyphLoad base = &loader->base;
+ FT_GlyphLoad current = &loader->current;
+
+ current->subglyphs = base->subglyphs + base->num_subglyphs;
+}
+
+
+/* Ensure that we can add `n_points' and `n_contours' to our glyph. this */
+/* function reallocates its outline tables if necessary. Note that it */
+/* DOESN'T change the number of points within the loader! */
+/* */
+FT_BASE_DEF(FT_Error)
+FT_GlyphLoader_CheckPoints(FT_GlyphLoader loader, FT_UInt n_points, FT_UInt n_contours) {
+ FT_Memory memory = loader->memory;
+ FT_Error error = FT_Err_Ok;
+ FT_Outline *base = &loader->base.outline;
+ FT_Outline *current = &loader->current.outline;
+ FT_Bool adjust = 1;
+
+ FT_UInt new_max, old_max;
+
+ /* check points & tags */
+ new_max = base->n_points + current->n_points + n_points;
+ old_max = loader->max_points;
+
+ if (new_max > old_max) {
+ new_max = (new_max + 7) & -8;
+
+ if (FT_RENEW_ARRAY(base->points, old_max, new_max) || FT_RENEW_ARRAY(base->tags, old_max, new_max))
+ goto Exit;
+
+ if (loader->use_extra && FT_RENEW_ARRAY(loader->base.extra_points, old_max, new_max))
+ goto Exit;
+
+ adjust = 1;
+ loader->max_points = new_max;
+ }
+
+ /* check contours */
+ old_max = loader->max_contours;
+ new_max = base->n_contours + current->n_contours + n_contours;
+ if (new_max > old_max) {
+ new_max = (new_max + 3) & -4;
+ if (FT_RENEW_ARRAY(base->contours, old_max, new_max))
+ goto Exit;
+
+ adjust = 1;
+ loader->max_contours = new_max;
+ }
+
+ if (adjust)
+ FT_GlyphLoader_Adjust_Points(loader);
+
+Exit:
+ return error;
+}
+
+
+/* Ensure that we can add `n_subglyphs' to our glyph. this function */
+/* reallocates its subglyphs table if necessary. Note that it DOES */
+/* NOT change the number of subglyphs within the loader! */
+/* */
+FT_BASE_DEF(FT_Error)
+FT_GlyphLoader_CheckSubGlyphs(FT_GlyphLoader loader, FT_UInt n_subs) {
+ FT_Memory memory = loader->memory;
+ FT_Error error = FT_Err_Ok;
+ FT_UInt new_max, old_max;
+
+ FT_GlyphLoad base = &loader->base;
+ FT_GlyphLoad current = &loader->current;
+
+ new_max = base->num_subglyphs + current->num_subglyphs + n_subs;
+ old_max = loader->max_subglyphs;
+ if (new_max > old_max) {
+ new_max = (new_max + 1) & -2;
+ if (FT_RENEW_ARRAY(base->subglyphs, old_max, new_max))
+ goto Exit;
+
+ loader->max_subglyphs = new_max;
+
+ FT_GlyphLoader_Adjust_Subglyphs(loader);
+ }
+
+Exit:
+ return error;
+}
+
+
+/* prepare loader for the addition of a new glyph on top of the base one */
+FT_BASE_DEF(void)
+FT_GlyphLoader_Prepare(FT_GlyphLoader loader) {
+ FT_GlyphLoad current = &loader->current;
+
+ current->outline.n_points = 0;
+ current->outline.n_contours = 0;
+ current->num_subglyphs = 0;
+
+ FT_GlyphLoader_Adjust_Points(loader);
+ FT_GlyphLoader_Adjust_Subglyphs(loader);
+}
+
+
+/* add current glyph to the base image - and prepare for another */
+FT_BASE_DEF(void)
+FT_GlyphLoader_Add(FT_GlyphLoader loader) {
+ FT_GlyphLoad base = &loader->base;
+ FT_GlyphLoad current = &loader->current;
+
+ FT_UInt n_curr_contours = current->outline.n_contours;
+ FT_UInt n_base_points = base->outline.n_points;
+ FT_UInt n;
+
+ base->outline.n_points = (short)(base->outline.n_points + current->outline.n_points);
+ base->outline.n_contours = (short)(base->outline.n_contours + current->outline.n_contours);
+
+ base->num_subglyphs += current->num_subglyphs;
+
+ /* adjust contours count in newest outline */
+ for (n = 0; n < n_curr_contours; n++)
+ current->outline.contours[n] =
+ (short)(current->outline.contours[n] + n_base_points);
+
+ /* prepare for another new glyph image */
+ FT_GlyphLoader_Prepare(loader);
+}
+
+
+FT_BASE_DEF(FT_Error)
+FT_GlyphLoader_CopyPoints(FT_GlyphLoader target, FT_GlyphLoader source) {
+ FT_Error error;
+ FT_UInt num_points = source->base.outline.n_points;
+ FT_UInt num_contours = source->base.outline.n_contours;
+
+ error = FT_GlyphLoader_CheckPoints(target, num_points, num_contours);
+ if (!error) {
+ FT_Outline *out = &target->base.outline;
+ FT_Outline *in = &source->base.outline;
+
+ FT_MEM_COPY(out->points, in->points, num_points * sizeof(FT_Vector));
+ FT_MEM_COPY(out->tags, in->tags, num_points * sizeof(char));
+ FT_MEM_COPY(out->contours, in->contours, num_contours * sizeof(short));
+
+ /* do we need to copy the extra points? */
+ if (target->use_extra && source->use_extra)
+ FT_MEM_COPY(target->base.extra_points, source->base.extra_points, num_points * sizeof(FT_Vector));
+
+ out->n_points = (short)num_points;
+ out->n_contours = (short)num_contours;
+
+ FT_GlyphLoader_Adjust_Points(target);
+ }
+
+ return error;
+}
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
diff --git a/engines/ags/lib/freetype-2.1.3/ftgloadr.h b/engines/ags/lib/freetype-2.1.3/ftgloadr.h
new file mode 100644
index 00000000000..5f767bccb20
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/ftgloadr.h
@@ -0,0 +1,151 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ftgloadr.h */
+/* */
+/* The FreeType glyph loader (specification). */
+/* */
+/* Copyright 2002 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. */
+/* */
+/***************************************************************************/
+
+
+#ifndef AGS_LIB_FREETYPE_FTGLOADR_H
+#define AGS_LIB_FREETYPE_FTGLOADR_H
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/freetype.h"
+
+namespace AGS3 {
+namespace FreeType213 {
+
+// FT_BEGIN_HEADER
+
+
+typedef struct FT_GlyphLoaderRec_ *FT_GlyphLoader;
+
+#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1
+#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2
+#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4
+#define FT_SUBGLYPH_FLAG_SCALE 8
+#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40
+#define FT_SUBGLYPH_FLAG_2X2 0x80
+#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200
+
+
+enum {
+ FT_GLYPH_OWN_BITMAP = 1
+};
+
+
+typedef struct FT_SubGlyphRec_ {
+ FT_Int index;
+ FT_UShort flags;
+ FT_Int arg1;
+ FT_Int arg2;
+ FT_Matrix transform;
+
+} FT_SubGlyphRec;
+
+
+typedef struct FT_GlyphLoadRec_ {
+ FT_Outline outline; /* outline */
+ FT_Vector *extra_points; /* extra points table */
+ FT_UInt num_subglyphs; /* number of subglyphs */
+ FT_SubGlyph subglyphs; /* subglyphs */
+
+} FT_GlyphLoadRec, *FT_GlyphLoad;
+
+
+typedef struct FT_GlyphLoaderRec_ {
+ FT_Memory memory;
+ FT_UInt max_points;
+ FT_UInt max_contours;
+ FT_UInt max_subglyphs;
+ FT_Bool use_extra;
+
+ FT_GlyphLoadRec base;
+ FT_GlyphLoadRec current;
+
+ void* other; /* for possible future extension? */
+
+} FT_GlyphLoaderRec;
+
+
+/* create new empty glyph loader */
+FT_BASE(FT_Error)
+FT_GlyphLoader_New(FT_Memory memory, FT_GlyphLoader *aloader);
+
+/* add an extra points table to a glyph loader */
+FT_BASE(FT_Error)
+FT_GlyphLoader_CreateExtra(FT_GlyphLoader loader);
+
+/* destroy a glyph loader */
+FT_BASE(void)
+FT_GlyphLoader_Done(FT_GlyphLoader loader);
+
+/* reset a glyph loader (frees everything int it) */
+FT_BASE(void)
+FT_GlyphLoader_Reset(FT_GlyphLoader loader);
+
+/* rewind a glyph loader */
+FT_BASE(void)
+FT_GlyphLoader_Rewind(FT_GlyphLoader loader);
+
+/* check that there is enough room to add 'n_points' and 'n_contours' */
+/* to the glyph loader */
+FT_BASE(FT_Error)
+FT_GlyphLoader_CheckPoints(FT_GlyphLoader loader, FT_UInt n_points, FT_UInt n_contours);
+
+/* check that there is enough room to add 'n_subs' sub-glyphs to */
+/* a glyph loader */
+FT_BASE(FT_Error)
+FT_GlyphLoader_CheckSubGlyphs(FT_GlyphLoader loader, FT_UInt n_subs);
+
+/* prepare a glyph loader, i.e. empty the current glyph */
+FT_BASE(void)
+FT_GlyphLoader_Prepare(FT_GlyphLoader loader);
+
+/* add the current glyph to the base glyph */
+FT_BASE(void)
+FT_GlyphLoader_Add(FT_GlyphLoader loader);
+
+/* copy points from one glyph loader to another */
+FT_BASE(FT_Error)
+FT_GlyphLoader_CopyPoints(FT_GlyphLoader target, FT_GlyphLoader source);
+
+
+// FT_END_HEADER
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
+
+#endif /* AGS_LIB_FREETYPE_FTGLOADR_H */
diff --git a/engines/ags/lib/freetype-2.1.3/ftmemory.h b/engines/ags/lib/freetype-2.1.3/ftmemory.h
new file mode 100644
index 00000000000..11637309072
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/ftmemory.h
@@ -0,0 +1,119 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ftmemory.h */
+/* */
+/* The FreeType memory management macros (specification). */
+/* */
+/* Copyright 1996-2001, 2002 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. */
+/* */
+/***************************************************************************/
+
+
+#ifndef AGS_LIB_FREETYPE_FTMEMORY_H
+#define AGS_LIB_FREETYPE_FTMEMORY_H
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/config/ftconfig.h"
+#include "engines/ags/lib/freetype-2.1.3/fttypes.h"
+
+namespace AGS3 {
+namespace FreeType213 {
+
+// FT_BEGIN_HEADER
+
+
+#undef FT_SET_ERROR
+#define FT_SET_ERROR(expression) ((error = (expression)) != 0)
+
+
+FT_BASE(FT_Error)
+FT_Alloc(FT_Memory memory, FT_Long size, void **P);
+
+FT_BASE(FT_Error)
+FT_Realloc(FT_Memory memory, FT_Long current, FT_Long size, void **P);
+
+FT_BASE(void)
+FT_Free(FT_Memory memory, void **P);
+
+
+#define FT_MEM_SET(dest, byte, count) ft_memset(dest, byte, count)
+#define FT_MEM_COPY(dest, source, count) ft_memcpy(dest, source, count)
+#define FT_MEM_MOVE(dest, source, count) ft_memmove(dest, source, count)
+#define FT_MEM_ZERO(dest, count) FT_MEM_SET(dest, 0, count)
+#define FT_ZERO(p) FT_MEM_ZERO(p, sizeof(*(p)))
+
+#define FT_MEM_ALLOC(_pointer_, _size_) FT_Alloc(memory, _size_, (void **)&(_pointer_))
+#define FT_MEM_FREE(_pointer_) FT_Free(memory, (void **)&(_pointer_))
+#define FT_MEM_REALLOC(_pointer_, _current_, _size_) FT_Realloc(memory, _current_, _size_, (void **)&(_pointer_))
+
+
+/*************************************************************************/
+/* */
+/* The following functions macros expect that their pointer argument is */
+/* _typed_ in order to automatically compute array element sizes. */
+/* */
+
+#define FT_MEM_NEW(_pointer_) FT_MEM_ALLOC(_pointer_, sizeof(*(_pointer_)))
+#define FT_MEM_NEW_ARRAY(_pointer_, _count_) FT_MEM_ALLOC(_pointer_, (_count_) * sizeof(*(_pointer_)))
+#define FT_MEM_RENEW_ARRAY(_pointer_, _old_, _new_) FT_MEM_REALLOC(_pointer_, (_old_) * sizeof(*(_pointer_)), (_new_) * sizeof(*(_pointer_)))
+
+/*************************************************************************/
+/* */
+/* the following macros are obsolete but kept for compatibility reasons */
+/* */
+
+#define FT_MEM_ALLOC_ARRAY(_pointer_, _count_, _type_) FT_MEM_ALLOC(_pointer_, (_count_) * sizeof(_type_))
+#define FT_MEM_REALLOC_ARRAY(_pointer_, _old_, _new_, _type_) FT_MEM_REALLOC(_pointer_, (_old_) * sizeof(_type), (_new_) * sizeof(_type_))
+
+/*************************************************************************/
+/* */
+/* The following macros are variants of their FT_MEM_XXXX equivalents; */
+/* they are used to set an _implicit_ `error' variable and return TRUE */
+/* if an error occured (i.e. if 'error != 0'). */
+/* */
+
+#define FT_ALLOC(_pointer_, _size_) FT_SET_ERROR(FT_MEM_ALLOC(_pointer_, _size_))
+#define FT_REALLOC(_pointer_, _current_, _size_) FT_SET_ERROR(FT_MEM_REALLOC(_pointer_, _current_, _size_))
+#define FT_FREE(_pointer_) FT_MEM_FREE(_pointer_)
+#define FT_NEW(_pointer_) FT_SET_ERROR(FT_MEM_NEW(_pointer_))
+#define FT_NEW_ARRAY(_pointer_, _count_) FT_SET_ERROR(FT_MEM_NEW_ARRAY(_pointer_, _count_))
+#define FT_RENEW_ARRAY(_pointer_, _old_, _new_) FT_SET_ERROR(FT_MEM_RENEW_ARRAY(_pointer_, _old_, _new_))
+#define FT_ALLOC_ARRAY(_pointer_, _count_, _type_) FT_SET_ERROR(FT_MEM_ALLOC(_pointer_, (_count_) * sizeof(_type_)))
+#define FT_REALLOC_ARRAY(_pointer_, _old_, _new_, _type_) FT_SET_ERROR(FT_MEM_REALLOC(_pointer_, (_old_) * sizeof(_type_), (_new_) * sizeof(_type_)))
+
+
+// FT_END_HEADER
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
+
+#endif /* __FTMEMORY_H__ */
diff --git a/engines/ags/lib/freetype-2.1.3/ftutil.cpp b/engines/ags/lib/freetype-2.1.3/ftutil.cpp
new file mode 100644
index 00000000000..fde499ef4b8
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/ftutil.cpp
@@ -0,0 +1,251 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* ftutil.c */
+/* */
+/* FreeType utility file for memory and list management (body). */
+/* */
+/* Copyright 2002 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. */
+/* */
+/***************************************************************************/
+
+
+#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
+#include "engines/ags/lib/freetype-2.1.3/ftdebug.h"
+#include "engines/ags/lib/freetype-2.1.3/ftmemory.h"
+#include "engines/ags/lib/freetype-2.1.3/ftlist.h"
+
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_memory
+
+namespace AGS3 {
+namespace FreeType213 {
+
+
+/**** MEMORY MANAGEMENT ****/
+
+FT_BASE_DEF(FT_Error)
+FT_Alloc(FT_Memory memory, FT_Long size, void **P) {
+ FT_ASSERT(P != 0);
+
+ if (size > 0) {
+ *P = memory->alloc(memory, size);
+ if (!*P) {
+ FT_ERROR(("FT_Alloc:"));
+ FT_ERROR((" Out of memory? (%ld requested)\n", size));
+
+ return FT_Err_Out_Of_Memory;
+ }
+ FT_MEM_ZERO(*P, size);
+ } else
+ *P = NULL;
+
+ FT_TRACE7(("FT_Alloc:"));
+ FT_TRACE7((" size = %ld, block = 0x%08p, ref = 0x%08p\n", size, *P, P));
+
+ return FT_Err_Ok;
+}
+
+FT_BASE_DEF(FT_Error)
+FT_Realloc(FT_Memory memory, FT_Long current, FT_Long size, void **P) {
+ void *Q;
+
+ FT_ASSERT(P != 0);
+
+ /* if the original pointer is NULL, call FT_Alloc() */
+ if (!*P)
+ return FT_Alloc(memory, size, P);
+
+ /* if the new block if zero-sized, clear the current one */
+ if (size <= 0) {
+ FT_Free(memory, P);
+ return FT_Err_Ok;
+ }
+
+ Q = memory->realloc(memory, current, size, *P);
+ if (!Q)
+ goto Fail;
+
+ if (size > current)
+ FT_MEM_ZERO((char *)Q + current, size - current);
+
+ *P = Q;
+ return FT_Err_Ok;
+
+Fail:
+ FT_ERROR(("FT_Realloc:"));
+ FT_ERROR((" Failed (current %ld, requested %ld)\n", current, size));
+ return FT_Err_Out_Of_Memory;
+}
+
+FT_BASE_DEF(void)
+FT_Free(FT_Memory memory, void **P) {
+ FT_TRACE7(("FT_Free:"));
+ FT_TRACE7((" Freeing block 0x%08p, ref 0x%08p\n", P, P ? *P : (void *)0));
+
+ if (P && *P) {
+ memory->free(memory, *P);
+ *P = 0;
+ }
+}
+
+
+/**** DOUBLE LINKED LISTS ****/
+
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_list
+
+FT_EXPORT_DEF(FT_ListNode)
+FT_List_Find(FT_List list, void *data) {
+ FT_ListNode cur;
+
+ cur = list->head;
+ while (cur) {
+ if (cur->data == data)
+ return cur;
+
+ cur = cur->next;
+ }
+
+ return (FT_ListNode)0;
+}
+
+FT_EXPORT_DEF(void)
+FT_List_Add(FT_List list, FT_ListNode node) {
+ FT_ListNode before = list->tail;
+
+ node->next = 0;
+ node->prev = before;
+
+ if (before)
+ before->next = node;
+ else
+ list->head = node;
+
+ list->tail = node;
+}
+
+FT_EXPORT_DEF(void)
+FT_List_Insert(FT_List list, FT_ListNode node) {
+ FT_ListNode after = list->head;
+
+ node->next = after;
+ node->prev = 0;
+
+ if (!after)
+ list->tail = node;
+ else
+ after->prev = node;
+
+ list->head = node;
+}
+
+FT_EXPORT_DEF(void)
+FT_List_Remove(FT_List list, FT_ListNode node) {
+ FT_ListNode before, after;
+
+ before = node->prev;
+ after = node->next;
+
+ if (before)
+ before->next = after;
+ else
+ list->head = after;
+
+ if (after)
+ after->prev = before;
+ else
+ list->tail = before;
+}
+
+FT_EXPORT_DEF(void)
+FT_List_Up(FT_List list, FT_ListNode node) {
+ FT_ListNode before, after;
+
+ before = node->prev;
+ after = node->next;
+
+ /* check whether we are already on top of the list */
+ if (!before)
+ return;
+
+ before->next = after;
+
+ if (after)
+ after->prev = before;
+ else
+ list->tail = before;
+
+ node->prev = 0;
+ node->next = list->head;
+ list->head->prev = node;
+ list->head = node;
+}
+
+FT_EXPORT_DEF(FT_Error)
+FT_List_Iterate(FT_List list, FT_List_Iterator iterator, void *user) {
+ FT_ListNode cur = list->head;
+ FT_Error error = FT_Err_Ok;
+
+ while (cur) {
+ FT_ListNode next = cur->next;
+
+ error = iterator(cur, user);
+ if (error)
+ break;
+
+ cur = next;
+ }
+
+ return error;
+}
+
+FT_EXPORT_DEF(void)
+FT_List_Finalize(FT_List list, FT_List_Destructor destroy, FT_Memory memory, void *user) {
+ FT_ListNode cur;
+
+ cur = list->head;
+ while (cur) {
+ FT_ListNode next = cur->next;
+ void *data = cur->data;
+
+ if (destroy)
+ destroy(memory, data, user);
+
+ FT_FREE(cur);
+ cur = next;
+ }
+
+ list->head = 0;
+ list->tail = 0;
+}
+
+} // End of namespace FreeType213
+} // End of namespace AGS3
Commit: 4c020ac29098c8736e125bbd7b701ab24e971da4
https://github.com/scummvm/scummvm/commit/4c020ac29098c8736e125bbd7b701ab24e971da4
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Add minimal fterrors and cleanup ftutil
Changed paths:
A engines/ags/lib/freetype-2.1.3/fterrors.h
engines/ags/lib/freetype-2.1.3/ftmemory.h
engines/ags/lib/freetype-2.1.3/ftutil.cpp
diff --git a/engines/ags/lib/freetype-2.1.3/fterrors.h b/engines/ags/lib/freetype-2.1.3/fterrors.h
new file mode 100644
index 00000000000..9fd2304c26d
--- /dev/null
+++ b/engines/ags/lib/freetype-2.1.3/fterrors.h
@@ -0,0 +1,50 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/***************************************************************************/
+/* */
+/* fterrors.h */
+/* */
+/* FreeType error codes */
+/* */
+/* Copyright 1996-2001, 2002 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. */
+/* */
+/***************************************************************************/
+
+#ifndef AGS_LIB_FREETYPE_FTERRORS_H
+#define AGS_LIB_FREETYPE_FTERRORS_H
+
+
+#define FT_Err_Ok 0x00
+#define FT_Err_Invalid_Argument 0x06
+#define FT_Err_Unimplemented_Feature 0x07
+#define FT_Err_Invalid_Composite 0x15
+#define FT_Err_Out_Of_Memory 0x40
+
+
+#endif /* AGS_LIB_FREETYPE_FTERRORS_H */
diff --git a/engines/ags/lib/freetype-2.1.3/ftmemory.h b/engines/ags/lib/freetype-2.1.3/ftmemory.h
index 11637309072..d835899175e 100644
--- a/engines/ags/lib/freetype-2.1.3/ftmemory.h
+++ b/engines/ags/lib/freetype-2.1.3/ftmemory.h
@@ -41,28 +41,20 @@
#define AGS_LIB_FREETYPE_FTMEMORY_H
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/config/ftconfig.h"
-#include "engines/ags/lib/freetype-2.1.3/fttypes.h"
+#include <ft2build.h>
+#include FT_TYPES_H
namespace AGS3 {
namespace FreeType213 {
-// FT_BEGIN_HEADER
-
#undef FT_SET_ERROR
#define FT_SET_ERROR(expression) ((error = (expression)) != 0)
-FT_BASE(FT_Error)
-FT_Alloc(FT_Memory memory, FT_Long size, void **P);
-
-FT_BASE(FT_Error)
-FT_Realloc(FT_Memory memory, FT_Long current, FT_Long size, void **P);
-
-FT_BASE(void)
-FT_Free(FT_Memory memory, void **P);
+FT_Error FT_Alloc(FT_Memory memory, FT_Long size, void **P);
+FT_Error FT_Realloc(FT_Memory memory, FT_Long current, FT_Long size, void **P);
+void FT_Free(FT_Memory memory, void **P);
#define FT_MEM_SET(dest, byte, count) ft_memset(dest, byte, count)
@@ -111,8 +103,6 @@ FT_Free(FT_Memory memory, void **P);
#define FT_REALLOC_ARRAY(_pointer_, _old_, _new_, _type_) FT_SET_ERROR(FT_MEM_REALLOC(_pointer_, (_old_) * sizeof(_type_), (_new_) * sizeof(_type_)))
-// FT_END_HEADER
-
} // End of namespace FreeType213
} // End of namespace AGS3
diff --git a/engines/ags/lib/freetype-2.1.3/ftutil.cpp b/engines/ags/lib/freetype-2.1.3/ftutil.cpp
index fde499ef4b8..775718429d8 100644
--- a/engines/ags/lib/freetype-2.1.3/ftutil.cpp
+++ b/engines/ags/lib/freetype-2.1.3/ftutil.cpp
@@ -36,14 +36,12 @@
/* */
/***************************************************************************/
-
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/ftdebug.h"
+#include <ft2build.h>
+#include "engines/ags/lib/freetype-2.1.3/fterrors.h"
#include "engines/ags/lib/freetype-2.1.3/ftmemory.h"
-#include "engines/ags/lib/freetype-2.1.3/ftlist.h"
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_memory
+#include "common/debug.h"
+
namespace AGS3 {
namespace FreeType213 {
@@ -51,33 +49,26 @@ namespace FreeType213 {
/**** MEMORY MANAGEMENT ****/
-FT_BASE_DEF(FT_Error)
-FT_Alloc(FT_Memory memory, FT_Long size, void **P) {
- FT_ASSERT(P != 0);
+FT_Error FT_Alloc(FT_Memory memory, FT_Long size, void **P) {
+ assert(P != 0);
if (size > 0) {
*P = memory->alloc(memory, size);
if (!*P) {
- FT_ERROR(("FT_Alloc:"));
- FT_ERROR((" Out of memory? (%ld requested)\n", size));
-
+ warning("FT_Alloc: Out of memory? (%ld requested)\n", size);
return FT_Err_Out_Of_Memory;
}
FT_MEM_ZERO(*P, size);
} else
*P = NULL;
- FT_TRACE7(("FT_Alloc:"));
- FT_TRACE7((" size = %ld, block = 0x%08p, ref = 0x%08p\n", size, *P, P));
-
return FT_Err_Ok;
}
-FT_BASE_DEF(FT_Error)
-FT_Realloc(FT_Memory memory, FT_Long current, FT_Long size, void **P) {
+FT_Error FT_Realloc(FT_Memory memory, FT_Long current, FT_Long size, void **P) {
void *Q;
- FT_ASSERT(P != 0);
+ assert(P != 0);
/* if the original pointer is NULL, call FT_Alloc() */
if (!*P)
@@ -100,16 +91,11 @@ FT_Realloc(FT_Memory memory, FT_Long current, FT_Long size, void **P) {
return FT_Err_Ok;
Fail:
- FT_ERROR(("FT_Realloc:"));
- FT_ERROR((" Failed (current %ld, requested %ld)\n", current, size));
+ warning("FT_Realloc: Failed (current %ld, requested %ld)\n", current, size);
return FT_Err_Out_Of_Memory;
}
-FT_BASE_DEF(void)
-FT_Free(FT_Memory memory, void **P) {
- FT_TRACE7(("FT_Free:"));
- FT_TRACE7((" Freeing block 0x%08p, ref 0x%08p\n", P, P ? *P : (void *)0));
-
+void FT_Free(FT_Memory memory, void **P) {
if (P && *P) {
memory->free(memory, *P);
*P = 0;
@@ -117,135 +103,5 @@ FT_Free(FT_Memory memory, void **P) {
}
-/**** DOUBLE LINKED LISTS ****/
-
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_list
-
-FT_EXPORT_DEF(FT_ListNode)
-FT_List_Find(FT_List list, void *data) {
- FT_ListNode cur;
-
- cur = list->head;
- while (cur) {
- if (cur->data == data)
- return cur;
-
- cur = cur->next;
- }
-
- return (FT_ListNode)0;
-}
-
-FT_EXPORT_DEF(void)
-FT_List_Add(FT_List list, FT_ListNode node) {
- FT_ListNode before = list->tail;
-
- node->next = 0;
- node->prev = before;
-
- if (before)
- before->next = node;
- else
- list->head = node;
-
- list->tail = node;
-}
-
-FT_EXPORT_DEF(void)
-FT_List_Insert(FT_List list, FT_ListNode node) {
- FT_ListNode after = list->head;
-
- node->next = after;
- node->prev = 0;
-
- if (!after)
- list->tail = node;
- else
- after->prev = node;
-
- list->head = node;
-}
-
-FT_EXPORT_DEF(void)
-FT_List_Remove(FT_List list, FT_ListNode node) {
- FT_ListNode before, after;
-
- before = node->prev;
- after = node->next;
-
- if (before)
- before->next = after;
- else
- list->head = after;
-
- if (after)
- after->prev = before;
- else
- list->tail = before;
-}
-
-FT_EXPORT_DEF(void)
-FT_List_Up(FT_List list, FT_ListNode node) {
- FT_ListNode before, after;
-
- before = node->prev;
- after = node->next;
-
- /* check whether we are already on top of the list */
- if (!before)
- return;
-
- before->next = after;
-
- if (after)
- after->prev = before;
- else
- list->tail = before;
-
- node->prev = 0;
- node->next = list->head;
- list->head->prev = node;
- list->head = node;
-}
-
-FT_EXPORT_DEF(FT_Error)
-FT_List_Iterate(FT_List list, FT_List_Iterator iterator, void *user) {
- FT_ListNode cur = list->head;
- FT_Error error = FT_Err_Ok;
-
- while (cur) {
- FT_ListNode next = cur->next;
-
- error = iterator(cur, user);
- if (error)
- break;
-
- cur = next;
- }
-
- return error;
-}
-
-FT_EXPORT_DEF(void)
-FT_List_Finalize(FT_List list, FT_List_Destructor destroy, FT_Memory memory, void *user) {
- FT_ListNode cur;
-
- cur = list->head;
- while (cur) {
- FT_ListNode next = cur->next;
- void *data = cur->data;
-
- if (destroy)
- destroy(memory, data, user);
-
- FT_FREE(cur);
- cur = next;
- }
-
- list->head = 0;
- list->tail = 0;
-}
-
} // End of namespace FreeType213
} // End of namespace AGS3
Commit: 365e74d51fc3eae6a0f9a535e3603fdcf3185690
https://github.com/scummvm/scummvm/commit/365e74d51fc3eae6a0f9a535e3603fdcf3185690
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Clean up ftgloadr.h/cpp
Changed paths:
engines/ags/lib/freetype-2.1.3/ftgloadr.cpp
engines/ags/lib/freetype-2.1.3/ftgloadr.h
diff --git a/engines/ags/lib/freetype-2.1.3/ftgloadr.cpp b/engines/ags/lib/freetype-2.1.3/ftgloadr.cpp
index d463a6059be..e01d42d84bc 100644
--- a/engines/ags/lib/freetype-2.1.3/ftgloadr.cpp
+++ b/engines/ags/lib/freetype-2.1.3/ftgloadr.cpp
@@ -37,20 +37,17 @@
/***************************************************************************/
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/ftgloadr.h"
+#include <ft2build.h>
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahhint.h"
#include "engines/ags/lib/freetype-2.1.3/ftmemory.h"
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_gloader
namespace AGS3 {
namespace FreeType213 {
/* create a new glyph loader */
-FT_BASE_DEF(FT_Error)
-FT_GlyphLoader_New(FT_Memory memory, FT_GlyphLoader *aloader) {
+FT_Error FT_GlyphLoader_New(FT_Memory memory, FT_GlyphLoader *aloader) {
FT_GlyphLoader loader;
FT_Error error;
@@ -63,8 +60,7 @@ FT_GlyphLoader_New(FT_Memory memory, FT_GlyphLoader *aloader) {
/* rewind the glyph loader - reset counters to 0 */
-FT_BASE_DEF(void)
-FT_GlyphLoader_Rewind(FT_GlyphLoader loader) {
+void FT_GlyphLoader_Rewind(FT_GlyphLoader loader) {
FT_GlyphLoad base = &loader->base;
FT_GlyphLoad current = &loader->current;
@@ -78,8 +74,7 @@ FT_GlyphLoader_Rewind(FT_GlyphLoader loader) {
/* reset the glyph loader, frees all allocated tables */
/* and starts from zero */
-FT_BASE_DEF(void)
-FT_GlyphLoader_Reset(FT_GlyphLoader loader) {
+void FT_GlyphLoader_Reset(FT_GlyphLoader loader) {
FT_Memory memory = loader->memory;
FT_FREE(loader->base.outline.points);
@@ -97,8 +92,7 @@ FT_GlyphLoader_Reset(FT_GlyphLoader loader) {
/* delete a glyph loader */
-FT_BASE_DEF(void)
-FT_GlyphLoader_Done(FT_GlyphLoader loader) {
+void FT_GlyphLoader_Done(FT_GlyphLoader loader) {
if (loader) {
FT_Memory memory = loader->memory;
@@ -123,8 +117,7 @@ static void FT_GlyphLoader_Adjust_Points(FT_GlyphLoader loader) {
}
-FT_BASE_DEF(FT_Error)
-FT_GlyphLoader_CreateExtra(FT_GlyphLoader loader) {
+FT_Error FT_GlyphLoader_CreateExtra(FT_GlyphLoader loader) {
FT_Error error;
FT_Memory memory = loader->memory;
@@ -149,8 +142,7 @@ static void FT_GlyphLoader_Adjust_Subglyphs(FT_GlyphLoader loader) {
/* function reallocates its outline tables if necessary. Note that it */
/* DOESN'T change the number of points within the loader! */
/* */
-FT_BASE_DEF(FT_Error)
-FT_GlyphLoader_CheckPoints(FT_GlyphLoader loader, FT_UInt n_points, FT_UInt n_contours) {
+FT_Error FT_GlyphLoader_CheckPoints(FT_GlyphLoader loader, FT_UInt n_points, FT_UInt n_contours) {
FT_Memory memory = loader->memory;
FT_Error error = FT_Err_Ok;
FT_Outline *base = &loader->base.outline;
@@ -200,8 +192,7 @@ Exit:
/* reallocates its subglyphs table if necessary. Note that it DOES */
/* NOT change the number of subglyphs within the loader! */
/* */
-FT_BASE_DEF(FT_Error)
-FT_GlyphLoader_CheckSubGlyphs(FT_GlyphLoader loader, FT_UInt n_subs) {
+FT_Error FT_GlyphLoader_CheckSubGlyphs(FT_GlyphLoader loader, FT_UInt n_subs) {
FT_Memory memory = loader->memory;
FT_Error error = FT_Err_Ok;
FT_UInt new_max, old_max;
@@ -227,8 +218,7 @@ Exit:
/* prepare loader for the addition of a new glyph on top of the base one */
-FT_BASE_DEF(void)
-FT_GlyphLoader_Prepare(FT_GlyphLoader loader) {
+void FT_GlyphLoader_Prepare(FT_GlyphLoader loader) {
FT_GlyphLoad current = &loader->current;
current->outline.n_points = 0;
@@ -241,8 +231,7 @@ FT_GlyphLoader_Prepare(FT_GlyphLoader loader) {
/* add current glyph to the base image - and prepare for another */
-FT_BASE_DEF(void)
-FT_GlyphLoader_Add(FT_GlyphLoader loader) {
+void FT_GlyphLoader_Add(FT_GlyphLoader loader) {
FT_GlyphLoad base = &loader->base;
FT_GlyphLoad current = &loader->current;
@@ -265,8 +254,7 @@ FT_GlyphLoader_Add(FT_GlyphLoader loader) {
}
-FT_BASE_DEF(FT_Error)
-FT_GlyphLoader_CopyPoints(FT_GlyphLoader target, FT_GlyphLoader source) {
+FT_Error FT_GlyphLoader_CopyPoints(FT_GlyphLoader target, FT_GlyphLoader source) {
FT_Error error;
FT_UInt num_points = source->base.outline.n_points;
FT_UInt num_contours = source->base.outline.n_contours;
diff --git a/engines/ags/lib/freetype-2.1.3/ftgloadr.h b/engines/ags/lib/freetype-2.1.3/ftgloadr.h
index 5f767bccb20..c95b19e6489 100644
--- a/engines/ags/lib/freetype-2.1.3/ftgloadr.h
+++ b/engines/ags/lib/freetype-2.1.3/ftgloadr.h
@@ -41,14 +41,11 @@
#define AGS_LIB_FREETYPE_FTGLOADR_H
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/freetype.h"
+#include "graphics/fonts/freetype.h"
namespace AGS3 {
namespace FreeType213 {
-// FT_BEGIN_HEADER
-
typedef struct FT_GlyphLoaderRec_ *FT_GlyphLoader;
@@ -101,49 +98,37 @@ typedef struct FT_GlyphLoaderRec_ {
/* create new empty glyph loader */
-FT_BASE(FT_Error)
-FT_GlyphLoader_New(FT_Memory memory, FT_GlyphLoader *aloader);
+FT_Error FT_GlyphLoader_New(FT_Memory memory, FT_GlyphLoader *aloader);
/* add an extra points table to a glyph loader */
-FT_BASE(FT_Error)
-FT_GlyphLoader_CreateExtra(FT_GlyphLoader loader);
+FT_Error FT_GlyphLoader_CreateExtra(FT_GlyphLoader loader);
/* destroy a glyph loader */
-FT_BASE(void)
-FT_GlyphLoader_Done(FT_GlyphLoader loader);
+void FT_GlyphLoader_Done(FT_GlyphLoader loader);
/* reset a glyph loader (frees everything int it) */
-FT_BASE(void)
-FT_GlyphLoader_Reset(FT_GlyphLoader loader);
+void FT_GlyphLoader_Reset(FT_GlyphLoader loader);
/* rewind a glyph loader */
-FT_BASE(void)
-FT_GlyphLoader_Rewind(FT_GlyphLoader loader);
+void FT_GlyphLoader_Rewind(FT_GlyphLoader loader);
/* check that there is enough room to add 'n_points' and 'n_contours' */
/* to the glyph loader */
-FT_BASE(FT_Error)
-FT_GlyphLoader_CheckPoints(FT_GlyphLoader loader, FT_UInt n_points, FT_UInt n_contours);
+FT_Error FT_GlyphLoader_CheckPoints(FT_GlyphLoader loader, FT_UInt n_points, FT_UInt n_contours);
/* check that there is enough room to add 'n_subs' sub-glyphs to */
/* a glyph loader */
-FT_BASE(FT_Error)
-FT_GlyphLoader_CheckSubGlyphs(FT_GlyphLoader loader, FT_UInt n_subs);
+FT_Error FT_GlyphLoader_CheckSubGlyphs(FT_GlyphLoader loader, FT_UInt n_subs);
/* prepare a glyph loader, i.e. empty the current glyph */
-FT_BASE(void)
-FT_GlyphLoader_Prepare(FT_GlyphLoader loader);
+void FT_GlyphLoader_Prepare(FT_GlyphLoader loader);
/* add the current glyph to the base glyph */
-FT_BASE(void)
-FT_GlyphLoader_Add(FT_GlyphLoader loader);
+void FT_GlyphLoader_Add(FT_GlyphLoader loader);
/* copy points from one glyph loader to another */
-FT_BASE(FT_Error)
-FT_GlyphLoader_CopyPoints(FT_GlyphLoader target, FT_GlyphLoader source);
-
+FT_Error FT_GlyphLoader_CopyPoints(FT_GlyphLoader target, FT_GlyphLoader source);
-// FT_END_HEADER
} // End of namespace FreeType213
} // End of namespace AGS3
Commit: c2ee3b8b34803dde92704073f76e126490dee5a9
https://github.com/scummvm/scummvm/commit/c2ee3b8b34803dde92704073f76e126490dee5a9
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Add required FT_SubGlyph type to ftgloadr
Changed paths:
engines/ags/lib/freetype-2.1.3/ftgloadr.h
diff --git a/engines/ags/lib/freetype-2.1.3/ftgloadr.h b/engines/ags/lib/freetype-2.1.3/ftgloadr.h
index c95b19e6489..4bf8d959ca0 100644
--- a/engines/ags/lib/freetype-2.1.3/ftgloadr.h
+++ b/engines/ags/lib/freetype-2.1.3/ftgloadr.h
@@ -72,6 +72,7 @@ typedef struct FT_SubGlyphRec_ {
} FT_SubGlyphRec;
+typedef FT_SubGlyphRec *FT_SubGlyph;
typedef struct FT_GlyphLoadRec_ {
FT_Outline outline; /* outline */
Commit: 5ea6b4c048f20a6057808786f4653e1a70f37151
https://github.com/scummvm/scummvm/commit/5ea6b4c048f20a6057808786f4653e1a70f37151
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Fix includes/declarations in ahangles / ahglobal
Changed paths:
engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp
engines/ags/lib/freetype-2.1.3/autohint/ahangles.h
engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp
index a3f990f151e..7c6b80431b9 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp
@@ -41,8 +41,8 @@
/***************************************************************************/
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahangles.h"
+#include <ft2build.h>
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahangles.h"
namespace AGS3 {
namespace FreeType213 {
@@ -85,8 +85,7 @@ const AH_Angle ah_arctan[1L << AH_ATAN_BITS] = {
63, 63, 63, 63, 63, 64, 64, 64
};
-FT_LOCAL_DEF(AH_Angle)
-ah_angle(FT_Vector *v) {
+AH_Angle ah_angle(FT_Vector *v) {
FT_Pos dx, dy;
AH_Angle angle;
@@ -139,8 +138,7 @@ ah_angle(FT_Vector *v) {
}
-FT_LOCAL_DEF(AH_Angle)
-ah_angle_diff(AH_Angle angle1, AH_Angle angle2) {
+AH_Angle ah_angle_diff(AH_Angle angle1, AH_Angle angle2) {
AH_Angle delta;
delta = (angle2 - angle1);
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahangles.h b/engines/ags/lib/freetype-2.1.3/autohint/ahangles.h
index 8be06c48138..1f5298a81ab 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahangles.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahangles.h
@@ -45,15 +45,12 @@
#define AGS_LIB_FREETYPE_AHANGLES_H
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/ftobjs.h"
-#include "ahtypes.h"
+#include <ft2build.h>
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h"
namespace AGS3 {
namespace FreeType213 {
-// FT_BEGIN_HEADER
-
/* PI expressed in ah_angles -- we don't really need an important */
/* precision, so 256 should be enough */
@@ -68,16 +65,11 @@ namespace FreeType213 {
extern const AH_Angle ah_arctan[1L << AH_ATAN_BITS];
-FT_LOCAL(AH_Angle)
-ah_angle(FT_Vector *v);
-
-FT_LOCAL(AH_Angle)
-ah_angle_diff(AH_Angle angle1, AH_Angle angle2);
-
+AH_Angle ah_angle(FT_Vector *v);
+AH_Angle ah_angle_diff(AH_Angle angle1, AH_Angle angle2);
-// FT_END_HEADER
} // End of namespace FreeType213
} // End of namespace AGS3
-#endif /* AGS_LIB_FREETYPE_AHANGLES_H */
\ No newline at end of file
+#endif /* AGS_LIB_FREETYPE_AHANGLES_H */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
index 9ef5ef35fa9..471fbb94bce 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
@@ -40,10 +40,9 @@
/***************************************************************************/
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/ftdebug.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahglobal.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahglyph.h"
+#include <ft2build.h>
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h"
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h"
#define MAX_TEST_CHARACTERS 12
@@ -362,8 +361,7 @@ Exit:
return error;
}
-FT_LOCAL_DEF(FT_Error)
-ah_hinter_compute_globals(AH_Hinter hinter) {
+FT_Error ah_hinter_compute_globals(AH_Hinter hinter) {
return ah_hinter_compute_widths(hinter) || ah_hinter_compute_blues(hinter);
}
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h
index 1cc0e20963d..3cbba2f8c3d 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h
@@ -45,24 +45,18 @@
#define AGS_LIB_FREETYPE_AHGLOBAL_H
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahtypes.h"
-#include "engines/ags/lib/freetype-2.1.3/ftobjs.h"
+#include <ft2build.h>
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h"
namespace AGS3 {
namespace FreeType213 {
-// FT_BEGIN_HEADER
-
#define AH_IS_TOP_BLUE(b) ((b) == AH_BLUE_CAPITAL_TOP || (b) == AH_BLUE_SMALL_TOP)
/* compute global metrics automatically */
-FT_LOCAL(FT_Error)
-ah_hinter_compute_globals(AH_Hinter hinter);
-
+FT_Error ah_hinter_compute_globals(AH_Hinter hinter);
-// FT_END_HEADER
} // End of namespace FreeType213
} // End of namespace AGS3
Commit: 7b39ad094a5ab0933374e91250771e4f0d00f4af
https://github.com/scummvm/scummvm/commit/7b39ad094a5ab0933374e91250771e4f0d00f4af
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Fix includes in ahtypes
Changed paths:
engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h b/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
index 904e495c76d..f2b624a6840 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
@@ -45,13 +45,13 @@
#define AGS_LIB_FREETYPE_AHTYPES_H
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/ftobjs.h"
+#include <ft2build.h>
+#include FT_TYPES_H
#ifdef DEBUG_HINTER
#include <../modules/autohint/ahloader.h>
#else
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahloader.h"
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahloader.h"
#endif
@@ -72,8 +72,6 @@
namespace AGS3 {
namespace FreeType213 {
-// FT_BEGIN_HEADER
-
/**** COMPILE-TIME BUILD OPTIONS ****/
@@ -339,8 +337,6 @@ extern FT_Bool ah_debug_disable_vert;
#endif /* DEBUG_HINTER */
-// FT_END_HEADER
-
} // End of namespace FreeType213
} // End of namespace AGS3
Commit: 35b82f7c8f9815c7bce7ab413cee53102e768881
https://github.com/scummvm/scummvm/commit/35b82f7c8f9815c7bce7ab413cee53102e768881
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Cleanup ahglyph/ahhint/ahloader headers
Changed paths:
engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h
engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
engines/ags/lib/freetype-2.1.3/autohint/ahloader.h
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h
index 1911eabc36a..5debd4ddb50 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h
@@ -45,14 +45,12 @@
#define AGS_LIB_FREETYPE_AHGLYPH_H
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahtypes.h"
+#include <ft2build.h>
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h"
namespace AGS3 {
namespace FreeType213 {
-// FT_BEGIN_HEADER
-
typedef enum AH_UV_ {
AH_UV_FXY,
@@ -66,40 +64,19 @@ typedef enum AH_UV_ {
} AH_UV;
-FT_LOCAL(void)
-ah_setup_uv(AH_Outline outline, AH_UV source);
+void ah_setup_uv(AH_Outline outline, AH_UV source);
/* AH_OutlineRec functions - they should be typically called in this order */
+FT_Error ah_outline_new(FT_Memory memory, AH_Outline *aoutline);
+FT_Error ah_outline_load(AH_Outline outline, FT_Face face);
+void ah_outline_compute_segments(AH_Outline outline);
+void ah_outline_link_segments(AH_Outline outline);
+void ah_outline_detect_features(AH_Outline outline);
+void ah_outline_compute_blue_edges(AH_Outline outline, AH_Face_Globals globals);
+void ah_outline_scale_blue_edges(AH_Outline outline, AH_Face_Globals globals);
+void ah_outline_save(AH_Outline outline, AH_Loader loader);
+void ah_outline_done(AH_Outline outline);
-FT_LOCAL(FT_Error)
-ah_outline_new(FT_Memory memory, AH_Outline *aoutline);
-
-FT_LOCAL(FT_Error)
-ah_outline_load(AH_Outline outline, FT_Face face);
-
-FT_LOCAL(void)
-ah_outline_compute_segments(AH_Outline outline);
-
-FT_LOCAL(void)
-ah_outline_link_segments(AH_Outline outline);
-
-FT_LOCAL(void)
-ah_outline_detect_features(AH_Outline outline);
-
-FT_LOCAL(void)
-ah_outline_compute_blue_edges(AH_Outline outline, AH_Face_Globals globals);
-
-FT_LOCAL(void)
-ah_outline_scale_blue_edges(AH_Outline outline, AH_Face_Globals globals);
-
-FT_LOCAL(void)
-ah_outline_save(AH_Outline outline, AH_Loader loader);
-
-FT_LOCAL(void)
-ah_outline_done(AH_Outline outline);
-
-
-// FT_END_HEADER
} // End of namespace FreeType213
} // End of namespace AGS3
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
index 95b1659f5e2..54ea12bf83c 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
@@ -44,14 +44,12 @@
#define AGS_LIB_FREETYPE_AHHINT_H
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahglobal.h"
+#include <ft2build.h>
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h"
namespace AGS3 {
namespace FreeType213 {
-// FT_BEGIN_HEADER
-
#define AH_HINT_DEFAULT 0
#define AH_HINT_NO_ALIGNMENT 1
@@ -59,28 +57,20 @@ namespace FreeType213 {
#define AH_HINT_NO_VERT_EDGES 0x400000L /* temporary hack */
/* create a new empty hinter object */
-FT_LOCAL(FT_Error)
-ah_hinter_new(FT_Library library, AH_Hinter *ahinter);
+FT_Error ah_hinter_new(FT_Library library, AH_Hinter *ahinter);
/* Load a hinted glyph in the hinter */
-FT_LOCAL(FT_Error)
-ah_hinter_load_glyph(AH_Hinter hinter, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags);
+FT_Error ah_hinter_load_glyph(AH_Hinter hinter, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags);
/* finalize a hinter object */
-FT_LOCAL(void)
-ah_hinter_done(AH_Hinter hinter);
-
-FT_LOCAL(void)
-ah_hinter_done_face_globals(AH_Face_Globals globals);
+void ah_hinter_done(AH_Hinter hinter);
-FT_LOCAL(void)
-ah_hinter_get_global_hints(AH_Hinter hinter, FT_Face face, void **global_hints, long *global_len);
+void ah_hinter_done_face_globals(AH_Face_Globals globals);
-FT_LOCAL(void)
-ah_hinter_done_global_hints(AH_Hinter hinter, void *global_hints);
+void ah_hinter_get_global_hints(AH_Hinter hinter, FT_Face face, void **global_hints, long *global_len);
+void ah_hinter_done_global_hints(AH_Hinter hinter, void *global_hints);
-// FT_END_HEADER
} // End of namespace FreeType213
} // End of namespace AGS3
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahloader.h b/engines/ags/lib/freetype-2.1.3/autohint/ahloader.h
index 2ada4930c43..1f6a2216eaf 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahloader.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahloader.h
@@ -45,12 +45,10 @@
#define AGS_LIB_FREETYPE_AHLOADER_H
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-
-
-// FT_BEGIN_HEADER
-
+#include <ft2build.h>
#include "engines/ags/lib/freetype-2.1.3/ftgloadr.h"
+#include FT_OUTLINE_H
+
#define AH_Load FT_GlyphLoad
#define AH_Loader FT_GlyphLoader
@@ -67,6 +65,4 @@
#define ah_loader_copy_points FT_GlyphLoader_CopyPoints
-// FT_END_HEADER
-
#endif /* AGS_LIB_FREETYPE_AHLOADER_H */
Commit: b31812213940497783ae05cf21605c5f1e901d68
https://github.com/scummvm/scummvm/commit/b31812213940497783ae05cf21605c5f1e901d68
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Fix headers/declarations ahglyph
Changed paths:
engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
index 30b3f76458b..da38e793e79 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
@@ -40,12 +40,17 @@
/* */
/***************************************************************************/
+#include <ft2build.h>
+
+#include "engines/ags/lib/freetype-2.1.3/ftmemory.h"
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h"
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahangles.h"
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h"
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h"
+
+// util.h for ABS
+#include "common/util.h"
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahglyph.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahangles.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahglobal.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/aherrors.h"
namespace AGS3 {
namespace FreeType213 {
@@ -270,8 +275,7 @@ Exit:
return n;
}
-FT_LOCAL_DEF(FT_Error)
-ah_outline_new(FT_Memory memory, AH_Outline *aoutline) {
+FT_Error ah_outline_new(FT_Memory memory, AH_Outline *aoutline) {
FT_Error error;
AH_Outline outline;
@@ -283,8 +287,7 @@ ah_outline_new(FT_Memory memory, AH_Outline *aoutline) {
return error;
}
-FT_LOCAL_DEF(void)
-ah_outline_done(AH_Outline outline) {
+void ah_outline_done(AH_Outline outline) {
FT_Memory memory = outline->memory;
FT_FREE(outline->horz_edges);
@@ -295,8 +298,7 @@ ah_outline_done(AH_Outline outline) {
FT_FREE(outline);
}
-FT_LOCAL_DEF(void)
-ah_outline_save(AH_Outline outline, AH_Loader gloader) {
+void ah_outline_save(AH_Outline outline, AH_Loader gloader) {
AH_Point point = outline->points;
AH_Point point_limit = point + outline->num_points;
FT_Vector *vec = gloader->current.outline.points;
@@ -316,8 +318,7 @@ ah_outline_save(AH_Outline outline, AH_Loader gloader) {
}
}
-FT_LOCAL_DEF(FT_Error)
-ah_outline_load(AH_Outline outline, FT_Face face) {
+FT_Error ah_outline_load(AH_Outline outline, FT_Face face) {
FT_Memory memory = outline->memory;
FT_Error error = FT_Err_Ok;
FT_Outline *source = &face->glyph->outline;
@@ -523,8 +524,7 @@ Exit:
return error;
}
-FT_LOCAL_DEF(void)
-ah_setup_uv(AH_Outline outline, AH_UV source) {
+void ah_setup_uv(AH_Outline outline, AH_UV source) {
AH_Point point = outline->points;
AH_Point point_limit = point + outline->num_points;
@@ -671,8 +671,7 @@ static void ah_outline_compute_inflections(AH_Outline outline) {
}
}
-FT_LOCAL_DEF(void)
-ah_outline_compute_segments(AH_Outline outline) {
+void ah_outline_compute_segments(AH_Outline outline) {
int dimension;
AH_Segment segments;
FT_Int *p_num_segments;
@@ -887,8 +886,7 @@ ah_outline_compute_segments(AH_Outline outline) {
}
}
-FT_LOCAL_DEF(void)
-ah_outline_link_segments(AH_Outline outline) {
+void ah_outline_link_segments(AH_Outline outline) {
AH_Segment segments;
AH_Segment segment_limit;
int dimension;
@@ -1203,16 +1201,14 @@ static void ah_outline_compute_edges(AH_Outline outline) {
}
}
-FT_LOCAL_DEF(void)
-ah_outline_detect_features(AH_Outline outline) {
+void ah_outline_detect_features(AH_Outline outline) {
ah_outline_compute_segments(outline);
ah_outline_link_segments(outline);
ah_outline_compute_edges(outline);
ah_outline_compute_inflections(outline);
}
-FT_LOCAL_DEF(void)
-ah_outline_compute_blue_edges(AH_Outline outline, AH_Face_Globals face_globals) {
+void ah_outline_compute_blue_edges(AH_Outline outline, AH_Face_Globals face_globals) {
AH_Edge edge = outline->horz_edges;
AH_Edge edge_limit = edge + outline->num_hedges;
AH_Globals globals = &face_globals->design;
@@ -1315,8 +1311,7 @@ ah_outline_compute_blue_edges(AH_Outline outline, AH_Face_Globals face_globals)
}
}
-FT_LOCAL_DEF(void)
-ah_outline_scale_blue_edges(AH_Outline outline, AH_Face_Globals globals) {
+void ah_outline_scale_blue_edges(AH_Outline outline, AH_Face_Globals globals) {
AH_Edge edge = outline->horz_edges;
AH_Edge edge_limit = edge + outline->num_hedges;
FT_Pos delta;
Commit: a0211934dbee2db6a79061b11cd266441212b5b9
https://github.com/scummvm/scummvm/commit/a0211934dbee2db6a79061b11cd266441212b5b9
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Fix headers/declarations ahhint
Changed paths:
engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
index b8e1d538313..c1699fda0e3 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
@@ -40,12 +40,15 @@
/***************************************************************************/
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahhint.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahglyph.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahangles.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/aherrors.h"
-#include "engines/ags/lib/freetype-2.1.3/ftoutln.h"
+#include <ft2build.h>
+#include FT_OUTLINE_H
+
+#include "engines/ags/lib/freetype-2.1.3/fterrors.h"
+#include "engines/ags/lib/freetype-2.1.3/ftmemory.h"
+#include "engines/ags/lib/freetype-2.1.3/ftgloadr.h"
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahhint.h"
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h"
+#include "engines/ags/lib/freetype-2.1.3/autohint/ahangles.h"
#define FACE_GLOBALS(face) ((AH_Face_Globals)(face)->autohint.data)
@@ -377,8 +380,7 @@ static void ah_hint_edges_3(AH_Hinter hinter) {
}
}
-FT_LOCAL_DEF(void)
-ah_hinter_hint_edges(AH_Hinter hinter) {
+void ah_hinter_hint_edges(AH_Hinter hinter) {
/* AH_Interpolate_Blue_Edges( hinter ); -- doesn't seem to help */
/* reduce the problem of the disappearing eye in the `e' of Times... */
/* also, creates some artifacts near the blue zones? */
@@ -701,8 +703,7 @@ static void ah_hinter_align_weak_points(AH_Hinter hinter) {
#endif /* !AH_OPTION_NO_WEAK_INTERPOLATION */
-FT_LOCAL_DEF(void)
-ah_hinter_align_points(AH_Hinter hinter) {
+void ah_hinter_align_points(AH_Hinter hinter) {
ah_hinter_align_edge_points(hinter);
#ifndef AH_OPTION_NO_STRONG_INTERPOLATION
@@ -771,8 +772,7 @@ static void ah_hinter_align(AH_Hinter hinter) {
}
/* finalize a hinter object */
-FT_LOCAL_DEF(void)
-ah_hinter_done(AH_Hinter hinter) {
+void ah_hinter_done(AH_Hinter hinter) {
if (hinter) {
FT_Memory memory = hinter->memory;
@@ -790,8 +790,7 @@ ah_hinter_done(AH_Hinter hinter) {
}
/* create a new empty hinter object */
-FT_LOCAL_DEF(FT_Error)
-ah_hinter_new(FT_Library library, AH_Hinter *ahinter) {
+FT_Error ah_hinter_new(FT_Library library, AH_Hinter *ahinter) {
AH_Hinter hinter = 0;
FT_Memory memory = library->memory;
FT_Error error;
@@ -822,8 +821,7 @@ Exit:
}
/* create a face's autohint globals */
-FT_LOCAL_DEF(FT_Error)
-ah_hinter_new_face_globals(AH_Hinter hinter, FT_Face face, AH_Globals globals) {
+FT_Error ah_hinter_new_face_globals(AH_Hinter hinter, FT_Face face, AH_Globals globals) {
FT_Error error;
FT_Memory memory = hinter->memory;
AH_Face_Globals face_globals;
@@ -848,8 +846,7 @@ Exit:
}
/* discard a face's autohint globals */
-FT_LOCAL_DEF(void)
-ah_hinter_done_face_globals(AH_Face_Globals globals) {
+void ah_hinter_done_face_globals(AH_Face_Globals globals) {
FT_Face face = globals->face;
FT_Memory memory = face->memory;
@@ -1138,8 +1135,7 @@ Exit:
}
/* load and hint a given glyph */
-FT_LOCAL_DEF(FT_Error)
-ah_hinter_load_glyph(AH_Hinter hinter, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags) {
+FT_Error ah_hinter_load_glyph(AH_Hinter hinter, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags) {
FT_Face face = slot->face;
FT_Error error;
FT_Fixed x_scale = size->metrics.x_scale;
@@ -1197,8 +1193,7 @@ Exit:
}
/* retrieve a face's autohint globals for client applications */
-FT_LOCAL_DEF(void)
-ah_hinter_get_global_hints(AH_Hinter hinter, FT_Face face, void **global_hints, long *global_len) {
+void ah_hinter_get_global_hints(AH_Hinter hinter, FT_Face face, void **global_hints, long *global_len) {
AH_Globals globals = 0;
FT_Memory memory = hinter->memory;
FT_Error error;
@@ -1227,8 +1222,7 @@ Fail:
*global_len = 0;
}
-FT_LOCAL_DEF(void)
-ah_hinter_done_global_hints(AH_Hinter hinter, void *global_hints) {
+void ah_hinter_done_global_hints(AH_Hinter hinter, void *global_hints) {
FT_Memory memory = hinter->memory;
FT_FREE(global_hints);
Commit: 4843b18fb2d7b66ea2ecc34ec91846c46e1df214
https://github.com/scummvm/scummvm/commit/4843b18fb2d7b66ea2ecc34ec91846c46e1df214
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Use FT_Memory in ah_hinter_new
Changed paths:
engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
index c1699fda0e3..b4781aef598 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
@@ -790,9 +790,8 @@ void ah_hinter_done(AH_Hinter hinter) {
}
/* create a new empty hinter object */
-FT_Error ah_hinter_new(FT_Library library, AH_Hinter *ahinter) {
+FT_Error ah_hinter_new(FT_Memory memory, AH_Hinter *ahinter) {
AH_Hinter hinter = 0;
- FT_Memory memory = library->memory;
FT_Error error;
*ahinter = 0;
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
index 54ea12bf83c..80e40b39864 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
@@ -57,7 +57,7 @@ namespace FreeType213 {
#define AH_HINT_NO_VERT_EDGES 0x400000L /* temporary hack */
/* create a new empty hinter object */
-FT_Error ah_hinter_new(FT_Library library, AH_Hinter *ahinter);
+FT_Error ah_hinter_new(FT_Memory memory, AH_Hinter *ahinter);
/* Load a hinted glyph in the hinter */
FT_Error ah_hinter_load_glyph(AH_Hinter hinter, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags);
Commit: cc168a16dd5303b4613e27952537d4ef765dcf7d
https://github.com/scummvm/scummvm/commit/cc168a16dd5303b4613e27952537d4ef765dcf7d
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Disable uncompilable code in ahhint
Changed paths:
engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
index b4781aef598..a1afb70ad4a 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
@@ -855,7 +855,7 @@ void ah_hinter_done_face_globals(AH_Face_Globals globals) {
static FT_Error ah_hinter_load(AH_Hinter hinter, FT_UInt glyph_index, FT_Int32 load_flags, FT_UInt depth) {
FT_Face face = hinter->face;
FT_GlyphSlot slot = face->glyph;
- FT_Slot_Internal internal = slot->internal;
+// FT_Slot_Internal internal = slot->internal;
FT_Fixed x_scale = face->size->metrics.x_scale;
FT_Fixed y_scale = face->size->metrics.y_scale;
FT_Error error;
@@ -868,6 +868,8 @@ static FT_Error ah_hinter_load(AH_Hinter hinter, FT_UInt glyph_index, FT_Int32 l
goto Exit;
/* Set `hinter->transformed' after loading with FT_LOAD_NO_RECURSE. */
+ // FIXME: Only used by Type1 and CFF?
+#if 0
hinter->transformed = internal->glyph_transformed;
if (hinter->transformed) {
@@ -880,6 +882,7 @@ static FT_Error ah_hinter_load(AH_Hinter hinter, FT_UInt glyph_index, FT_Int32 l
FT_Matrix_Invert(&imatrix);
FT_Vector_Transform(&hinter->trans_delta, &imatrix);
}
+#endif
/* set linear horizontal metrics */
slot->linearHoriAdvance = slot->metrics.horiAdvance;
@@ -1116,12 +1119,17 @@ Hint_Metrics:
slot->metrics.horiAdvance = (slot->metrics.horiAdvance + 32) & -64;
/* now copy outline into glyph slot */
+
+ // FIXME: check if needed
+#if 0
ah_loader_rewind(slot->internal->loader);
error = ah_loader_copy_points(slot->internal->loader, gloader);
if (error)
goto Exit;
-
slot->outline = slot->internal->loader->base.outline;
+#endif
+
+ slot->outline = gloader->base.outline;
slot->format = FT_GLYPH_FORMAT_OUTLINE;
}
Commit: cee11c1b9935ed8d769be8ce1fa0a0ce7566ddde
https://github.com/scummvm/scummvm/commit/cee11c1b9935ed8d769be8ce1fa0a0ce7566ddde
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Update alfont and enable compilation
Changed paths:
engines/ags/lib/alfont/alfont.cpp
engines/ags/module.mk
diff --git a/engines/ags/lib/alfont/alfont.cpp b/engines/ags/lib/alfont/alfont.cpp
index 6dda8817a85..981807a9220 100644
--- a/engines/ags/lib/alfont/alfont.cpp
+++ b/engines/ags/lib/alfont/alfont.cpp
@@ -50,10 +50,16 @@
#include "ags/lib/allegro/unicode.h"
#include "graphics/fonts/freetype.h"
+#ifndef NO_FT213_AUTOHINT
+#include "ags/lib/freetype-2.1.3/autohint/ahhint.h"
+#endif
+
namespace AGS3 {
using Graphics::FreeType::Init_FreeType;
+using Graphics::FreeType::Init_FreeType_With_Mem;
using Graphics::FreeType::Done_FreeType;
+using Graphics::FreeType::Done_FreeType_With_Mem;
using Graphics::FreeType::Load_Glyph;
using Graphics::FreeType::Get_Glyph;
using Graphics::FreeType::Glyph_Copy;
@@ -119,6 +125,10 @@ BITMAP *default_bmp; //Draw Font on default BITMAP;
static FT_Library ft_library;
static int alfont_textmode = 0;
static int alfont_inited = 0;
+static FT_Memory ft_memory;
+#ifndef NO_FT213_AUTOHINT
+static FreeType213::AH_Hinter ft_hinter;
+#endif
const char *alfont_get_name(ALFONT_FONT *f) {
if (!f)
@@ -560,7 +570,10 @@ int alfont_get_font_real_height(ALFONT_FONT *f) {
void alfont_exit(void) {
if (alfont_inited) {
alfont_inited = 0;
- Done_FreeType(ft_library);
+#ifndef NO_FT213_AUTOHINT
+ FreeType213::ah_hinter_done(ft_hinter);
+#endif
+ Done_FreeType_With_Mem(ft_library, ft_memory);
memset(&ft_library, 0, sizeof(ft_library));
}
}
@@ -572,10 +585,20 @@ int alfont_init(void) {
else {
int error;
memset(&ft_library, 0, sizeof(ft_library));
- error = Init_FreeType(&ft_library);
+ error = Init_FreeType_With_Mem(&ft_library, &ft_memory);
- if (!error)
- alfont_inited = 1;
+ if (!error) {
+#ifndef NO_FT213_AUTOHINT
+ error = FreeType213::ah_hinter_new(ft_memory, &ft_hinter);
+ if (error) {
+ Done_FreeType_With_Mem(ft_library, ft_memory);
+ }
+#endif
+
+ if (!error) {
+ alfont_inited = 1;
+ }
+ }
return error;
}
diff --git a/engines/ags/module.mk b/engines/ags/module.mk
index e82e7f5da27..0e3aa59d3b3 100644
--- a/engines/ags/module.mk
+++ b/engines/ags/module.mk
@@ -27,6 +27,12 @@ MODULE_OBJS = \
lib/allegro/surface_generic.o \
lib/allegro/system.o \
lib/allegro/unicode.o \
+ lib/freetype-2.1.3/autohint/ahangles.o \
+ lib/freetype-2.1.3/autohint/ahglobal.o \
+ lib/freetype-2.1.3/autohint/ahglyph.o \
+ lib/freetype-2.1.3/autohint/ahhint.o \
+ lib/freetype-2.1.3/ftgloadr.o \
+ lib/freetype-2.1.3/ftutil.o \
lib/std/std.o \
lib/system/datetime.o \
shared/ac/dynobj/script_audio_clip.o \
Commit: d2e445fc49690cd158add59e698316cd2c30ec51
https://github.com/scummvm/scummvm/commit/d2e445fc49690cd158add59e698316cd2c30ec51
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: apply autohinting in alfont glyph loader
Changed paths:
engines/ags/lib/alfont/alfont.cpp
diff --git a/engines/ags/lib/alfont/alfont.cpp b/engines/ags/lib/alfont/alfont.cpp
index 981807a9220..0eadd2e6b8b 100644
--- a/engines/ags/lib/alfont/alfont.cpp
+++ b/engines/ags/lib/alfont/alfont.cpp
@@ -304,8 +304,36 @@ static void _alfont_cache_glyph(ALFONT_FONT *f, int glyph_number) {
/* if glyph not cached yet */
if (!f->cached_glyphs[glyph_number].is_cached) {
FT_Glyph new_glyph;
+
/* load the font glyph */
+
+#ifdef NO_FT213_AUTOHINT
Load_Glyph(f->face, glyph_number, FT_LOAD_DEFAULT);
+#else
+ FT_Int32 load_flags = FT_LOAD_DEFAULT;
+ FT_GlyphSlot slot = f->face->glyph;
+
+ FreeType213::ah_hinter_load_glyph(ft_hinter, slot, f->face->size, glyph_number, FT_LOAD_DEFAULT);
+
+ /* compute the advance */
+ if (load_flags & FT_LOAD_VERTICAL_LAYOUT) {
+ slot->advance.x = 0;
+ slot->advance.y = slot->metrics.vertAdvance;
+ } else {
+ slot->advance.x = slot->metrics.horiAdvance;
+ slot->advance.y = 0;
+ }
+
+ /* compute the linear advance in 16.16 pixels */
+ if ((load_flags & FT_LOAD_LINEAR_DESIGN) == 0) {
+ FT_UInt EM = f->face->units_per_EM;
+ FT_Size_Metrics *metrics = &f->face->size->metrics;
+
+ slot->linearHoriAdvance = FT_MulDiv(slot->linearHoriAdvance, (FT_Long)metrics->x_ppem << 16, EM);
+ slot->linearVertAdvance = FT_MulDiv(slot->linearVertAdvance, (FT_Long)metrics->y_ppem << 16, EM);
+ }
+#endif
+
Get_Glyph(f->face->glyph, &new_glyph);
/* ok, this glyph is now cached */
Commit: 1698b26bcbbc059c5666eae7e94e98d31f89b667
https://github.com/scummvm/scummvm/commit/1698b26bcbbc059c5666eae7e94e98d31f89b667
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: remove unneeded files
Changed paths:
R engines/ags/lib/freetype-2.1.3/autohint/aherrors.h
R engines/ags/lib/freetype-2.1.3/autohint/ahmodule.cpp
R engines/ags/lib/freetype-2.1.3/autohint/ahmodule.h
R engines/ags/lib/freetype-2.1.3/autohint/ahoptim.cpp
R engines/ags/lib/freetype-2.1.3/autohint/ahoptim.h
R engines/ags/lib/freetype-2.1.3/autohint/autohint.h
R engines/ags/lib/freetype-2.1.3/freetype.h
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/aherrors.h b/engines/ags/lib/freetype-2.1.3/autohint/aherrors.h
deleted file mode 100644
index 640096f2347..00000000000
--- a/engines/ags/lib/freetype-2.1.3/autohint/aherrors.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/***************************************************************************/
-/* */
-/* aherrors.h */
-/* */
-/* Autohinter error codes (specification only). */
-/* */
-/* Copyright 2001 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. */
-/* */
-/***************************************************************************/
-
-
-/*************************************************************************/
-/* */
-/* This file is used to define the Autohinter error enumeration */
-/* constants. */
-/* */
-/*************************************************************************/
-
-#ifndef AGS_LIB_FREETYPE_AHERRORS_H
-#define AGS_LIB_FREETYPE_AHERRORS_H
-
-#include "engines/ags/lib/freetype-2.1.3/ftmoderr.h"
-
-#undef AGS_LIB_FREETYPE_FTERRORS_H
-
-#define FT_ERR_PREFIX AH_Err_
-#define FT_ERR_BASE FT_Mod_Err_Autohint
-
-#include "engines/ags/lib/freetype-2.1.3/fterrors.h"
-
-#endif /* AGS_LIB_FREETYPE_AHERRORS_H */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahmodule.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahmodule.cpp
deleted file mode 100644
index cc3f9fc07a2..00000000000
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahmodule.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/***************************************************************************/
-/* */
-/* ahmodule.c */
-/* */
-/* Auto-hinting module implementation (declaration). */
-/* */
-/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
-/* Author: David Turner */
-/* */
-/* This file is part of the Catharon Typography Project and shall only */
-/* be used, modified, and distributed under the terms of the Catharon */
-/* Open Source License that should come with this file under the name */
-/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/* Note that this license is compatible with the FreeType license. */
-/* */
-/***************************************************************************/
-
-
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/ftmodule.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahhint.h"
-
-namespace AGS3 {
-namespace FreeType213 {
-
-
-#ifdef DEBUG_HINTER
-AH_Hinter ah_debug_hinter = NULL;
-FT_Bool ah_debug_disable_horz = 0;
-FT_Bool ah_debug_disable_vert = 0;
-#endif
-
-typedef struct FT_AutoHinterRec_ {
- FT_ModuleRec root;
- AH_Hinter hinter;
-} FT_AutoHinterRec;
-
-FT_CALLBACK_DEF(FT_Error)
-ft_autohinter_init(FT_AutoHinter module) {
- FT_Error error;
-
- error = ah_hinter_new(module->root.library, &module->hinter);
-#ifdef DEBUG_HINTER
- if (!error)
- ah_debug_hinter = module->hinter;
-#endif
- return error;
-}
-
-FT_CALLBACK_DEF(void)
-ft_autohinter_done(FT_AutoHinter module) {
- ah_hinter_done(module->hinter);
-
-#ifdef DEBUG_HINTER
- ah_debug_hinter = NULL;
-#endif
-}
-
-FT_CALLBACK_DEF(FT_Error)
-ft_autohinter_load_glyph(FT_AutoHinter module, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags) {
- return ah_hinter_load_glyph(module->hinter, slot, size, glyph_index, load_flags);
-}
-
-FT_CALLBACK_DEF(void)
-ft_autohinter_reset_globals(FT_AutoHinter module, FT_Face face) {
- FT_UNUSED(module);
-
- if (face->autohint.data)
- ah_hinter_done_face_globals((AH_Face_Globals)(face->autohint.data));
-}
-
-FT_CALLBACK_DEF(void)
-ft_autohinter_get_globals(FT_AutoHinter module, FT_Face face, void **global_hints, long *global_len) {
- ah_hinter_get_global_hints(module->hinter, face, global_hints, global_len);
-}
-
-FT_CALLBACK_DEF(void)
-ft_autohinter_done_globals(FT_AutoHinter module, void *global_hints) {
- ah_hinter_done_global_hints(module->hinter, global_hints);
-}
-
-FT_CALLBACK_TABLE_DEF
-const FT_AutoHinter_ServiceRec ft_autohinter_service = {
- ft_autohinter_reset_globals,
- ft_autohinter_get_globals,
- ft_autohinter_done_globals,
- ft_autohinter_load_glyph};
-
-FT_CALLBACK_TABLE_DEF
-const FT_Module_Class autohint_module_class = {
- ft_module_hinter,
- sizeof(FT_AutoHinterRec),
-
- "autohinter",
- 0x10000L, /* version 1.0 of the autohinter */
- 0x20000L, /* requires FreeType 2.0 or above */
-
- (const void *)&ft_autohinter_service,
-
- (FT_Module_Constructor)ft_autohinter_init,
- (FT_Module_Destructor)ft_autohinter_done,
- (FT_Module_Requester)0};
-
-
-} // End of namespace FreeType213
-} // End of namespace AGS3
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahmodule.h b/engines/ags/lib/freetype-2.1.3/autohint/ahmodule.h
deleted file mode 100644
index b6701655f15..00000000000
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahmodule.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/***************************************************************************/
-/* */
-/* ahmodule.h */
-/* */
-/* Auto-hinting module (declaration). */
-/* */
-/* Copyright 2000-2001 Catharon Productions Inc. */
-/* Author: David Turner */
-/* */
-/* This file is part of the Catharon Typography Project and shall only */
-/* be used, modified, and distributed under the terms of the Catharon */
-/* Open Source License that should come with this file under the name */
-/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/* Note that this license is compatible with the FreeType license. */
-/* */
-/***************************************************************************/
-
-
-#ifndef AGS_LIB_FREETYPE_AHMODULE_H
-#define AGS_LIB_FREETYPE_AHMODULE_H
-
-
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/ftmodule.h"
-
-namespace AGS3 {
-namespace FreeType213 {
-
-// FT_BEGIN_HEADER
-
-
-FT_CALLBACK_TABLE
-const FT_Module_Class autohint_module_class;
-
-
-// FT_END_HEADER
-
-} // End of namespace FreeType213
-} // End of namespace AGS3
-
-#endif /* AGS_LIB_FREETYPE_AHMODULE_H */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahoptim.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahoptim.cpp
deleted file mode 100644
index 66c65463335..00000000000
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahoptim.cpp
+++ /dev/null
@@ -1,848 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/***************************************************************************/
-/* */
-/* ahoptim.c */
-/* */
-/* FreeType auto hinting outline optimization (body). */
-/* */
-/* Copyright 2000-2001, 2002 Catharon Productions Inc. */
-/* Author: David Turner */
-/* */
-/* This file is part of the Catharon Typography Project and shall only */
-/* be used, modified, and distributed under the terms of the Catharon */
-/* Open Source License that should come with this file under the name */
-/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/* Note that this license is compatible with the FreeType license. */
-/* */
-/***************************************************************************/
-
-
-/*************************************************************************/
-/* */
-/* This module is in charge of optimising the outlines produced by the */
-/* auto-hinter in direct mode. This is required at small pixel sizes in */
-/* order to ensure coherent spacing, among other things.. */
-/* */
-/* The technique used in this module is a simplified simulated */
-/* annealing. */
-/* */
-/*************************************************************************/
-
-
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/ftobjs.h" /* for FT_ALLOC_ARRAY() and FT_FREE() */
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahoptim.h"
-
-
-/* define this macro to use brute force optimization -- this is slow, */
-/* but a good way to perfect the distortion function `by hand' through */
-/* tweaking */
-#define AH_BRUTE_FORCE
-
-
-#define xxxAH_DEBUG_OPTIM
-
-
-#undef LOG
-#ifdef AH_DEBUG_OPTIM
-
-#define LOG( x ) optim_log ## x
-
-#else
-
-#define LOG( x )
-
-#endif /* AH_DEBUG_OPTIM */
-
-namespace AGS3 {
-namespace FreeType213 {
-
-#ifdef AH_DEBUG_OPTIM
-
-#include <stdarg.h>
-#include <stdlib.h>
-
-#define FLOAT( x ) ( (float)( (x) / 64.0 ) )
-
-
-static void
-optim_log( const char* fmt, ... ) {
- va_list ap;
-
-
- va_start( ap, fmt );
- vprintf( fmt, ap );
- va_end( ap );
-}
-
-
-static void
-AH_Dump_Stems( AH_Optimizer* optimizer ) {
- int n;
- AH_Stem* stem;
-
-
- stem = optimizer->stems;
- for ( n = 0; n < optimizer->num_stems; n++, stem++ ) {
- LOG(( " %c%2d [%.1f:%.1f]={%.1f:%.1f}="
- "<%1.f..%1.f> force=%.1f speed=%.1f\n",
- optimizer->vertical ? 'V' : 'H', n,
- FLOAT( stem->edge1->opos ), FLOAT( stem->edge2->opos ),
- FLOAT( stem->edge1->pos ), FLOAT( stem->edge2->pos ),
- FLOAT( stem->min_pos ), FLOAT( stem->max_pos ),
- FLOAT( stem->force ), FLOAT( stem->velocity ) ));
- }
-}
-
-
-static void
-AH_Dump_Stems2( AH_Optimizer* optimizer ) {
- int n;
- AH_Stem* stem;
-
-
- stem = optimizer->stems;
- for ( n = 0; n < optimizer->num_stems; n++, stem++ ) {
- LOG(( " %c%2d [%.1f]=<%1.f..%1.f> force=%.1f speed=%.1f\n",
- optimizer->vertical ? 'V' : 'H', n,
- FLOAT( stem->pos ),
- FLOAT( stem->min_pos ), FLOAT( stem->max_pos ),
- FLOAT( stem->force ), FLOAT( stem->velocity ) ));
- }
-}
-
-
-static void
-AH_Dump_Springs( AH_Optimizer* optimizer ) {
- int n;
- AH_Spring* spring;
- AH_Stem* stems;
-
-
- spring = optimizer->springs;
- stems = optimizer->stems;
- LOG(( "%cSprings ", optimizer->vertical ? 'V' : 'H' ));
-
- for ( n = 0; n < optimizer->num_springs; n++, spring++ ) {
- LOG(( " [%d-%d:%.1f:%1.f:%.1f]",
- spring->stem1 - stems, spring->stem2 - stems,
- FLOAT( spring->owidth ),
- FLOAT( spring->stem2->pos -
- ( spring->stem1->pos + spring->stem1->width ) ),
- FLOAT( spring->tension ) ));
- }
-
- LOG(( "\n" ));
-}
-
-#endif /* AH_DEBUG_OPTIM */
-
-
-/*************************************************************************/
-/*************************************************************************/
-/*************************************************************************/
-/**** ****/
-/**** COMPUTE STEMS AND SPRINGS IN AN OUTLINE ****/
-/**** ****/
-/*************************************************************************/
-/*************************************************************************/
-/*************************************************************************/
-
-
-static int
-valid_stem_segments( AH_Segment seg1,
- AH_Segment seg2 ) {
- return seg1->serif == 0 &&
- seg2 &&
- seg2->link == seg1 &&
- seg1->pos < seg2->pos &&
- seg1->min_coord <= seg2->max_coord &&
- seg2->min_coord <= seg1->max_coord;
-}
-
-
-/* compute all stems in an outline */
-static int
-optim_compute_stems( AH_Optimizer* optimizer ) {
- AH_Outline outline = optimizer->outline;
- FT_Fixed scale;
- FT_Memory memory = optimizer->memory;
- FT_Error error = 0;
- FT_Int dimension;
- AH_Edge edges;
- AH_Edge edge_limit;
- AH_Stem** p_stems;
- FT_Int* p_num_stems;
-
-
- edges = outline->horz_edges;
- edge_limit = edges + outline->num_hedges;
- scale = outline->y_scale;
-
- p_stems = &optimizer->horz_stems;
- p_num_stems = &optimizer->num_hstems;
-
- for ( dimension = 1; dimension >= 0; dimension-- ) {
- AH_Stem* stems = 0;
- FT_Int num_stems = 0;
- AH_Edge edge;
-
-
- /* first of all, count the number of stems in this direction */
- for ( edge = edges; edge < edge_limit; edge++ ) {
- AH_Segment seg = edge->first;
-
-
- do {
- if (valid_stem_segments( seg, seg->link ) )
- num_stems++;
-
- seg = seg->edge_next;
-
- } while ( seg != edge->first );
- }
-
- /* now allocate the stems and build their table */
- if ( num_stems > 0 ) {
- AH_Stem* stem;
-
-
- if ( FT_NEW_ARRAY( stems, num_stems ) )
- goto Exit;
-
- stem = stems;
- for ( edge = edges; edge < edge_limit; edge++ ) {
- AH_Segment seg = edge->first;
- AH_Segment seg2;
-
-
- do {
- seg2 = seg->link;
- if ( valid_stem_segments( seg, seg2 ) ) {
- AH_Edge edge1 = seg->edge;
- AH_Edge edge2 = seg2->edge;
-
-
- stem->edge1 = edge1;
- stem->edge2 = edge2;
- stem->opos = edge1->opos;
- stem->pos = edge1->pos;
- stem->owidth = edge2->opos - edge1->opos;
- stem->width = edge2->pos - edge1->pos;
-
- /* compute min_coord and max_coord */
- {
- FT_Pos min_coord = seg->min_coord;
- FT_Pos max_coord = seg->max_coord;
-
-
- if ( seg2->min_coord > min_coord )
- min_coord = seg2->min_coord;
-
- if ( seg2->max_coord < max_coord )
- max_coord = seg2->max_coord;
-
- stem->min_coord = min_coord;
- stem->max_coord = max_coord;
- }
-
- /* compute minimum and maximum positions for stem -- */
- /* note that the left-most/bottom-most stem has always */
- /* a fixed position */
- if ( stem == stems || edge1->blue_edge || edge2->blue_edge ) {
- /* this stem cannot move; it is snapped to a blue edge */
- stem->min_pos = stem->pos;
- stem->max_pos = stem->pos;
- } else {
- /* this edge can move; compute its min and max positions */
- FT_Pos pos1 = stem->opos;
- FT_Pos pos2 = pos1 + stem->owidth - stem->width;
- FT_Pos min1 = pos1 & -64;
- FT_Pos min2 = pos2 & -64;
-
-
- stem->min_pos = min1;
- stem->max_pos = min1 + 64;
- if ( min2 < min1 )
- stem->min_pos = min2;
- else
- stem->max_pos = min2 + 64;
-
- /* XXX: just to see what it does */
- stem->max_pos += 64;
-
- /* just for the case where direct hinting did some */
- /* incredible things (e.g. blue edge shifts) */
- if ( stem->min_pos > stem->pos )
- stem->min_pos = stem->pos;
-
- if ( stem->max_pos < stem->pos )
- stem->max_pos = stem->pos;
- }
-
- stem->velocity = 0;
- stem->force = 0;
-
- stem++;
- }
- seg = seg->edge_next;
-
- } while ( seg != edge->first );
- }
- }
-
- *p_stems = stems;
- *p_num_stems = num_stems;
-
- edges = outline->vert_edges;
- edge_limit = edges + outline->num_vedges;
- scale = outline->x_scale;
-
- p_stems = &optimizer->vert_stems;
- p_num_stems = &optimizer->num_vstems;
- }
-
-Exit:
-
-#ifdef AH_DEBUG_OPTIM
- AH_Dump_Stems( optimizer );
-#endif
-
- return error;
-}
-
-
-/* returns the spring area between two stems, 0 if none */
-static FT_Pos
-stem_spring_area( AH_Stem* stem1,
- AH_Stem* stem2 ) {
- FT_Pos area1 = stem1->max_coord - stem1->min_coord;
- FT_Pos area2 = stem2->max_coord - stem2->min_coord;
- FT_Pos min = stem1->min_coord;
- FT_Pos max = stem1->max_coord;
- FT_Pos area;
-
-
- /* order stems */
- if ( stem2->opos <= stem1->opos + stem1->owidth )
- return 0;
-
- if ( min < stem2->min_coord )
- min = stem2->min_coord;
-
- if ( max < stem2->max_coord )
- max = stem2->max_coord;
-
- area = ( max-min );
- if ( 2 * area < area1 && 2 * area < area2 )
- area = 0;
-
- return area;
-}
-
-
-/* compute all springs in an outline */
-static int
-optim_compute_springs( AH_Optimizer* optimizer ) {
- /* basically, a spring exists between two stems if most of their */
- /* surface is aligned */
- FT_Memory memory = optimizer->memory;
-
- AH_Stem* stems;
- AH_Stem* stem_limit;
- AH_Stem* stem;
- int dimension;
- int error = 0;
-
- FT_Int* p_num_springs;
- AH_Spring** p_springs;
-
-
- stems = optimizer->horz_stems;
- stem_limit = stems + optimizer->num_hstems;
-
- p_springs = &optimizer->horz_springs;
- p_num_springs = &optimizer->num_hsprings;
-
- for ( dimension = 1; dimension >= 0; dimension-- ) {
- FT_Int num_springs = 0;
- AH_Spring* springs = 0;
-
-
- /* first of all, count stem springs */
- for ( stem = stems; stem + 1 < stem_limit; stem++ ) {
- AH_Stem* stem2;
-
-
- for ( stem2 = stem+1; stem2 < stem_limit; stem2++ )
- if ( stem_spring_area( stem, stem2 ) )
- num_springs++;
- }
-
- /* then allocate and build the springs table */
- if ( num_springs > 0 ) {
- AH_Spring* spring;
-
-
- /* allocate table of springs */
- if ( FT_NEW_ARRAY( springs, num_springs ) )
- goto Exit;
-
- /* fill the springs table */
- spring = springs;
- for ( stem = stems; stem+1 < stem_limit; stem++ ) {
- AH_Stem* stem2;
- FT_Pos area;
-
-
- for ( stem2 = stem + 1; stem2 < stem_limit; stem2++ ) {
- area = stem_spring_area( stem, stem2 );
- if ( area ) {
- /* add a new spring here */
- spring->stem1 = stem;
- spring->stem2 = stem2;
- spring->owidth = stem2->opos - ( stem->opos + stem->owidth );
- spring->tension = 0;
-
- spring++;
- }
- }
- }
- }
- *p_num_springs = num_springs;
- *p_springs = springs;
-
- stems = optimizer->vert_stems;
- stem_limit = stems + optimizer->num_vstems;
-
- p_springs = &optimizer->vert_springs;
- p_num_springs = &optimizer->num_vsprings;
- }
-
-Exit:
-
-#ifdef AH_DEBUG_OPTIM
- AH_Dump_Springs( optimizer );
-#endif
-
- return error;
-}
-
-
-/*************************************************************************/
-/*************************************************************************/
-/*************************************************************************/
-/**** ****/
-/**** OPTIMIZE THROUGH MY STRANGE SIMULATED ANNEALING ALGO ;-) ****/
-/**** ****/
-/*************************************************************************/
-/*************************************************************************/
-/*************************************************************************/
-
-#ifndef AH_BRUTE_FORCE
-
-/* compute all spring tensions */
-static void
-optim_compute_tensions( AH_Optimizer* optimizer ) {
- AH_Spring* spring = optimizer->springs;
- AH_Spring* limit = spring + optimizer->num_springs;
-
-
- for ( ; spring < limit; spring++ ) {
- AH_Stem* stem1 = spring->stem1;
- AH_Stem* stem2 = spring->stem2;
- FT_Int status;
-
- FT_Pos width;
- FT_Pos tension;
- FT_Pos sign;
-
-
- /* compute the tension; it simply is -K*(new_width-old_width) */
- width = stem2->pos - ( stem1->pos + stem1->width );
- tension = width - spring->owidth;
-
- sign = 1;
- if ( tension < 0 ) {
- sign = -1;
- tension = -tension;
- }
-
- if ( width <= 0 )
- tension = 32000;
- else
- tension = ( tension << 10 ) / width;
-
- tension = -sign * FT_MulFix( tension, optimizer->tension_scale );
- spring->tension = tension;
-
- /* now, distribute tension among the englobing stems, if they */
- /* are able to move */
- status = 0;
- if ( stem1->pos <= stem1->min_pos )
- status |= 1;
- if ( stem2->pos >= stem2->max_pos )
- status |= 2;
-
- if ( !status )
- tension /= 2;
-
- if ( ( status & 1 ) == 0 )
- stem1->force -= tension;
-
- if ( ( status & 2 ) == 0 )
- stem2->force += tension;
- }
-}
-
-
-/* compute all stem movements -- returns 0 if nothing moved */
-static int
-optim_compute_stem_movements( AH_Optimizer* optimizer ) {
- AH_Stem* stems = optimizer->stems;
- AH_Stem* limit = stems + optimizer->num_stems;
- AH_Stem* stem = stems;
- int moved = 0;
-
-
- /* set initial forces to velocity */
- for ( stem = stems; stem < limit; stem++ ) {
- stem->force = stem->velocity;
- stem->velocity /= 2; /* XXX: Heuristics */
- }
-
- /* compute the sum of forces applied on each stem */
- optim_compute_tensions( optimizer );
-
-#ifdef AH_DEBUG_OPTIM
- AH_Dump_Springs( optimizer );
- AH_Dump_Stems2( optimizer );
-#endif
-
- /* now, see whether something can move */
- for ( stem = stems; stem < limit; stem++ ) {
- if ( stem->force > optimizer->tension_threshold ) {
- /* there is enough tension to move the stem to the right */
- if ( stem->pos < stem->max_pos ) {
- stem->pos += 64;
- stem->velocity = stem->force / 2;
- moved = 1;
- } else
- stem->velocity = 0;
- } else if ( stem->force < optimizer->tension_threshold ) {
- /* there is enough tension to move the stem to the left */
- if ( stem->pos > stem->min_pos ) {
- stem->pos -= 64;
- stem->velocity = stem->force / 2;
- moved = 1;
- } else
- stem->velocity = 0;
- }
- }
-
- /* return 0 if nothing moved */
- return moved;
-}
-
-#endif /* AH_BRUTE_FORCE */
-
-
-/* compute current global distortion from springs */
-static FT_Pos
-optim_compute_distortion( AH_Optimizer* optimizer ) {
- AH_Spring* spring = optimizer->springs;
- AH_Spring* limit = spring + optimizer->num_springs;
- FT_Pos distortion = 0;
-
-
- for ( ; spring < limit; spring++ ) {
- AH_Stem* stem1 = spring->stem1;
- AH_Stem* stem2 = spring->stem2;
- FT_Pos width;
-
- width = stem2->pos - ( stem1->pos + stem1->width );
- width -= spring->owidth;
- if ( width < 0 )
- width = -width;
-
- distortion += width;
- }
-
- return distortion;
-}
-
-
-/* record stems configuration in `best of' history */
-static void
-optim_record_configuration( AH_Optimizer* optimizer ) {
- FT_Pos distortion;
- AH_Configuration* configs = optimizer->configs;
- AH_Configuration* limit = configs + optimizer->num_configs;
- AH_Configuration* config;
-
-
- distortion = optim_compute_distortion( optimizer );
- LOG(( "config distortion = %.1f ", FLOAT( distortion * 64 ) ));
-
- /* check that we really need to add this configuration to our */
- /* sorted history */
- if ( limit > configs && limit[-1].distortion < distortion ) {
- LOG(( "ejected\n" ));
- return;
- }
-
- /* add new configuration at the end of the table */
- {
- int n;
-
-
- config = limit;
- if ( optimizer->num_configs < AH_MAX_CONFIGS )
- optimizer->num_configs++;
- else
- config--;
-
- config->distortion = distortion;
-
- for ( n = 0; n < optimizer->num_stems; n++ )
- config->positions[n] = optimizer->stems[n].pos;
- }
-
- /* move the current configuration towards the front of the list */
- /* when necessary -- yes this is slow bubble sort ;-) */
- while ( config > configs && config[0].distortion < config[-1].distortion ) {
- AH_Configuration temp;
-
-
- config--;
- temp = config[0];
- config[0] = config[1];
- config[1] = temp;
- }
- LOG(( "recorded!\n" ));
-}
-
-
-#ifdef AH_BRUTE_FORCE
-
-/* optimize outline in a single direction */
-static void
-optim_compute( AH_Optimizer* optimizer ) {
- int n;
- FT_Bool moved;
-
- AH_Stem* stem = optimizer->stems;
- AH_Stem* limit = stem + optimizer->num_stems;
-
-
- /* empty, exit */
- if ( stem >= limit )
- return;
-
- optimizer->num_configs = 0;
-
- stem = optimizer->stems;
- for ( ; stem < limit; stem++ )
- stem->pos = stem->min_pos;
-
- do {
- /* record current configuration */
- optim_record_configuration( optimizer );
-
- /* now change configuration */
- moved = 0;
- for ( stem = optimizer->stems; stem < limit; stem++ ) {
- if ( stem->pos < stem->max_pos ) {
- stem->pos += 64;
- moved = 1;
- break;
- }
-
- stem->pos = stem->min_pos;
- }
- } while ( moved );
-
- /* now, set the best stem positions */
- for ( n = 0; n < optimizer->num_stems; n++ ) {
- AH_Stem* stem = optimizer->stems + n;
- FT_Pos pos = optimizer->configs[0].positions[n];
-
-
- stem->edge1->pos = pos;
- stem->edge2->pos = pos + stem->width;
-
- stem->edge1->flags |= AH_EDGE_DONE;
- stem->edge2->flags |= AH_EDGE_DONE;
- }
-}
-
-#else /* AH_BRUTE_FORCE */
-
-/* optimize outline in a single direction */
-static void
-optim_compute( AH_Optimizer* optimizer ) {
- int n, counter, counter2;
-
-
- optimizer->num_configs = 0;
- optimizer->tension_scale = 0x80000L;
- optimizer->tension_threshold = 64;
-
- /* record initial configuration threshold */
- optim_record_configuration( optimizer );
-
- counter = 0;
- for ( counter2 = optimizer->num_stems*8; counter2 >= 0; counter2-- ) {
- if ( counter == 0 )
- counter = 2 * optimizer->num_stems;
-
- if ( !optim_compute_stem_movements( optimizer ) )
- break;
-
- optim_record_configuration( optimizer );
-
- counter--;
- if ( counter == 0 )
- optimizer->tension_scale /= 2;
- }
-
- /* now, set the best stem positions */
- for ( n = 0; n < optimizer->num_stems; n++ ) {
- AH_Stem* stem = optimizer->stems + n;
- FT_Pos pos = optimizer->configs[0].positions[n];
-
-
- stem->edge1->pos = pos;
- stem->edge2->pos = pos + stem->width;
-
- stem->edge1->flags |= AH_EDGE_DONE;
- stem->edge2->flags |= AH_EDGE_DONE;
- }
-}
-
-#endif /* AH_BRUTE_FORCE */
-
-
-/*************************************************************************/
-/*************************************************************************/
-/*************************************************************************/
-/**** ****/
-/**** HIGH-LEVEL OPTIMIZER API ****/
-/**** ****/
-/*************************************************************************/
-/*************************************************************************/
-/*************************************************************************/
-
-
-/* releases the optimization data */
-void
-AH_Optimizer_Done( AH_Optimizer* optimizer ) {
- if ( optimizer ) {
- FT_Memory memory = optimizer->memory;
-
-
- FT_FREE( optimizer->horz_stems );
- FT_FREE( optimizer->vert_stems );
- FT_FREE( optimizer->horz_springs );
- FT_FREE( optimizer->vert_springs );
- FT_FREE( optimizer->positions );
- }
-}
-
-
-/* loads the outline into the optimizer */
-int
-AH_Optimizer_Init( AH_Optimizer* optimizer,
- AH_Outline outline,
- FT_Memory memory ) {
- FT_Error error;
-
-
- FT_MEM_ZERO( optimizer, sizeof ( *optimizer ) );
- optimizer->outline = outline;
- optimizer->memory = memory;
-
- LOG(( "initializing new optimizer\n" ));
- /* compute stems and springs */
- error = optim_compute_stems ( optimizer ) ||
- optim_compute_springs( optimizer );
- if ( error )
- goto Fail;
-
- /* allocate stem positions history and configurations */
- {
- int n, max_stems;
-
-
- max_stems = optimizer->num_hstems;
- if ( max_stems < optimizer->num_vstems )
- max_stems = optimizer->num_vstems;
-
- if ( FT_NEW_ARRAY( optimizer->positions, max_stems * AH_MAX_CONFIGS ) )
- goto Fail;
-
- optimizer->num_configs = 0;
- for ( n = 0; n < AH_MAX_CONFIGS; n++ )
- optimizer->configs[n].positions = optimizer->positions +
- n * max_stems;
- }
-
- return error;
-
-Fail:
- AH_Optimizer_Done( optimizer );
- return error;
-}
-
-
-/* compute optimal outline */
-void
-AH_Optimizer_Compute( AH_Optimizer* optimizer ) {
- optimizer->num_stems = optimizer->num_hstems;
- optimizer->stems = optimizer->horz_stems;
- optimizer->num_springs = optimizer->num_hsprings;
- optimizer->springs = optimizer->horz_springs;
-
- if ( optimizer->num_springs > 0 ) {
- LOG(( "horizontal optimization ------------------------\n" ));
- optim_compute( optimizer );
- }
-
- optimizer->num_stems = optimizer->num_vstems;
- optimizer->stems = optimizer->vert_stems;
- optimizer->num_springs = optimizer->num_vsprings;
- optimizer->springs = optimizer->vert_springs;
-
- if ( optimizer->num_springs ) {
- LOG(( "vertical optimization --------------------------\n" ));
- optim_compute( optimizer );
- }
-}
-
-} // End of namespace FreeType213
-} // End of namespace AGS3
-
-/* END */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahoptim.h b/engines/ags/lib/freetype-2.1.3/autohint/ahoptim.h
deleted file mode 100644
index 9e1712047b1..00000000000
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahoptim.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/***************************************************************************/
-/* */
-/* ahoptim.h */
-/* */
-/* FreeType auto hinting outline optimization (declaration). */
-/* */
-/* Copyright 2000-2001 Catharon Productions Inc. */
-/* Author: David Turner */
-/* */
-/* This file is part of the Catharon Typography Project and shall only */
-/* be used, modified, and distributed under the terms of the Catharon */
-/* Open Source License that should come with this file under the name */
-/* `CatharonLicense.txt'. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/* Note that this license is compatible with the FreeType license. */
-/* */
-/***************************************************************************/
-
-
-#ifndef AGS_LIB_FREETYPE_AHOPTIM_H
-#define AGS_LIB_FREETYPE_AHOPTIM_H
-
-
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/modules/autohint/ahtypes.h"
-
-namespace AGS3 {
-namespace FreeType213 {
-
-// FT_BEGIN_HEADER
-
-
-/* the maximal number of stem configurations to record */
-/* during optimization */
-#define AH_MAX_CONFIGS 8
-
-
-typedef struct AH_Stem_ {
- FT_Pos pos; /* current position */
- FT_Pos velocity; /* current velocity */
- FT_Pos force; /* sum of current forces */
- FT_Pos width; /* normalized width */
-
- FT_Pos min_pos; /* minimum grid position */
- FT_Pos max_pos; /* maximum grid position */
-
- AH_Edge edge1; /* left/bottom edge */
- AH_Edge edge2; /* right/top edge */
-
- FT_Pos opos; /* original position */
- FT_Pos owidth; /* original width */
-
- FT_Pos min_coord; /* minimum coordinate */
- FT_Pos max_coord; /* maximum coordinate */
-} AH_Stem;
-
-
-/* A spring between two stems */
-typedef struct AH_Spring_ {
- AH_Stem *stem1;
- AH_Stem *stem2;
- FT_Pos owidth; /* original width */
- FT_Pos tension; /* current tension */
-} AH_Spring;
-
-
-/* A configuration records the position of each stem at a given time */
-/* as well as the associated distortion */
-typedef struct AH_Configuration_ {
- FT_Pos *positions;
- FT_Long distortion;
-} AH_Configuration;
-
-
-typedef struct AH_Optimizer_ {
- FT_Memory memory;
- AH_Outline outline;
-
- FT_Int num_hstems;
- AH_Stem *horz_stems;
-
- FT_Int num_vstems;
- AH_Stem *vert_stems;
-
- FT_Int num_hsprings;
- FT_Int num_vsprings;
- AH_Spring *horz_springs;
- AH_Spring *vert_springs;
-
- FT_Int num_configs;
- AH_Configuration configs[AH_MAX_CONFIGS];
- FT_Pos *positions;
-
- /* during each pass, use these instead */
- FT_Int num_stems;
- AH_Stem *stems;
-
- FT_Int num_springs;
- AH_Spring *springs;
- FT_Bool vertical;
-
- FT_Fixed tension_scale;
- FT_Pos tension_threshold;
-} AH_Optimizer;
-
-
-/* loads the outline into the optimizer */
-int AH_Optimizer_Init(AH_Optimizer *optimizer, AH_Outline outline, FT_Memory memory);
-
-/* compute optimal outline */
-void AH_Optimizer_Compute(AH_Optimizer *optimizer);
-
-/* release the optimization data */
-void AH_Optimizer_Done(AH_Optimizer *optimizer);
-
-
-// FT_END_HEADER
-
-} // End of namespace FreeType213
-} // End of namespace AGS3
-
-#endif /* AGS_LIB_FREETYPE_AHOPTIM_H */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/autohint.h b/engines/ags/lib/freetype-2.1.3/autohint/autohint.h
deleted file mode 100644
index 5b6797f0d7a..00000000000
--- a/engines/ags/lib/freetype-2.1.3/autohint/autohint.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/***************************************************************************/
-/* */
-/* autohint.h */
-/* */
-/* High-level `autohint' module-specific interface (specification). */
-/* */
-/* Copyright 1996-2001, 2002 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 auto-hinter is used to load and automatically hint glyphs if a */
-/* format-specific hinter isn't available. */
-/* */
-/*************************************************************************/
-
-
-#ifndef AGS_LIB_FREETYPE_AUTOHINT_H
-#define AGS_LIB_FREETYPE_AUTOHINT_H
-
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/freetype.h"
-
-namespace AGS3 {
-namespace FreeType213 {
-
-// FT_BEGIN_HEADER
-
-
-typedef struct FT_AutoHinterRec_ *FT_AutoHinter;
-typedef void (*FT_AutoHinter_GlobalGetFunc)(FT_AutoHinter hinter, FT_Face face, void **global_hints, long *global_len);
-typedef void (*FT_AutoHinter_GlobalDoneFunc)(FT_AutoHinter hinter, void *global);
-typedef void (*FT_AutoHinter_GlobalResetFunc)(FT_AutoHinter hinter, FT_Face face);
-typedef FT_Error (*FT_AutoHinter_GlyphLoadFunc)(FT_AutoHinter hinter, FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags);
-
-typedef struct FT_AutoHinter_ServiceRec_ {
- FT_AutoHinter_GlobalResetFunc reset_face;
- FT_AutoHinter_GlobalGetFunc get_global_hints;
- FT_AutoHinter_GlobalDoneFunc done_global_hints;
- FT_AutoHinter_GlyphLoadFunc load_glyph;
-} FT_AutoHinter_ServiceRec, *FT_AutoHinter_Service;
-
-
-// FT_END_HEADER
-
-} // End of namespace FreeType213
-} // End of namespace AGS3
-
-#endif /* AGS_LIB_FREETYPE_AUTOHINT_H */
diff --git a/engines/ags/lib/freetype-2.1.3/freetype.h b/engines/ags/lib/freetype-2.1.3/freetype.h
deleted file mode 100644
index ef152c94ca3..00000000000
--- a/engines/ags/lib/freetype-2.1.3/freetype.h
+++ /dev/null
@@ -1,511 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/***************************************************************************/
-/* */
-/* freetype.h */
-/* */
-/* FreeType high-level API and common types (specification only). */
-/* */
-/* Copyright 1996-2001, 2002 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. */
-/* */
-/***************************************************************************/
-
-
-#ifndef AGS_LIB_FREETYPE_FREETYPE_H
-#define AGS_LIB_FREETYPE_FREETYPE_H
-
-
-/*************************************************************************/
-/* */
-/* The `raster' component duplicates some of the declarations in */
-/* freetype.h for stand-alone use if _FREETYPE_ isn't defined. */
-/* */
-
-
-/*************************************************************************/
-/* */
-/* The FREETYPE_MAJOR and FREETYPE_MINOR macros are used to version the */
-/* new FreeType design, which is able to host several kinds of font */
-/* drivers. It starts at 2.0. */
-/* */
-#define FREETYPE213_MAJOR 2
-#define FREETYPE213_MINOR 1
-#define FREETYPE213_PATCH 3
-
-
-#include "engines/ags/lib/freetype-2.1.3/ft213build.h"
-#include "engines/ags/lib/freetype-2.1.3/config/ftconfig.h"
-#include "engines/ags/lib/freetype-2.1.3/fterrors.h"
-#include "engines/ags/lib/freetype-2.1.3/fttypes.h"
-
-namespace AGS3 {
-namespace FreeType213 {
-
-// FT_BEGIN_HEADER
-
-typedef struct FT_Glyph_Metrics_ {
- FT_Pos width; /* glyph width */
- FT_Pos height; /* glyph height */
-
- FT_Pos horiBearingX; /* left side bearing in horizontal layouts */
- FT_Pos horiBearingY; /* top side bearing in horizontal layouts */
- FT_Pos horiAdvance; /* advance width for horizontal layout */
-
- FT_Pos vertBearingX; /* left side bearing in vertical layouts */
- FT_Pos vertBearingY; /* top side bearing in vertical layouts */
- FT_Pos vertAdvance; /* advance height for vertical layout */
-} FT_Glyph_Metrics;
-
-typedef struct FT_Bitmap_Size_ {
- FT_Short height;
- FT_Short width;
-} FT_Bitmap_Size;
-
-
-typedef struct FT_LibraryRec_ *FT_Library;
-typedef struct FT_ModuleRec_ *FT_Module;
-typedef struct FT_DriverRec_ *FT_Driver;
-typedef struct FT_RendererRec_ *FT_Renderer;
-typedef struct FT_FaceRec_ *FT_Face;
-typedef struct FT_SizeRec_ *FT_Size;
-typedef struct FT_GlyphSlotRec_ *FT_GlyphSlot;
-typedef struct FT_CharMapRec_ *FT_CharMap;
-
-
-#ifndef FT_ENC_TAG
-#define FT_ENC_TAG(value, a, b, c, d) \
- value = (((FT_UInt32)(a) << 24) | \
- ((FT_UInt32)(b) << 16) | \
- ((FT_UInt32)(c) << 8) | \
- (FT_UInt32)(d))
-#endif
-
-
-typedef enum FT_Encoding_ {
- FT_ENC_TAG(FT_ENCODING_NONE, 0, 0, 0, 0),
-
- FT_ENC_TAG(FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b'),
- FT_ENC_TAG(FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c'),
-
- FT_ENC_TAG(FT_ENCODING_MS_SJIS, 's', 'j', 'i', 's'),
- FT_ENC_TAG(FT_ENCODING_MS_GB2312, 'g', 'b', ' ', ' '),
- FT_ENC_TAG(FT_ENCODING_MS_BIG5, 'b', 'i', 'g', '5'),
- FT_ENC_TAG(FT_ENCODING_MS_WANSUNG, 'w', 'a', 'n', 's'),
- FT_ENC_TAG(FT_ENCODING_MS_JOHAB, 'j', 'o', 'h', 'a'),
-
- FT_ENC_TAG(FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B'),
- FT_ENC_TAG(FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E'),
- FT_ENC_TAG(FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C'),
- FT_ENC_TAG(FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1'),
-
- FT_ENC_TAG(FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2'),
-
- FT_ENC_TAG(FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n')
-} FT_Encoding;
-
-/* These constants are deprecated; use the corresponding @FT_Encoding */
-/* values instead. */
-#define ft_encoding_none FT_ENCODING_NONE
-#define ft_encoding_unicode FT_ENCODING_UNICODE
-#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
-#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
-#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
-#define ft_encoding_sjis FT_ENCODING_MS_SJIS
-#define ft_encoding_gb2312 FT_ENCODING_MS_GB2312
-#define ft_encoding_big5 FT_ENCODING_MS_BIG5
-#define ft_encoding_wansung FT_ENCODING_MS_WANSUNG
-#define ft_encoding_johab FT_ENCODING_MS_JOHAB
-
-#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
-#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
-#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
-#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
-
-
-typedef struct FT_CharMapRec_ {
- FT_Face face;
- FT_Encoding encoding;
- FT_UShort platform_id;
- FT_UShort encoding_id;
-} FT_CharMapRec;
-
-typedef struct FT_Face_InternalRec_ *FT_Face_Internal;
-
-typedef struct FT_FaceRec_ {
- FT_Long num_faces;
- FT_Long face_index;
-
- FT_Long face_flags;
- FT_Long style_flags;
-
- FT_Long num_glyphs;
-
- FT_String *family_name;
- FT_String *style_name;
-
- FT_Int num_fixed_sizes;
- FT_Bitmap_Size *available_sizes;
-
- FT_Int num_charmaps;
- FT_CharMap *charmaps;
-
- FT_Generic generic;
-
- /*# the following are only relevant to scalable outlines */
- FT_BBox bbox;
-
- FT_UShort units_per_EM;
- FT_Short ascender;
- FT_Short descender;
- FT_Short height;
-
- FT_Short max_advance_width;
- FT_Short max_advance_height;
-
- FT_Short underline_position;
- FT_Short underline_thickness;
-
- FT_GlyphSlot glyph;
- FT_Size size;
- FT_CharMap charmap;
-
- /*@private begin */
-
- FT_Driver driver;
- FT_Memory memory;
- FT_Stream stream;
-
- FT_ListRec sizes_list;
-
- FT_Generic autohint;
- void *extensions;
-
- FT_Face_Internal internal;
-
- /*@private end */
-
-} FT_FaceRec;
-
-
-#define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
-#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
-#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
-#define FT_FACE_FLAG_SFNT ( 1L << 3 )
-#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
-#define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
-#define FT_FACE_FLAG_KERNING ( 1L << 6 )
-#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
-#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
-#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
-#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
-
-#define FT_HAS_HORIZONTAL(face) \
- (face->face_flags & FT_FACE_FLAG_HORIZONTAL)
-
-#define FT_HAS_VERTICAL(face) \
- (face->face_flags & FT_FACE_FLAG_VERTICAL)
-
-#define FT_HAS_KERNING(face) \
- (face->face_flags & FT_FACE_FLAG_KERNING)
-
-#define FT_IS_SCALABLE(face) \
- (face->face_flags & FT_FACE_FLAG_SCALABLE)
-
-#define FT_IS_SFNT(face) \
- (face->face_flags & FT_FACE_FLAG_SFNT)
-
-#define FT_IS_FIXED_WIDTH(face) \
- (face->face_flags & FT_FACE_FLAG_FIXED_WIDTH)
-
-#define FT_HAS_FIXED_SIZES(face) \
- (face->face_flags & FT_FACE_FLAG_FIXED_SIZES)
-
-#define FT_HAS_FAST_GLYPHS(face) \
- (face->face_flags & FT_FACE_FLAG_FAST_GLYPHS)
-
-#define FT_HAS_GLYPH_NAMES(face) \
- (face->face_flags & FT_FACE_FLAG_GLYPH_NAMES)
-
-#define FT_HAS_MULTIPLE_MASTERS(face) \
- (face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS)
-
-#define FT_STYLE_FLAG_ITALIC (1 << 0)
-#define FT_STYLE_FLAG_BOLD (1 << 1)
-
-
-typedef struct FT_Size_InternalRec_ *FT_Size_Internal;
-
-typedef struct FT_Size_Metrics_ {
- FT_UShort x_ppem; /* horizontal pixels per EM */
- FT_UShort y_ppem; /* vertical pixels per EM */
-
- FT_Fixed x_scale; /* two scales used to convert font units */
- FT_Fixed y_scale; /* to 26.6 frac. pixel coordinates.. */
-
- FT_Pos ascender; /* ascender in 26.6 frac. pixels */
- FT_Pos descender; /* descender in 26.6 frac. pixels */
- FT_Pos height; /* text height in 26.6 frac. pixels */
- FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
-} FT_Size_Metrics;
-
-typedef struct FT_SizeRec_ {
- FT_Face face; /* parent face object */
- FT_Generic generic; /* generic pointer for client uses */
- FT_Size_Metrics metrics; /* size metrics */
- FT_Size_Internal internal;
-} FT_SizeRec;
-
-typedef struct FT_SubGlyphRec_ *FT_SubGlyph;
-typedef struct FT_Slot_InternalRec_ *FT_Slot_Internal;
-
-typedef struct FT_GlyphSlotRec_ {
- FT_Library library;
- FT_Face face;
- FT_GlyphSlot next;
- FT_UInt flags;
- FT_Generic generic;
-
- FT_Glyph_Metrics metrics;
- FT_Fixed linearHoriAdvance;
- FT_Fixed linearVertAdvance;
- FT_Vector advance;
-
- FT_Glyph_Format format;
-
- FT_Bitmap bitmap;
- FT_Int bitmap_left;
- FT_Int bitmap_top;
-
- FT_Outline outline;
-
- FT_UInt num_subglyphs;
- FT_SubGlyph subglyphs;
-
- void *control_data;
- long control_len;
-
- void *other;
-
- FT_Slot_Internal internal;
-
-} FT_GlyphSlotRec;
-
-
-/*************************************************************************/
-/* F U N C T I O N S */
-/*************************************************************************/
-
-FT_EXPORT(FT_Error)
-FT_Init_FreeType(FT_Library *alibrary);
-
-FT_EXPORT(void)
-FT_Library_Version(FT_Library library, FT_Int *amajor, FT_Int *aminor, FT_Int *apatch);
-
-FT_EXPORT(FT_Error)
-FT_Done_FreeType(FT_Library library);
-
-
-typedef enum {
- FT_OPEN_MEMORY = 1,
- FT_OPEN_STREAM = 2,
- FT_OPEN_PATHNAME = 4,
- FT_OPEN_DRIVER = 8,
- FT_OPEN_PARAMS = 16
-} FT_Open_Flags;
-
-#define FT_OPEN_MEMORY FT_OPEN_MEMORY
-#define FT_OPEN_STREAM FT_OPEN_STREAM
-#define FT_OPEN_PATHNAME FT_OPEN_PATHNAME
-#define FT_OPEN_DRIVER FT_OPEN_DRIVER
-#define FT_OPEN_PARAMS FT_OPEN_PARAMS
-
-typedef struct FT_Parameter_ {
- FT_ULong tag;
- FT_Pointer data;
-} FT_Parameter;
-
-typedef struct FT_Open_Args_ {
- FT_Open_Flags flags;
- const FT_Byte *memory_base;
- FT_Long memory_size;
- FT_String *pathname;
- FT_Stream stream;
- FT_Module driver;
- FT_Int num_params;
- FT_Parameter *params;
-} FT_Open_Args;
-
-FT_EXPORT(FT_Error)
-FT_New_Face(FT_Library library, const char *filepathname, FT_Long face_index, FT_Face *aface);
-
-FT_EXPORT(FT_Error)
-FT_New_Memory_Face(FT_Library library, const FT_Byte *file_base, FT_Long file_size, FT_Long face_index, FT_Face *aface);
-
-FT_EXPORT(FT_Error)
-FT_Open_Face(FT_Library library, const FT_Open_Args *args, FT_Long face_index, FT_Face *aface);
-
-FT_EXPORT(FT_Error)
-FT_Attach_File(FT_Face face, const char *filepathname);
-
-FT_EXPORT(FT_Error)
-FT_Attach_Stream(FT_Face face, FT_Open_Args *parameters);
-
-FT_EXPORT(FT_Error)
-FT_Done_Face(FT_Face face);
-
-FT_EXPORT(FT_Error)
-FT_Set_Char_Size(FT_Face face, FT_F26Dot6 char_width, FT_F26Dot6 char_height, FT_UInt horz_resolution, FT_UInt vert_resolution);
-
-FT_EXPORT(FT_Error)
-FT_Set_Pixel_Sizes(FT_Face face, FT_UInt pixel_width, FT_UInt pixel_height);
-
-FT_EXPORT(FT_Error)
-FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags);
-
-FT_EXPORT(FT_Error)
-FT_Load_Char(FT_Face face, FT_ULong char_code, FT_Int32 load_flags);
-
-
-#define FT_LOAD_NO_SCALE 0x1
-#define FT_LOAD_NO_HINTING 0x2
-#define FT_LOAD_RENDER 0x4
-#define FT_LOAD_NO_BITMAP 0x8
-#define FT_LOAD_VERTICAL_LAYOUT 0x10
-#define FT_LOAD_FORCE_AUTOHINT 0x20
-#define FT_LOAD_CROP_BITMAP 0x40
-#define FT_LOAD_PEDANTIC 0x80
-#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 0x200
-#define FT_LOAD_NO_RECURSE 0x400
-#define FT_LOAD_IGNORE_TRANSFORM 0x800
-#define FT_LOAD_MONOCHROME 0x1000
-#define FT_LOAD_LINEAR_DESIGN 0x2000
-
-/* temporary hack! */
-#define FT_LOAD_SBITS_ONLY 0x4000
-#define FT_LOAD_NO_AUTOHINT 0x8000U
-
-#define FT_LOAD_TARGET_(x) ((FT_Int32)((x) & 15) << 16)
-#define FT_LOAD_TARGET_MODE(x) ((FT_Render_Mode)(((x) >> 16) & 15))
-
-#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_(FT_RENDER_MODE_NORMAL)
-#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_(FT_RENDER_MODE_LIGHT)
-#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_(FT_RENDER_MODE_MONO)
-#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_(FT_RENDER_MODE_LCD)
-#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_(FT_RENDER_MODE_LCD_V)
-
-#define FT_LOAD_DEFAULT 0x0
-
-FT_EXPORT(void)
-FT_Set_Transform(FT_Face face, FT_Matrix *matrix, FT_Vector *delta);
-
-typedef enum FT_Render_Mode_ {
- FT_RENDER_MODE_NORMAL = 0,
- FT_RENDER_MODE_LIGHT,
- FT_RENDER_MODE_MONO,
- FT_RENDER_MODE_LCD,
- FT_RENDER_MODE_LCD_V,
- FT_RENDER_MODE_MAX
-} FT_Render_Mode;
-
-/* These constats are deprecated. */
-#define ft_render_mode_normal FT_RENDER_MODE_NORMAL
-#define ft_render_mode_mono FT_RENDER_MODE_MONO
-
-FT_EXPORT(FT_Error)
-FT_Render_Glyph(FT_GlyphSlot slot, FT_Render_Mode render_mode);
-
-typedef enum FT_Kerning_Mode_ {
- FT_KERNING_DEFAULT = 0,
- FT_KERNING_UNFITTED,
- FT_KERNING_UNSCALED
-} FT_Kerning_Mode;
-
-/* These constats are deprecated. */
-#define ft_kerning_default FT_KERNING_DEFAULT
-#define ft_kerning_unfitted FT_KERNING_UNFITTED
-#define ft_kerning_unscaled FT_KERNING_UNSCALED
-
-FT_EXPORT(FT_Error)
-FT_Get_Kerning(FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph, FT_UInt kern_mode, FT_Vector *akerning);
-
-FT_EXPORT(FT_Error)
-FT_Get_Glyph_Name(FT_Face face, FT_UInt glyph_index, FT_Pointer buffer, FT_UInt buffer_max);
-
-FT_EXPORT(const char *)
-FT_Get_Postscript_Name(FT_Face face);
-
-FT_EXPORT(FT_Error)
-FT_Select_Charmap(FT_Face face, FT_Encoding encoding);
-
-FT_EXPORT(FT_Error)
-FT_Set_Charmap(FT_Face face, FT_CharMap charmap);
-
-FT_EXPORT(FT_UInt)
-FT_Get_Char_Index(FT_Face face, FT_ULong charcode);
-
-FT_EXPORT(FT_ULong)
-FT_Get_First_Char(FT_Face face, FT_UInt *agindex);
-
-FT_EXPORT(FT_ULong)
-FT_Get_Next_Char(FT_Face face, FT_ULong char_code, FT_UInt *agindex);
-
-FT_EXPORT(FT_UInt)
-FT_Get_Name_Index(FT_Face face, FT_String *glyph_name);
-
-
-/* COMPUTATIONS */
-
-FT_EXPORT(FT_Long)
-FT_MulDiv(FT_Long a, FT_Long b, FT_Long c);
-
-FT_EXPORT(FT_Long)
-FT_MulFix(FT_Long a, FT_Long b);
-
-FT_EXPORT(FT_Long)
-FT_DivFix(FT_Long a, FT_Long b);
-
-FT_EXPORT(FT_Fixed)
-FT_RoundFix(FT_Fixed a);
-
-FT_EXPORT(FT_Fixed)
-FT_CeilFix(FT_Fixed a);
-
-FT_EXPORT(FT_Fixed)
-FT_FloorFix(FT_Fixed a);
-
-FT_EXPORT(void)
-FT_Vector_Transform(FT_Vector *vec, FT_Matrix *matrix);
-
-
-// FT_END_HEADER
-
-} // End of namespace FreeType213
-} // End of namespace AGS3
-
-#endif /* AGS_LIB_FREETYPE_FREETYPE_H */
Commit: 1d7b00963853c3d352347136e56c57aff823b595
https://github.com/scummvm/scummvm/commit/1d7b00963853c3d352347136e56c57aff823b595
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Remove newline from warnings
Changed paths:
engines/ags/lib/freetype-2.1.3/ftutil.cpp
diff --git a/engines/ags/lib/freetype-2.1.3/ftutil.cpp b/engines/ags/lib/freetype-2.1.3/ftutil.cpp
index 775718429d8..2cba0c8b29a 100644
--- a/engines/ags/lib/freetype-2.1.3/ftutil.cpp
+++ b/engines/ags/lib/freetype-2.1.3/ftutil.cpp
@@ -55,7 +55,7 @@ FT_Error FT_Alloc(FT_Memory memory, FT_Long size, void **P) {
if (size > 0) {
*P = memory->alloc(memory, size);
if (!*P) {
- warning("FT_Alloc: Out of memory? (%ld requested)\n", size);
+ warning("FT_Alloc: Out of memory? (%ld requested)", size);
return FT_Err_Out_Of_Memory;
}
FT_MEM_ZERO(*P, size);
@@ -91,7 +91,7 @@ FT_Error FT_Realloc(FT_Memory memory, FT_Long current, FT_Long size, void **P) {
return FT_Err_Ok;
Fail:
- warning("FT_Realloc: Failed (current %ld, requested %ld)\n", current, size);
+ warning("FT_Realloc: Failed (current %ld, requested %ld)", current, size);
return FT_Err_Out_Of_Memory;
}
Commit: c08d7492c4351a1a53ea432b0291b2aa84fc3168
https://github.com/scummvm/scummvm/commit/c08d7492c4351a1a53ea432b0291b2aa84fc3168
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Remove unneeded debugging directives
Changed paths:
engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
index a1afb70ad4a..4b18a2560d2 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
@@ -1133,10 +1133,6 @@ Hint_Metrics:
slot->format = FT_GLYPH_FORMAT_OUTLINE;
}
-#ifdef DEBUG_HINTER
- ah_debug_hinter = hinter;
-#endif
-
Exit:
return error;
}
@@ -1174,11 +1170,6 @@ FT_Error ah_hinter_load_glyph(AH_Hinter hinter, FT_GlyphSlot slot, FT_Size size,
hinter->do_horz_hints = !FT_BOOL(load_flags & FT_LOAD_NO_AUTOHINT);
hinter->do_vert_hints = !FT_BOOL(load_flags & FT_LOAD_NO_AUTOHINT);
-#ifdef DEBUG_HINTER
- hinter->do_horz_hints = !ah_debug_disable_vert; /* not a bug, the meaning */
- hinter->do_vert_hints = !ah_debug_disable_horz; /* of h/v is inverted! */
-#endif
-
/* we snap the width of vertical stems for the monochrome and */
/* horizontal LCD rendering targets only. Corresponds to X snapping. */
hinter->do_horz_snapping = FT_BOOL(hint_mode == FT_RENDER_MODE_MONO || hint_mode == FT_RENDER_MODE_LCD);
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h b/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
index f2b624a6840..3585024ad29 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
@@ -48,26 +48,10 @@
#include <ft2build.h>
#include FT_TYPES_H
-#ifdef DEBUG_HINTER
-#include <../modules/autohint/ahloader.h>
-#else
#include "engines/ags/lib/freetype-2.1.3/autohint/ahloader.h"
-#endif
-
-
-#define xxAH_DEBUG
-
-
-#ifdef AH_DEBUG
-
-#include <stdio.h>
-#define AH_LOG(x) printf##x
-
-#else
#define AH_LOG(x) do ; while(0) /* nothing */
-#endif /* AH_DEBUG */
namespace AGS3 {
namespace FreeType213 {
@@ -327,16 +311,6 @@ typedef struct AH_HinterRec {
} AH_HinterRec, *AH_Hinter;
-#ifdef DEBUG_HINTER
-extern AH_Hinter ah_debug_hinter;
-extern FT_Bool ah_debug_disable_horz;
-extern FT_Bool ah_debug_disable_vert;
-#else
-#define ah_debug_disable_horz 0
-#define ah_debug_disable_vert 0
-#endif /* DEBUG_HINTER */
-
-
} // End of namespace FreeType213
} // End of namespace AGS3
Commit: ccf816a83a7cb54b05d7646d74f069460d015663
https://github.com/scummvm/scummvm/commit/ccf816a83a7cb54b05d7646d74f069460d015663
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Use scummvm debug logging
Changed paths:
engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
index 471fbb94bce..6b5d38eea0c 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
@@ -44,6 +44,7 @@
#include "engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h"
#include "engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h"
+#include "common/debug.h"
#define MAX_TEST_CHARACTERS 12
@@ -104,15 +105,15 @@ static FT_Error ah_hinter_compute_blues(AH_Hinter hinter) {
/* 'blue_chars[blues]' string, then compute its top-most and */
/* bottom-most points */
- AH_LOG(("blue zones computation\n"));
- AH_LOG(("------------------------------------------------\n"));
+ debug(6, "blue zones computation");
+ debug(6, "------------------------------------------------");
for (blue = AH_BLUE_CAPITAL_TOP; blue < AH_BLUE_MAX; blue++) {
const char *p = blue_chars[blue];
const char *limit = p + MAX_TEST_CHARACTERS;
FT_Pos *blue_ref, *blue_shoot;
- AH_LOG(("blue %3d: ", blue));
+ debugN(6, "blue %3d: ", blue);
num_flats = 0;
num_rounds = 0;
@@ -129,7 +130,7 @@ static FT_Error ah_hinter_compute_blues(AH_Hinter hinter) {
if (!*p)
break;
- AH_LOG(("`%c'", *p));
+ debugN(6, "`%c'", *p);
/* load the character in the face -- skip unknown or empty ones */
glyph_index = FT_Get_Char_Index(face, (FT_UInt)*p);
@@ -157,7 +158,7 @@ static FT_Error ah_hinter_compute_blues(AH_Hinter hinter) {
extremum = point;
}
- AH_LOG(("%5d", (int)extremum->y));
+ debugN(6, "%5d", (int)extremum->y);
/* now, check whether the point belongs to a straight or round */
/* segment; we first need to find in which contour the extremum */
@@ -219,7 +220,7 @@ static FT_Error ah_hinter_compute_blues(AH_Hinter hinter) {
FT_CURVE_TAG(glyph->outline.tags[prev]) != FT_CURVE_TAG_ON ||
FT_CURVE_TAG(glyph->outline.tags[next]) != FT_CURVE_TAG_ON);
- AH_LOG(("%c ", round ? 'r' : 'f'));
+ debugN(6, "%c ", round ? 'r' : 'f');
}
if (round)
@@ -228,7 +229,7 @@ static FT_Error ah_hinter_compute_blues(AH_Hinter hinter) {
flats[num_flats++] = extremum->y;
}
- AH_LOG(("\n"));
+ debugN(6, "\n");
/* we have computed the contents of the `rounds' and `flats' tables, */
/* now determine the reference and overshoot position of the blue; */
@@ -262,7 +263,7 @@ static FT_Error ah_hinter_compute_blues(AH_Hinter hinter) {
*blue_shoot = *blue_ref = (shoot + ref) / 2;
}
- AH_LOG(("-- ref = %ld, shoot = %ld\n", *blue_ref, *blue_shoot));
+ debug(6, "-- ref = %ld, shoot = %ld", *blue_ref, *blue_shoot);
}
/* reset original face charmap */
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h b/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
index 3585024ad29..229678ef5f7 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
@@ -50,8 +50,6 @@
#include "engines/ags/lib/freetype-2.1.3/autohint/ahloader.h"
-#define AH_LOG(x) do ; while(0) /* nothing */
-
namespace AGS3 {
namespace FreeType213 {
Commit: 4a333749396527989c4c84aed80ba1c219032636
https://github.com/scummvm/scummvm/commit/4a333749396527989c4c84aed80ba1c219032636
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Use scummvm logging in autohint debug functions
These two functions are not actually used, but still nice to have
Changed paths:
engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
index da38e793e79..bb1c3b96722 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
@@ -48,6 +48,7 @@
#include "engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h"
#include "engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h"
+#include "common/debug.h"
// util.h for ABS
#include "common/util.h"
@@ -55,9 +56,6 @@
namespace AGS3 {
namespace FreeType213 {
-#ifdef AH_DEBUG
-
-#include <stdio.h>
void ah_dump_edges(AH_Outline outline) {
AH_Edge edges;
@@ -72,13 +70,13 @@ void ah_dump_edges(AH_Outline outline) {
for (dimension = 1; dimension >= 0; dimension--) {
AH_Edge edge;
- printf("Table of %s edges:\n", !dimension ? "vertical" : "horizontal");
- printf(" [ index | pos | dir | link |"
- " serif | blue | opos | pos ]\n");
+ debug(6, "Table of %s edges:", !dimension ? "vertical" : "horizontal");
+ debug(6, " [ index | pos | dir | link |"
+ " serif | blue | opos | pos ]");
for (edge = edges; edge < edge_limit; edge++) {
- printf(" [ %5d | %4d | %5s | %4d | %5d | %c | %5.2f | %5.2f ]\n",
- edge - edges,
+ debug(6, " [ %5d | %4d | %5s | %4d | %5d | %c | %5.2f | %5.2f ]",
+ (int)(edge - edges),
(int)edge->fpos,
edge->dir == AH_DIR_UP
? "up"
@@ -89,8 +87,8 @@ void ah_dump_edges(AH_Outline outline) {
: (edge->dir == AH_DIR_RIGHT
? "right"
: "none"))),
- edge->link ? (edge->link - edges) : -1,
- edge->serif ? (edge->serif - edges) : -1,
+ edge->link ? (int)(edge->link - edges) : -1,
+ edge->serif ? (int)(edge->serif - edges) : -1,
edge->blue_edge ? 'y' : 'n',
edge->opos / 64.0,
edge->pos / 64.0);
@@ -116,14 +114,14 @@ void ah_dump_segments(AH_Outline outline) {
for (dimension = 1; dimension >= 0; dimension--) {
AH_Segment seg;
- printf("Table of %s segments:\n",
+ debug(6, "Table of %s segments:",
!dimension ? "vertical" : "horizontal");
- printf(" [ index | pos | dir | link | serif |"
- " numl | first | start ]\n");
+ debug(6, " [ index | pos | dir | link | serif |"
+ " numl | first | start ]");
for (seg = segments; seg < segment_limit; seg++) {
- printf(" [ %5d | %4d | %5s | %4d | %5d | %4d | %5d | %5d ]\n",
- seg - segments,
+ debug(6, " [ %5d | %4d | %5s | %4d | %5d | %4d | %5d | %5d ]",
+ (int)(seg - segments),
(int)seg->pos,
seg->dir == AH_DIR_UP
? "up"
@@ -134,11 +132,11 @@ void ah_dump_segments(AH_Outline outline) {
: (seg->dir == AH_DIR_RIGHT
? "right"
: "none"))),
- seg->link ? (seg->link - segments) : -1,
- seg->serif ? (seg->serif - segments) : -1,
+ seg->link ? (int)(seg->link - segments) : -1,
+ seg->serif ? (int)(seg->serif - segments) : -1,
(int)seg->num_linked,
- seg->first - points,
- seg->last - points);
+ (int)(seg->first - points),
+ (int)(seg->last - points));
}
segments = outline->vert_segments;
@@ -146,7 +144,6 @@ void ah_dump_segments(AH_Outline outline) {
}
}
-#endif /* AH_DEBUG */
/* compute the direction value of a given vector.. */
static AH_Direction ah_compute_direction(FT_Pos dx, FT_Pos dy) {
Commit: 85db570098aacfcaf0c2558647c23470cc7bd3db
https://github.com/scummvm/scummvm/commit/85db570098aacfcaf0c2558647c23470cc7bd3db
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Remove unused variable
Changed paths:
engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
index bb1c3b96722..3dc6d965247 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
@@ -60,12 +60,10 @@ namespace FreeType213 {
void ah_dump_edges(AH_Outline outline) {
AH_Edge edges;
AH_Edge edge_limit;
- AH_Segment segments;
FT_Int dimension;
edges = outline->horz_edges;
edge_limit = edges + outline->num_hedges;
- segments = outline->horz_segments;
for (dimension = 1; dimension >= 0; dimension--) {
AH_Edge edge;
@@ -96,7 +94,6 @@ void ah_dump_edges(AH_Outline outline) {
edges = outline->vert_edges;
edge_limit = edges + outline->num_vedges;
- segments = outline->vert_segments;
}
}
Commit: 7279c8a5403356864960baad8775b9135777e0b9
https://github.com/scummvm/scummvm/commit/7279c8a5403356864960baad8775b9135777e0b9
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Trim include paths
Changed paths:
engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp
engines/ags/lib/freetype-2.1.3/autohint/ahangles.h
engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h
engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h
engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
engines/ags/lib/freetype-2.1.3/autohint/ahloader.h
engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
engines/ags/lib/freetype-2.1.3/ftgloadr.cpp
engines/ags/lib/freetype-2.1.3/ftutil.cpp
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp
index 7c6b80431b9..bbb4d2a3a6e 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahangles.cpp
@@ -42,7 +42,7 @@
#include <ft2build.h>
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahangles.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahangles.h"
namespace AGS3 {
namespace FreeType213 {
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahangles.h b/engines/ags/lib/freetype-2.1.3/autohint/ahangles.h
index 1f5298a81ab..989c669f963 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahangles.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahangles.h
@@ -46,7 +46,7 @@
#include <ft2build.h>
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahtypes.h"
namespace AGS3 {
namespace FreeType213 {
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
index 6b5d38eea0c..7f9bb40e111 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.cpp
@@ -41,8 +41,8 @@
#include <ft2build.h>
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h"
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahglobal.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahglyph.h"
#include "common/debug.h"
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h
index 3cbba2f8c3d..6d1e6e58242 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h
@@ -46,7 +46,7 @@
#include <ft2build.h>
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahtypes.h"
namespace AGS3 {
namespace FreeType213 {
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
index 3dc6d965247..2f8c3aa7aa9 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.cpp
@@ -42,11 +42,11 @@
#include <ft2build.h>
-#include "engines/ags/lib/freetype-2.1.3/ftmemory.h"
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h"
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahangles.h"
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h"
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h"
+#include "ags/lib/freetype-2.1.3/ftmemory.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahglyph.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahangles.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahglobal.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahtypes.h"
#include "common/debug.h"
// util.h for ABS
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h
index 5debd4ddb50..1779554dbbe 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h
@@ -46,7 +46,7 @@
#include <ft2build.h>
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahtypes.h"
namespace AGS3 {
namespace FreeType213 {
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
index 4b18a2560d2..b541b9881a3 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.cpp
@@ -43,12 +43,12 @@
#include <ft2build.h>
#include FT_OUTLINE_H
-#include "engines/ags/lib/freetype-2.1.3/fterrors.h"
-#include "engines/ags/lib/freetype-2.1.3/ftmemory.h"
-#include "engines/ags/lib/freetype-2.1.3/ftgloadr.h"
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahhint.h"
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahglyph.h"
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahangles.h"
+#include "ags/lib/freetype-2.1.3/fterrors.h"
+#include "ags/lib/freetype-2.1.3/ftmemory.h"
+#include "ags/lib/freetype-2.1.3/ftgloadr.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahhint.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahglyph.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahangles.h"
#define FACE_GLOBALS(face) ((AH_Face_Globals)(face)->autohint.data)
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
index 80e40b39864..f3ea018fc6e 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahhint.h
@@ -45,7 +45,7 @@
#include <ft2build.h>
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahglobal.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahglobal.h"
namespace AGS3 {
namespace FreeType213 {
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahloader.h b/engines/ags/lib/freetype-2.1.3/autohint/ahloader.h
index 1f6a2216eaf..9b3e54c938b 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahloader.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahloader.h
@@ -46,7 +46,7 @@
#include <ft2build.h>
-#include "engines/ags/lib/freetype-2.1.3/ftgloadr.h"
+#include "ags/lib/freetype-2.1.3/ftgloadr.h"
#include FT_OUTLINE_H
diff --git a/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h b/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
index 229678ef5f7..95d81703535 100644
--- a/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
+++ b/engines/ags/lib/freetype-2.1.3/autohint/ahtypes.h
@@ -48,7 +48,7 @@
#include <ft2build.h>
#include FT_TYPES_H
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahloader.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahloader.h"
namespace AGS3 {
diff --git a/engines/ags/lib/freetype-2.1.3/ftgloadr.cpp b/engines/ags/lib/freetype-2.1.3/ftgloadr.cpp
index e01d42d84bc..c9aac9d8508 100644
--- a/engines/ags/lib/freetype-2.1.3/ftgloadr.cpp
+++ b/engines/ags/lib/freetype-2.1.3/ftgloadr.cpp
@@ -38,8 +38,8 @@
#include <ft2build.h>
-#include "engines/ags/lib/freetype-2.1.3/autohint/ahhint.h"
-#include "engines/ags/lib/freetype-2.1.3/ftmemory.h"
+#include "ags/lib/freetype-2.1.3/autohint/ahhint.h"
+#include "ags/lib/freetype-2.1.3/ftmemory.h"
namespace AGS3 {
diff --git a/engines/ags/lib/freetype-2.1.3/ftutil.cpp b/engines/ags/lib/freetype-2.1.3/ftutil.cpp
index 2cba0c8b29a..81d3258f012 100644
--- a/engines/ags/lib/freetype-2.1.3/ftutil.cpp
+++ b/engines/ags/lib/freetype-2.1.3/ftutil.cpp
@@ -37,8 +37,8 @@
/***************************************************************************/
#include <ft2build.h>
-#include "engines/ags/lib/freetype-2.1.3/fterrors.h"
-#include "engines/ags/lib/freetype-2.1.3/ftmemory.h"
+#include "ags/lib/freetype-2.1.3/fterrors.h"
+#include "ags/lib/freetype-2.1.3/ftmemory.h"
#include "common/debug.h"
Commit: ab6b7b0360e7da5cf88c3394a50e4ee1eb1e41ac
https://github.com/scummvm/scummvm/commit/ab6b7b0360e7da5cf88c3394a50e4ee1eb1e41ac
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
DISTS: Add Catharon license and include in builds
Changed paths:
A LICENSES/COPYING.CATHARON
Makefile.common
backends/platform/maemo/debian/rules
backends/platform/sdl/win32/win32.mk
devtools/create_project/create_project.cpp
devtools/create_project/xcode.cpp
dists/irix/scummvm.idb
dists/redhat/scummvm.spec
dists/redhat/scummvm.spec.in
dists/win32/migration.txt
ports.mk
diff --git a/LICENSES/COPYING.CATHARON b/LICENSES/COPYING.CATHARON
new file mode 100644
index 00000000000..795df49c7d5
--- /dev/null
+++ b/LICENSES/COPYING.CATHARON
@@ -0,0 +1,128 @@
+NOTE: The only part of ScummVM under the "Catharon License" is the
+automatic hinting code in the AGS engine
+(/engines/ags/lib/freetype-2.1.3/autohint)
+
+
+ The Catharon Open Source LICENSE
+ ----------------------------
+
+ 2000-Jul-04
+
+ Copyright (C) 2000 by Catharon Productions, Inc.
+
+
+
+Introduction
+============
+
+ This license applies to source files distributed by Catharon
+ Productions, Inc. in several archive packages. This license
+ applies to all files found in such packages which do not fall
+ under their own explicit license.
+
+ This license was inspired by the BSD, Artistic, and IJG
+ (Independent JPEG Group) licenses, which all encourage inclusion
+ and use of free software in commercial and freeware products
+ alike. As a consequence, its main points are that:
+
+ o We don't promise that this software works. However, we are
+ interested in any kind of bug reports. (`as is' distribution)
+
+ o You can use this software for whatever you want, in parts or
+ full form, without having to pay us. (`royalty-free' usage)
+
+ o You may not pretend that you wrote this software. If you use
+ it, or only parts of it, in a program, you must acknowledge
+ somewhere in your documentation that you have used the
+ Catharon Code. (`credits')
+
+ We specifically permit and encourage the inclusion of this
+ software, with or without modifications, in commercial products.
+ We disclaim all warranties covering the packages distributed by
+ Catharon Productions, Inc. and assume no liability related to
+ their use.
+
+
+Legal Terms
+===========
+
+0. Definitions
+--------------
+
+ Throughout this license, the terms `Catharon Package', `package',
+ and `Catharon Code' refer to the set of files originally
+ distributed by Catharon Productions, Inc.
+
+ `You' refers to the licensee, or person using the project, where
+ `using' is a generic term including compiling the project's source
+ code as well as linking it to form a `program' or `executable'.
+ This program is referred to as `a program using one of the
+ Catharon Packages'.
+
+ This license applies to all files distributed in the original
+ Catharon Package(s), including all source code, binaries and
+ documentation, unless otherwise stated in the file in its
+ original, unmodified form as distributed in the original archive.
+ If you are unsure whether or not a particular file is covered by
+ this license, you must contact us to verify this.
+
+ The Catharon Packages are copyright (C) 2000 by Catharon
+ Productions, Inc. All rights reserved except as specified below.
+
+1. No Warranty
+--------------
+
+ THE CATHARON PACKAGES ARE PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OF OR THE INABILITY TO
+ USE THE CATHARON PACKAGE.
+
+2. Redistribution
+-----------------
+
+ This license grants a worldwide, royalty-free, perpetual and
+ irrevocable right and license to use, execute, perform, compile,
+ display, copy, create derivative works of, distribute and
+ sublicense the Catharon Packages (in both source and object code
+ forms) and derivative works thereof for any purpose; and to
+ authorize others to exercise some or all of the rights granted
+ herein, subject to the following conditions:
+
+ o Redistribution of source code must retain this license file
+ (`license.txt') unaltered; any additions, deletions or changes
+ to the original files must be clearly indicated in
+ accompanying documentation. The copyright notices of the
+ unaltered, original files must be preserved in all copies of
+ source files.
+
+ o Redistribution in binary form must provide a disclaimer that
+ states that the software is based in part on the work of
+ Catharon Productions, Inc. in the distribution documentation.
+
+ These conditions apply to any software derived from or based on
+ the Catharon Packages, not just the unmodified files. If you use
+ our work, you must acknowledge us. However, no fee need be paid
+ to us.
+
+3. Advertising
+--------------
+
+ Neither Catharon Productions, Inc. and contributors nor you shall
+ use the name of the other for commercial, advertising, or
+ promotional purposes without specific prior written permission.
+
+ We suggest, but do not require, that you use the following phrase
+ to refer to this software in your documentation: 'this software is
+ based in part on the Catharon Typography Project'.
+
+ As you have not signed this license, you are not required to
+ accept it. However, as the Catharon Packages are copyrighted
+ material, only this license, or another one contracted with the
+ authors, grants you the right to use, distribute, and modify it.
+ Therefore, by using, distributing, or modifying the Catharon
+ Packages, you indicate that you understand and accept all the
+ terms of this license.
+
+--- end of license.txt ---
diff --git a/Makefile.common b/Makefile.common
index db52cf2f63b..2acfff8ad06 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -362,8 +362,8 @@ dist-src: \
# Common files
DIST_FILES_DOCS:=$(addprefix $(srcdir)/,AUTHORS COPYING LICENSES/COPYING.BSD LICENSES/COPYING.LGPL \
LICENSES/COPYING.FREEFONT LICENSES/COPYING.OFL LICENSES/COPYING.ISC LICENSES/COPYING.LUA \
- LICENSES/COPYING.MIT LICENSES/COPYING.MKV LICENSES/COPYING.TINYGL LICENSES/COPYING.GLAD\
- COPYRIGHT NEWS.md README.md CONTRIBUTING.md)
+ LICENSES/COPYING.MIT LICENSES/COPYING.MKV LICENSES/COPYING.TINYGL LICENSES/COPYING.GLAD \
+ LICENSES/COPYING.CATHARON COPYRIGHT NEWS.md README.md CONTRIBUTING.md)
ifdef USE_PANDOC
DIST_FILES_DOCS+=README$(PANDOCEXT) NEWS$(PANDOCEXT) CONTRIBUTING$(PANDOCEXT)
endif
diff --git a/backends/platform/maemo/debian/rules b/backends/platform/maemo/debian/rules
index 89bd8de8bbe..d2359ca5266 100755
--- a/backends/platform/maemo/debian/rules
+++ b/backends/platform/maemo/debian/rules
@@ -57,7 +57,7 @@ install: build
install -m0644 -d debian/scummvm/usr/share/doc/scummvm
install -m0644 AUTHORS COPYING LICENSES/COPYING.BSD LICENSES/COPYING.LGPL LICENSES/COPYING.FREEFONT LICENSES/COPYING.OFL \
LICENSES/COPYING.ISC LICENSES/COPYING.LUA LICENSES/COPYING.MIT LICENSES/COPYING.MKV LICENSES/COPYING.TINYGL \
- LICENSES/COPYING.GLAD COPYRIGHT NEWS.md README.md debian/scummvm/usr/share/doc/scummvm
+ LICENSES/COPYING.GLAD LICENSES/COPYING.CATHARON COPYRIGHT NEWS.md README.md debian/scummvm/usr/share/doc/scummvm
binary: binary-arch
binary-arch: build install
diff --git a/backends/platform/sdl/win32/win32.mk b/backends/platform/sdl/win32/win32.mk
index 84870fe58c1..7a2d3e8109b 100644
--- a/backends/platform/sdl/win32/win32.mk
+++ b/backends/platform/sdl/win32/win32.mk
@@ -29,6 +29,7 @@ win32-data: all
cp $(srcdir)/LICENSES/COPYING.MKV $(WIN32PATH)/COPYING.MKV.txt
cp $(srcdir)/LICENSES/COPYING.TINYGL $(WIN32PATH)/COPYING.TINYGL.txt
cp $(srcdir)/LICENSES/COPYING.GLAD $(WIN32PATH)/COPYING.GLAD.txt
+ cp $(srcdir)/LICENSES/COPYING.CATHARON $(WIN32PATH)/COPYING.CATHARON.txt
cp $(srcdir)/COPYRIGHT $(WIN32PATH)/COPYRIGHT.txt
cp $(srcdir)/doc/cz/PrectiMe $(WIN32PATH)/doc/cz/PrectiMe.txt
cp $(srcdir)/doc/QuickStart $(WIN32PATH)/doc/QuickStart.txt
diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp
index 6aca7d730b7..f76d82f86e8 100644
--- a/devtools/create_project/create_project.cpp
+++ b/devtools/create_project/create_project.cpp
@@ -1671,6 +1671,7 @@ void ProjectProvider::createProject(BuildSetup &setup) {
in.push_back(setup.srcDir + "/LICENSES/COPYING.MKV");
in.push_back(setup.srcDir + "/LICENSES/COPYING.TINYGL");
in.push_back(setup.srcDir + "/LICENSES/COPYING.GLAD");
+ in.push_back(setup.srcDir + "/LICENSES/COPYING.CATHARON");
in.push_back(setup.srcDir + "/COPYRIGHT");
in.push_back(setup.srcDir + "/NEWS.md");
in.push_back(setup.srcDir + "/README.md");
diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp
index 989bf1ab8de..8983bcac5e2 100644
--- a/devtools/create_project/xcode.cpp
+++ b/devtools/create_project/xcode.cpp
@@ -1157,6 +1157,7 @@ XcodeProvider::ValueList& XcodeProvider::getResourceFiles(const BuildSetup &setu
files.push_back("LICENSES/COPYING.MKV");
files.push_back("LICENSES/COPYING.TINYGL");
files.push_back("LICENSES/COPYING.GLAD");
+ files.push_back("LICENSES/COPYING.CATHARON");
files.push_back("NEWS.md");
files.push_back("README.md");
}
diff --git a/dists/irix/scummvm.idb b/dists/irix/scummvm.idb
index f5cafd0f570..c58976c2f6b 100644
--- a/dists/irix/scummvm.idb
+++ b/dists/irix/scummvm.idb
@@ -10,6 +10,7 @@ f 0644 root sys usr/ScummVM/COPYING.MIT LICENSES/COPYING.MIT scummvm.man.readme
f 0644 root sys usr/ScummVM/COPYING.MKV LICENSES/COPYING.MKV scummvm.man.readme
f 0644 root sys usr/ScummVM/COPYING.TINYGL LICENSES/COPYING.TINYGL scummvm.man.readme
f 0644 root sys usr/ScummVM/COPYING.GLAD LICENSES/COPYING.GLAD scummvm.man.readme
+f 0644 root sys usr/ScummVM/COPYING.CATHARON LICENSES/COPYING.CATHARON scummvm.man.readme
f 0644 root sys usr/ScummVM/COPYRIGHT COPYRIGHT scummvm.man.readme
f 0644 root sys usr/ScummVM/NEWS.md NEWS.module scummvm.man.readme
f 0644 root sys usr/ScummVM/README.md README.md scummvm.man.readme
diff --git a/dists/redhat/scummvm.spec b/dists/redhat/scummvm.spec
index db974cfeef9..69d158d8c23 100644
--- a/dists/redhat/scummvm.spec
+++ b/dists/redhat/scummvm.spec
@@ -86,7 +86,7 @@ fi
#------------------------------------------------------------------------------
%files
%defattr(0644,root,root,0755)
-%doc AUTHORS README.md NEWS.md COPYING LICENSES/COPYING.BSD LICENSES/COPYING.LGPL LICENSES/COPYING.FREEFONT LICENSES/COPYING.OFL LICENSES/COPYING.ISC LICENSES/COPYING.LUA LICENSES/COPYING.MIT LICENSES/COPYING.MKV LICENSES/COPYING.TINYGL LICENSES/COPYING.GLAD COPYRIGHT
+%doc AUTHORS README.md NEWS.md COPYING LICENSES/COPYING.BSD LICENSES/COPYING.LGPL LICENSES/COPYING.FREEFONT LICENSES/COPYING.OFL LICENSES/COPYING.ISC LICENSES/COPYING.LUA LICENSES/COPYING.MIT LICENSES/COPYING.MKV LICENSES/COPYING.TINYGL LICENSES/COPYING.GLAD LICENSES/COPYING.CATHARON COPYRIGHT
%attr(0755,root,root)%{_bindir}/scummvm
%{_datadir}/applications/*
%{_datadir}/pixmaps/org.scummvm.scummvm.xpm
diff --git a/dists/redhat/scummvm.spec.in b/dists/redhat/scummvm.spec.in
index 9cf421f4271..222cca7be38 100644
--- a/dists/redhat/scummvm.spec.in
+++ b/dists/redhat/scummvm.spec.in
@@ -86,7 +86,7 @@ fi
#------------------------------------------------------------------------------
%files
%defattr(0644,root,root,0755)
-%doc AUTHORS README.md NEWS.md COPYING LICENSES/COPYING.BSD LICENSES/COPYING.LGPL LICENSES/COPYING.FREEFONT LICENSES/COPYING.OFL LICENSES/COPYING.ISC LICENSES/COPYING.LUA LICENSES/COPYING.MIT LICENSES/COPYING.MKV LICENSES/COPYING.TINYGL LICENSES/COPYING.GLAD COPYRIGHT
+%doc AUTHORS README.md NEWS.md COPYING LICENSES/COPYING.BSD LICENSES/COPYING.LGPL LICENSES/COPYING.FREEFONT LICENSES/COPYING.OFL LICENSES/COPYING.ISC LICENSES/COPYING.LUA LICENSES/COPYING.MIT LICENSES/COPYING.MKV LICENSES/COPYING.TINYGL LICENSES/COPYING.GLAD LICENSES/COPYING.CATHARON COPYRIGHT
%attr(0755,root,root)%{_bindir}/scummvm
%{_datadir}/applications/*
%{_datadir}/pixmaps/org.scummvm.scummvm.xpm
diff --git a/dists/win32/migration.txt b/dists/win32/migration.txt
index 2dbed856508..ac4c47f590e 100644
--- a/dists/win32/migration.txt
+++ b/dists/win32/migration.txt
@@ -9,6 +9,7 @@ COPYING.MKV.txt
COPYING.OFL.txt
COPYING.TINYGL
COPYING.GLAD
+COPYING.CATHARON.txt
COPYING.txt
COPYRIGHT.txt
access.dat
diff --git a/ports.mk b/ports.mk
index ac6b486eafe..ea36f79354e 100644
--- a/ports.mk
+++ b/ports.mk
@@ -558,6 +558,7 @@ osxsnap: bundle
mv ./ScummVM-snapshot/COPYING.MKV ./ScummVM-snapshot/License\ \(MKV\)
mv ./ScummVM-snapshot/COPYING.TINYGL ./ScummVM-snapshot/License\ \(TinyGL\)
mv ./ScummVM-snapshot/COPYING.GLAD ./ScummVM-snapshot/License\ \(Glad\)
+ mv ./ScummVM-snapshot/COPYING.CATHARON ./ScummVM-snapshot/License\ \(Catharon\)
$(XCODETOOLSPATH)/SetFile -t ttro -c ttxt ./ScummVM-snapshot/*
mkdir ScummVM-snapshot/doc
cp $(srcdir)/doc/QuickStart ./ScummVM-snapshot/doc/QuickStart
Commit: 892f46f382c8e1a9d7c10ef8daabfbfed11c2aac
https://github.com/scummvm/scummvm/commit/892f46f382c8e1a9d7c10ef8daabfbfed11c2aac
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
AGS: Freetype: Build autohint sources only if freetype2 is enabled
Changed paths:
engines/ags/module.mk
diff --git a/engines/ags/module.mk b/engines/ags/module.mk
index 0e3aa59d3b3..1ce1c53937c 100644
--- a/engines/ags/module.mk
+++ b/engines/ags/module.mk
@@ -27,12 +27,6 @@ MODULE_OBJS = \
lib/allegro/surface_generic.o \
lib/allegro/system.o \
lib/allegro/unicode.o \
- lib/freetype-2.1.3/autohint/ahangles.o \
- lib/freetype-2.1.3/autohint/ahglobal.o \
- lib/freetype-2.1.3/autohint/ahglyph.o \
- lib/freetype-2.1.3/autohint/ahhint.o \
- lib/freetype-2.1.3/ftgloadr.o \
- lib/freetype-2.1.3/ftutil.o \
lib/std/std.o \
lib/system/datetime.o \
shared/ac/dynobj/script_audio_clip.o \
@@ -370,6 +364,16 @@ MODULE_OBJS = \
plugins/ags_waves/warper.o \
plugins/ags_waves/weather.o
+ifdef USE_FREETYPE2
+MODULE_OBJS += \
+ lib/freetype-2.1.3/autohint/ahangles.o \
+ lib/freetype-2.1.3/autohint/ahglobal.o \
+ lib/freetype-2.1.3/autohint/ahglyph.o \
+ lib/freetype-2.1.3/autohint/ahhint.o \
+ lib/freetype-2.1.3/ftgloadr.o \
+ lib/freetype-2.1.3/ftutil.o
+endif
+
ifdef ENABLE_AGS_TESTS
MODULE_OBJS += \
tests/test_all.o \
Commit: d117a48aaff513408e6bea2ec955d11026dd54f8
https://github.com/scummvm/scummvm/commit/d117a48aaff513408e6bea2ec955d11026dd54f8
Author: Walter Agazzi (walter.agazzi at protonmail.com)
Date: 2023-09-03T22:27:43+02:00
Commit Message:
DISTS: Keep Catharon license original naming
Changed paths:
A LICENSES/CatharonLicense.txt
R LICENSES/COPYING.CATHARON
Makefile.common
backends/platform/maemo/debian/rules
backends/platform/sdl/win32/win32.mk
devtools/create_project/create_project.cpp
devtools/create_project/xcode.cpp
dists/irix/scummvm.idb
dists/redhat/scummvm.spec
dists/redhat/scummvm.spec.in
dists/win32/migration.txt
ports.mk
diff --git a/LICENSES/COPYING.CATHARON b/LICENSES/CatharonLicense.txt
similarity index 100%
rename from LICENSES/COPYING.CATHARON
rename to LICENSES/CatharonLicense.txt
diff --git a/Makefile.common b/Makefile.common
index 2acfff8ad06..8d5ed21b695 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -363,7 +363,7 @@ dist-src: \
DIST_FILES_DOCS:=$(addprefix $(srcdir)/,AUTHORS COPYING LICENSES/COPYING.BSD LICENSES/COPYING.LGPL \
LICENSES/COPYING.FREEFONT LICENSES/COPYING.OFL LICENSES/COPYING.ISC LICENSES/COPYING.LUA \
LICENSES/COPYING.MIT LICENSES/COPYING.MKV LICENSES/COPYING.TINYGL LICENSES/COPYING.GLAD \
- LICENSES/COPYING.CATHARON COPYRIGHT NEWS.md README.md CONTRIBUTING.md)
+ LICENSES/CatharonLicense.txt COPYRIGHT NEWS.md README.md CONTRIBUTING.md)
ifdef USE_PANDOC
DIST_FILES_DOCS+=README$(PANDOCEXT) NEWS$(PANDOCEXT) CONTRIBUTING$(PANDOCEXT)
endif
diff --git a/backends/platform/maemo/debian/rules b/backends/platform/maemo/debian/rules
index d2359ca5266..0018c795dad 100755
--- a/backends/platform/maemo/debian/rules
+++ b/backends/platform/maemo/debian/rules
@@ -57,7 +57,7 @@ install: build
install -m0644 -d debian/scummvm/usr/share/doc/scummvm
install -m0644 AUTHORS COPYING LICENSES/COPYING.BSD LICENSES/COPYING.LGPL LICENSES/COPYING.FREEFONT LICENSES/COPYING.OFL \
LICENSES/COPYING.ISC LICENSES/COPYING.LUA LICENSES/COPYING.MIT LICENSES/COPYING.MKV LICENSES/COPYING.TINYGL \
- LICENSES/COPYING.GLAD LICENSES/COPYING.CATHARON COPYRIGHT NEWS.md README.md debian/scummvm/usr/share/doc/scummvm
+ LICENSES/COPYING.GLAD LICENSES/CatharonLicense.txt COPYRIGHT NEWS.md README.md debian/scummvm/usr/share/doc/scummvm
binary: binary-arch
binary-arch: build install
diff --git a/backends/platform/sdl/win32/win32.mk b/backends/platform/sdl/win32/win32.mk
index 7a2d3e8109b..5106d0f1be4 100644
--- a/backends/platform/sdl/win32/win32.mk
+++ b/backends/platform/sdl/win32/win32.mk
@@ -29,7 +29,7 @@ win32-data: all
cp $(srcdir)/LICENSES/COPYING.MKV $(WIN32PATH)/COPYING.MKV.txt
cp $(srcdir)/LICENSES/COPYING.TINYGL $(WIN32PATH)/COPYING.TINYGL.txt
cp $(srcdir)/LICENSES/COPYING.GLAD $(WIN32PATH)/COPYING.GLAD.txt
- cp $(srcdir)/LICENSES/COPYING.CATHARON $(WIN32PATH)/COPYING.CATHARON.txt
+ cp $(srcdir)/LICENSES/CatharonLicense.txt $(WIN32PATH)/CatharonLicense.txt
cp $(srcdir)/COPYRIGHT $(WIN32PATH)/COPYRIGHT.txt
cp $(srcdir)/doc/cz/PrectiMe $(WIN32PATH)/doc/cz/PrectiMe.txt
cp $(srcdir)/doc/QuickStart $(WIN32PATH)/doc/QuickStart.txt
diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp
index f76d82f86e8..b64cef443cb 100644
--- a/devtools/create_project/create_project.cpp
+++ b/devtools/create_project/create_project.cpp
@@ -1671,7 +1671,7 @@ void ProjectProvider::createProject(BuildSetup &setup) {
in.push_back(setup.srcDir + "/LICENSES/COPYING.MKV");
in.push_back(setup.srcDir + "/LICENSES/COPYING.TINYGL");
in.push_back(setup.srcDir + "/LICENSES/COPYING.GLAD");
- in.push_back(setup.srcDir + "/LICENSES/COPYING.CATHARON");
+ in.push_back(setup.srcDir + "/LICENSES/CatharonLicense.txt");
in.push_back(setup.srcDir + "/COPYRIGHT");
in.push_back(setup.srcDir + "/NEWS.md");
in.push_back(setup.srcDir + "/README.md");
diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp
index 8983bcac5e2..8232aec5dd1 100644
--- a/devtools/create_project/xcode.cpp
+++ b/devtools/create_project/xcode.cpp
@@ -1157,7 +1157,7 @@ XcodeProvider::ValueList& XcodeProvider::getResourceFiles(const BuildSetup &setu
files.push_back("LICENSES/COPYING.MKV");
files.push_back("LICENSES/COPYING.TINYGL");
files.push_back("LICENSES/COPYING.GLAD");
- files.push_back("LICENSES/COPYING.CATHARON");
+ files.push_back("LICENSES/CatharonLicense.txt");
files.push_back("NEWS.md");
files.push_back("README.md");
}
diff --git a/dists/irix/scummvm.idb b/dists/irix/scummvm.idb
index c58976c2f6b..683fb910d78 100644
--- a/dists/irix/scummvm.idb
+++ b/dists/irix/scummvm.idb
@@ -10,7 +10,7 @@ f 0644 root sys usr/ScummVM/COPYING.MIT LICENSES/COPYING.MIT scummvm.man.readme
f 0644 root sys usr/ScummVM/COPYING.MKV LICENSES/COPYING.MKV scummvm.man.readme
f 0644 root sys usr/ScummVM/COPYING.TINYGL LICENSES/COPYING.TINYGL scummvm.man.readme
f 0644 root sys usr/ScummVM/COPYING.GLAD LICENSES/COPYING.GLAD scummvm.man.readme
-f 0644 root sys usr/ScummVM/COPYING.CATHARON LICENSES/COPYING.CATHARON scummvm.man.readme
+f 0644 root sys usr/ScummVM/CatharonLicense.txt LICENSES/CatharonLicense.txt scummvm.man.readme
f 0644 root sys usr/ScummVM/COPYRIGHT COPYRIGHT scummvm.man.readme
f 0644 root sys usr/ScummVM/NEWS.md NEWS.module scummvm.man.readme
f 0644 root sys usr/ScummVM/README.md README.md scummvm.man.readme
diff --git a/dists/redhat/scummvm.spec b/dists/redhat/scummvm.spec
index 69d158d8c23..e6072583fcf 100644
--- a/dists/redhat/scummvm.spec
+++ b/dists/redhat/scummvm.spec
@@ -86,7 +86,7 @@ fi
#------------------------------------------------------------------------------
%files
%defattr(0644,root,root,0755)
-%doc AUTHORS README.md NEWS.md COPYING LICENSES/COPYING.BSD LICENSES/COPYING.LGPL LICENSES/COPYING.FREEFONT LICENSES/COPYING.OFL LICENSES/COPYING.ISC LICENSES/COPYING.LUA LICENSES/COPYING.MIT LICENSES/COPYING.MKV LICENSES/COPYING.TINYGL LICENSES/COPYING.GLAD LICENSES/COPYING.CATHARON COPYRIGHT
+%doc AUTHORS README.md NEWS.md COPYING LICENSES/COPYING.BSD LICENSES/COPYING.LGPL LICENSES/COPYING.FREEFONT LICENSES/COPYING.OFL LICENSES/COPYING.ISC LICENSES/COPYING.LUA LICENSES/COPYING.MIT LICENSES/COPYING.MKV LICENSES/COPYING.TINYGL LICENSES/COPYING.GLAD LICENSES/CatharonLicense.txt COPYRIGHT
%attr(0755,root,root)%{_bindir}/scummvm
%{_datadir}/applications/*
%{_datadir}/pixmaps/org.scummvm.scummvm.xpm
diff --git a/dists/redhat/scummvm.spec.in b/dists/redhat/scummvm.spec.in
index 222cca7be38..a24f51c7128 100644
--- a/dists/redhat/scummvm.spec.in
+++ b/dists/redhat/scummvm.spec.in
@@ -86,7 +86,7 @@ fi
#------------------------------------------------------------------------------
%files
%defattr(0644,root,root,0755)
-%doc AUTHORS README.md NEWS.md COPYING LICENSES/COPYING.BSD LICENSES/COPYING.LGPL LICENSES/COPYING.FREEFONT LICENSES/COPYING.OFL LICENSES/COPYING.ISC LICENSES/COPYING.LUA LICENSES/COPYING.MIT LICENSES/COPYING.MKV LICENSES/COPYING.TINYGL LICENSES/COPYING.GLAD LICENSES/COPYING.CATHARON COPYRIGHT
+%doc AUTHORS README.md NEWS.md COPYING LICENSES/COPYING.BSD LICENSES/COPYING.LGPL LICENSES/COPYING.FREEFONT LICENSES/COPYING.OFL LICENSES/COPYING.ISC LICENSES/COPYING.LUA LICENSES/COPYING.MIT LICENSES/COPYING.MKV LICENSES/COPYING.TINYGL LICENSES/COPYING.GLAD LICENSES/CatharonLicense.txt COPYRIGHT
%attr(0755,root,root)%{_bindir}/scummvm
%{_datadir}/applications/*
%{_datadir}/pixmaps/org.scummvm.scummvm.xpm
diff --git a/dists/win32/migration.txt b/dists/win32/migration.txt
index ac4c47f590e..530800c25b4 100644
--- a/dists/win32/migration.txt
+++ b/dists/win32/migration.txt
@@ -9,7 +9,7 @@ COPYING.MKV.txt
COPYING.OFL.txt
COPYING.TINYGL
COPYING.GLAD
-COPYING.CATHARON.txt
+CatharonLicense.txt
COPYING.txt
COPYRIGHT.txt
access.dat
diff --git a/ports.mk b/ports.mk
index ea36f79354e..a2a66af379c 100644
--- a/ports.mk
+++ b/ports.mk
@@ -558,7 +558,7 @@ osxsnap: bundle
mv ./ScummVM-snapshot/COPYING.MKV ./ScummVM-snapshot/License\ \(MKV\)
mv ./ScummVM-snapshot/COPYING.TINYGL ./ScummVM-snapshot/License\ \(TinyGL\)
mv ./ScummVM-snapshot/COPYING.GLAD ./ScummVM-snapshot/License\ \(Glad\)
- mv ./ScummVM-snapshot/COPYING.CATHARON ./ScummVM-snapshot/License\ \(Catharon\)
+ mv ./ScummVM-snapshot/CatharonLicense.txt ./ScummVM-snapshot/CatharonLicense.txt
$(XCODETOOLSPATH)/SetFile -t ttro -c ttxt ./ScummVM-snapshot/*
mkdir ScummVM-snapshot/doc
cp $(srcdir)/doc/QuickStart ./ScummVM-snapshot/doc/QuickStart
More information about the Scummvm-git-logs
mailing list