## Uniscribe integration

If your client program is running on Windows, HarfBuzz offers an additional API that can help integrate with Microsoft's Uniscribe engine and the Windows GDI.

Overall, the Uniscribe API covers a broader set of typographic layout functions than HarfBuzz implements, but HarfBuzz's shaping API can serve as a drop-in replacement for Uniscribe's shaping functionality. In fact, one of HarfBuzz's design goals is to accurately reproduce the same output for shaping a given text segment that Uniscribe produces — even to the point of duplicating known shaping bugs or deviations from the specification — so you can be confident that your users' documents with their existing fonts will not be affected adversely by switching to HarfBuzz.

At a basic level, HarfBuzz's `hb_shape()` function replaces both the `ScriptShape()` and `ScriptPlace()` functions from Uniscribe.

However, whereas `ScriptShape()` returns the glyphs and clusters for a shaped sequence and `ScriptPlace()` returns the advances and offsets for those glyphs, `hb_shape()` handles both. After `hb_shape()` shapes a buffer, the output glyph IDs and cluster IDs are returned as an array of hb_glyph_info_t structures, and the glyph advances and offsets are returned as an array of hb_glyph_position_t structures.

Your client program only needs to ensure that it converts correctly between HarfBuzz's low-level data types (such as hb_position_t) and Windows's corresponding types (such as GOFFSET and ABC). Be sure you read the Buffers, language, script and direction chapter for a full explanation of how HarfBuzz input buffers are used, and see the section called “Shaping and buffer output” for the details of what `hb_shape()` returns in the output buffer when shaping is complete.

Although `hb_shape()` itself is functionally equivalent to Uniscribe's shaping routines, there are two additional HarfBuzz functions you may want to use to integrate the libraries in your code. Both are used to link HarfBuzz font objects to the equivalent Windows structures.

The `hb_uniscribe_font_get_logfontw()` function takes a hb_font_t font object and returns a pointer to the LOGFONTW "logical font" that corresponds to it. A LOGFONTW structure holds font-wide attributes, including metrics, size, and style information.

The `hb_uniscribe_font_get_hfont()` function also takes a hb_font_t font object, but it returns an HFONT — a handle to the underlying logical font — instead.

LOGFONTWs and HFONTs are both needed by other Uniscribe functions.

As a final note, you may notice a reference to an optional `uniscribe` shaper back-end in the the section called “Configuration options” section of the HarfBuzz manual. This option is not a Uniscribe-integration facility.

Instead, it is a internal code path used in the hb-shape command-line utility, which hands shaping functionality over to Uniscribe entirely, when run on a Windows system. That allows testing HarfBuzz's native output against the Uniscribe engine, for tracking compatibility and debugging.

Because this back-end is only used when testing HarfBuzz functionality, it is disabled by default when building the HarfBuzz binaries.