committed by
Maciej Suminski
7 changed files with 99 additions and 57 deletions
-
1common/CMakeLists.txt
-
20common/gal/opengl/bitmap_font_desc.c
-
7common/gal/opengl/bitmap_font_img.c
-
41common/gal/opengl/gl_resources.cpp
-
46common/gal/opengl/gl_resources.h
-
39common/gal/opengl/opengl_gal.cpp
-
2include/gal/opengl/opengl_gal.h
7
common/gal/opengl/bitmap_font_img.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,41 @@ |
|||
// The current font is "Ubuntu Mono" available under Ubuntu Font Licence 1.0
|
|||
// (see ubuntu-font-licence-1.0.txt for details)
|
|||
#include <algorithm>
|
|||
#include "gl_resources.h"
|
|||
|
|||
#define BITMAP_FONT_USE_SPANS
|
|||
|
|||
namespace KIGFX { |
|||
namespace BUILTIN_FONT { |
|||
|
|||
#include "bitmap_font_img.c"
|
|||
#include "bitmap_font_desc.c"
|
|||
|
|||
const FONT_GLYPH_TYPE* LookupGlyph( unsigned int aCodepoint ) |
|||
{ |
|||
#ifdef BITMAP_FONT_USE_SPANS
|
|||
auto *end = font_codepoint_spans |
|||
+ sizeof( font_codepoint_spans ) / sizeof(FONT_SPAN_TYPE); |
|||
auto ptr = std::upper_bound( font_codepoint_spans, end, aCodepoint, |
|||
[]( unsigned int codepoint, const FONT_SPAN_TYPE& span ) |
|||
{ |
|||
return codepoint < span.end; |
|||
} |
|||
); |
|||
|
|||
if( ptr != end && ptr->start <= aCodepoint ) |
|||
{ |
|||
unsigned int index = aCodepoint - ptr->start + ptr->cumulative; |
|||
return &font_codepoint_infos[ index ]; |
|||
} |
|||
else |
|||
{ |
|||
return nullptr; |
|||
} |
|||
#else
|
|||
return &bitmap_chars[codepoint]; |
|||
#endif
|
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,46 @@ |
|||
#ifndef GAL_OPENGL_RESOURCES_H___ |
|||
#define GAL_OPENGL_RESOURCES_H___ |
|||
|
|||
#define BITMAP_FONT_USE_SPANS |
|||
|
|||
namespace KIGFX { |
|||
|
|||
namespace BUILTIN_FONT { |
|||
|
|||
struct FONT_IMAGE_TYPE { |
|||
unsigned int width, height; |
|||
unsigned int char_border; |
|||
unsigned int spacing; |
|||
unsigned char pixels[1024 * 1024 * 3]; |
|||
}; |
|||
|
|||
struct FONT_INFO_TYPE { |
|||
unsigned int smooth_pixels; |
|||
float min_y; |
|||
float max_y; |
|||
}; |
|||
|
|||
struct FONT_SPAN_TYPE { |
|||
unsigned int start; |
|||
unsigned int end; |
|||
unsigned int cumulative; |
|||
}; |
|||
|
|||
struct FONT_GLYPH_TYPE { |
|||
unsigned int atlas_x, atlas_y; |
|||
unsigned int atlas_w, atlas_h; |
|||
float minx, maxx; |
|||
float miny, maxy; |
|||
float advance; |
|||
}; |
|||
|
|||
extern FONT_IMAGE_TYPE font_image; |
|||
extern FONT_INFO_TYPE font_information; |
|||
|
|||
const FONT_GLYPH_TYPE* LookupGlyph( unsigned int aCodePoint ); |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
#endif |
Write
Preview
Loading…
Cancel
Save
Reference in new issue