From c0bb66ecbff712221fb7c97f628ed026926229b2 Mon Sep 17 00:00:00 2001 From: Nathan Willis Date: Fri, 24 May 2019 18:49:40 +0100 Subject: [PATCH] [Docs] Usermanual: integration chapter; add CoreText/Mac section. --- docs/usermanual-integration.xml | 107 ++++++++++++++++++++++++++------ 1 file changed, 89 insertions(+), 18 deletions(-) diff --git a/docs/usermanual-integration.xml b/docs/usermanual-integration.xml index 9fd94c85a..7ed85dd30 100644 --- a/docs/usermanual-integration.xml +++ b/docs/usermanual-integration.xml @@ -303,13 +303,14 @@
Uniscribe integration - If your client program is running on Windows, HarfBuzz can - integrate with the Uniscribe engine. + 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 the shaping + 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 @@ -321,8 +322,9 @@ At a basic level, HarfBuzz's hb_shape() function replaces both the ScriptShape() - and ScriptPlace() functions from - Uniscribe. + and ScriptPlace() + functions from Uniscribe. However, whereas ScriptShape() returns the @@ -363,10 +365,14 @@ structure holds font-wide attributes, including metrics, size, and style information. - -SCRIPT_CACHE holds context, including LOGFONT https://docs.microsoft.com/en-us/windows/desktop/Intl/script-cache - https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-logfontw - + The hb_uniscribe_font_get_hfont() function also takes a hb_font_t font object, but it returns @@ -399,30 +405,95 @@ SCRIPT_CACHE holds context, including LOGFONT https://docs.microsoft.com/en
- CoreText integration + Core Text integration - + If your client program is running on macOS or iOS, HarfBuzz offers + an additional API that can help integrate with Apple's + Core Text engine and the underlying Core Graphics + framework. HarfBuzz does not attempt to offer the same + drop-in-replacement functionality for Core Text that it strives + for with Uniscribe on Windows, but you can still user HarfBuzz + to perform text shaping in native macOS and iOS applications. - + Note, though, that if your interest is just in using fonts that + contain Apple Advanced Typography (AAT) features, then you do + not need to add Core Text integration. HarfBuzz natively + supports AAT features and will shape AAT fonts (on any platform) + automatically, without requiring additional work on your + part. This includes support for AAT-specific TrueType tables + such as mort, morx, and + kerx, which AAT fonts use instead of + GSUB and GPOS. - + On a macOS or iOS system, the primary integration points offered + by HarfBuzz are for face objects and font objects. - + The Apple APIs offer a pair of data structures that map well to + HarfBuzz's face and font objects. The Core Graphics API, which + is slightly lower-level than Core Text, provides + CGFontRef, which enables access to typeface + properties, but does not include size information. Core Text's + CTFontRef is analagous to a HarfBuzz font object, + with all of the properties required to render text at a specific + size and configuration. + Consequently, a HarfBuzz hb_font_t font object can + be hooked up to a Core Text CTFontRef, and a HarfBuzz + hb_face_t face object can be hooked up to a + CGFontRef. - + You can create a hb_face_t from a + CGFontRef by using the + hb_coretext_face_create(). Subsequently, + you can retrieve the CGFontRef from a + hb_face_t with hb_coretext_face_get_cg_font(). - + Likewise, you create a hb_font_t from a + CTFontRef by calling + hb_coretext_font_create(), and you can + fetch the associated CTFontRef from a + hb_font_t font object with + hb_coretext_face_get_ct_font(). - + HarfBuzz also offers a hb_font_set_ptem() + that you an use to set the nominal point size on any + hb_font_t font object. Core Text uses this value to + implement optical scaling. - + When integrating your client code with Core Text, it is + important to recognize that Core Text points + are not typographic points (standardized at 72 per inch) as the + term is used elsewhere in OpenType. Instead, Core Text points + are CSS points, which are standardized at 96 per inch. + + + HarfBuzz's font functions take this distinction into account, + but it can be an easy detail to miss in cross-platform + code. + + + As a final note, you may notice a reference to an optional + coretext shaper back-end in the section of the HarfBuzz manual. This + option is not a CoreText-integration facility. + + + Instead, it is a internal code path used in the + hb-shape command-line utility, which hands + shaping functionality over to CoreText entirely, when run on a + macOS system. That allows testing HarfBuzz's native output + against the CoreText 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.