Files
lime/project/include/text/Font.h
Chris Speciale 579efa5351 Font: Allow setting dpi internally
This fixes some unexpected changes in text rendering for OpenFL which rely on a private function in Lime. Previously we defaulted at 72 dpi, which apparently is expected to layout the text properly. Most displays are 96 dpi or higher today, so we should probably look into this. For RenderGlyph, which was previously broken over several versions, we will now use a dpi of 96 for now. In the next version of lime, we absolutely should alter the function signature to allow for renderGlyph to accept a dpi argument.
2024-10-30 12:49:30 -04:00

79 lines
1.2 KiB
C++

#ifndef LIME_TEXT_FONT_H
#define LIME_TEXT_FONT_H
#include <graphics/ImageBuffer.h>
#include <system/CFFI.h>
#include <system/System.h>
#include <utils/Resource.h>
#ifdef HX_WINDOWS
#undef GetGlyphIndices
#endif
namespace lime {
typedef struct {
unsigned long codepoint;
size_t size;
int index;
int height;
} GlyphInfo;
typedef struct {
uint32_t index;
uint32_t width;
uint32_t height;
uint32_t x;
uint32_t y;
unsigned char data;
} GlyphImage;
class Font {
public:
Font (Resource *resource, int faceIndex = 0);
~Font ();
void* Decompose (bool useCFFIValue, int em);
int GetAscender ();
int GetDescender ();
wchar_t *GetFamilyName ();
int GetGlyphIndex (const char* character);
void* GetGlyphIndices (bool useCFFIValue, const char* characters);
void* GetGlyphMetrics (bool useCFFIValue, int index);
int GetHeight ();
int GetNumGlyphs ();
int GetUnderlinePosition ();
int GetUnderlineThickness ();
int GetUnitsPerEM ();
int RenderGlyph (int index, Bytes *bytes, int offset = 0);
int RenderGlyphs (value indices, Bytes *bytes);
void SetSize (size_t size, size_t dpi);
void* library;
void* face;
void* faceMemory;
private:
size_t mSize;
};
}
#endif