I’ve discovered the situation when the same code works in main program block, but fails with the following error in UnitTests:
System.Exception: Text shaper factory failed to return text shaper for 'C:\WINDOWS\Fonts\calibrib.ttf', face index '0' ---> System.DllNotFoundException: Unable to load DLL 'harfbuzz': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
It seems like the issue based in wrong harfbuzz.dll version referred: it seems like Program copies 32-bit version into bin folder, while UnitTests copies 64-bit version.
Please find attached .net solution with demonstration the problem: HarfBuzz_error.zip (35.1 KB)
Also please note, it is another issue with this project. I think you’ll not able to compile it from attached sources, because mentioned harfbuzz.dll file will not be copied into bin folder. You need to reinstall HarfBuzz nuget. Or play with platform setting to forcing copy.
Or you can create your own solution in some simply steps:
-
Create console project
-
Create UnitTest project
-
Add HarfBuzz nuget for both
-
Check efficiency with the following sample code:
var doc = new Document(@"..\..\..\input_Thai.docx"); doc.LayoutOptions.TextShaperFactory = HarfBuzzTextShaperFactory.Instance; doc.Save(@"..\..\..\output_Thai.pdf", SaveFormat.Pdf);