diff --git a/BUILD.gn b/BUILD.gn index beedba3..9566958 100755 --- a/BUILD.gn +++ b/BUILD.gn @@ -93,9 +93,14 @@ action("freetype_action") { "$freetype_path", "--source-dir", "$freetype_source_path", - "--cfp-enable", - "$freetype_feature_cfp_enable" ] + + if (freetype_feature_cfp_enable) { + args += [ + "--cfp-enable", + "$freetype_feature_cfp_enable" + ] + } } if (defined(ohos_lite)) { @@ -187,7 +192,6 @@ if (defined(ohos_lite)) { "//third_party/skia/m133:typeface_freetype", "//third_party/skia/m133:typeface_freetype_tests", "//out/*", - "//vendor/thirdparty/*", ] sources = get_target_outputs(":freetype_action") @@ -197,8 +201,8 @@ if (defined(ohos_lite)) { external_deps = [ "zlib:libz" ] defines = [ "FT_CONFIG_OPTION_SYSTEM_ZLIB" ] if (freetype_feature_cfp_enable) { + visibility += [ "//vendor/thirdparty/*" ] defines += [ "FT_CONFIG_OPTION_ENABLE_CFP" ] - external_deps += [ "hilog:libhilog" ] } if (current_os == "ohos") { defines += [ "FT_CONFIG_OPTION_USE_PNG" ] diff --git a/backport-freetype-enable-cfp.patch b/backport-freetype-enable-cfp.patch index 94c1c92..39c0373 100644 --- a/backport-freetype-enable-cfp.patch +++ b/backport-freetype-enable-cfp.patch @@ -1,5 +1,5 @@ diff --git a/src/base/ftinit.c b/src/base/ftinit.c -index 9a6c00e..767c318 100644 +index 9a6c00e..58cd267 100644 --- a/src/base/ftinit.c +++ b/src/base/ftinit.c @@ -4,7 +4,7 @@ @@ -39,12 +39,12 @@ index 9a6c00e..767c318 100644 + if (cfp_modlue == NULL) { + FT_Bool res = CFP_Load_Plugin(); + if (!res) { -+ FT_LOGE("Fail to load cfp plugin"); ++ FT_TRACE1(( "Fail to load cfp plugin\n" )); + } + + cfp_modlue = (FT_Module_Class *)CFP_Load_Module(); + if (cfp_modlue == NULL) { -+ FT_LOGE("Fail to load cfp module class"); ++ FT_TRACE1(( "Fail to load cfp module class\n" )); + } + } + @@ -55,10 +55,10 @@ index 9a6c00e..767c318 100644 * FT_Module_Class** != const FT_Module_Class* const* diff --git a/src/cfp/cfp.c b/src/cfp/cfp.c new file mode 100755 -index 0000000..04a65a2 +index 0000000..9e95620 --- /dev/null +++ b/src/cfp/cfp.c -@@ -0,0 +1,92 @@ +@@ -0,0 +1,91 @@ +/* + * Copyright (c) 2026 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); @@ -91,14 +91,14 @@ index 0000000..04a65a2 + if (g_handle == NULL) { + g_handle = dlopen(CFP_PLUGIN_LIB_PATH, RTLD_LAZY); + if (!g_handle) { -+ FT_LOGE("Fail to dlopen cfp plugin %{public}s", dlerror()); ++ FT_TRACE1(( "Fail to dlopen cfp plugin %s\n", dlerror() )); + return 0; + } + } + + create_plugin_func = (CFP_Create_Plugin_Func)dlsym(g_handle, CFP_CREATE_PLUGIN); + if (create_plugin_func == NULL) { -+ FT_LOGE("Fail to dlsym create plugin func %{public}s", dlerror()); ++ FT_TRACE1(( "Fail to dlsym create plugin func %s\n", dlerror() )); + return 0; + } + @@ -106,8 +106,7 @@ index 0000000..04a65a2 + if (cfp != NULL) { + return 1; + } -+ -+ FT_LOGE("Fail to unsupported cfp plugin, please disable the freetype_feature_cfp_enable feature"); ++ FT_TRACE1(( "Fail to unsupported cfp plugin, please disable the freetype_feature_cfp_enable feature" )); + return 0; +} + @@ -117,7 +116,7 @@ index 0000000..04a65a2 + return cfp->load_module(); + } + -+ FT_LOGE("Fail to load plugin"); ++ FT_TRACE1(( "Fail to load plugin" )); + return NULL; +} + @@ -154,7 +153,7 @@ index 0000000..04a65a2 \ No newline at end of file diff --git a/src/cfp/cfp.h b/src/cfp/cfp.h new file mode 100755 -index 0000000..0d965c0 +index 0000000..4fd0f9e --- /dev/null +++ b/src/cfp/cfp.h @@ -0,0 +1,69 @@ @@ -177,9 +176,9 @@ index 0000000..0d965c0 +#define CFP_H_ + +#include ++#include +#include + -+#include "../..//src/cfp/ftlog.h" +#include "../..//src/truetype/ttobjs.h" + +FT_BEGIN_HEADER @@ -228,53 +227,6 @@ index 0000000..0d965c0 + +#endif /* CFP_H_ */ \ No newline at end of file -diff --git a/src/cfp/ftlog.h b/src/cfp/ftlog.h -new file mode 100755 -index 0000000..1779e72 ---- /dev/null -+++ b/src/cfp/ftlog.h -@@ -0,0 +1,40 @@ -+/* -+ * Copyright (c) 2026 Huawei Device Co., Ltd. -+ * Licensed under the Apache License, Version 2.0 (the "License"); -+ * you may not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ */ -+ -+#ifndef FT_LOG_H_ -+#define FT_LOG_H_ -+ -+#include -+ -+#ifndef LOG_DOMAIN -+#define LOG_DOMAIN 0xD001408 -+#endif -+ -+#ifndef LOG_TAG -+#define LOG_TAG "FreeType" -+#endif -+ -+#define FILE_NAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) -+ -+#define FT_LOGD(fmt, ...) \ -+ HILOG_DEBUG(LOG_CORE, "[%{public}s %{public}s:%{public}d] " fmt, FILE_NAME, __func__, __LINE__, ##__VA_ARGS__) -+#define FT_LOGI(fmt, ...) \ -+ HILOG_INFO(LOG_CORE, "[%{public}s %{public}s:%{public}d] " fmt, FILE_NAME, __func__, __LINE__, ##__VA_ARGS__) -+#define FT_LOGW(fmt, ...) \ -+ HILOG_WARN(LOG_CORE, "[%{public}s %{public}s:%{public}d] " fmt, FILE_NAME, __func__, __LINE__, ##__VA_ARGS__) -+#define FT_LOGE(fmt, ...) \ -+ HILOG_ERROR(LOG_CORE, "[%{public}s %{public}s:%{public}d] " fmt, FILE_NAME, __func__, __LINE__, ##__VA_ARGS__) -+ -+#endif /* FT_LOG_H_ */ -\ No newline at end of file diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index b656ccf..d68fc38 100644 --- a/src/truetype/ttgload.c diff --git a/bundle.json b/bundle.json index bdd6d44..b87e8d7 100644 --- a/bundle.json +++ b/bundle.json @@ -24,8 +24,7 @@ "deps": { "components": [ "libpng", - "zlib", - "hilog" + "zlib" ], "third_party": [ ] diff --git a/install.py b/install.py index e436794..b70d1ab 100755 --- a/install.py +++ b/install.py @@ -98,13 +98,13 @@ def main(): freetype_path = argparse.ArgumentParser() freetype_path.add_argument('--gen-dir', help='generate path of log', required=True) freetype_path.add_argument('--source-dir', help='generate path of log', required=True) - freetype_path.add_argument('--cfp-enable', help='generate path of log', required=True) + freetype_path.add_argument('--cfp-enable', help='generate path of log') args = freetype_path.parse_args() tar_file_path = os.path.join(args.source_dir, "freetype-2.13.3.tar.xz") target_dir = os.path.join(args.gen_dir, "freetype") target_include_dir = os.path.join(target_dir, "include") - cfp_enable = args.cfp_enable.lower() == "true" + cfp_enable = (args.cfp_enable is not None and args.cfp_enable.lower() == "true") untar_file(tar_file_path, target_dir) move_file(args.source_dir, target_dir, cfp_enable) move_include(args.source_dir, target_include_dir)