diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-07-07 13:55:41 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-07-25 00:47:48 -0400 |
commit | a1b3306be686047a9bed9af038db2b0b6e23ee86 (patch) | |
tree | 037a98d8241edadf94ee37749937922dc8e301e6 /pango/pango-impl-utils.h | |
parent | 2b4e7c7fd5666917608f240dcdb99bac6c048892 (diff) | |
download | pango-a1b3306be686047a9bed9af038db2b0b6e23ee86.tar.gz |
Add a utility function for ignorables
This returns nicknames and formatting information
for default ignorable characters. This will be
used to render customized hex boxes for these
characters.
Diffstat (limited to 'pango/pango-impl-utils.h')
-rw-r--r-- | pango/pango-impl-utils.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/pango/pango-impl-utils.h b/pango/pango-impl-utils.h index 9570da80..378f14a1 100644 --- a/pango/pango-impl-utils.h +++ b/pango/pango-impl-utils.h @@ -128,6 +128,76 @@ pango_glyph_string_reverse_range (PangoGlyphString *glyphs, } } +/* The cairo hexbox drawing code assumes + * that these nicks are 1-6 ASCII chars + */ +static struct { + gunichar ch; + const char *nick; +} ignorables[] = { + { 0x00ad, "SHY" }, /* SOFT HYPHEN */ + { 0x034f, "CGJ" }, /* COMBINING GRAPHEME JOINER */ + { 0x200b, "ZWS" }, /* ZERO WIDTH SPACE */ + { 0x200c, "ZWNJ" }, /* ZERO WIDTH NON-JOINER */ + { 0x200d, "ZWJ" }, /* ZERO WIDTH JOINER */ + { 0x200e, "LRM" }, /* LEFT-TO-RIGHT MARK */ + { 0x200f, "RLM" }, /* RIGHT-TO-LEFT MARK */ + { 0x2028, "LS" }, /* LINE SEPARATOR */ + { 0x2029, "PS" }, /* PARAGRAPH SEPARATOR */ + { 0x202a, "LRE" }, /* LEFT-TO-RIGHT EMBEDDING */ + { 0x202b, "RLE" }, /* RIGHT-TO-LEFT EMBEDDING */ + { 0x202c, "PDF" }, /* POP DIRECTIONAL FORMATTING */ + { 0x202d, "LRO" }, /* LEFT-TO-RIGHT OVERRIDE */ + { 0x202e, "RLO" }, /* RIGHT-TO-LEFT OVERRIDE */ + { 0x2060, "WJ" }, /* WORD JOINER */ + { 0x2061, "FA" }, /* FUNCTION APPLICATION */ + { 0x2062, "IT" }, /* INVISIBLE TIMES */ + { 0x2063, "IS" }, /* INVISIBLE SEPARATOR */ + { 0xfeff, "ZWNBS" }, /* ZERO WIDTH NO-BREAK SPACE */ +}; + +static inline G_GNUC_UNUSED const char * +pango_get_ignorable (gunichar ch) +{ + for (int i = 0; i < G_N_ELEMENTS (ignorables); i++) + { + if (ch == ignorables[i].ch) + return ignorables[i].nick; + } + return NULL; +} + +static inline G_GNUC_UNUSED const char * +pango_get_ignorable_size (gunichar ch, + int *rows, + int *cols) +{ + const char *nick; + int len; + + nick = pango_get_ignorable (ch); + if (nick) + { + len = strlen (nick); + if (len < 4) + { + *rows = 1; + *cols = len; + } + else if (len > 4) + { + *rows = 2; + *cols = 3; + } + else + { + *rows = 2; + *cols = 2; + } + } + + return nick; +} G_END_DECLS |