afdko: upgrade to 5.0.1
txNew, txFree and doSingleFileSet are public now, so the extern_tx patches go away. The mergeFonts crash fix is merged upstream. The noverbose patch is replaced by a SAL logger installed through slogger::getLogger. A new fatal-callback patch lets fatal errors raise exceptions, which appSpecificFree used to do. afdko 5.0 replaces makeotfexe with addfeatures, drops the typecomp Type 1 to CFF converter, and rewrites most of c/shared in C++. hotconv now only reads CFF, so makeotf() first converts its Type 1 input to bare CFF with tx, the same step the upstream makeotf driver script performs. Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com> Change-Id: I1e5b6ac8413eb66d81034f4f1d0b7f2e46e12233 Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/4251 Tested-by: Jenkins CPCI <releng@collaboraoffice.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit 6c40019917bd6e88f6b54d0a2d53d64729c64166) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207285 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
committed by
Xisco Fauli
parent
14ce8debf9
commit
dce3608001
@@ -4417,8 +4417,8 @@ $(call gb_LinkTarget_use_unpacked,$(1),afdko)
|
||||
$(call gb_LinkTarget_set_include,$(1),\
|
||||
-I$(gb_UnpackedTarball_workdir)/afdko/c/shared/include \
|
||||
-I$(gb_UnpackedTarball_workdir)/afdko/c/shared/resource \
|
||||
-I$(gb_UnpackedTarball_workdir)/afdko/c/makeotf/include \
|
||||
-I$(gb_UnpackedTarball_workdir)/afdko/c/makeotf/source \
|
||||
-I$(gb_UnpackedTarball_workdir)/afdko/c/addfeatures/include \
|
||||
-I$(gb_UnpackedTarball_workdir)/afdko/c/addfeatures \
|
||||
$$(INCLUDE) \
|
||||
)
|
||||
$(call gb_LinkTarget_use_static_libraries,$(1),afdko)
|
||||
|
||||
+2
-2
@@ -574,8 +574,8 @@ PDFIUM_TARBALL := pdfium-7795.tar.bz2
|
||||
# three static lines
|
||||
# so that git cherry-pick
|
||||
# will not run into conflicts
|
||||
AFDKO_SHA256SUM := 5feed7c2468e25b25fce0479c04af07f4ed2680bc9251bb4c4aef9ec2fba5720
|
||||
AFDKO_TARBALL := afdko-4.0.3.tar.gz
|
||||
AFDKO_SHA256SUM := 083b504a1cd865e8bfbb42134a34318ce42ef5130daebfc5b0e2f2fb444326c5
|
||||
AFDKO_TARBALL := afdko-5.0.1.tar.gz
|
||||
# three static lines
|
||||
# so that git cherry-pick
|
||||
# will not run into conflicts
|
||||
|
||||
+93
-102
@@ -15,11 +15,14 @@ $(eval $(call gb_StaticLibrary_set_warnings_disabled,afdko))
|
||||
|
||||
$(eval $(call gb_StaticLibrary_set_generated_cxx_suffix,afdko,cpp))
|
||||
|
||||
# c/shared/include must come before c/addfeatures/include so that the
|
||||
# shared sources find their own pstoken.h. The addfeatures consumers of
|
||||
# the other pstoken.h are patched to include it by relative path, see
|
||||
# extern_addfeatures.patch.
|
||||
$(eval $(call gb_StaticLibrary_set_include,afdko,\
|
||||
-I$(gb_UnpackedTarball_workdir)/afdko/c/shared/include \
|
||||
-I$(gb_UnpackedTarball_workdir)/afdko/c/shared/resource \
|
||||
-I$(gb_UnpackedTarball_workdir)/afdko/c/shared/source/tx_shared \
|
||||
-I$(gb_UnpackedTarball_workdir)/afdko/c/makeotf \
|
||||
-I$(gb_UnpackedTarball_workdir)/afdko/c/addfeatures/include \
|
||||
-I$(gb_UnpackedTarball_workdir)/afdko/a4/runtime/src \
|
||||
$$(INCLUDE) \
|
||||
))
|
||||
@@ -29,113 +32,101 @@ $(eval $(call gb_StaticLibrary_use_externals,afdko,\
|
||||
))
|
||||
|
||||
$(eval $(call gb_StaticLibrary_add_defs,afdko, \
|
||||
-DTC_EURO_SUPPORT=1 \
|
||||
-DTC_SUBR_SUPPORT=1 \
|
||||
-DTC_HINT_CHECK=1 \
|
||||
-DANTLR4CPP_STATIC \
|
||||
))
|
||||
|
||||
$(eval $(call gb_StaticLibrary_add_generated_cobjects,afdko,\
|
||||
UnpackedTarball/afdko/c/shared/source/absfont/absfont \
|
||||
UnpackedTarball/afdko/c/shared/source/absfont/absfont_afm \
|
||||
UnpackedTarball/afdko/c/shared/source/absfont/absfont_compare \
|
||||
UnpackedTarball/afdko/c/shared/source/absfont/absfont_desc \
|
||||
UnpackedTarball/afdko/c/shared/source/absfont/absfont_draw \
|
||||
UnpackedTarball/afdko/c/shared/source/absfont/absfont_dump \
|
||||
UnpackedTarball/afdko/c/shared/source/absfont/absfont_metrics \
|
||||
UnpackedTarball/afdko/c/shared/source/absfont/absfont_path \
|
||||
UnpackedTarball/afdko/c/shared/source/cfembed/cfembed \
|
||||
UnpackedTarball/afdko/c/shared/source/cffread/cffread \
|
||||
UnpackedTarball/afdko/c/shared/source/cffwrite/cffwrite \
|
||||
UnpackedTarball/afdko/c/shared/source/cffwrite/cffwrite_charset \
|
||||
UnpackedTarball/afdko/c/shared/source/cffwrite/cffwrite_dict \
|
||||
UnpackedTarball/afdko/c/shared/source/cffwrite/cffwrite_encoding \
|
||||
UnpackedTarball/afdko/c/shared/source/cffwrite/cffwrite_fdselect \
|
||||
UnpackedTarball/afdko/c/shared/source/cffwrite/cffwrite_sindex \
|
||||
UnpackedTarball/afdko/c/shared/source/cffwrite/cffwrite_subr \
|
||||
UnpackedTarball/afdko/c/shared/source/cffwrite/cffwrite_t2cstr \
|
||||
UnpackedTarball/afdko/c/shared/source/cffwrite/cffwrite_varstore \
|
||||
UnpackedTarball/afdko/c/shared/source/ctutil/ctutil \
|
||||
UnpackedTarball/afdko/c/shared/source/dynarr/dynarr \
|
||||
UnpackedTarball/afdko/c/shared/source/nameread/nameread \
|
||||
UnpackedTarball/afdko/c/shared/source/pdfwrite/pdfwrite \
|
||||
UnpackedTarball/afdko/c/shared/source/pstoken/pstoken \
|
||||
UnpackedTarball/afdko/c/shared/source/sfntread/sfntread \
|
||||
UnpackedTarball/afdko/c/shared/source/sfntwrite/sfntwrite \
|
||||
UnpackedTarball/afdko/c/shared/source/sha1/sha1 \
|
||||
UnpackedTarball/afdko/c/shared/source/support/canthappen \
|
||||
UnpackedTarball/afdko/c/shared/source/support/except \
|
||||
UnpackedTarball/afdko/c/shared/source/support/fixed \
|
||||
UnpackedTarball/afdko/c/shared/source/svgwrite/svgwrite \
|
||||
UnpackedTarball/afdko/c/shared/source/svread/svread \
|
||||
UnpackedTarball/afdko/c/shared/source/t1cstr/t1cstr \
|
||||
UnpackedTarball/afdko/c/shared/source/t1read/t1read \
|
||||
UnpackedTarball/afdko/c/shared/source/t1write/t1write \
|
||||
UnpackedTarball/afdko/c/shared/source/t2cstr/t2cstr \
|
||||
UnpackedTarball/afdko/c/shared/source/ttread/ttread \
|
||||
UnpackedTarball/afdko/c/shared/source/varread/varread \
|
||||
UnpackedTarball/afdko/c/shared/source/uforead/uforead \
|
||||
UnpackedTarball/afdko/c/shared/source/ufowrite/ufowrite \
|
||||
UnpackedTarball/afdko/c/shared/source/tx_shared/tx_shared \
|
||||
))
|
||||
|
||||
$(eval $(call gb_StaticLibrary_add_generated_cobjects,afdko,\
|
||||
UnpackedTarball/afdko/c/tx/source/tx \
|
||||
))
|
||||
|
||||
$(eval $(call gb_StaticLibrary_add_generated_cobjects,afdko,\
|
||||
UnpackedTarball/afdko/c/mergefonts/source/mergeFonts \
|
||||
))
|
||||
|
||||
$(eval $(call gb_StaticLibrary_add_generated_cobjects,afdko,\
|
||||
UnpackedTarball/afdko/c/makeotf/source/c_main \
|
||||
UnpackedTarball/afdko/c/makeotf/source/cb \
|
||||
UnpackedTarball/afdko/c/makeotf/source/cbpriv \
|
||||
UnpackedTarball/afdko/c/makeotf/source/fcdb \
|
||||
UnpackedTarball/afdko/c/makeotf/source/file \
|
||||
UnpackedTarball/afdko/c/makeotf/source/mac \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/cffread/cffread \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/BASE \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/CFF_ \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/GDEF \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/GPOS \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/GSUB \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/OS_2 \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/STAT \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/VORG \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/anon \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/cmap \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/head \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/hhea \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/hmtx \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/hot \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/map \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/maxp \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/name \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/otl \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/post \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/sfnt \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/vhea \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/vmtx \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/pstoken/pstoken \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/typecomp/charset \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/typecomp/cs \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/typecomp/dict \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/typecomp/encoding \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/typecomp/fdselect \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/typecomp/parse \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/typecomp/recode \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/typecomp/sindex \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/typecomp/subr \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/typecomp/t13 \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/typecomp/tc \
|
||||
UnpackedTarball/afdko/c/shared/cffread \
|
||||
UnpackedTarball/afdko/c/shared/ctutil \
|
||||
UnpackedTarball/afdko/c/shared/da \
|
||||
UnpackedTarball/afdko/c/shared/dynarr \
|
||||
UnpackedTarball/afdko/c/shared/sha1 \
|
||||
UnpackedTarball/afdko/c/shared/smem \
|
||||
UnpackedTarball/afdko/c/shared/support/except \
|
||||
UnpackedTarball/afdko/c/shared/support/fixed \
|
||||
))
|
||||
|
||||
$(eval $(call gb_StaticLibrary_add_generated_exception_objects,afdko,\
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/FeatCtx \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/FeatLexer \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/FeatParser \
|
||||
UnpackedTarball/afdko/c/makeotf/lib/hotconv/FeatVisitor \
|
||||
UnpackedTarball/afdko/c/shared/absfont/absfont \
|
||||
UnpackedTarball/afdko/c/shared/absfont/absfont_afm \
|
||||
UnpackedTarball/afdko/c/shared/absfont/absfont_compare \
|
||||
UnpackedTarball/afdko/c/shared/absfont/absfont_desc \
|
||||
UnpackedTarball/afdko/c/shared/absfont/absfont_draw \
|
||||
UnpackedTarball/afdko/c/shared/absfont/absfont_dump \
|
||||
UnpackedTarball/afdko/c/shared/absfont/absfont_metrics \
|
||||
UnpackedTarball/afdko/c/shared/absfont/absfont_path \
|
||||
UnpackedTarball/afdko/c/shared/afdko_version \
|
||||
UnpackedTarball/afdko/c/shared/cfembed \
|
||||
UnpackedTarball/afdko/c/shared/cffread_abs \
|
||||
UnpackedTarball/afdko/c/shared/cffwrite/cffwrite \
|
||||
UnpackedTarball/afdko/c/shared/cffwrite/cffwrite_charset \
|
||||
UnpackedTarball/afdko/c/shared/cffwrite/cffwrite_dict \
|
||||
UnpackedTarball/afdko/c/shared/cffwrite/cffwrite_encoding \
|
||||
UnpackedTarball/afdko/c/shared/cffwrite/cffwrite_fdselect \
|
||||
UnpackedTarball/afdko/c/shared/cffwrite/cffwrite_sindex \
|
||||
UnpackedTarball/afdko/c/shared/cffwrite/cffwrite_subr \
|
||||
UnpackedTarball/afdko/c/shared/cffwrite/cffwrite_t2cstr \
|
||||
UnpackedTarball/afdko/c/shared/cffwrite/cffwrite_varstore \
|
||||
UnpackedTarball/afdko/c/shared/designspace \
|
||||
UnpackedTarball/afdko/c/shared/goadb \
|
||||
UnpackedTarball/afdko/c/shared/namesupport \
|
||||
UnpackedTarball/afdko/c/shared/pdfwrite \
|
||||
UnpackedTarball/afdko/c/shared/pstoken \
|
||||
UnpackedTarball/afdko/c/shared/sfile \
|
||||
UnpackedTarball/afdko/c/shared/sfntread \
|
||||
UnpackedTarball/afdko/c/shared/sfntwrite \
|
||||
UnpackedTarball/afdko/c/shared/slogger \
|
||||
UnpackedTarball/afdko/c/shared/svgwrite \
|
||||
UnpackedTarball/afdko/c/shared/svread/svread \
|
||||
UnpackedTarball/afdko/c/shared/t1cstr \
|
||||
UnpackedTarball/afdko/c/shared/t1read \
|
||||
UnpackedTarball/afdko/c/shared/t1write/t1write \
|
||||
UnpackedTarball/afdko/c/shared/t2cstr \
|
||||
UnpackedTarball/afdko/c/shared/ttread \
|
||||
UnpackedTarball/afdko/c/shared/tx_shared \
|
||||
UnpackedTarball/afdko/c/shared/uforead \
|
||||
UnpackedTarball/afdko/c/shared/ufowrite \
|
||||
UnpackedTarball/afdko/c/shared/varsupport \
|
||||
))
|
||||
|
||||
$(eval $(call gb_StaticLibrary_add_generated_exception_objects,afdko,\
|
||||
UnpackedTarball/afdko/c/mergefonts/mergeFonts \
|
||||
))
|
||||
|
||||
$(eval $(call gb_StaticLibrary_add_generated_cobjects,afdko,\
|
||||
UnpackedTarball/afdko/c/addfeatures/pstoken/pstoken \
|
||||
))
|
||||
|
||||
$(eval $(call gb_StaticLibrary_add_generated_exception_objects,afdko,\
|
||||
UnpackedTarball/afdko/c/addfeatures/cb \
|
||||
UnpackedTarball/afdko/c/addfeatures/fcdb \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/BASE \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/FeatCtx \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/FeatLexer \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/FeatParser \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/FeatParserBaseVisitor \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/FeatParserVisitor \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/FeatVisitor \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/GDEF \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/GPOS \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/GSUB \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/MVAR \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/OS_2 \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/STAT \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/anon \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/cmap \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/glyphmetrics \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/head \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/hmtx \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/hot \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/hotlogger \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/map \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/maxp \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/name \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/otl \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/post \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/sfnt \
|
||||
UnpackedTarball/afdko/c/addfeatures/hotconv/vmtx \
|
||||
))
|
||||
|
||||
$(eval $(call gb_StaticLibrary_add_generated_exception_objects,afdko,\
|
||||
|
||||
+15
-8
@@ -17,19 +17,26 @@ $(eval $(call gb_UnpackedTarball_set_pre_action,afdko,\
|
||||
|
||||
$(eval $(call gb_UnpackedTarball_set_patchlevel,afdko,1))
|
||||
|
||||
# mergeFonts_crash.patch upstream attempt as:
|
||||
# https://github.com/adobe-type-tools/afdko/pull/1806
|
||||
# lookuplist-deref.patch upstream attempt as:
|
||||
# https://github.com/adobe-type-tools/afdko/pull/1840
|
||||
# glyphmetrics-instance.patch upstream attempt as:
|
||||
# https://github.com/adobe-type-tools/afdko/pull/1841
|
||||
|
||||
$(eval $(call gb_UnpackedTarball_add_patches,afdko, \
|
||||
external/afdko/extern_tx.patch \
|
||||
external/afdko/extern_tx_shared.patch \
|
||||
external/afdko/extern_mergefonts.patch \
|
||||
external/afdko/extern_makeotf.patch \
|
||||
external/afdko/warnings.patch \
|
||||
external/afdko/mergeFonts_crash.patch \
|
||||
external/afdko/noverbose.patch \
|
||||
external/afdko/extern_addfeatures.patch \
|
||||
external/afdko/fatal-callback.patch \
|
||||
external/afdko/glyphmetrics-instance.patch \
|
||||
external/afdko/lookuplist-deref.patch \
|
||||
external/afdko/pastend-iterators.patch \
|
||||
external/afdko/itemvariationstore-tag.patch \
|
||||
external/afdko/sfnt-named-structs.patch \
|
||||
external/afdko/antlr4-chrono.patch \
|
||||
external/afdko/ubsan.patch.0 \
|
||||
))
|
||||
|
||||
# static replacement for the cmake-generated version files
|
||||
$(eval $(call gb_UnpackedTarball_add_file,afdko,c/shared/include/afdko_version.h,external/afdko/afdko_version.h))
|
||||
$(eval $(call gb_UnpackedTarball_add_file,afdko,c/shared/afdko_version.cpp,external/afdko/afdko_version.cpp))
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
||||
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* AFDKO Version Implementation
|
||||
*
|
||||
* Static replacement for the cmake-generated afdko_version.cpp. Keep the
|
||||
* version here in sync with AFDKO_TARBALL in download.lst.
|
||||
*/
|
||||
|
||||
#include "afdko_version.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static const char build_version[] = "5.0.1";
|
||||
|
||||
/* Mutable version pointer - initialized by init_fdk_version() */
|
||||
char *FDK_VERSION = NULL;
|
||||
|
||||
/* Initialize FDK_VERSION with a malloc'd copy */
|
||||
void init_fdk_version(void) {
|
||||
if (FDK_VERSION == NULL) {
|
||||
FDK_VERSION = (char *)malloc(strlen(build_version) + 1);
|
||||
if (FDK_VERSION != NULL) {
|
||||
strcpy(FDK_VERSION, build_version);
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* AFDKO Version Header
|
||||
*
|
||||
* Static replacement for the cmake-generated afdko_version.h. Keep the
|
||||
* version in afdko_version.cpp in sync with AFDKO_TARBALL in download.lst.
|
||||
*/
|
||||
|
||||
#ifndef AFDKO_VERSION_H
|
||||
#define AFDKO_VERSION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Mutable version pointer - must be initialized by init_fdk_version() */
|
||||
extern char *FDK_VERSION;
|
||||
|
||||
/* Initialize FDK_VERSION with the build-time version */
|
||||
void init_fdk_version(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AFDKO_VERSION_H */
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
--- afdko/c/addfeatures/cb.h
|
||||
+++ afdko/c/addfeatures/cb.h
|
||||
@@ -19,7 +19,8 @@
|
||||
|
||||
/* --- Basic functions --- */
|
||||
cbCtx cbNew(const char *progname, const char *indir, const char *outdir,
|
||||
- const char *cmapdir, const char *featdir, dnaCtx mainDnaCtx);
|
||||
+ const char *cmapdir, const char *featdir, dnaCtx mainDnaCtx,
|
||||
+ void (*fatal)(void *ctx));
|
||||
void cbConvert(cbCtx h, int flags, const char *clientVers,
|
||||
const char *infile, const char *outfile,
|
||||
const char *featurefile, const char *hcmapfile,
|
||||
--- afdko/c/addfeatures/cb.cpp
|
||||
+++ afdko/c/addfeatures/cb.cpp
|
||||
@@ -91,6 +91,7 @@
|
||||
std::shared_ptr<GOADB> goadb;
|
||||
std::shared_ptr<Designspace> ds;
|
||||
std::shared_ptr<slogger> logger;
|
||||
+ void (*clientFatal)(void *ctx) = NULL; /* Called by myfatal() in place of process exit. Must not return. */
|
||||
};
|
||||
|
||||
/* ----------------------------- Error Handling ---------------------------- */
|
||||
@@ -98,6 +99,8 @@
|
||||
/* Fatal exception handler */
|
||||
static void myfatal(void *ctx) {
|
||||
cbCtx h = (cbCtx) ctx;
|
||||
+ if (h->clientFatal != NULL)
|
||||
+ h->clientFatal(ctx);
|
||||
/*This seems to cause all kinds of crashes on Windows and OSX*/
|
||||
/* hotFree(h->hot.ctx);*/ /* Free library context */
|
||||
|
||||
@@ -468,9 +471,12 @@
|
||||
|
||||
/* Create new callback context */
|
||||
cbCtx cbNew(const char *progname, const char *indir, const char *outdir,
|
||||
- const char *cmapdir, const char *featdir, dnaCtx mainDnaCtx) {
|
||||
+ const char *cmapdir, const char *featdir, dnaCtx mainDnaCtx,
|
||||
+ void (*fatal)(void *ctx)) {
|
||||
cbCtx h = new cbCtx_;
|
||||
|
||||
+ h->clientFatal = fatal;
|
||||
+
|
||||
hotcbInit(h);
|
||||
|
||||
stmClear(&h->in);
|
||||
@@ -808,3 +814,12 @@
|
||||
|
||||
delete h;
|
||||
}
|
||||
+
|
||||
+/* Defined in main.cpp upstream, which is not compiled here. */
|
||||
+extern "C" const char *curdir() {
|
||||
+ return ".";
|
||||
+}
|
||||
+
|
||||
+extern "C" const char *sep() {
|
||||
+ return "/";
|
||||
+}
|
||||
--- afdko/c/addfeatures/pstoken/pstoken.c
|
||||
+++ afdko/c/addfeatures/pstoken/pstoken.c
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
-#include "pstoken.h"
|
||||
+#include "../include/pstoken.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
--- afdko/c/addfeatures/hotconv/map.cpp
|
||||
+++ afdko/c/addfeatures/hotconv/map.cpp
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "otl.h"
|
||||
#include "FeatCtx.h"
|
||||
|
||||
-#include "pstoken.h"
|
||||
+#include "../include/pstoken.h"
|
||||
|
||||
#define SET_BIT_ARR(a, b) (a[(b) / 32] |= 1UL << (b) % 32)
|
||||
#define TEST_BIT_ARR(a, b) (a[(b) / 32] & 1UL << (b) % 32)
|
||||
Vendored
-354
@@ -1,354 +0,0 @@
|
||||
--- afdko/c/makeotf/source/c_main.c
|
||||
+++ afdko/c/makeotf/source/c_main.c
|
||||
@@ -269,6 +269,7 @@
|
||||
exit(0);
|
||||
}
|
||||
|
||||
+#if 0
|
||||
extern char *sep();
|
||||
|
||||
/* Copy directory path with overflow checking */
|
||||
@@ -744,6 +745,7 @@
|
||||
|
||||
convert.fontDone = 1;
|
||||
}
|
||||
+#endif
|
||||
|
||||
/*Used to parse the parameter string passed in by python
|
||||
* start is the start index and is updated to the beginning of the next substring
|
||||
@@ -822,6 +824,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
+#if 0
|
||||
/* Main program */
|
||||
int c_main(int argc, char *argv[]) {
|
||||
dnaCtx mainDnaCtx = NULL;
|
||||
@@ -874,3 +877,4 @@
|
||||
|
||||
return 0;
|
||||
}
|
||||
+#endif
|
||||
--- afdko/c/makeotf/source/cb.c 2025-09-23 13:18:57.919265608 +0100
|
||||
+++ afdko/c/makeotf/source/cb.c 2025-09-23 13:20:13.039352315 +0100
|
||||
@@ -267,14 +267,14 @@
|
||||
/* Full block */
|
||||
*count = fileReadN(&h->ps.file, BUFSIZ, h->ps.buf);
|
||||
if (*count != BUFSIZ) {
|
||||
- fileError(&h->ps.file);
|
||||
+ fileHandleError(&h->ps.file);
|
||||
}
|
||||
h->ps.left -= BUFSIZ;
|
||||
} else if (h->ps.left > 0) {
|
||||
/* Partial block */
|
||||
*count = fileReadN(&h->ps.file, h->ps.left, h->ps.buf);
|
||||
if (*count != h->ps.left) {
|
||||
- fileError(&h->ps.file);
|
||||
+ fileHandleError(&h->ps.file);
|
||||
}
|
||||
h->ps.left = 0;
|
||||
} else {
|
||||
@@ -531,7 +531,7 @@
|
||||
cbCtx h = ctx;
|
||||
h->tmp.file.name = "tmpfile";
|
||||
if ((h->tmp.file.fp = tmpfile()) == NULL) {
|
||||
- fileError(&h->tmp.file);
|
||||
+ fileHandleError(&h->tmp.file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -636,7 +636,7 @@
|
||||
File *file = &h->fcdb.files.array[fileid];
|
||||
fileSeek(file, offset, SEEK_SET);
|
||||
if (fileReadN(file, length, buf) != length)
|
||||
- fileError(file);
|
||||
+ fileHandleError(file);
|
||||
}
|
||||
|
||||
// [fcdb callback] Report database parsing warning.
|
||||
@@ -1185,7 +1185,8 @@
|
||||
|
||||
/* Create new callback context */
|
||||
cbCtx cbNew(char *progname, char *pfbdir, char *otfdir,
|
||||
- char *cmapdir, char *featdir, dnaCtx mainDnaCtx) {
|
||||
+ char *cmapdir, char *featdir, dnaCtx mainDnaCtx,
|
||||
+ void (*fatal)(void*)) {
|
||||
static hotCallbacks template = {
|
||||
NULL, /* Callback context; set after creation */
|
||||
myfatal,
|
||||
@@ -1233,6 +1234,8 @@
|
||||
h->dir.cmap = cmapdir;
|
||||
|
||||
h->hot.cb = template; /* Copy template */
|
||||
+ if (fatal)
|
||||
+ h->hot.cb.fatal = fatal;
|
||||
h->hot.cb.ctx = h;
|
||||
|
||||
h->dnaCtx = mainDnaCtx;
|
||||
--- afdko/c/makeotf/source/file.c 2025-09-23 13:18:57.919265608 +0100
|
||||
+++ afdko/c/makeotf/source/file.c 2025-09-23 13:20:04.148358137 +0100
|
||||
@@ -23,7 +23,7 @@
|
||||
#endif /* SUNOS */
|
||||
|
||||
/* Print file error message and quit */
|
||||
-void fileError(File *f) {
|
||||
+void fileHandleError(File *f) {
|
||||
cbFatal(f->h, "file error <%s> [%s]", strerror(errno), f->name);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
f->name = filename;
|
||||
f->fp = fopen(filename, mode);
|
||||
if (f->fp == NULL) {
|
||||
- fileError(f);
|
||||
+ fileHandleError(f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
int fileReadN(File *f, size_t count, void *ptr) {
|
||||
size_t n = fread(ptr, 1, count, f->fp);
|
||||
if (n == 0 && ferror(f->fp)) {
|
||||
- fileError(f);
|
||||
+ fileHandleError(f);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
@@ -61,7 +61,7 @@
|
||||
int fileWriteN(File *f, size_t count, void *ptr) {
|
||||
size_t n = fwrite(ptr, 1, count, f->fp);
|
||||
if (n != count) {
|
||||
- fileError(f);
|
||||
+ fileHandleError(f);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
@@ -88,7 +88,7 @@
|
||||
/* Seek on file */
|
||||
void fileSeek(File *f, long offset, int wherefrom) {
|
||||
if (fseek(f->fp, offset, wherefrom) != 0) {
|
||||
- fileError(f);
|
||||
+ fileHandleError(f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
long fileTell(File *f) {
|
||||
long posn = ftell(f->fp);
|
||||
if (posn == -1) {
|
||||
- fileError(f);
|
||||
+ fileHandleError(f);
|
||||
}
|
||||
return posn;
|
||||
}
|
||||
@@ -104,7 +104,7 @@
|
||||
/* Check for errors and close file */
|
||||
void fileClose(File *f) {
|
||||
if (ferror(f->fp)) {
|
||||
- fileError(f);
|
||||
+ fileHandleError(f);
|
||||
}
|
||||
fclose(f->fp);
|
||||
}
|
||||
--- afdko/c/makeotf/source/file.h 2025-09-23 13:18:57.919265608 +0100
|
||||
+++ afdko/c/makeotf/source/file.h 2025-09-23 13:20:01.042950337 +0100
|
||||
@@ -29,6 +29,6 @@
|
||||
void fileSeek(File *file, long offset, int wherefrom);
|
||||
long fileTell(File *file);
|
||||
void fileClose(File *file);
|
||||
-void fileError(File *file);
|
||||
+void fileHandleError(File *file);
|
||||
|
||||
#endif /* MAKEOTF_FILE_H */
|
||||
--- afdko/c/makeotf/lib/hotconv/common.h
|
||||
+++ afdko/c/makeotf/lib/hotconv/common.h
|
||||
@@ -14,7 +14,7 @@
|
||||
-#include "hotconv.h"
|
||||
+#include "../../include/hotconv.h"
|
||||
#include "dynarr.h"
|
||||
#include "txops.h"
|
||||
-#include "cffread.h"
|
||||
+#include "../../include/cffread.h"
|
||||
-#include "typecomp.h"
|
||||
+#include "../../include/typecomp.h"
|
||||
#include "ctutil.h"
|
||||
|
||||
--- afdko/c/makeotf/source/package.h
|
||||
+++ afdko/c/makeotf/source/package.h
|
||||
@@ -7,7 +7,7 @@
|
||||
#define MAKEOTF_PACKAGE_SPECS_H
|
||||
|
||||
#define TYPECOMP "typecomp.h"
|
||||
-#define HOTCONV "hotconv.h"
|
||||
+#define HOTCONV "../include/hotconv.h"
|
||||
#define DYNARR "dynarr.h"
|
||||
|
||||
#endif /* MAKEOTF_PACKAGE_SPECS_H */
|
||||
--- afdko/c/makeotf/include/cffread.h
|
||||
+++ afdko/c/makeotf/include/cffread.h
|
||||
@@ -144,7 +144,7 @@
|
||||
to cffFontInfo data structure the function returns. This data structure is
|
||||
described below. */
|
||||
|
||||
-#include "txops.h"
|
||||
+#include "../resource/txops.h"
|
||||
|
||||
typedef unsigned short cffSID; /* String identifier */
|
||||
typedef short cffFWord; /* Font metric in em-relative units */
|
||||
--- afdko/c/makeotf/lib/typecomp/common.h
|
||||
+++ afdko/c/makeotf/lib/typecomp/common.h
|
||||
@@ -7,7 +7,7 @@
|
||||
#define COMMON_H
|
||||
|
||||
#include "dynarr.h"
|
||||
-#include "typecomp.h"
|
||||
+#include "../../include/typecomp.h"
|
||||
#include "stdint.h"
|
||||
|
||||
/* Types */
|
||||
--- afdko/c/makeotf/lib/typecomp/t13.h
|
||||
+++ afdko/c/makeotf/lib/typecomp/t13.h
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "common.h"
|
||||
#include "cs.h"
|
||||
|
||||
-#include "pstoken.h"
|
||||
+#include "../../include/pstoken.h"
|
||||
|
||||
void t13New(tcCtx g);
|
||||
void t13Free(tcCtx g);
|
||||
--- afdko/c/makeotf/lib/hotconv/map.c
|
||||
+++ afdko/c/makeotf/lib/hotconv/map.c
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
|
||||
-#include "pstoken.h"
|
||||
+#include "../../include/pstoken.h"
|
||||
|
||||
#define SET_BIT_ARR(a, b) (a[(b) / 32] |= 1UL << (b) % 32)
|
||||
#define TEST_BIT_ARR(a, b) (a[(b) / 32] & 1UL << (b) % 32)
|
||||
--- afdko/c/makeotf/lib/pstoken/pstoken.c
|
||||
+++ afdko/c/makeotf/lib/pstoken/pstoken.c
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
-#include "pstoken.h"
|
||||
+#include "../../include/pstoken.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
--- afdko/c/makeotf/lib/hotconv/cmap.c
|
||||
+++ afdko/c/makeotf/lib/hotconv/cmap.c
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
-#include "hotconv.h"
|
||||
+#include "../../include/hotconv.h"
|
||||
#include "cmap.h"
|
||||
#include "hotmap.h"
|
||||
#include "feat.h"
|
||||
--- afdko/c/makeotf/lib/cffread/cffread.c
|
||||
+++ afdko/c/makeotf/lib/cffread/cffread.c
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
-#include "cffread.h"
|
||||
-#include "dictops.h"
|
||||
+#include "../../include/cffread.h"
|
||||
+#include "../../resource/dictops.h"
|
||||
|
||||
/* Define to supply Microsoft-specific function calling info, e.g. __cdecl */
|
||||
#ifndef CDECL
|
||||
--- afdko/c/makeotf/lib/typecomp/recode.c
|
||||
+++ afdko/c/makeotf/lib/typecomp/recode.c
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "parse.h"
|
||||
#include "subr.h"
|
||||
|
||||
-#include "txops.h"
|
||||
+#include "../../resource/txops.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
@@ -248,7 +248,7 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
-#include "cffread.h"
|
||||
+#include "../../include/cffread.h"
|
||||
|
||||
/* Degrees to radians multiplying constant */
|
||||
#define DEG_2_RAD (3.141592653589793 / 180)
|
||||
|
||||
--- afdko/c/makeotf/lib/typecomp/parse.c
|
||||
+++ afdko/c/makeotf/lib/typecomp/parse.c
|
||||
@@ -15,8 +15,8 @@
|
||||
#include "t13.h"
|
||||
#include "recode.h"
|
||||
|
||||
-#include "txops.h"
|
||||
-#include "pstoken.h"
|
||||
+#include "../../resource/txops.h"
|
||||
+#include "../../include/pstoken.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
--- afdko/c/makeotf/lib/typecomp/dict.h
|
||||
+++ afdko/c/makeotf/lib/typecomp/dict.h
|
||||
@@ -11,7 +11,7 @@
|
||||
#define DICT_H
|
||||
|
||||
#include "common.h"
|
||||
-#include "dictops.h"
|
||||
+#include "../../resource/dictops.h"
|
||||
|
||||
/* Tokenized dictionary data */
|
||||
typedef dnaDCL(char, DICT);
|
||||
--- afdko/c/makeotf/source/cbpriv.c
|
||||
+++ afdko/c/makeotf/source/cbpriv.c
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
-#include "hotconv.h"
|
||||
+#include "../include/hotconv.h"
|
||||
#include "cb.h"
|
||||
|
||||
extern void myfatal(void *ctx);
|
||||
--- afdko/c/makeotf/source/cb.h
|
||||
+++ afdko/c/makeotf/source/cb.h
|
||||
@@ -8,6 +8,11 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include "dynarr.h"
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+extern "C" {
|
||||
+#endif
|
||||
+
|
||||
typedef struct cbCtx_ *cbCtx;
|
||||
|
||||
/* Define to supply Microsoft-specific function calling info, e.g. __cdecl */
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
/* --- Basic functions --- */
|
||||
extern cbCtx cbNew(char *progname, char *pfbdir, char *otfdir,
|
||||
- char *cmapdir, char *featdir, dnaCtx mainDnaCtx);
|
||||
+ char *cmapdir, char *featdir, dnaCtx mainDnaCtx,
|
||||
+ void (*fatal)(void*));
|
||||
extern void cbConvert(cbCtx h, int flags, char *clientVers,
|
||||
char *pfbfile, char *otffile,
|
||||
char *featurefile, char *hcmapfile, char *vcmapfile,
|
||||
@@ -80,4 +85,8 @@
|
||||
#define OTHERFLAGS_VERBOSE (1 << 15)
|
||||
#define OTHERFLAGS_FINAL_NAMES (1 << 16)
|
||||
|
||||
+#ifdef __cplusplus
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
#endif /* CB_H */
|
||||
+50
-113
@@ -1,116 +1,53 @@
|
||||
--- afdko/c/mergefonts/source/mergeFonts.c 2025-09-23 10:51:19.857082828 +0100
|
||||
+++ afdko/c/mergefonts/source/mergeFonts.c 2025-09-23 10:51:40.645895437 +0100
|
||||
@@ -1200,7 +1200,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
-static void readCIDFontInfo(txCtx h, char *filePath) {
|
||||
+void readCIDFontInfo(txCtx h, char *filePath) {
|
||||
int lineno;
|
||||
FILE *fp;
|
||||
MergeInfo *mergeInfo = (MergeInfo *)h->appSpecificInfo;
|
||||
@@ -1677,7 +1677,7 @@
|
||||
|
||||
/* Process merging multi-file set. Return index of last used arg. */
|
||||
/* Currently implemented only for mode_cff */
|
||||
-static int doMergeFileSet(txCtx h, int argc, char *argv[], int i) {
|
||||
+int doMergeFileSet(txCtx h, int argc, char *argv[], int i) {
|
||||
sourceCtx srcCtx;
|
||||
int fileIndex = 0;
|
||||
int fileCount = 0;
|
||||
@@ -2609,10 +2609,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
+void mergeFontsFree(txCtx h);
|
||||
+
|
||||
/* Initialize context. */
|
||||
-static void txNew(txCtx h, char *progname) {
|
||||
+txCtx mergeFontsNew(char *progname) {
|
||||
ctlMemoryCallbacks cb;
|
||||
- MergeInfo *mergeInfo = (MergeInfo *)h->appSpecificInfo;
|
||||
+ txCtx h;
|
||||
+ MergeInfo *mergeInfo;
|
||||
+
|
||||
+ /* Allocate program context */
|
||||
+ h = malloc(sizeof(struct txCtx_));
|
||||
+ if (h == NULL) {
|
||||
+ fprintf(stderr, "%s: out of memory\n", progname);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ memset(h, 0, sizeof(struct txCtx_));
|
||||
+
|
||||
+ h->app = APP_MERGEFONTS;
|
||||
+ h->appSpecificInfo = malloc(sizeof(MergeInfo));
|
||||
+ if (h == NULL) {
|
||||
+ fprintf(stderr, "%s: out of memory\n", progname);
|
||||
+ free(h);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ memset(h->appSpecificInfo, 0, sizeof(MergeInfo));
|
||||
+
|
||||
+ h->appSpecificFree = mergeFontsFree;
|
||||
+
|
||||
+ mergeInfo = (MergeInfo *)h->appSpecificInfo;
|
||||
|
||||
h->progname = progname;
|
||||
h->flags = 0;
|
||||
@@ -2690,10 +2714,12 @@
|
||||
|
||||
/* Clear the SEEN_MODE bit after setting the default mode */
|
||||
h->flags = 0;
|
||||
+
|
||||
+ return h;
|
||||
}
|
||||
|
||||
/* Free context. */
|
||||
-static void txFree(txCtx h) {
|
||||
+void mergeFontsFree(txCtx h) {
|
||||
long i;
|
||||
|
||||
memFree(h, h->script.buf);
|
||||
@@ -2749,6 +2775,7 @@
|
||||
free(h);
|
||||
}
|
||||
|
||||
+#if 0
|
||||
/* Main program. */
|
||||
int CTL_CDECL main(int argc, char *argv[]) {
|
||||
txCtx h;
|
||||
@@ -2770,25 +2797,11 @@
|
||||
--argc;
|
||||
++argv;
|
||||
|
||||
- /* Allocate program context */
|
||||
- h = malloc(sizeof(struct txCtx_));
|
||||
- if (h == NULL) {
|
||||
- fprintf(stderr, "%s: out of memory\n", progname);
|
||||
- return EXIT_FAILURE;
|
||||
- }
|
||||
- memset(h, 0, sizeof(struct txCtx_));
|
||||
-
|
||||
- h->app = APP_MERGEFONTS;
|
||||
- h->appSpecificInfo = malloc(sizeof(MergeInfo));
|
||||
+ h = mergeFontsNew(progname);
|
||||
if (h == NULL) {
|
||||
fprintf(stderr, "%s: out of memory\n", progname);
|
||||
exit(1);
|
||||
}
|
||||
- memset(h->appSpecificInfo, 0, sizeof(MergeInfo));
|
||||
-
|
||||
- h->appSpecificFree = txFree;
|
||||
-
|
||||
- txNew(h, progname);
|
||||
|
||||
if (argc > 1 && getOptionIndex(argv[argc - 2]) == opt_s) {
|
||||
/* Option list ends with script option */
|
||||
@@ -2810,7 +2823,8 @@
|
||||
fprintf(stderr, "mem_manage() called %ld times in this run.\n",
|
||||
h->failmem.iCall);
|
||||
}
|
||||
- txFree(h);
|
||||
+ mergeFontsFree(h);
|
||||
--- afdko/c/mergefonts/mergeFonts.cpp
|
||||
+++ afdko/c/mergefonts/mergeFonts.cpp
|
||||
@@ -1384,3 +1384,50 @@
|
||||
|
||||
return 0;
|
||||
}
|
||||
+#endif
|
||||
+
|
||||
+/* Embedding interface: the same wiring as main__mergefonts above, but with
|
||||
+ heap allocation and caller-driven steps in place of argv parsing. */
|
||||
+extern "C" txCtx mergeFontsNew(void) {
|
||||
+ MergeInfo *mi = (MergeInfo *)calloc(1, sizeof(MergeInfo));
|
||||
+ txExtCtx e = (txExtCtx)calloc(1, sizeof(struct txExtCtx_));
|
||||
+ txCtx h = (txCtx)calloc(1, sizeof(struct txCtx_));
|
||||
+
|
||||
+ if (mi == NULL || e == NULL || h == NULL) {
|
||||
+ free(mi);
|
||||
+ free(e);
|
||||
+ free(h);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ e->extData = mi;
|
||||
+ e->progname = "mergefonts";
|
||||
+ e->version = MERGEFONTS_VERSION;
|
||||
+ e->processOption = &mf_processOption;
|
||||
+ e->usage = &mf_usage;
|
||||
+ e->help = &mf_help;
|
||||
+ e->cfr_ReadFontCB = &mf_cfr_ReadFontCB;
|
||||
+
|
||||
+ mi->tx = h;
|
||||
+
|
||||
+ txNew(h, e);
|
||||
+
|
||||
+ return h;
|
||||
+}
|
||||
+
|
||||
+extern "C" void mergeFontsFree(txCtx h) {
|
||||
+ txExtCtx e = h->ext;
|
||||
+ void *mi = e->extData;
|
||||
+
|
||||
+ txFree(h);
|
||||
+ free(mi);
|
||||
+ free(e);
|
||||
+ free(h);
|
||||
+}
|
||||
+
|
||||
+extern "C" void mergeFontsReadCIDFontInfo(txCtx h, const char *filePath) {
|
||||
+ readCIDFontInfo((MergeInfo *)h->ext->extData, filePath);
|
||||
+}
|
||||
+
|
||||
+extern "C" int mergeFontsDoMergeFileSet(txCtx h, int argc, char *argv[], int i) {
|
||||
+ return doMergeFileSet(h, argc, argv, i);
|
||||
+}
|
||||
|
||||
Vendored
-64
@@ -1,64 +0,0 @@
|
||||
--- afdko/c/tx/source/tx.c
|
||||
+++ afdko/c/tx/source/tx.c
|
||||
@@ -127,7 +127,7 @@
|
||||
/* ---------------------------- cffread Library ---------------------------- */
|
||||
|
||||
/* Read font with cffread library. */
|
||||
-static void cfrReadFont(txCtx h, long origin, int ttcIndex) {
|
||||
+void cfrReadFont(txCtx h, long origin, int ttcIndex) {
|
||||
float *uv;
|
||||
if (h->cfr.ctx == NULL) {
|
||||
h->cfr.ctx = cfrNew(&h->cb.mem, &h->cb.stm, CFR_CHECK_ARGS);
|
||||
@@ -1403,9 +1403,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
+void txFree(txCtx h);
|
||||
+
|
||||
/* Initialize context. */
|
||||
-static void txNew(txCtx h, char *progname) {
|
||||
+txCtx txNew(char *progname) {
|
||||
ctlMemoryCallbacks cb;
|
||||
+ txCtx h;
|
||||
+
|
||||
+ /* Allocate program context */
|
||||
+ h = malloc(sizeof(struct txCtx_));
|
||||
+ if (h == NULL) {
|
||||
+ fprintf(stderr, "%s: out of memory\n", progname);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ memset(h, 0, sizeof(struct txCtx_));
|
||||
+
|
||||
+ h->app = APP_TX;
|
||||
+ h->appSpecificInfo = NULL; /* unused in tx.c, used in rotateFont.c & mergeFonts.c */
|
||||
+ h->appSpecificFree = txFree;
|
||||
|
||||
h->progname = progname;
|
||||
h->flags = 0;
|
||||
@@ -1480,10 +1495,12 @@
|
||||
|
||||
/* Clear the SEEN_MODE bit after setting the default mode */
|
||||
h->flags = 0;
|
||||
+
|
||||
+ return h;
|
||||
}
|
||||
|
||||
/* Free context. */
|
||||
-static void txFree(txCtx h) {
|
||||
+void txFree(txCtx h) {
|
||||
long i;
|
||||
|
||||
memFree(h, h->script.buf);
|
||||
@@ -1539,6 +1556,7 @@
|
||||
free(h);
|
||||
}
|
||||
|
||||
+#if 0
|
||||
/* Main program. */
|
||||
int CTL_CDECL main(int argc, char *argv[]) {
|
||||
txCtx h;
|
||||
@@ -1602,3 +1620,4 @@
|
||||
|
||||
return 0;
|
||||
}
|
||||
+#endif
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
--- afdko/c/shared/include/tx_shared.h
|
||||
+++ afdko/c/shared/include/tx_shared.h
|
||||
@@ -86,6 +86,11 @@
|
||||
#define sig_UFO CTL_TAG('<', '?', 'x', 'm')
|
||||
/* Generate n-bit mask */
|
||||
#define N_BIT_MASK(n) (~(~0UL << (n)))
|
||||
+
|
||||
+#ifdef __cplusplus
|
||||
+extern "C" {
|
||||
+#endif
|
||||
+
|
||||
enum { MAX_VERSION_SIZE = 100 };
|
||||
|
||||
typedef struct txCtx_ *txCtx; /* tx program context */
|
||||
@@ -587,4 +592,8 @@
|
||||
void ttrReadFont(txCtx h, long origin, int iTTC);
|
||||
void ufoReadFont(txCtx h, long origin);
|
||||
|
||||
+#ifdef __cplusplus
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
#endif /* TX_SHARED_H */
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
--- afdko/c/shared/include/tx_shared.h
|
||||
+++ afdko/c/shared/include/tx_shared.h
|
||||
@@ -288,6 +288,7 @@
|
||||
int mode; /* Current mode */
|
||||
const char *modename; /* Name of current mode */
|
||||
txExtCtx ext; /* Extension context (if any) */
|
||||
+ void (*fatalCallback)(struct txCtx_ *h); /* Called by fatal() in place of process exit. Must not return. */
|
||||
abfTopDict *top; /* Top dictionary */
|
||||
struct { /* Source data */
|
||||
int type; /* Font technology type */
|
||||
--- afdko/c/shared/tx_shared.cpp
|
||||
+++ afdko/c/shared/tx_shared.cpp
|
||||
@@ -33,6 +33,8 @@
|
||||
} else {
|
||||
h->logger->msg(sFATAL, "fatal error");
|
||||
}
|
||||
+ if (h->fatalCallback != NULL)
|
||||
+ h->fatalCallback(h);
|
||||
txFree(h);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
--- afdko/c/addfeatures/hotconv/glyphmetrics.cpp
|
||||
+++ afdko/c/addfeatures/hotconv/glyphmetrics.cpp
|
||||
@@ -294,7 +294,7 @@
|
||||
}
|
||||
|
||||
void GlyphMetrics::processGlyphs(const std::vector<uint16_t> &gids) {
|
||||
- static abfGlyphCallbacks glyphcb = {
|
||||
+ abfGlyphCallbacks glyphcb = {
|
||||
(void *)this,
|
||||
NULL,
|
||||
NULL,
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
The type is defined as a class in varsupport.h and forward declared as a
|
||||
class in cffread_abs.h. absfont.h forward declared it as a struct, which
|
||||
trips -Wmismatched-tags on clang and C4099 on MSVC when both headers are
|
||||
pulled into the same translation unit. absfont.h is only ever included by
|
||||
C++ sources, so the class keyword is safe here.
|
||||
|
||||
--- afdko/c/shared/include/absfont.h
|
||||
+++ afdko/c/shared/include/absfont.h
|
||||
@@ -102,7 +102,7 @@
|
||||
};
|
||||
|
||||
/* item variation store */
|
||||
-struct itemVariationStore;
|
||||
+class itemVariationStore;
|
||||
|
||||
/* Top dictionary data. Comments indicate default/initial values. */
|
||||
typedef struct {
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
--- afdko/c/addfeatures/hotconv/otl.cpp
|
||||
+++ afdko/c/addfeatures/hotconv/otl.cpp
|
||||
@@ -674,15 +674,15 @@ void OTL::prepLookupList() {
|
||||
|
||||
auto prevl = subtables.begin();
|
||||
for (auto sl = prevl + 1; sl <= subtables.end(); sl++) {
|
||||
- auto &slr = *sl;
|
||||
+ Subtable *slr = sl == subtables.end() ? nullptr : sl->get();
|
||||
auto &prevlr = *prevl;
|
||||
- if (sl == subtables.end() || slr->isRef() || slr->isParam() ||
|
||||
+ if (slr == nullptr || slr->isRef() || slr->isParam() ||
|
||||
slr->index.lookup != prevlr->index.lookup) {
|
||||
/* Lookup index change */
|
||||
prevlr->span.lookup = sl;
|
||||
prevl = sl;
|
||||
}
|
||||
- if (sl != subtables.end() && (slr->isRef() || slr->isParam()))
|
||||
+ if (slr != nullptr && (slr->isRef() || slr->isParam()))
|
||||
break;
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
--- afdko/c/mergefonts/source/mergeFonts.c
|
||||
+++ afdko/c/mergefonts/source/mergeFonts.c
|
||||
@@ -1177,21 +1177,21 @@
|
||||
if (end == 0)
|
||||
return;
|
||||
|
||||
- while (start < MAX_DICT_ENTRY_LEN) {
|
||||
- if ((str[start] == ' ') || (str[start] == '\t') || (str[start] == '(') || (str[start] == '\r') || (str[start] == '\n'))
|
||||
- start++;
|
||||
+ while (end >= 0) {
|
||||
+ if ((str[end] == ' ') || (str[end] == '\t') || (str[end] == ')') || (str[end] == '\r') || (str[end] == '\n'))
|
||||
+ end--;
|
||||
else
|
||||
break;
|
||||
}
|
||||
+ str[end + 1] = 0;
|
||||
|
||||
- while (end >= 0) {
|
||||
- if ((str[end] == ' ') || (str[end] == '\t') || (str[end] == ')') || (str[end] == '\r') || (str[end] == '\n'))
|
||||
- end--;
|
||||
+ while (start < MAX_DICT_ENTRY_LEN) {
|
||||
+ if ((str[start] == ' ') || (str[start] == '\t') || (str[start] == '(') || (str[start] == '\r') || (str[start] == '\n'))
|
||||
+ start++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
- str[end + 1] = 0;
|
||||
if (start > 0)
|
||||
memmove(str, &str[start], (end - start) + 2);
|
||||
if (strlen(str) == 0) {
|
||||
Vendored
-56
@@ -1,56 +0,0 @@
|
||||
--- afdko/c/mergefonts/source/mergeFonts.c 2025-10-22 13:47:13.840056699 +0100
|
||||
+++ afdko/c/mergefonts/source/mergeFonts.c 2025-10-22 13:48:02.496428544 +0100
|
||||
@@ -1727,7 +1727,9 @@
|
||||
for (j = 0; j < mergeInfo->newiFDArray.cnt; j++) {
|
||||
if (curMaxFD < mergeInfo->newiFDArray.array[j]) {
|
||||
curMaxFD = mergeInfo->newiFDArray.array[j];
|
||||
- fprintf(stderr, "Adding font dict %d from %s.\n", curMaxFD, h->src.stm.filename);
|
||||
+ if (h->flags & SHOW_NAMES) {
|
||||
+ fprintf(stderr, "Adding font dict %d from %s.\n", curMaxFD, h->src.stm.filename);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
--- afdko/c/makeotf/include/hotconv.h 2025-10-22 14:51:54.161381982 +0100
|
||||
+++ afdko/c/makeotf/include/hotconv.h 2025-10-22 14:57:50.948032645 +0100
|
||||
@@ -383,6 +383,7 @@
|
||||
#define HOT_SUBSET (1<<13)
|
||||
#define HOT_SUPRESS__WIDTH_OPT (1<<14) /* suppress width optimization in CFF: makes it easier to poke at charstrings with other tools */
|
||||
#define HOT_VERBOSE (1<<15) /* Print all warnings and notes: else suppress the most annoying ones. */
|
||||
+#define HOT_SUPRESS_WARNINGS (1<<16) /* Print standard warnings and notes: else suppress the standard warnings. */
|
||||
|
||||
struct hotReadFontOverrides_ /* Record for instructions to modify font as it is read in. */
|
||||
{
|
||||
--- afdko/c/makeotf/lib/hotconv/hot.c 2025-10-22 14:51:49.995353104 +0100
|
||||
+++ afdko/c/makeotf/lib/hotconv/hot.c 2025-10-22 14:56:10.084139451 +0100
|
||||
@@ -324,7 +324,9 @@
|
||||
|
||||
/* Convert to CFF */
|
||||
tcflags = 0;
|
||||
- tcflags |= TC_DO_WARNINGS;
|
||||
+ if (!(flags & HOT_SUPRESS_WARNINGS)) {
|
||||
+ tcflags |= TC_DO_WARNINGS;
|
||||
+ }
|
||||
if (flags & HOT_ADD_AUTH_AREA) {
|
||||
tcflags |= TC_ADDAUTHAREA;
|
||||
}
|
||||
@@ -385,7 +385,9 @@
|
||||
fi->FontName.length);
|
||||
g->font.FontName.array[fi->FontName.length] = '\0';
|
||||
g->font.FontName.cnt = fi->FontName.length + 1;
|
||||
- hotMsg(g, hotHEADING, "processing font <%s>", g->font.FontName.array);
|
||||
+ if (!(flags & HOT_SUPRESS_WARNINGS)) {
|
||||
+ hotMsg(g, hotHEADING, "processing font <%s>", g->font.FontName.array);
|
||||
+ }
|
||||
|
||||
/* Copy basic font information */
|
||||
g->font.Notice = fi->Notice;
|
||||
@@ -1444,7 +1444,7 @@
|
||||
/* Print note, error, warning, or fatal message (from note buffer is fmt is
|
||||
NULL). If note used, handle reuse of g->note. */
|
||||
void CDECL hotMsg(hotCtx g, int level, const char *fmt, ...) {
|
||||
- if (g->cb.message != NULL) {
|
||||
+ if (g->cb.message != NULL && g->convertFlags & HOT_CONVERT_VERBOSE) {
|
||||
// int lenName = g->font.FontName.cnt + 2;
|
||||
|
||||
if (fmt == NULL) {
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
--- afdko/c/addfeatures/hotconv/GPOS.cpp
|
||||
+++ afdko/c/addfeatures/hotconv/GPOS.cpp
|
||||
@@ -1025,12 +1025,14 @@ GPOS::PairPos::Format1::Format1(GPOS &h, GPOS::SubtableInfo &si) : PairPos(h, si
|
||||
auto previ = si.pairs.begin();
|
||||
std::vector<decltype(previ)> pairSetEnds;
|
||||
cac->coverageBegin();
|
||||
- for (auto i = previ + 1; i <= si.pairs.end(); i++) {
|
||||
+ for (auto i = previ + 1;; i++) {
|
||||
if (i == si.pairs.end() || i->first != previ->first) {
|
||||
cac->coverageAddGlyph(previ->first);
|
||||
pairSetEnds.emplace_back(i);
|
||||
previ = i;
|
||||
}
|
||||
+ if (i == si.pairs.end())
|
||||
+ break;
|
||||
}
|
||||
|
||||
auto nvals = MetricsInfo::numValues(ValueFormat1) + MetricsInfo::numValues(ValueFormat2);
|
||||
--- afdko/c/addfeatures/hotconv/otl.cpp
|
||||
+++ afdko/c/addfeatures/hotconv/otl.cpp
|
||||
@@ -463,34 +463,41 @@ void OTL::calcFeatureListIndices() {
|
||||
void OTL::prepScriptList() {
|
||||
std::stable_sort(subtables.begin(), subtables.end(), Subtable::ltScriptList);
|
||||
|
||||
+ if (subtables.size() == 0)
|
||||
+ return;
|
||||
+
|
||||
auto prevs = subtables.begin();
|
||||
- for (auto ss = prevs + 1; ss <= subtables.end(); ss++) {
|
||||
+ for (auto ss = prevs + 1;; ss++) {
|
||||
if (ss == subtables.end() || (*ss)->isAnon() || (*ss)->isStandAlone() ||
|
||||
(*ss)->script != (*prevs)->script) {
|
||||
// script change
|
||||
(*prevs)->span.script = ss;
|
||||
|
||||
auto prevl = prevs;
|
||||
- for (auto sl = prevl + 1; sl <= ss ; sl++) {
|
||||
+ for (auto sl = prevl + 1;; sl++) {
|
||||
if (sl == ss || (*sl)->language != (*prevl)->language) {
|
||||
// language change
|
||||
(*prevl)->span.language = sl;
|
||||
|
||||
auto prevf = prevl;
|
||||
- for (auto sf = prevf + 1; sf <= sl ; sf++) {
|
||||
+ for (auto sf = prevf + 1;; sf++) {
|
||||
if (sf == sl ||
|
||||
(*sf)->index.feature != (*prevf)->index.feature) {
|
||||
// feature index change
|
||||
(*prevf)->span.feature = sf;
|
||||
prevf = sf;
|
||||
}
|
||||
+ if (sf == sl)
|
||||
+ break;
|
||||
}
|
||||
prevl = sl;
|
||||
}
|
||||
+ if (sl == ss)
|
||||
+ break;
|
||||
}
|
||||
prevs = ss;
|
||||
}
|
||||
- if (ss != subtables.end() && ((*ss)->isAnon() || (*ss)->isStandAlone()))
|
||||
+ if (ss == subtables.end() || (*ss)->isAnon() || (*ss)->isStandAlone())
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -560,8 +567,11 @@ Offset OTL::fillScriptList() {
|
||||
void OTL::prepFeatureList() {
|
||||
std::stable_sort(subtables.begin(), subtables.end(), Subtable::ltFeatureList);
|
||||
|
||||
+ if (subtables.size() == 0)
|
||||
+ return;
|
||||
+
|
||||
auto prevf = subtables.begin();
|
||||
- for (auto sf = prevf + 1; sf <= subtables.end(); sf++) {
|
||||
+ for (auto sf = prevf + 1;; sf++) {
|
||||
// Whenever we encounter new feature index, store the current subtable
|
||||
// index in the first subtable of the sequence of subtables that
|
||||
// had the previous subtable index. The array is this divided into
|
||||
@@ -576,16 +586,18 @@ void OTL::prepFeatureList() {
|
||||
(*prevf)->span.feature = sf;
|
||||
|
||||
auto prevl = prevf;
|
||||
- for (auto sl = prevl + 1; sl <= sf; sl++) {
|
||||
+ for (auto sl = prevl + 1;; sl++) {
|
||||
if (sl == sf || (*sl)->index.lookup != (*prevl)->index.lookup) {
|
||||
// lookup index change
|
||||
(*prevl)->span.lookup = sl;
|
||||
prevl = sl;
|
||||
}
|
||||
+ if (sl == sf)
|
||||
+ break;
|
||||
}
|
||||
prevf = sf;
|
||||
}
|
||||
- if (sf != subtables.end() && ((*sf)->isStandAlone() || (*sf)->isAnon()))
|
||||
+ if (sf == subtables.end() || (*sf)->isStandAlone() || (*sf)->isAnon())
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -672,8 +684,11 @@ void OTL::fixFeatureParamOffsets(Offset shortfeatureParamBaseOffset) {
|
||||
void OTL::prepLookupList() {
|
||||
std::stable_sort(subtables.begin(), subtables.end(), Subtable::ltLookupList);
|
||||
|
||||
+ if (subtables.size() == 0)
|
||||
+ return;
|
||||
+
|
||||
auto prevl = subtables.begin();
|
||||
- for (auto sl = prevl + 1; sl <= subtables.end(); sl++) {
|
||||
+ for (auto sl = prevl + 1;; sl++) {
|
||||
Subtable *slr = sl == subtables.end() ? nullptr : sl->get();
|
||||
auto &prevlr = *prevl;
|
||||
if (slr == nullptr || slr->isRef() || slr->isParam() ||
|
||||
@@ -682,7 +697,7 @@ void OTL::prepLookupList() {
|
||||
prevlr->span.lookup = sl;
|
||||
prevl = sl;
|
||||
}
|
||||
- if (slr != nullptr && (slr->isRef() || slr->isParam()))
|
||||
+ if (slr == nullptr || slr->isRef() || slr->isParam())
|
||||
break;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
Give these two structs a tag name. C++20 forbids default member
|
||||
initializers in an unnamed class that is given a typedef name for linkage
|
||||
purposes, which MSVC reports as the hard error C7626. Naming the class
|
||||
takes it out of that rule. clang and gcc accept it either way.
|
||||
|
||||
--- afdko/c/addfeatures/hotconv/sfnt.cpp
|
||||
+++ afdko/c/addfeatures/hotconv/sfnt.cpp
|
||||
@@ -77,7 +77,7 @@
|
||||
|
||||
/* ---------------------------- Table Definition --------------------------- */
|
||||
|
||||
-typedef struct {
|
||||
+typedef struct Entry {
|
||||
int32_t tag = 0;
|
||||
uint32_t checksum = 0;
|
||||
uint32_t offset = 0;
|
||||
@@ -85,7 +85,7 @@
|
||||
} Entry;
|
||||
#define ENTRY_SIZE (uint32 * 4)
|
||||
|
||||
-typedef struct {
|
||||
+typedef struct sfntTbl {
|
||||
Fixed version = 0;
|
||||
uint16_t numTables = 0;
|
||||
uint16_t searchRange = 0;
|
||||
Vendored
+53
-73
@@ -1,53 +1,6 @@
|
||||
--- c/makeotf/lib/cffread/cffread.c
|
||||
+++ c/makeotf/lib/cffread/cffread.c
|
||||
@@ -49,7 +49,7 @@
|
||||
/* Type conversions */
|
||||
#define INT(f) ((int16_t)(((f)&0xffff0000) >> 16))
|
||||
#define FRAC(f) ((f)&0x0000ffff)
|
||||
-#define INT2FIX(i) ((Fixed)(i) << 16)
|
||||
+#define INT2FIX(i) ((Fixed)((uint32_t)(i) << 16))
|
||||
#define FIX2INT(f) ((short)(((f) + FixedHalf) >> 16))
|
||||
#define FIX2DBL(f) ((double)((f) / fixedScale))
|
||||
#define DBL2FIX(d) ((Fixed)((d)*fixedScale + ((d) < 0 ? -0.5 : 0.5)))
|
||||
--- c/makeotf/lib/typecomp/common.h
|
||||
+++ c/makeotf/lib/typecomp/common.h
|
||||
@@ -36,7 +36,7 @@
|
||||
#define INDEX_SIZE(items, size) \
|
||||
((items) == 0 ? sizeCard16 : (sizeCard16 + sizeCard8 + ((items) + 1) * INDEX_OFF_SIZE(size) + (size)))
|
||||
#define FixedHalf ((Fixed)0x00008000)
|
||||
-#define INT2FIX(i) ((Fixed)((uint32_t)i) << 16)
|
||||
+#define INT2FIX(i) ((Fixed)((uint32_t)i << 16))
|
||||
#define DBL2FIX(d) ((Fixed)((double)(d)*65536.0 + ((d) < 0 ? -0.5 : 0.5)))
|
||||
#define FIX2DBL(f) ((double)(f) / 65536.0)
|
||||
#define RNDFIX(f) (((f) + FixedHalf) & 0xffff0000)
|
||||
--- c/makeotf/lib/typecomp/recode.c
|
||||
+++ c/makeotf/lib/typecomp/recode.c
|
||||
@@ -1727,10 +1727,10 @@
|
||||
|
||||
case 255: {
|
||||
/* 5 byte number */
|
||||
- int32_t value = (int32_t)cstr[i + 1] << 24 | (int32_t)cstr[i + 2] << 16 |
|
||||
- (int32_t)cstr[i + 3] << 8 | (int32_t)cstr[i + 4];
|
||||
+ int32_t value = (uint32_t)cstr[i + 1] << 24 | (uint32_t)cstr[i + 2] << 16 |
|
||||
+ (uint32_t)cstr[i + 3] << 8 | (uint32_t)cstr[i + 4];
|
||||
if (-32000 <= value && value <= 32000) {
|
||||
- value <<= 16;
|
||||
+ value = (uint32_t)value << 16;
|
||||
} else {
|
||||
h->intDiv = 1;
|
||||
}
|
||||
@@ -3690,7 +3690,7 @@
|
||||
/* Remove encryption */
|
||||
for (i = 0; i < length; i++) {
|
||||
unsigned char plain = cstr[i] ^ (r1 >> 8);
|
||||
- r1 = (cstr[i] + r1) * 52845 + 22719;
|
||||
+ r1 = (unsigned)(cstr[i] + r1) * 52845 + 22719;
|
||||
cstr[i] = plain;
|
||||
}
|
||||
}
|
||||
--- c/shared/include/cffwrite.h
|
||||
+++ c/shared/include/cffwrite.h
|
||||
@@ -156,7 +156,7 @@
|
||||
@@ -168,7 +168,7 @@
|
||||
compatible with a destination font dict of the same FontName, the function
|
||||
returns 1 else it returns 0. */
|
||||
|
||||
@@ -56,20 +9,20 @@
|
||||
|
||||
/* cfwMergeFDArray() merges all the fdArray font dicts of the passed-in source
|
||||
font top dict into the destination font. It also fills in the array pointed
|
||||
--- c/shared/source/cffwrite/cffwrite.c
|
||||
+++ c/shared/source/cffwrite/cffwrite.c
|
||||
@@ -488,7 +488,8 @@
|
||||
--- c/shared/cffwrite/cffwrite.cpp
|
||||
+++ c/shared/cffwrite/cffwrite.cpp
|
||||
@@ -469,7 +469,8 @@
|
||||
return newFDIndex;
|
||||
}
|
||||
|
||||
-int cfwMergeFDArray(cfwCtx g, abfTopDict *top, int *newFDIndex) {
|
||||
+long cfwMergeFDArray(void *g_, abfTopDict *top, int *newFDIndex) {
|
||||
+ cfwCtx g = g_;
|
||||
+ cfwCtx g = (cfwCtx)g_;
|
||||
abfFontDict *srcDict = &top->FDArray.array[0];
|
||||
int i = 0;
|
||||
|
||||
--- c/shared/source/dynarr/dynarr.c
|
||||
+++ c/shared/source/dynarr/dynarr.c
|
||||
--- c/shared/dynarr.c
|
||||
+++ c/shared/dynarr.c
|
||||
@@ -68,6 +68,9 @@
|
||||
0. If the client has arranged to trap allocation failures in the memory
|
||||
callback functions by using setjmp/longjmp, for example, the -1 return will
|
||||
@@ -80,9 +33,9 @@
|
||||
long dnaGrow(void *object, size_t elemsize, long index) {
|
||||
void *new_ptr;
|
||||
size_t new_size;
|
||||
--- c/shared/source/pstoken/pstoken.c
|
||||
+++ c/shared/source/pstoken/pstoken.c
|
||||
@@ -201,7 +201,7 @@
|
||||
--- c/shared/pstoken.cpp
|
||||
+++ c/shared/pstoken.cpp
|
||||
@@ -199,7 +199,7 @@
|
||||
else {
|
||||
unsigned char cipher = hi_nib << 4 | nib;
|
||||
*dst++ = cipher ^ (h->cipher.r >> 8);
|
||||
@@ -91,7 +44,7 @@
|
||||
hi_nib = -1;
|
||||
}
|
||||
} while (src < end);
|
||||
@@ -232,7 +232,7 @@
|
||||
@@ -230,7 +230,7 @@
|
||||
for (i = 0; i < length; i++) {
|
||||
unsigned char cipher = *src++;
|
||||
*dst++ = cipher ^ (h->cipher.r >> 8);
|
||||
@@ -100,9 +53,9 @@
|
||||
}
|
||||
|
||||
return 0;
|
||||
--- c/shared/source/t1cstr/t1cstr.c
|
||||
+++ c/shared/source/t1cstr/t1cstr.c
|
||||
@@ -1504,13 +1504,13 @@
|
||||
--- c/shared/t1cstr.cpp
|
||||
+++ c/shared/t1cstr.cpp
|
||||
@@ -1494,13 +1494,13 @@
|
||||
|
||||
/* Prime state from random initial bytes */
|
||||
while (lenIV--)
|
||||
@@ -118,29 +71,56 @@
|
||||
}
|
||||
}
|
||||
return t1cSuccess;
|
||||
--- c/shared/source/t1write/t1write.c
|
||||
+++ c/shared/source/t1write/t1write.c
|
||||
@@ -187,7 +187,7 @@
|
||||
@@ -1524,7 +1524,7 @@
|
||||
while (lenIV--) {
|
||||
single = *c ^ (r2 >> 8);
|
||||
r2 = (*c++ + r2) * 16477 + 21483;
|
||||
- r1 = (single + r1) * 52845 + 22719;
|
||||
+ r1 = (unsigned)(single + r1) * 52845 + 22719;
|
||||
}
|
||||
|
||||
/* Double decrypt and copy bytes */
|
||||
@@ -1533,7 +1533,7 @@
|
||||
single = c1 ^ (r2 >> 8);
|
||||
r2 = (c1 + r2) * 16477 + 21483;
|
||||
*p++ = single ^ (r1 >> 8);
|
||||
- r1 = (single + r1) * 52845 + 22719;
|
||||
+ r1 = (unsigned)(single + r1) * 52845 + 22719;
|
||||
}
|
||||
}
|
||||
return t1cSuccess;
|
||||
--- c/shared/t1write/t1write.cpp
|
||||
+++ c/shared/t1write/t1write.cpp
|
||||
@@ -166,7 +166,7 @@
|
||||
char *q = buf;
|
||||
while (cnt--) {
|
||||
unsigned char c = *p++ ^ h->eexec.r >> 8;
|
||||
uint8_t c = *p++ ^ h->eexec.r >> 8;
|
||||
- h->eexec.r = (c + h->eexec.r) * 52845 + 22719;
|
||||
+ h->eexec.r = (unsigned)(c + h->eexec.r) * 52845 + 22719;
|
||||
*q++ = hexmap[c >> 4 & 0xf];
|
||||
*q++ = hexmap[c & 0xf];
|
||||
}
|
||||
@@ -376,7 +376,7 @@
|
||||
@@ -192,7 +192,7 @@
|
||||
/* Binary eexec; encrypt in-place */
|
||||
while (cnt--) {
|
||||
uint8_t c = *p ^ h->eexec.r >> 8;
|
||||
- h->eexec.r = (c + h->eexec.r) * 52845 + 22719;
|
||||
+ h->eexec.r = (unsigned)(c + h->eexec.r) * 52845 + 22719;
|
||||
*p++ = c;
|
||||
}
|
||||
writeDst(h, h->dst.cnt, h->dst.buf);
|
||||
@@ -355,7 +355,7 @@
|
||||
p = data;
|
||||
for (i = 0; i < length; i++) {
|
||||
unsigned char c = *p ^ (r >> 8);
|
||||
uint8_t c = *p ^ (r >> 8);
|
||||
- r = (c + r) * 52845 + 22719;
|
||||
+ r = (unsigned)(c + r) * 52845 + 22719;
|
||||
*p++ = c;
|
||||
}
|
||||
|
||||
--- c/shared/source/t2cstr/t2cstr.c
|
||||
+++ c/shared/source/t2cstr/t2cstr.c
|
||||
@@ -673,7 +673,7 @@
|
||||
--- c/shared/t2cstr.cpp
|
||||
+++ c/shared/t2cstr.cpp
|
||||
@@ -661,7 +661,7 @@
|
||||
|
||||
/* Compute mask length and unused bit mask */
|
||||
h->mask.length = (short)((h->stems.cnt + 7) / 8);
|
||||
@@ -149,9 +129,9 @@
|
||||
|
||||
return 0;
|
||||
}
|
||||
--- c/shared/source/ttread/ttread.c
|
||||
+++ c/shared/source/ttread/ttread.c
|
||||
@@ -721,7 +721,7 @@
|
||||
--- c/shared/ttread.cpp
|
||||
+++ c/shared/ttread.cpp
|
||||
@@ -673,7 +673,7 @@
|
||||
|
||||
/* Read 4-byte signed number. */
|
||||
static int32_t sread4(ttrCtx h) {
|
||||
|
||||
Vendored
-20
@@ -1,20 +0,0 @@
|
||||
--- afdko/c/shared/include/tx_shared.h
|
||||
+++ afdko/c/shared/include/tx_shared.h
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
-#if PLAT_MAC
|
||||
+#ifdef PLAT_MAC
|
||||
#include <console.h>
|
||||
#include <file_io.h>
|
||||
#endif /* PLAT_MAC */
|
||||
@@ -48,7 +48,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <limits.h>
|
||||
|
||||
-#if _WIN32
|
||||
+#ifdef _WIN32
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#define stat _stat
|
||||
@@ -3603,6 +3603,8 @@ extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.h
|
||||
extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.cpp
|
||||
extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.h
|
||||
extensions/test/ole/unoTocomCalls/XCallback_Impl/resource.h
|
||||
external/afdko/afdko_version.cpp
|
||||
external/afdko/afdko_version.h
|
||||
external/bluez_bluetooth/inc/bluetooth/bluetooth.h
|
||||
external/cairo/configs/wnt_cairo_config.h
|
||||
external/cairo/configs/wnt_cairo_features.h
|
||||
|
||||
@@ -15,19 +15,37 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// the afdko headers are not warning-clean
|
||||
#if defined __GNUC__ || defined __clang__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wundef"
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
#endif
|
||||
#if defined _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4100) // goadb.h error() ignores its message parameter
|
||||
#pragma warning(disable : 4309) // varsupport.h passes 0x8000 to the int16_t writer w2
|
||||
#endif
|
||||
|
||||
#include <afdko_version.h>
|
||||
#include <tx_shared.h>
|
||||
#include <hotconv.h>
|
||||
#include <cb.h>
|
||||
|
||||
extern "C" {
|
||||
extern txCtx txNew(char* progname);
|
||||
extern void txFree(txCtx h);
|
||||
extern void cfrReadFont(txCtx h, long origin, int ttcIndex);
|
||||
#if defined __GNUC__ || defined __clang__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
extern txCtx mergeFontsNew(char* progname);
|
||||
// the mergefonts embedding interface added by extern_mergefonts.patch
|
||||
extern "C" {
|
||||
extern txCtx mergeFontsNew(void);
|
||||
extern void mergeFontsFree(txCtx h);
|
||||
extern void readCIDFontInfo(txCtx h, char* filePath);
|
||||
extern int doMergeFileSet(txCtx h, int argc, char* args[], int i);
|
||||
extern void mergeFontsReadCIDFontInfo(txCtx h, const char* filePath);
|
||||
extern int mergeFontsDoMergeFileSet(txCtx h, int argc, char* argv[], int i);
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
|
||||
@@ -24,71 +24,54 @@
|
||||
|
||||
#if HAVE_FEATURE_AFDKO && !USE_AFDKO_PROGRAMS
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "afdko.hxx"
|
||||
|
||||
#define SUPERVERBOSE 0
|
||||
|
||||
static bool convertTx(txCtx h)
|
||||
namespace
|
||||
{
|
||||
h->src.stm.fp = fopen(h->src.stm.filename, "rb");
|
||||
if (!h->src.stm.fp)
|
||||
return false;
|
||||
|
||||
h->src.stm.flags = STM_DONT_CLOSE;
|
||||
|
||||
buildFontList(h);
|
||||
|
||||
for (long i = 0; i < h->fonts.cnt; ++i)
|
||||
// Routes afdko messages to the sal log so nothing is written to stderr.
|
||||
class SalLogger final : public slogger
|
||||
{
|
||||
public:
|
||||
void msg(int level, const char* message) override
|
||||
{
|
||||
const FontRec& rec = h->fonts.array[i];
|
||||
|
||||
h->src.type = rec.type;
|
||||
|
||||
switch (h->src.type)
|
||||
{
|
||||
case src_Type1:
|
||||
t1rReadFont(h, rec.offset);
|
||||
break;
|
||||
case src_OTF:
|
||||
h->cfr.flags |= CFR_NO_ENCODING;
|
||||
[[fallthrough]];
|
||||
case src_CFF:
|
||||
cfrReadFont(h, rec.offset, rec.iTTC);
|
||||
break;
|
||||
case src_TrueType:
|
||||
ttrReadFont(h, rec.offset, rec.iTTC);
|
||||
break;
|
||||
default:
|
||||
SAL_WARN("vcl.fonts", "unhandled font type: " << h->src.type);
|
||||
break;
|
||||
}
|
||||
if (level >= sWARNING)
|
||||
SAL_WARN("vcl.fonts", "afdko: " << message);
|
||||
else
|
||||
SAL_INFO("vcl.fonts", "afdko: " << message);
|
||||
}
|
||||
int set_context(const char*, int, const char*) override { return log_context_new; }
|
||||
int clear_context(const char*) override { return 0; }
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void suppressDebugMessagess(txCtx h)
|
||||
std::shared_ptr<slogger> createSalLogger(const char* /*name*/)
|
||||
{
|
||||
#if !SUPERVERBOSE
|
||||
h->t1r.dbg.fp = nullptr;
|
||||
h->cfr.dbg.fp = nullptr;
|
||||
h->svr.dbg.fp = nullptr;
|
||||
h->ufr.dbg.fp = nullptr;
|
||||
h->ufow.dbg.fp = nullptr;
|
||||
h->ttr.dbg.fp = nullptr;
|
||||
h->cfw.dbg.fp = nullptr;
|
||||
h->t1w.dbg.fp = nullptr;
|
||||
h->svw.dbg.fp = nullptr;
|
||||
#else
|
||||
(void)h;
|
||||
#endif
|
||||
static std::shared_ptr<slogger> aLogger = std::make_shared<SalLogger>();
|
||||
return aLogger;
|
||||
}
|
||||
|
||||
static void txFatalCallback(txCtx h)
|
||||
// Both logger channels: getLogger covers the C++ contexts created by
|
||||
// txNew/cbNew, extc_logger covers the sLog calls from the C sources.
|
||||
void installSalLogger()
|
||||
{
|
||||
slogger::getLogger = createSalLogger;
|
||||
slogger::extc_logger = createSalLogger(nullptr);
|
||||
}
|
||||
|
||||
void txFatalCallback(txCtx h)
|
||||
{
|
||||
txFree(h);
|
||||
throw std::runtime_error("fatal tx error");
|
||||
}
|
||||
|
||||
void mergeFontsFatalCallback(txCtx h)
|
||||
{
|
||||
mergeFontsFree(h);
|
||||
throw std::runtime_error("fatal mergeFonts error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// System afdko could be used by calling: tx -dump src dest here
|
||||
@@ -112,21 +95,16 @@ bool EmbeddedFontsManager::tx_dump(const OUString& srcFontUrl, const OUString& d
|
||||
|
||||
return system(txCommand.getStr()) == 0;
|
||||
#else
|
||||
txCtx h = txNew(nullptr);
|
||||
if (!h)
|
||||
return false;
|
||||
// appSpecificFree is only called on error so we can piggyback on that
|
||||
// to intercept what would otherwise be a fatal error
|
||||
h->appSpecificFree = txFatalCallback;
|
||||
suppressDebugMessagess(h);
|
||||
|
||||
h->src.stm.filename = const_cast<char*>(srcFontPathA.getStr());
|
||||
h->dst.stm.filename = const_cast<char*>(destFilePathA.getStr());
|
||||
installSalLogger();
|
||||
try
|
||||
{
|
||||
bool result = convertTx(h);
|
||||
txFree(h);
|
||||
return result;
|
||||
struct txCtx_ aTx = {};
|
||||
txNew(&aTx, nullptr);
|
||||
aTx.fatalCallback = txFatalCallback;
|
||||
dstFileSetName(&aTx, destFilePathA.getStr());
|
||||
doSingleFileSet(&aTx, srcFontPathA.getStr());
|
||||
txFree(&aTx);
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
@@ -160,23 +138,17 @@ bool EmbeddedFontsManager::tx_t1(const OUString& srcFontUrl, const OUString& des
|
||||
SAL_INFO("vcl.fonts", txCommand);
|
||||
return system(txCommand.getStr()) == 0;
|
||||
#else
|
||||
txCtx h = txNew(nullptr);
|
||||
if (!h)
|
||||
return false;
|
||||
// appSpecificFree is only called on error so we can piggyback on that
|
||||
// to intercept what would otherwise be a fatal error
|
||||
h->appSpecificFree = txFatalCallback;
|
||||
suppressDebugMessagess(h);
|
||||
|
||||
setMode(h, mode_t1);
|
||||
|
||||
h->src.stm.filename = const_cast<char*>(srcFontPathA.getStr());
|
||||
h->dst.stm.filename = const_cast<char*>(destFilePathA.getStr());
|
||||
installSalLogger();
|
||||
try
|
||||
{
|
||||
bool result = convertTx(h);
|
||||
txFree(h);
|
||||
return result;
|
||||
struct txCtx_ aTx = {};
|
||||
txNew(&aTx, nullptr);
|
||||
aTx.fatalCallback = txFatalCallback;
|
||||
setMode(&aTx, mode_t1);
|
||||
dstFileSetName(&aTx, destFilePathA.getStr());
|
||||
doSingleFileSet(&aTx, srcFontPathA.getStr());
|
||||
txFree(&aTx);
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
@@ -190,14 +162,6 @@ bool EmbeddedFontsManager::tx_t1(const OUString& srcFontUrl, const OUString& des
|
||||
return false;
|
||||
}
|
||||
|
||||
#if HAVE_FEATURE_AFDKO && !USE_AFDKO_PROGRAMS
|
||||
static void mergeFontsFatalCallback(txCtx h)
|
||||
{
|
||||
mergeFontsFree(h);
|
||||
throw std::runtime_error("fatal mergeFonts error");
|
||||
}
|
||||
#endif
|
||||
|
||||
// System afdko could be used by calling: mergefonts -cid cidfontinfo destfile [glyphaliasfile mergefontfile]+ here
|
||||
bool EmbeddedFontsManager::mergefonts(const OUString& cidFontInfoUrl, const OUString& destFileUrl,
|
||||
const std::vector<std::pair<OUString, OUString>>& fonts)
|
||||
@@ -233,6 +197,10 @@ bool EmbeddedFontsManager::mergefonts(const OUString& cidFontInfoUrl, const OUSt
|
||||
OString cidFontInfoPathA(cidFontInfoPath.toUtf8());
|
||||
OString destFilePathA(destFilePath.toUtf8());
|
||||
|
||||
bool result = false;
|
||||
OUString tmpdestfile = destFilePath + ".temp";
|
||||
OString tmpdestfileA = tmpdestfile.toUtf8();
|
||||
|
||||
#if USE_AFDKO_PROGRAMS
|
||||
OStringBuffer aBuffer;
|
||||
for (const auto& path : paths)
|
||||
@@ -243,22 +211,25 @@ bool EmbeddedFontsManager::mergefonts(const OUString& cidFontInfoUrl, const OUSt
|
||||
|
||||
if (system(mergeFontsCommand.getStr()) != 0)
|
||||
return false;
|
||||
|
||||
// convert that merged cid result to Type 1
|
||||
OString txCommand = TX " -t1 " + destFilePathA + " " + tmpdestfileA;
|
||||
SAL_INFO("vcl.fonts", txCommand);
|
||||
result = system(txCommand.getStr()) == 0;
|
||||
#else
|
||||
txCtx h = mergeFontsNew(nullptr);
|
||||
installSalLogger();
|
||||
txCtx h = mergeFontsNew();
|
||||
if (!h)
|
||||
return false;
|
||||
// appSpecificFree is only called on error so we can piggyback on that
|
||||
// to intercept what would otherwise be a fatal error
|
||||
h->appSpecificFree = mergeFontsFatalCallback;
|
||||
suppressDebugMessagess(h);
|
||||
h->fatalCallback = mergeFontsFatalCallback;
|
||||
|
||||
try
|
||||
{
|
||||
readCIDFontInfo(h, const_cast<char*>(cidFontInfoPathA.getStr()));
|
||||
mergeFontsReadCIDFontInfo(h, cidFontInfoPathA.getStr());
|
||||
|
||||
setMode(h, mode_cff);
|
||||
|
||||
dstFileSetName(h, const_cast<char*>(destFilePathA.getStr()));
|
||||
dstFileSetName(h, destFilePathA.getStr());
|
||||
h->cfw.flags |= CFW_CHECK_IF_GLYPHS_DIFFER;
|
||||
h->cfw.flags |= CFW_PRESERVE_GLYPH_ORDER;
|
||||
|
||||
@@ -268,33 +239,16 @@ bool EmbeddedFontsManager::mergefonts(const OUString& cidFontInfoUrl, const OUSt
|
||||
args.push_back(const_cast<char*>(path.getStr()));
|
||||
}
|
||||
// merge the input fonts into destfile
|
||||
size_t resultarg = doMergeFileSet(h, args.size(), args.data(), 0);
|
||||
size_t resultarg = mergeFontsDoMergeFileSet(h, args.size(), args.data(), 0);
|
||||
SAL_WARN_IF(resultarg != args.size() - 1, "vcl.fonts",
|
||||
"suspicious doMergeFileSet result of: " << resultarg);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
SAL_WARN("vcl.fonts", "mergeFonts failure: " << e.what());
|
||||
}
|
||||
#endif
|
||||
|
||||
// convert that merged cid result to Type 1
|
||||
bool result = false;
|
||||
OUString tmpdestfile = destFilePath + ".temp";
|
||||
OString tmpdestfileA = tmpdestfile.toUtf8();
|
||||
|
||||
#if USE_AFDKO_PROGRAMS
|
||||
OString txCommand = TX " -t1 " + destFilePathA + " " + tmpdestfileA;
|
||||
SAL_INFO("vcl.fonts", txCommand);
|
||||
result = system(txCommand.getStr()) == 0;
|
||||
#else
|
||||
try
|
||||
{
|
||||
h->src.stm.filename = const_cast<char*>(destFilePathA.getStr());
|
||||
h->dst.stm.filename = const_cast<char*>(tmpdestfileA.getStr());
|
||||
// convert that merged cid result to Type 1
|
||||
setMode(h, mode_t1);
|
||||
result = convertTx(h);
|
||||
dstFileSetName(h, tmpdestfileA.getStr());
|
||||
doSingleFileSet(h, destFilePathA.getStr());
|
||||
mergeFontsFree(h);
|
||||
result = true;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
@@ -311,8 +265,8 @@ bool EmbeddedFontsManager::mergefonts(const OUString& cidFontInfoUrl, const OUSt
|
||||
(void)cidFontInfoUrl;
|
||||
(void)destFileUrl;
|
||||
(void)fonts;
|
||||
#endif
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HAVE_FEATURE_AFDKO && !USE_AFDKO_PROGRAMS
|
||||
@@ -330,10 +284,10 @@ static void* cb_memory(ctlMemoryCallbacks* /*cb*/, void* old, size_t size)
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static void makeOtfFatalCallback(void*) { throw std::runtime_error("fatal tx error"); }
|
||||
static void makeOtfFatalCallback(void*) { throw std::runtime_error("fatal addfeatures error"); }
|
||||
#endif
|
||||
|
||||
// System afdko could be used by calling: makeotf[exe] -mf fontMenuNameDB -f srcFont -o destFile -ch charMap [-ff features]
|
||||
// System afdko could be used by calling: makeotf -mf fontMenuNameDB -f srcFont -o destFile -ch charMap [-ff features]
|
||||
bool EmbeddedFontsManager::makeotf(const OUString& srcFontUrl, const OUString& destFileUrl,
|
||||
const OUString& fontMenuNameDBUrl, const OUString& charMapUrl,
|
||||
const OUString& featuresUrl)
|
||||
@@ -387,39 +341,58 @@ bool EmbeddedFontsManager::makeotf(const OUString& srcFontUrl, const OUString& d
|
||||
|
||||
return system(makeotfCommand.getStr()) == 0;
|
||||
#else
|
||||
installSalLogger();
|
||||
|
||||
// hotconv only reads CFF (or an sfnt wrapping one), so first convert the
|
||||
// Type 1 input to bare CFF the same way the makeotf driver script does
|
||||
// with: tx -cff -std -F
|
||||
OString cffFilePathA = destFilePathA + ".cff";
|
||||
try
|
||||
{
|
||||
struct txCtx_ aTx = {};
|
||||
txNew(&aTx, nullptr);
|
||||
aTx.fatalCallback = txFatalCallback;
|
||||
setMode(&aTx, mode_cff);
|
||||
aTx.cfw.flags |= CFW_FORCE_STD_ENCODING;
|
||||
aTx.cfw.flags |= CFW_NO_FAMILY_OPT;
|
||||
dstFileSetName(&aTx, cffFilePathA.getStr());
|
||||
doSingleFileSet(&aTx, srcFontPathA.getStr());
|
||||
txFree(&aTx);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
SAL_WARN("vcl.fonts", "tx failure: " << e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
ctlMemoryCallbacks cb_dna_memcb{ nullptr, cb_memory };
|
||||
dnaCtx mainDnaCtx = dnaNew(&cb_dna_memcb, DNA_CHECK_ARGS);
|
||||
|
||||
cbCtx cbctx
|
||||
= cbNew(nullptr, const_cast<char*>(""), const_cast<char*>(""), const_cast<char*>(""),
|
||||
const_cast<char*>(""), mainDnaCtx, makeOtfFatalCallback);
|
||||
cbCtx cbctx = cbNew("addfeatures", "", "", "", "", mainDnaCtx, makeOtfFatalCallback);
|
||||
|
||||
ret = true;
|
||||
try
|
||||
{
|
||||
cbFCDBRead(cbctx, const_cast<char*>(fontMenuNameDBPathA.getStr()));
|
||||
cbFCDBRead(cbctx, fontMenuNameDBPathA.getStr());
|
||||
|
||||
int flags = HOT_NO_OLD_OPS;
|
||||
int fontConvertFlags = 0;
|
||||
#if !SUPERVERBOSE
|
||||
flags |= HOT_SUPRESS_WARNINGS | HOT_SUPRESS_HINT_WARNINGS;
|
||||
#else
|
||||
fontConvertFlags |= HOT_CONVERT_VERBOSE;
|
||||
#endif
|
||||
|
||||
cbConvert(cbctx, flags, nullptr, const_cast<char*>(srcFontPathA.getStr()),
|
||||
const_cast<char*>(destFilePathA.getStr()),
|
||||
!featuresPathA.isEmpty() ? const_cast<char*>(featuresPathA.getStr()) : nullptr,
|
||||
!charMapPathA.isEmpty() ? const_cast<char*>(charMapPathA.getStr()) : nullptr,
|
||||
nullptr, nullptr, nullptr, fontConvertFlags, 0, 0, 0, 0, -1, -1, 0, nullptr);
|
||||
// the name table version string asserts on a null client version
|
||||
init_fdk_version();
|
||||
cbConvert(cbctx, 0, FDK_VERSION, cffFilePathA.getStr(), destFilePathA.getStr(),
|
||||
!featuresPathA.isEmpty() ? featuresPathA.getStr() : nullptr,
|
||||
!charMapPathA.isEmpty() ? charMapPathA.getStr() : nullptr, nullptr, nullptr,
|
||||
nullptr, 0, HOT_CMAP_UNKNOWN, HOT_CMAP_UNKNOWN, 0, -1, -1, 0, nullptr);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
SAL_WARN("vcl.fonts", "mergeFonts failure: " << e.what());
|
||||
SAL_WARN("vcl.fonts", "addfeatures failure: " << e.what());
|
||||
ret = false;
|
||||
}
|
||||
|
||||
cbFree(cbctx);
|
||||
|
||||
OUString cffFileUrl;
|
||||
osl::FileBase::getFileURLFromSystemPath(destFilePath + ".cff", cffFileUrl);
|
||||
osl::File::remove(cffFileUrl);
|
||||
#endif
|
||||
#else
|
||||
(void)srcFontUrl;
|
||||
|
||||
Reference in New Issue
Block a user