Progress on text support

This commit is contained in:
Joshua Granick
2015-03-07 20:57:00 -08:00
parent f88a35f890
commit 7b5130f6d9
16 changed files with 1318 additions and 439 deletions

View File

@@ -1,39 +0,0 @@
#ifndef LIME_GRAPHICS_TEXT_H
#define LIME_GRAPHICS_TEXT_H
#include <hx/CFFI.h>
#include <hb.h>
namespace lime {
class Font;
class Text {
public:
Text (hb_tag_t direction, const char *script, const char *language);
~Text ();
value FromString (Font *font, size_t size, const char *text);
private:
hb_buffer_t *mBuffer;
hb_direction_t mDirection;
hb_script_t mScript;
hb_language_t mLanguage;
};
}
#endif

View File

@@ -1,20 +1,11 @@
#ifndef LIME_GRAPHICS_FONT_H
#define LIME_GRAPHICS_FONT_H
#ifndef LIME_TEXT_FONT_H
#define LIME_TEXT_FONT_H
#include <graphics/ImageBuffer.h>
#include <utils/Resource.h>
#include <hx/CFFI.h>
#include <list>
#include <graphics/ImageBuffer.h>
#ifdef LIME_FREETYPE
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_BITMAP_H
#include FT_SFNT_NAMES_H
#include FT_TRUETYPE_IDS_H
#include FT_GLYPH_H
#include FT_OUTLINE_H
#endif
namespace lime {
@@ -27,13 +18,8 @@ namespace lime {
unsigned long codepoint;
size_t size;
#ifdef LIME_FREETYPE
FT_UInt index;
FT_Pos height;
#else
int index;
int height;
#endif
} GlyphInfo;
@@ -43,25 +29,22 @@ namespace lime {
public:
static Font *FromFile (const char *fontFace);
Font (void* face = 0);
Font (Resource *resource, int faceIndex = 0);
~Font ();
value Decompose (int em);
value GetFamilyName ();
wchar_t *GetFamilyName ();
bool InsertCodepointFromIndex (unsigned long codepoint);
void LoadGlyphs (const char *glyphs);
void LoadRange (unsigned long start, unsigned long end);
value RenderToImage (ImageBuffer *image);
void SetSize (size_t size);
bool InsertCodepointFromIndex (unsigned long codepoint);
#ifdef LIME_FREETYPE
Font (FT_Face face);
FT_Face face;
#else
void* face;
#endif
private:
bool InsertCodepoint (unsigned long codepoint, bool b = true);
std::list<GlyphInfo> glyphList;

View File

@@ -0,0 +1,35 @@
#ifndef LIME_TEXT_TEXT_LAYOUT_H
#define LIME_TEXT_TEXT_LAYOUT_H
#include <text/Font.h>
#include <hx/CFFI.h>
namespace lime {
class TextLayout {
public:
TextLayout (int direction, const char *script, const char *language);
~TextLayout ();
value Layout (Font *font, size_t size, const char *text);
private:
void *mBuffer;
int mDirection;
int mScript;
int mLanguage;
};
}
#endif

View File

@@ -35,6 +35,7 @@ namespace lime {
ByteArray ();
ByteArray (struct _value *Value);
ByteArray (const QuickVec<unsigned char> &inValue);
ByteArray (const OSChar *inFilename);
void Resize (int inSize);
int Size() const;
@@ -44,7 +45,6 @@ namespace lime {
struct _value *mValue;
static ByteArray FromFile (const OSChar *inFilename);
static int ToFile (const OSChar *inFilename, const ByteArray array);