mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[kandinsky] Remove warning, add missing file
This commit is contained in:
committed by
LeaNumworks
parent
da4cc4356f
commit
83662ebf70
@@ -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
45
kandinsky/src/font.h
Normal 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
|
||||
Reference in New Issue
Block a user