Branch data Line data Source code
1 : : /* gunibreak.c - line break properties 2 : : * 3 : : * Copyright 2000 Red Hat, Inc. 4 : : * 5 : : * SPDX-License-Identifier: LGPL-2.1-or-later 6 : : * 7 : : * This library is free software; you can redistribute it and/or 8 : : * modify it under the terms of the GNU Lesser General Public 9 : : * License as published by the Free Software Foundation; either 10 : : * version 2.1 of the License, or (at your option) any later version. 11 : : * 12 : : * This library is distributed in the hope that it will be useful, 13 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 : : * Lesser General Public License for more details. 16 : : * 17 : : * You should have received a copy of the GNU Lesser General Public License 18 : : * along with this library; if not, see <http://www.gnu.org/licenses/>. 19 : : */ 20 : : 21 : : #include "config.h" 22 : : 23 : : #include <stdlib.h> 24 : : 25 : : #include "gunibreak.h" 26 : : 27 : : #define TPROP_PART1(Page, Char) \ 28 : : ((break_property_table_part1[Page] >= G_UNICODE_MAX_TABLE_INDEX) \ 29 : : ? (break_property_table_part1[Page] - G_UNICODE_MAX_TABLE_INDEX) \ 30 : : : (break_property_data[break_property_table_part1[Page]][Char])) 31 : : 32 : : #define TPROP_PART2(Page, Char) \ 33 : : ((break_property_table_part2[Page] >= G_UNICODE_MAX_TABLE_INDEX) \ 34 : : ? (break_property_table_part2[Page] - G_UNICODE_MAX_TABLE_INDEX) \ 35 : : : (break_property_data[break_property_table_part2[Page]][Char])) 36 : : 37 : : #define PROP(Char) \ 38 : : (((Char) <= G_UNICODE_LAST_CHAR_PART1) \ 39 : : ? TPROP_PART1 ((Char) >> 8, (Char) & 0xff) \ 40 : : : (((Char) >= 0xe0000 && (Char) <= G_UNICODE_LAST_CHAR) \ 41 : : ? TPROP_PART2 (((Char) - 0xe0000) >> 8, (Char) & 0xff) \ 42 : : : G_UNICODE_BREAK_UNKNOWN)) 43 : : 44 : : /** 45 : : * g_unichar_break_type: 46 : : * @c: a Unicode character 47 : : * 48 : : * Determines the break type of @c. @c should be a Unicode character 49 : : * (to derive a character from UTF-8 encoded text, use 50 : : * g_utf8_get_char()). The break type is used to find word and line 51 : : * breaks ("text boundaries"), Pango implements the Unicode boundary 52 : : * resolution algorithms and normally you would use a function such 53 : : * as pango_break() instead of caring about break types yourself. 54 : : * 55 : : * Returns: the break type of @c 56 : : **/ 57 : : GUnicodeBreakType 58 : 48 : g_unichar_break_type (gunichar c) 59 : : { 60 [ + - + + : 48 : return PROP (c); - - - - - - ] 61 : : }