mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[kandinsky/font] Define IndexForReplacementCharacterCodePoint
This commit is contained in:
committed by
Léa Saviot
parent
dd92450115
commit
7cfdadd394
@@ -59,6 +59,7 @@ public:
|
||||
CodePoint m_codePoint;
|
||||
GlyphIndex m_glyphIndex;
|
||||
};
|
||||
static constexpr GlyphIndex IndexForReplacementCharacterCodePoint = 132;
|
||||
GlyphIndex indexForCodePoint(CodePoint c) const;
|
||||
|
||||
void setGlyphGreyscalesForCodePoint(CodePoint codePoint, GlyphBuffer * glyphBuffer) const;
|
||||
|
||||
@@ -83,9 +83,6 @@ 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
|
||||
int lowerBound = 0;
|
||||
@@ -157,6 +154,7 @@ KDFont::GlyphIndex KDFont::indexForCodePoint(CodePoint c) const {
|
||||
return endPair->glyphIndex();
|
||||
}
|
||||
NoMatchingGlyph:
|
||||
return defaultIndex;
|
||||
assert(CodePoints[IndexForReplacementCharacterCodePoint] == 0xFFFD);
|
||||
return IndexForReplacementCharacterCodePoint;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -11,26 +11,24 @@ static constexpr KDFont::CodePointIndexPair table[] = {
|
||||
|
||||
constexpr KDFont testFont(4, table, 10, 10, nullptr, nullptr);
|
||||
|
||||
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),
|
||||
KDFont::IndexForReplacementCharacterCodePoint,
|
||||
KDFont::IndexForReplacementCharacterCodePoint,
|
||||
KDFont::IndexForReplacementCharacterCodePoint,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
KDFont::IndexForReplacementCharacterCodePoint,
|
||||
KDFont::IndexForReplacementCharacterCodePoint,
|
||||
KDFont::IndexForReplacementCharacterCodePoint,
|
||||
4,
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
KDFont::IndexForReplacementCharacterCodePoint,
|
||||
KDFont::IndexForReplacementCharacterCodePoint,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
static_cast<KDFont::GlyphIndex>(defaultIndex),
|
||||
KDFont::IndexForReplacementCharacterCodePoint,
|
||||
};
|
||||
|
||||
QUIZ_CASE(kandinsky_font_index_for_code_point) {
|
||||
|
||||
Reference in New Issue
Block a user