1 | /* Pango |
2 | * break-latin.c: |
3 | * |
4 | * Copyright (C) 2021 Jordi Mas i Hernàndez <jmas@softcatala.org> |
5 | * |
6 | * This library is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU Library General Public |
8 | * License as published by the Free Software Foundation; either |
9 | * version 2 of the License, or (at your option) any later version. |
10 | * |
11 | * This library is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * Library General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Library General Public |
17 | * License along with this library; if not, write to the Free Software |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
19 | */ |
20 | |
21 | #include "config.h" |
22 | |
23 | #include "pango-break.h" |
24 | #include "pango-impl-utils.h" |
25 | |
26 | static void |
27 | break_latin (const char *text, |
28 | int length, |
29 | const PangoAnalysis *analysis, |
30 | PangoLogAttr *attrs, |
31 | int attrs_len G_GNUC_UNUSED) |
32 | { |
33 | int i; |
34 | const char *p, *next; |
35 | gunichar wc, prev_wc; |
36 | |
37 | if (!analysis || !analysis->language || |
38 | g_ascii_strncasecmp (pango_language_to_string (analysis->language), s2: "ca-" , n: 3) != 0) |
39 | return; |
40 | |
41 | for (p = text, i = 0, prev_wc = 0; |
42 | p < text + length; |
43 | p = next, i++, prev_wc = wc) |
44 | { |
45 | wc = g_utf8_get_char (p); |
46 | next = g_utf8_next_char (p); |
47 | |
48 | /* Catalan middle dot does not break words */ |
49 | if (wc == 0x00b7) |
50 | { |
51 | gunichar middle_next = g_utf8_get_char (p: next); |
52 | if (g_unichar_tolower (c: middle_next) == 'l' && g_unichar_tolower (c: prev_wc) == 'l') |
53 | { |
54 | attrs[i].is_word_end = FALSE; |
55 | attrs[i+1].is_word_start = FALSE; |
56 | } |
57 | } |
58 | } |
59 | } |
60 | |