1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*
# image-char.c: manipulate information about the characters in the image.
#
# Copyright (C) 1992, 2011 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
*/
#include "config.h"
#include "image-char.h"
/* Return an initialized, empty list. */
image_char_list_type
new_image_char_list ()
{
image_char_list_type l;
IMAGE_CHAR_LIST_LENGTH (l) = 0;
IMAGE_CHAR_LIST_DATA (l) = NULL;
return l;
}
/* Append the character C to the list L. */
void
append_image_char (image_char_list_type *l, image_char_type c)
{
IMAGE_CHAR_LIST_LENGTH (*l)++;
IMAGE_CHAR_LIST_DATA (*l)
= xrealloc (IMAGE_CHAR_LIST_DATA (*l),
IMAGE_CHAR_LIST_LENGTH (*l) * sizeof (image_char_type));
IMAGE_CHAR (*l, IMAGE_CHAR_LIST_LENGTH (*l) - 1) = c;
}
/* Return false if the box BOX_COUNT boxes beyond CURRENT_CHAR in LIST
is in the middle of a character, true otherwise. To do this, we must
add up all the box counts for characters starting at FIRST_CHAR,
until we see where we land. */
boolean
box_at_char_boundary_p (image_char_list_type list, unsigned current_char,
unsigned box_count)
{
unsigned count = 0;
while (count < box_count && current_char < IMAGE_CHAR_LIST_LENGTH (list))
{
image_char_type c = IMAGE_CHAR (list, current_char);
count += IMAGE_CHAR_BB_COUNT (c);
current_char++;
}
return count == box_count;
}
|