[kandinsky] Remove warning, add missing file

This commit is contained in:
Romain Goyet
2018-10-06 22:15:10 +02:00
committed by LeaNumworks
parent da4cc4356f
commit 83662ebf70
3 changed files with 45 additions and 3 deletions

2
.gitignore vendored
View File

@@ -21,8 +21,6 @@ poincare/src/simplification/demo_ruleset.h
# Font related generated files.
kandinsky/fonts/rasterizer
kandinsky/src/font.c
kandinsky/src/font.h
# No i18n headers
apps/i18n.h

View File

@@ -23,7 +23,6 @@ void KDFont::fetchGlyphForChar(char c, const KDFont::RenderPalette & renderPalet
uint8_t * greyscaleBuffer = reinterpret_cast<uint8_t *>(pixelBuffer);
fetchGreyscaleGlyphForChar(c, greyscaleBuffer);
int numberOfPixels = m_glyphWidth*m_glyphHeight;
uint8_t mask = (0xFF >> (8-k_bitsPerPixel));
int pixelIndex = m_glyphWidth * m_glyphHeight;
int greyscaleByteIndex = pixelIndex / k_bitsPerPixel;

45
kandinsky/src/font.h Normal file
View File

@@ -0,0 +1,45 @@
#ifndef KANDINSKY_FONT_H
#define KANDINSKY_FONT_H
#include <stdint.h>
#include <kandinsky/coordinate.h>
#include "palette.h"
class KDFont {
private:
static constexpr int k_bitsPerPixel = 4;
public:
static const KDFont * LargeFont;
static const KDFont * SmallFont;
using RenderPalette = KDPalette<k_bitsPerPixel>;
void fetchGlyphForChar(char c, const RenderPalette & renderPalette, KDColor * pixelBuffer) const;
RenderPalette renderPalette(KDColor textColor, KDColor backgroundColor) const {
return RenderPalette::Gradient(textColor, backgroundColor);
}
KDCoordinate glyphWidth() const { return m_glyphWidth; }
KDCoordinate glyphHeight() const { return m_glyphWidth; }
constexpr KDFont(KDCoordinate glyphWidth, KDCoordinate glyphHeight, const uint16_t * glyphDataOffset, const uint8_t * data) :
m_glyphWidth(glyphWidth), m_glyphHeight(glyphHeight), m_glyphDataOffset(glyphDataOffset), m_data(data) { }
private:
void fetchGreyscaleGlyphForChar(char c, uint8_t * greyscaleBuffer) const;
const uint8_t * compressedGlyphData(char c) const {
return m_data + m_glyphDataOffset[charAsIndex(c)];
}
uint16_t compressedGlyphDataSize(char c) const {
return m_glyphDataOffset[charAsIndex(c)+1] - m_glyphDataOffset[charAsIndex(c)];
}
uint8_t charAsIndex(char c) const {
// FIXME: This is most likely false for chars greater than 127
return static_cast<uint8_t>(c);
}
KDCoordinate m_glyphWidth;
KDCoordinate m_glyphHeight;
const uint16_t * m_glyphDataOffset;
const uint8_t * m_data;
};
#endif