diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-07-04 11:16:05 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-07-04 11:17:21 -0400 |
commit | bcdce34c8ac0adffd589e9fb68b62ff09368bb0f (patch) | |
tree | 7b92ba875b22212d15ffb9d9620d517cfa427a1e /pango2/break-latin.c | |
parent | b197cc08b18bc44a3e93f859ca7e61dfe335bbc5 (diff) | |
download | pango-bcdce34c8ac0adffd589e9fb68b62ff09368bb0f.tar.gz |
Move the code from pango/ to pango2/
Life is easier if the src path matches the installed
header path prefix, so make them match. Update all
users.
Diffstat (limited to 'pango2/break-latin.c')
-rw-r--r-- | pango2/break-latin.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/pango2/break-latin.c b/pango2/break-latin.c new file mode 100644 index 00000000..ffbc8f9e --- /dev/null +++ b/pango2/break-latin.c @@ -0,0 +1,60 @@ +/* Pango2 + * break-latin.c: + * + * Copyright (C) 2021 Jordi Mas i Hernàndez <jmas@softcatala.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#include "pango-break.h" +#include "pango-item-private.h" +#include "pango-impl-utils.h" + +static void +break_latin (const char *text, + int length, + const Pango2Analysis *analysis, + Pango2LogAttr *attrs, + int attrs_len G_GNUC_UNUSED) +{ + int i; + const char *p, *next; + gunichar wc, prev_wc; + + if (!analysis || !analysis->language || + g_ascii_strncasecmp (pango2_language_to_string (analysis->language), "ca-", 3) != 0) + return; + + for (p = text, i = 0, prev_wc = 0; + p < text + length; + p = next, i++, prev_wc = wc) + { + wc = g_utf8_get_char (p); + next = g_utf8_next_char (p); + + /* Catalan middle dot does not break words */ + if (wc == 0x00b7) + { + gunichar middle_next = g_utf8_get_char (next); + if (g_unichar_tolower (middle_next) == 'l' && g_unichar_tolower (prev_wc) == 'l') + { + attrs[i].is_word_end = FALSE; + attrs[i+1].is_word_start = FALSE; + } + } + } +} |