kc3-lang/harfbuzz/README.mingw.md

Download

Most HarfBuzz developers do so on Linux or macOS. However, HarfBuzz is a cross-platform library and it is important to ensure that it works on Windows as well. In particular, we use this workflow to develop and test the HarfBuzz Uniscribe shaper and DirectWrite shaper and font backend, all from Linux or macOS.

This document provides instructions for cross-compiling HarfBuzz on Linux or macOS, for Windows, using the MinGW toolchain, and running tests and utilties under Wine.

We then discuss using native Windows Uniscribe or DirectWrite DLLs, which allows you to test HarfBuzz’s shaping against the Microsoft shaping engines instead of those provided by Wine.

This document assumes that you are familiar with building HarfBuzz on Linux or macOS.

You can build for 32bit or 64bit Windows. If your intention is to use a native Uniscribe usp10.dll from Windows 7 or before, you would need to build for 32bit. If you want to use a native DirectWrite DLL from Windows 10 or later, you would need to build for 64bit.

We suggest you read to the end of this document before starting, as it provides a few different ways to build and test HarfBuzz for Windows.

  1. Install Wine.
  1. Install the mingw-w64 cross-compiler.
  1. Install dependencies.

Or you could simply pull them all in one go with:

If you cannot find these packages for your distribution, or you are on macOS, you can skip to the next step, as meson will automatically download and build the dependencies for you.

  1. If you are familiar with meson, you can use the cross-compile files we provide to find your way around. Read until the end of this section before deciding which one to use.

In which case, you will proceed to run ninja as usual to build:

Or you can simply invoke the scripts we provide for our Continuous Integration system, to configure and build HarfBuzz for you. This is the easiest way to build HarfBuzz for Windows and how we build our Windows binaries:

If you are on Linux and your Wine has configured itself as the processor for the EXE files (called binfmt_misc in Linux), you can run the executables EXE directly. But it is advised that instead, you modify the cross-file to use the exe_wrapper option, which will allow you to run the executables under Wine. This is the most reliable way to run the executables under Wine.

This might take a while, since, if you do not have the dependencies installed, meson will download and build them for you.

  1. If everything succeeds, you should have the hb-shape.exe, hb-view.exe, hb-subset.exe, and hb-info.exe executables in build-win/util.

  2. Configure your wine to find system mingw libraries. While there, set it also to find the built HarfBuzz DLLs:

Adjust for the path where you have built HarfBuzz. You might want to add this to your .bashrc or .zshrc file.

Alternatively, if you uncommented the exe_wrapper line in the cross-file, you can skip this step, as the exe_wrapper will make meson take care of setting the WINEPATH if commands are run through the meson devenv command, which we will introduce in the next step.

  1. Run the hb-shape executable under Wine:

Or using meson devenv to do the same: -meson devenv -C build-win util/hb-shape.exe perf/fonts/Roboto-Regular.ttf TestYou probably will get lots of Wine warnings, but if all works fine, you should see: ``` [gid57=0+1123|gid74=1+1086|gid88=2+1057|gid89=3+670] ``` You can make Wine less verbose, without hiding all errors, by setting: -export WINEDEBUG=fixme-all,warn-all,err-plugplay,err-seh,err-rpc,err-ntoskrnl,err-winediag,err-systray,err-hidAdd this to your.bashrcor.zshrcfile as well. Next, let's try some non-Latin text. Unfortunately, the command-line parsing of our cross-compiled glib is not quite Unicode-aware, at least when run under Wine. So you will need to find some other way to feed Unicode text to the shaper. There are three different ways you can try: -echo حرف | wine build-win/util/hb-shape.exe perf/fonts/Amiri-Regular.ttf-wine build-win/util/hb-shape.exe perf/fonts/Amiri-Regular.ttf -u 062D,0631,0641-wine build-win/util/hb-shape.exe perf/fonts/Amiri-Regular.ttf –text-file harf.txtTo get the Unicode codepoints for a string, you can use thehb-unicode-decodeutility: ``` $ test/shape/hb-unicode-decode حرف U+062D,U+0631,U+0641 ``` 8. Next, let's try thehb-viewutility. By default,hb-viewoutputs ANSI text, which Wine will not display correctly. You can use the-ooption to redirect the output to a file, or just redirect the output using the shell, which will produce a PNG file. -wine build-win/util/hb-view.exe perf/fonts/Roboto-Regular.ttf Test > test.png7. As noted, if your Linux hasbinfmt_miscenabled, you can run the executables directly. If not, you can modify the cross-file to use theexe_wrapperoption as specified before. -build-win/util/hb-shape.exe perf/fonts/Roboto-Regular.ttf TestIf that does not work, you can use thewinecommand as shown above. 10. You can try running the test suite. If on Linux withbinfmt_miscenabled, you can run the tests directly: -ninja -C build-win testIf not, you might need to reconfigure the build directory to tell meson to use Wine to run the tests. This part needs improvement, but for now: edit the cross-file you used to build HarfBuzz and uncomment theexe_wrapperline: - 32bit:.ci/win32-cross-file.txt- 64bit:.ci/win64-cross-file.txtThen go back to step 4 above and rebuild HarfBuzz with theexe_wrapperset. If all goes well, tests should run with the aboveninjacommand. If all is well, you should probably see over 300 tests pass, some skipped, and just thedirectwritetest fail. The reason thedirectwritetest fails is that we are running against the Wine-provided DirectWrite DLL, which is an incomplete reimplementation of the DirectWrite API by Wine, and not the real thing. If you want to test the Uniscribe or DirectWrite shapers against the real Uniscribe / DirectWrite, you can follow the instructions below. 11. Old Uniscribe: Assuming a 32bit build for now. Bring a 32bit version ofusp10.dllfor yourself fromC:\Windows\SysWOW64\usp10.dllof your 64bit Windows installation, orC:\Windows\System32\usp10.dllfor 32bit Windows installation. You want one from Windows 7 or earlier. One that is not just a proxy forTextShaping.dll. Rule of thumb, yourusp10.dllshould have a size more than 500kb. Put the file in~/.wine/drive_c/windows/syswow64/so wine can find it. You can now tell wine to use the nativeusp10.dll: -export WINEDLLOVERRIDES=”usp10=n”-wine build-win/util/hb-shape.exe perf/fonts/Roboto-Regular.ttf Test –shaper=uniscribe12. DirectWrite and new Uniscribe: You can use the same method to test the DirectWrite shaper against the native DirectWrite DLL. Try with a 64bit build this time. BringTextShaping.dll,DWrite.dll, andusp10.dllfrom your 64bit Windows installation (C:\Windows\System32) to~/.wine/drive_c/windows/system32/. You want the ones from Windows 10 or later. You might have some luck downloading them from the internet, but be careful with the source. I had success with the DLLs from [https://dllme.com](dllme.com), but I cannot vouch for the site. You can now tell wine to use the native DirectWrite: -export WINEDLLOVERRIDES=”textshaping,dwrite,usp10=n”-wine build-win/util/hb-shape.exe perf/fonts/Roboto-Regular.ttf Test –shaper=directwrite` If all works well, you should be able to rerun the tests and see all pass this time. 13. For some old instructions on how to test HarfBuzz’s native Indic shaper against Uniscribe, see: https://github.com/harfbuzz/harfbuzz/issues/3671 14. That’s it! If you made it this far, you are now able to develop and test HarfBuzz on Windows, from Linux or macOS. Enjoy!


Source

Download