diff --git a/thirdparty/fontconfig/HPKBUILD b/thirdparty/fontconfig/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..8b5d7ab74ea79be8ee1b146fbf6889042e659381 --- /dev/null +++ b/thirdparty/fontconfig/HPKBUILD @@ -0,0 +1,124 @@ +# Contributor: 小肉头君 +# Maintainer: 小肉头君 + +pkgname=fontconfig +pkgver=2.14.2 +pkgrel=0 +pkgdesc="Font configuration and customization library." +url="https://gitlab.freedesktop.org/fontconfig/fontconfig" +archs=("armeabi-v7a" "arm64-v8a") +license=("MIT License") +depends=("freetype2" "libxml2" "libpng" "json-c") +makedepends=("gperf" "gettextize" "autopoint" "libtool") +source="https://gitlab.freedesktop.org/fontconfig/${pkgname}/-/archive/2.14.2/${pkgname}-${pkgver}.tar.gz" + +autounpack=true +downloadpackage=true +buildtools="configure" + +builddir=$pkgname-$pkgver +packagename=$builddir.tar.gz +autogenflag=true +testpatch=true + +source envset.sh +host= +prepare() { + mkdir -p $builddir/$ARCH-build + if [ $ARCH == "armeabi-v7a" ] + then + setarm32ENV + host=arm-linux + fi + if [ $ARCH == "arm64-v8a" ] + then + setarm64ENV + host=aarch64-linux + fi + if $autogenflag + then + cd $builddir + ./autogen.sh > `pwd`/build.log 2>&1 + cd $OLDPWD + autogenflag=false + fi +} + +build() { + cd $builddir/$ARCH-build + FREETYPE_CFLAGS="-I${LYCIUM_ROOT}/usr/freetype2/$ARCH/include/freetype2 ${LYCIUM_ROOT}/usr/bzip2/$ARCH/lib/libbz2.a \ + ${LYCIUM_ROOT}/usr/libpng/$ARCH/lib/libpng.a ${LYCIUM_ROOT}/usr/brotli/$ARCH/lib/libbrotlicommon.so \ + ${LYCIUM_ROOT}/usr/brotli/$ARCH/lib/libbrotlienc.so ${LYCIUM_ROOT}/usr/brotli/$ARCH/lib/libbrotlidec.so -lz" \ + FREETYPE_LIBS="${LYCIUM_ROOT}/usr/freetype2/$ARCH/lib/libfreetype.a" CFLAGS="$FREETYPE_CFLAGS $FREETYPE_LIBS" \ + PKG_CONFIG_PATH="${pkgconfigpath}" ../configure "$@" --host=$host --enable-libxml2 --enable-static \ + --enable-shared --disable-silent-rules > `pwd`/build.log 2>&1 # --sysconfdir="/etc" --localstatedir="/var" --datarootdir="/share" + make -j4 >> `pwd`/build.log 2>&1 + # 对最关键一步的退出码进行判断 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir/$ARCH-build + make install >> `pwd`/build.log 2>&1 + cd $OLDPWD +} + +check() { + # 下载字库 + # 测试过程需要curl下载字体,为避免测试机下载失败,采用提前下载好 + cd $builddir/$ARCH-build/test + mkdir noto + curl -s -o noto/noto.zip https://noto-website-2.storage.googleapis.com/pkgs/NotoSans-hinted.zip + cd $OLDPWD + cd $builddir/$ARCH-build/test/noto + unzip noto.zip > `pwd`/build.log 2>&1 + tar -zcf noto.tar.gz *.ttf README LICENSE_OFL.txt + cp noto.tar.gz ../ + cd $OLDPWD + # 编译测试用例 + cd $builddir/$ARCH-build/test + make test-pthread test-crbug1004254 test-bz89617 test-bz131804 test-migration \ + test-bz96676 test-name-parse test-bz106618 test-bz106632 test-issue107 test-bz1744377 \ + test-issue180 test-family-matching >> `pwd`/build.log 2>&1 + if $testpatch + then + sed -i '435d' ../../test/run-test.sh + sed -i '434a cp $MyPWD/noto.tar.gz "$FONTDIR"/noto.tar.gz' ../../test/run-test.sh + sed -i '/.*(cd "$FONTDIR"; unzip noto.zip)/c\ (cd "$FONTDIR"; tar -zxf noto.tar.gz)' ../../test/run-test.sh + testpatch=false + fi + sed -i '/.*check-TESTS: $(check_PROGRAMS) $(check_SCRIPTS)/c\check-TESTS: $(check_SCRIPTS) #$(check_PROGRAMS)' Makefile + sed -i '/.*test-bz89617.log: test-bz89617$(EXEEXT)/c\test-bz89617.log: #test-bz89617$(EXEEXT)' Makefile + sed -i '/.*test-bz131804.log: test-bz131804$(EXEEXT)/c\test-bz131804.log: #test-bz131804$(EXEEXT)' Makefile + sed -i '/.*test-bz96676.log: test-bz96676$(EXEEXT)/c\test-bz96676.log: #test-bz96676$(EXEEXT)' Makefile + sed -i '/.*test-name-parse.log: test-name-parse$(EXEEXT)/c\test-name-parse.log: #test-name-parse$(EXEEXT)' Makefile + sed -i '/.*test-bz106632.log: test-bz106632$(EXEEXT)/c\test-bz106632.log: #test-bz106632$(EXEEXT)' Makefile + sed -i '/.*test-issue107.log: test-issue107$(EXEEXT)/c\test-issue107.log: #test-issue107$(EXEEXT)' Makefile + sed -i '/.*test-issue110.log: test-issue110$(EXEEXT)/c\test-issue110.log: #test-issue110$(EXEEXT)' Makefile + sed -i '/.*test-d1f48f11.log: test-d1f48f11$(EXEEXT)/c\test-d1f48f11.log: #test-d1f48f11$(EXEEXT)' Makefile + sed -i '/.*test-bz1744377.log: test-bz1744377$(EXEEXT)/c\test-bz1744377.log: #test-bz1744377$(EXEEXT)' Makefile + sed -i '/.*test-issue180.log: test-issue180$(EXEEXT)/c\test-issue180.log: #test-issue180$(EXEEXT)' Makefile + sed -i '/.*test-family-matching.log: test-family-matching$(EXEEXT)/c\test-family-matching.log: #test-family-matching$(EXEEXT)' Makefile + + cd $OLDPWD + if [ $ARCH == "armeabi-v7a" ] + then + unsetarm32ENV + fi + if [ $ARCH == "arm64-v8a" ] + then + unsetarm64ENV + fi + unset host + echo "The test must be on an OpenHarmony device!" + # real test + # copy 依赖库 + # make -C test check-TESTS + +} + +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packagename +} \ No newline at end of file diff --git a/thirdparty/fontconfig/README.OpenSource b/thirdparty/fontconfig/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..6e40f28b2c4a1f9b7e66d662f0cd4d9949319df4 --- /dev/null +++ b/thirdparty/fontconfig/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "fontconfig", + "License": "MIT license", + "License File": "COPYING", + "Version Number": "2.14.2", + "Owner": "chenbaodi@huawei.com", + "Upstream URL": "https://gitlab.freedesktop.org/fontconfig/fontconfig/-/archive/2.14.2/fontconfig-2.14.2.tar.gz", + "Description": "Font configuration and customization library" + } +] diff --git a/thirdparty/fontconfig/README_zh.md b/thirdparty/fontconfig/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..e766f01e3b13bf4bb1ff4f962e6d9db3e7aa9d3b --- /dev/null +++ b/thirdparty/fontconfig/README_zh.md @@ -0,0 +1,12 @@ +# fontconfig三方库说明 +## 功能简介 +Fontconfig是字体相关的计算机程序库,用于配置、定制全系统的字体,或将字体提供给应用程序使用。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Beta2 +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:2.14.2 +- 当前适配的功能:提供字体能力 +- [MIT license](https://gitlab.freedesktop.org/fontconfig/fontconfig/-/blob/main/COPYING) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/fontconfig/SHA512SUM b/thirdparty/fontconfig/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..0a94efdad4fe76e658f3a37bfc6d21e61a12b7ee --- /dev/null +++ b/thirdparty/fontconfig/SHA512SUM @@ -0,0 +1 @@ +b6cbb4ad7db224dabfb8a96c1d0743bab5bbe8f403e49d9b9a44effd161fd97062a2f7205a700308a1f805655038538ba2fb1b65169faa2d69ea88e477230849 fontconfig-2.14.2.tar.gz diff --git a/thirdparty/fontconfig/docs/hap_integrate.md b/thirdparty/fontconfig/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..3e38ab2b6acfe496e927776b86e0451731c05302 --- /dev/null +++ b/thirdparty/fontconfig/docs/hap_integrate.md @@ -0,0 +1,88 @@ +# fontconfig 集成到应用hap + +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +## 开发环境 + +- ubuntu20.04 +- [OpenHarmony3.2Release镜像](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fdayu200_standard_arm32.tar.gz) +- [ohos_sdk_public 3.2.11.9 (API Version 9 Release)](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fohos-sdk-windows_linux-public.tar.gz) +- [DevEco Studio 3.1 Beta2](https://gitee.com/link?target=https%3A%2F%2Fcontentcenter-vali-drcn.dbankcdn.cn%2Fpvt_2%2FDeveloperAlliance_package_901_9%2Ff3%2Fv3%2FuJyuq3syQ2ak4hE1QZmAug%2Fdevecostudio-windows-3.1.0.400.zip%3FHW-CC-KV%3DV1%26HW-CC-Date%3D20230408T013335Z%26HW-CC-Expire%3D315360000%26HW-CC-Sign%3D96262721EDC9B34E6F62E66884AB7AE2A94C2A7B8C28D6F7FC891F46EB211A70) +- [准备三方库构建环境](../../../tools/README.md#编译环境准备) +- [准备三方库测试环境](../../../tools/README.md#ci环境准备) + +## 编译三方库 + +- 下载本仓库 + + ```shell + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ``` + tpc_c_cplusplus/thirdparty/fontconfig #三方库fontconfig的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将fontconfig拷贝至tools/main目录下 + + ``` + cd tpc_c_cplusplus + cp thirdparty/fontconfig tools/main -rf + ``` + +- 在tools目录下编译三方库 + + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + + ``` + cd tools + ./build.sh fontconfig + ``` + +- 三方库头文件及生成的库 + + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + + ``` + fontconfig/arm64-v8a fontconfig/armeabi-v7a + ``` + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示: + +  ![thirdparty_install_dir](pic/fontconfig_install_dir1.png) + +- 拷贝动态库到`\\entry\libs\${OHOS_ARCH}\`目录: + + 动态库需要在`\\entry\libs\${OHOS_ARCH}\`目录,才能集成到hap包中,所以需要将对应的so文件拷贝到对应CPU架构的目录: + +  ![thirdparty_install_dir](pic/fontconfig_install_dir2.png) + +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句: + + ``` + #将三方库加入工程中,fontconfig是对应的三方库名 + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zlib/${OHOS_ARCH}/lib/libz.so) + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libxml2/${OHOS_ARCH}/lib/libxml2.so) + target_link_libraries(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/fontconfig/${OHOS_ARCH}/lib/libfontconfig.so.1) + #将三方库的头文件加入工程中,fontconfig是对应的三方库名 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/zlib/${OHOS_ARCH}/include) + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libxml2/${OHOS_ARCH}/include) + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/fontconfig/${OHOS_ARCH}/include) + ``` + ![fontconfig_usage](pic/fontconfig_usage.png) + +## 参考资料 + +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) +- [通过DevEco Studio开发一个NAPI工程](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md) \ No newline at end of file diff --git a/thirdparty/fontconfig/docs/pic/fontconfig_install_dir1.png b/thirdparty/fontconfig/docs/pic/fontconfig_install_dir1.png new file mode 100644 index 0000000000000000000000000000000000000000..5e41bad0d0bdf00ece32936a423d4ce67529373a Binary files /dev/null and b/thirdparty/fontconfig/docs/pic/fontconfig_install_dir1.png differ diff --git a/thirdparty/fontconfig/docs/pic/fontconfig_install_dir2.png b/thirdparty/fontconfig/docs/pic/fontconfig_install_dir2.png new file mode 100644 index 0000000000000000000000000000000000000000..c0b00149d6a9d205335f944f3c8c2ec677453ab6 Binary files /dev/null and b/thirdparty/fontconfig/docs/pic/fontconfig_install_dir2.png differ diff --git a/thirdparty/fontconfig/docs/pic/fontconfig_usage.png b/thirdparty/fontconfig/docs/pic/fontconfig_usage.png new file mode 100644 index 0000000000000000000000000000000000000000..89b297c99913b74050d98b0e37b8e497af7abb01 Binary files /dev/null and b/thirdparty/fontconfig/docs/pic/fontconfig_usage.png differ