Debian Codegraph @

src/kate_font.c

raw
1 /* Copyright (C) 2008 Vincent Penquerc'h.
2 This file is part of the Kate codec library.
3 Written by Vincent Penquerc'h.
4
5 Use, distribution and reproduction of this library is governed
6 by a BSD style source license included with this source in the
7 file 'COPYING'. Please read these terms before distributing. */
8
9
10 #define KATE_INTERNAL
11 #include "kate_internal.h"
12
13 #include "kate/kate.h"
14
15 /**
16 \ingroup font
17 Returns the index of the bitmap which corresponds to the given code point, if any.
18 \param kfm the font mapping to search
19 \param c the code point to search for
20 \returns 0 success
21 \returns KATE_E_* error
22 */
23 int kate_font_get_index_from_code_point(const kate_font_mapping *kfm,int c)
24 {
25 size_t n;
26
27 if (!kfm) return KATE_E_INVALID_PARAMETER;
28 if (!kate_is_valid_code_point(c)) return KATE_E_TEXT;
29
30 for (n=0;n<kfm->nranges;++n) {
31 const kate_font_range *kfr=kfm->ranges[n];
32 if (c>=kfr->first_code_point && c<=kfr->last_code_point) {
33 return kfr->first_bitmap+c-kfr->first_code_point;
34 }
35 }
36
37 /* not found */
38 return KATE_E_NOT_FOUND;
39 }
40