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.
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
31namespace KIGFX {
32namespace BUILTIN_FONT {
33
34#include "bitmap_font_img.c"
35#include "bitmap_font_desc.c"
36
37const FONT_GLYPH_TYPE* LookupGlyph( unsigned int aCodepoint )
38{
39#ifdef BITMAP_FONT_USE_SPANS
40 auto *end = font_codepoint_spans + sizeof( font_codepoint_spans ) / sizeof(FONT_SPAN_TYPE);
41
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 if( ptr != end && ptr->start <= aCodepoint )
49 {
50 unsigned int index = aCodepoint - ptr->start + ptr->cumulative;
51 return &font_codepoint_infos[ index ];
52 }
53 else
54 {
55 return nullptr;
56 }
57#else
58 return &bitmap_chars[codepoint];
59#endif
60}
61
62}
63}
const FONT_GLYPH_TYPE * LookupGlyph(unsigned int aCodepoint)
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247