KiCad PCB EDA Suite
gl_resources.cpp
Go to the documentation of this file.
1 /*
2 * This program source code file is part of KICAD, a free EDA CAD application.
3 *
4 * Copyright (C) 2016 Kicad Developers, see change_log.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23 
24 // The current font is "Ubuntu Mono" available under Ubuntu Font Licence 1.0
25 // (see ubuntu-font-licence-1.0.txt for details)
26 #include <algorithm>
27 #include "gl_resources.h"
28 
29 #define BITMAP_FONT_USE_SPANS
30 
31 namespace KIGFX {
32  namespace BUILTIN_FONT {
33 
34 #include "bitmap_font_img.c"
35 #include "bitmap_font_desc.c"
36 
37  const FONT_GLYPH_TYPE* LookupGlyph( unsigned int aCodepoint )
38  {
39 #ifdef BITMAP_FONT_USE_SPANS
40  auto *end = font_codepoint_spans
41  + sizeof( font_codepoint_spans ) / sizeof(FONT_SPAN_TYPE);
42  auto ptr = std::upper_bound( font_codepoint_spans, end, aCodepoint,
43  []( unsigned int codepoint, const FONT_SPAN_TYPE& span )
44  {
45  return codepoint < span.end;
46  }
47  );
48 
49  if( ptr != end && ptr->start <= aCodepoint )
50  {
51  unsigned int index = aCodepoint - ptr->start + ptr->cumulative;
52  return &font_codepoint_infos[ index ];
53  }
54  else
55  {
56  return nullptr;
57  }
58 #else
59  return &bitmap_chars[codepoint];
60 #endif
61  }
62 
63  }
64 }
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:56
const FONT_GLYPH_TYPE * LookupGlyph(unsigned int aCodepoint)
FONT_SPAN_TYPE font_codepoint_spans[]
Definition: gl_resources.cpp:9
FONT_GLYPH_TYPE font_codepoint_infos[]