How to compile Freetype (2) and Harfbuzz (with vis

2019-07-28 22:50发布

问题:

I have found good documentations on this known problem of compiling Freetype related to Harfbuzz: http://www.gregwessels.com/dev/2017/05/02/freetype-harfbuzz.html and here 44184890

But they seem obsolet nowadays: freetype-2.9 with harfbuzz-1.7.6

Here is my way compiling:

  • download Freetype tarball
  • extract the tarball...
  • open builds\windows\vc2010\freetype.sln
  • it must already Generate well (as dll)
  • download Harfbuzz
  • extract the tarball next to freetype...
  • run cmake ./ at root level to obtain a .sln
  • it must already Generate well (as lib)

At this point you have 2 separate libs not working together which means:

Freetype will not open GSUB scripts of your fonts. (or maybe I am wrong)

To do so, I need help! I also need confirmations!!!

Is seems to be needed to enable the use of Harfbuzz in Freetype at compile time; I have found a precompiler directive called FT_CONFIG_OPTION_USE_HARFBUZZ

But when activating it, I have some compile link errors when using both libs in a third project:

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

Good to know, hb_ft_font_create is an extern function in harfbuzz.

So it seems to be a cyclic extern problem... I certainly don't have the good config at a point, but I have browsed many docs and helps, found nothing...

-- edit -- After both pojects decompression, you have normaly to obtain such a tree:

.
├── 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

回答1:

Just use https://github.com/Microsoft/vcpkg/ to install both and don't look back :) Both HarfBuzz and Freetype have a port there and are well supported.

About the cyclic dependency, FreeType to HarfBuzz dependency is not a must think to have. vcpkg handles HarfBuzz to FreeType dependency and that is what most project will need.



回答2:

Or configure harfbuzz like --with-freetype=no --with-fontconfig=no to avoid circular deps...I think so anyway...