mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[kandinsky] Fix font test
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
#ifndef KANDINSKY_FONTS_CODE_POINTS_H
|
||||
#define KANDINSKY_FONTS_CODE_POINTS_H
|
||||
|
||||
// [0x30a].map{|i| "0x" + i.to_s(16) +", // " + [i].pack("U") + " // " + Unicode::Name.of([i].pack("U"))}.join("|")
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -147,3 +150,5 @@ uint32_t CodePoints[] = {
|
||||
};
|
||||
|
||||
int NumberOfCodePoints = sizeof(CodePoints)/sizeof(CodePoints[0]);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -82,6 +82,7 @@ void KDFont::colorizeGlyphBuffer(const RenderPalette * renderPalette, GlyphBuffe
|
||||
|
||||
KDFont::GlyphIndex KDFont::indexForCodePoint(CodePoint c) const {
|
||||
int defaultIndex = NumberOfCodePoints - 2;
|
||||
assert(defaultIndex == 132); // If not, change kandinsky/test/font.cpp
|
||||
assert(CodePoints[defaultIndex] == 0xFFFD);
|
||||
#define USE_BINARY_SEARCH 0
|
||||
#if USE_BINARY_SEARCH
|
||||
|
||||
@@ -11,13 +11,30 @@ static constexpr KDFont::CodePointIndexPair table[] = {
|
||||
|
||||
constexpr KDFont testFont(4, table, 10, 10, nullptr, nullptr);
|
||||
|
||||
const KDFont::GlyphIndex index_for_code_point[] = {
|
||||
/* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 */
|
||||
0, 0, 0, 1, 2, 3, 0, 0, 0, 4, 0, 0, 5, 6, 7, 0
|
||||
constexpr int defaultIndex = 132; // Taken from KDFont::indexForCodePoint
|
||||
|
||||
constexpr int numberOfTests = 16;
|
||||
const KDFont::GlyphIndex index_for_code_point[numberOfTests] = {
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
4,
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
};
|
||||
|
||||
QUIZ_CASE(kandinsky_font_index_for_code_point) {
|
||||
for (int i=0; i<16; i++) {
|
||||
for (int i=0; i<numberOfTests; i++) {
|
||||
KDFont::GlyphIndex result = testFont.indexForCodePoint(i);
|
||||
quiz_assert(result == index_for_code_point[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user