如何编译 Freetype (2) 和 Harfbuzz (with visual studio) 让它们一起工作?

How to compile Freetype (2) and Harfbuzz (with visual studio) to make them work together?

我找到了关于编译与 Harfbuzz 相关的 Freetype 的这个已知问题的很好的文档:http://www.gregwessels.com/dev/2017/05/02/freetype-harfbuzz.html and here 44184890

但它们现在似乎已经过时了:freetype-2.9 和 harfbuzz-1.7.6

这是我的编译方式:

此时您有 2 个独立的库不能一起工作,这意味着:

Freetype 不会打开您字体的 GSUB 脚本。(或者我错了)

为此,我需要帮助!我也需要确认!!!

似乎需要在编译时在 Freetype 中启用 Harfbuzz;我找到了一个名为 FT_CONFIG_OPTION_USE_HARFBUZZ

的预编译器指令

但是在激活它时,我在第三个项目中使用两个库时遇到一些编译 link 错误:

autofit.obj : error LNK2019: external symbol not found _hb_ft_font_create referenced in function _af_face_globals_new

很高兴知道,hb_ft_font_create 是 harfbuzz 中的外部函数。

所以这似乎是一个循环外部问题...我当然没有一个好的配置,但我浏览了很多文档和帮助,什么也没发现...

-- 编辑 -- 两个项目解压后,你通常会得到这样一棵树:

.
├── freetype-2.9
│   ├── autogen.sh
│   ├── builds
│   │   ├── ...
│   │   └── windows
│   │       └── vc2010    <<<< The .sln to use is in here
│   ├── CMakeLists.txt    <<<< It is also good to obtain proper sln
│   ├── configure
│   ├── devel
│   │   ├── ft2build.h
│   │   └── ftoption.h
│   ├── include
│   │   ├── freetype
│   │   └── ft2build.h
│   ├── ...
│   ├── objs
│   │   ├── freetype.dll
│   │   ├── freetype.lib
│   │   ├── README
│   │   └── Win32
│   ├── README
│   ├── README.git
│   └── src
└── harfbuzz-1.7.6
    ├── ...
    ├── cmake_install.cmake
    ├── CMakeLists.txt   <<<< The cmake project to obtain proper sln is this one
    ├── compile
    ├── ...
    ├── COPYING
    ├── CTestTestfile.cmake
    ├── Debug
    │   ├── harfbuzz.lib
    │   ├── harfbuzz-subset.lib
    │   └── ...
    ├── depcomp
    ├── docs
    ├── gtk-doc.make
    ├── harfbuzz.sln
    ├── harfbuzz.vcxproj
    ├── ...
    ├── main.dir
    │   └── Debug
    ├── NEWS
    ├── README
    ├── README.python
    ├── RELEASING.md
    ├── replace-enum-strings.cmake
    ├── RUN_TESTS.vcxproj
    ├── RUN_TESTS.vcxproj.filters
    ├── src
    │   ├── *.hh
    │   └── *.cc
    ├── test
    ├── THANKS
    ├── TODO
    ├── util
    └── Win32
        └── Debug

只需使用 https://github.com/Microsoft/vcpkg/ 来安装它们,不要回头看:) HarfBuzz 和 Freetype 都有一个端口并且得到很好的支持。

关于循环依赖,FreeType 到 HarfBuzz 的依赖不是必须的。 vcpkg 处理 HarfBuzz 对 FreeType 的依赖,这是大多数项目需要的。

或者像 --with-freetype=no --with-fontconfig=no 这样配置 harfbuzz 来避免循环依赖...我是这么认为的...