From dcc01f5b01401d454a851b363578141442bf6dda Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 15 Feb 2017 23:52:16 -0500 Subject: [PATCH] Started putting the typographical features attributes into the example program. --- examples/drawtext/attributes.c | 69 +++++++++++++++++++++++++++++++++- examples/drawtext/main.c | 7 ++++ 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/examples/drawtext/attributes.c b/examples/drawtext/attributes.c index 9d0c2310..47601933 100644 --- a/examples/drawtext/attributes.c +++ b/examples/drawtext/attributes.c @@ -165,7 +165,74 @@ static void setupAttributedString(void) uiAttributedStringAppendUnattributed(attrstr, ", "); - next = "multiple TODO"; + next = "or any combination of the above"; + // TODO + + uiAttributedStringAppendUnattributed(attrstr, ". In addition, a variety of typographical features are available (depending on the chosen font) that can be switched on (or off, if the font enables them by default): "); + + next = "fi"; + uiAttributedStringAppendUnattributed(attrstr, "standard ligatures like f+i ("); + start = uiAttributedStringLen(attrstr); + end = start + strlen(next); + uiAttributedStringAppendUnattributed(attrstr, next); + spec.Type = uiAttributeStandardLigatures; + spec.Value = 1; + uiAttributedStringSetAttribute(attrstr, &spec, start, end); + uiAttributedStringAppendUnattributed(attrstr, ")"); + + uiAttributedStringAppendUnattributed(attrstr, ", "); + + // note the use of RTL embeds to make sure the bidi algorithm doesn't kick in for our demonstration (it will produce incorrect results) + // see also: https://www.w3.org/International/articles/inline-bidi-markup/#nomarkup + next = "\xD9\x84\xD8\xA7"; + uiAttributedStringAppendUnattributed(attrstr, "required ligatures like \xE2\x80\xAB\xD9\x84\xE2\x80\xAC+\xE2\x80\xAB\xD8\xA7\xE2\x80\xAC (\xE2\x80\xAB"); + start = uiAttributedStringLen(attrstr); + end = start + strlen(next); + uiAttributedStringAppendUnattributed(attrstr, next); + spec.Type = uiAttributeRequiredLigatures; + spec.Value = 1; + uiAttributedStringSetAttribute(attrstr, &spec, start, end); + uiAttributedStringAppendUnattributed(attrstr, "\xE2\x80\xAC)"); + + uiAttributedStringAppendUnattributed(attrstr, ", "); + + next = "ct"; + uiAttributedStringAppendUnattributed(attrstr, "discretionary/rare ligatures like c+t ("); + start = uiAttributedStringLen(attrstr); + end = start + strlen(next); + uiAttributedStringAppendUnattributed(attrstr, next); + spec.Type = uiAttributeDiscretionaryLigatures; + spec.Value = 1; + uiAttributedStringSetAttribute(attrstr, &spec, start, end); + uiAttributedStringAppendUnattributed(attrstr, ")"); + + uiAttributedStringAppendUnattributed(attrstr, ", "); + + next = "the"; + uiAttributedStringAppendUnattributed(attrstr, "contextual ligatures like h+e in the ("); + start = uiAttributedStringLen(attrstr); + end = start + strlen(next); + uiAttributedStringAppendUnattributed(attrstr, next); + spec.Type = uiAttributeContextualLigatures; + spec.Value = 1; + uiAttributedStringSetAttribute(attrstr, &spec, start, end); + uiAttributedStringAppendUnattributed(attrstr, ")"); + + uiAttributedStringAppendUnattributed(attrstr, ", "); + + next = "\xC3\x9F"; + uiAttributedStringAppendUnattributed(attrstr, "historical ligatures like the decomposition of \xC3\x9F ("); + start = uiAttributedStringLen(attrstr); + end = start + strlen(next); + uiAttributedStringAppendUnattributed(attrstr, next); + spec.Type = uiAttributeHistoricalLigatures; + spec.Value = 1; + uiAttributedStringSetAttribute(attrstr, &spec, start, end); + uiAttributedStringAppendUnattributed(attrstr, ")"); + + uiAttributedStringAppendUnattributed(attrstr, ", "); + + // TODO unicase } static char fontFamily[] = "Times New Roman"; diff --git a/examples/drawtext/main.c b/examples/drawtext/main.c index 848def89..22b532fe 100644 --- a/examples/drawtext/main.c +++ b/examples/drawtext/main.c @@ -5,6 +5,13 @@ // - occasional segfaults on startup // - very rare size attributes in the attributed string example don't terminate for a while, making everything big // - very very rare trace/bpt faults on startup +/* +objc[14827]: autorelease pool page 0x7feeab88b000 corrupted + magic 0xe000007f 0xeea9f2df 0x0000007f 0xeea9f2e0 + should be 0xa1a1a1a1 0x4f545541 0x454c4552 0x21455341 + pthread 0x0 + should be 0x7fff727a1000 +*/ static uiWindow *mainwin; static uiBox *box;