From 6bd4c082e49143d0631881645b81f999347257f8 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Tue, 19 Feb 2019 02:23:58 +0200 Subject: [PATCH] [doc] Document hb_feature_from_string() syntax Copied and edited from the util option documentation. The docbook table syntax is too verbose, but that is the best I can come up with. --- src/hb-common.cc | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/hb-common.cc b/src/hb-common.cc index 93f5b79..fb8c7b7 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -974,7 +974,40 @@ parse_one_feature (const char **pp, const char *end, hb_feature_t *feature) * * Parses a string into a #hb_feature_t. * - * TODO: document the syntax here. + * The format for specifying feature strings follows. All valid CSS + * font-feature-settings values other than 'normal' and 'inherited' are also + * accepted, though, not documented below. + * + * The range indices refer to the positions between Unicode characters. The + * position before the first character is always 0. + * + * The format is Python-esque. Here is how it all works: + * + * + * + * + * Syntax Value Start End + * + * + * Setting value: + * kern 1 0 ∞ Turn feature on + * +kern 1 0 ∞ Turn feature on + * -kern 0 0 ∞ Turn feature off + * kern=0 0 0 ∞ Turn feature off + * kern=1 1 0 ∞ Turn feature on + * aalt=2 2 0 ∞ Choose 2nd alternate + * Setting index: + * kern[] 1 0 ∞ Turn feature on + * kern[:] 1 0 ∞ Turn feature on + * kern[5:] 1 5 ∞ Turn feature on, partial + * kern[:5] 1 0 5 Turn feature on, partial + * kern[3:5] 1 3 5 Turn feature on, range + * kern[3] 1 3 3+1 Turn feature on, single char + * Mixing it all: + * aalt[3:5]=2 2 3 5 Turn 2nd alternate on for range + * + * + * * * Return value: * %true if @str is successfully parsed, %false otherwise. -- 2.7.4