mirror of
https://github.com/godotengine/godot.git
synced 2024-12-21 10:25:24 +08:00
4c3f7d1290
Adds multi-channel SDF font texture generation and rendering support. Adds per-font oversampling support. Adds FontData import plugins (for dynamic fonts, BMFonts and monospaced image fonts), font texture cache pre-generation and loading. Adds BMFont binary format and outline support.
44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
|
|
#pragma once
|
|
|
|
#include <cstdlib>
|
|
|
|
namespace msdfgen {
|
|
|
|
typedef unsigned char byte;
|
|
|
|
/// Reference to a 2D image bitmap or a buffer acting as one. Pixel storage not owned or managed by the object.
|
|
template <typename T, int N = 1>
|
|
struct BitmapRef {
|
|
|
|
T *pixels;
|
|
int width, height;
|
|
|
|
inline BitmapRef() : pixels(NULL), width(0), height(0) { }
|
|
inline BitmapRef(T *pixels, int width, int height) : pixels(pixels), width(width), height(height) { }
|
|
|
|
inline T * operator()(int x, int y) const {
|
|
return pixels+N*(width*y+x);
|
|
}
|
|
|
|
};
|
|
|
|
/// Constant reference to a 2D image bitmap or a buffer acting as one. Pixel storage not owned or managed by the object.
|
|
template <typename T, int N = 1>
|
|
struct BitmapConstRef {
|
|
|
|
const T *pixels;
|
|
int width, height;
|
|
|
|
inline BitmapConstRef() : pixels(NULL), width(0), height(0) { }
|
|
inline BitmapConstRef(const T *pixels, int width, int height) : pixels(pixels), width(width), height(height) { }
|
|
inline BitmapConstRef(const BitmapRef<T, N> &orig) : pixels(orig.pixels), width(orig.width), height(orig.height) { }
|
|
|
|
inline const T * operator()(int x, int y) const {
|
|
return pixels+N*(width*y+x);
|
|
}
|
|
|
|
};
|
|
|
|
}
|