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