KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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.
4* Copyright The KiCad Developers, see AUTHORS.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, see <https://www.gnu.org/licenses/>.
18*/
19
20// The current font is "Ubuntu Mono" available under Ubuntu Font Licence 1.0
21// (see ubuntu-font-licence-1.0.txt for details)
22#include <algorithm>
23#include "gl_resources.h"
24
25#define BITMAP_FONT_USE_SPANS
26
27namespace KIGFX {
28namespace BUILTIN_FONT {
29
30#include "bitmap_font_img.c"
31#include "bitmap_font_desc.c"
32
33const FONT_GLYPH_TYPE* LookupGlyph( unsigned int aCodepoint )
34{
35#ifdef BITMAP_FONT_USE_SPANS
36 auto *end = font_codepoint_spans + sizeof( font_codepoint_spans ) / sizeof(FONT_SPAN_TYPE);
37
38 auto ptr = std::upper_bound( font_codepoint_spans, end, aCodepoint,
39 []( unsigned int codepoint, const FONT_SPAN_TYPE& span )
40 {
41 return codepoint < span.end;
42 } );
43
44 if( ptr != end && ptr->start <= aCodepoint )
45 {
46 unsigned int index = aCodepoint - ptr->start + ptr->cumulative;
47 return &font_codepoint_infos[ index ];
48 }
49 else
50 {
51 return nullptr;
52 }
53#else
54 return &bitmap_chars[codepoint];
55#endif
56}
57
58}
59}
int index
const FONT_GLYPH_TYPE * LookupGlyph(unsigned int aCodepoint)
FONT_SPAN_TYPE font_codepoint_spans[]
FONT_GLYPH_TYPE font_codepoint_infos[]
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:29
VECTOR2I end