#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_TRUETYPE_TABLES_H
-#include <freetype/ttunpat.h>
+#include FT_UNPATENTED_HINTING_H
#define property _property
#include "harfbuzz.h"
#undef property
static HB_Script theCurrentScript;
-static unichar UTF16GetChar(uint16 *string, int * nw)
+static unichar UTF16GetChar(const uint16 *string, int * nw)
{
unichar ch;
if(HB_IsHighSurrogate(string[0]) && HB_IsLowSurrogate(string[1]))
return ch;
}
-static HB_Bool hb_stringToGlyphs(HB_Font font, uint16 * string, uint length, HB_Glyph *glyphs, uint *numGlyphs, HB_Bool rightToLeft)
+static HB_Bool hb_stringToGlyphs(HB_Font font, const uint16 * string, uint length, HB_Glyph *glyphs, uint *numGlyphs, HB_Bool rightToLeft)
{
FT_Face face = ((FontEntry)font->userData).face;
int glyph_pos = 0;
}
}
-static HB_Bool hb_canRender(HB_Font font, uint16 * string, uint length)
+static HB_Bool hb_canRender(HB_Font font, const uint16 * string, uint length)
{
FT_Face face = ((FontEntry)font->userData).face;
int c, nw;
~FontEntry()
{
- char * fileName = (char *)key;
- delete fileName;
+ delete (char *)key;
delete buffer;
if(hbFace)
HB_FreeFace(hbFace);
FontEntry fontEntry = null;
FT_Face faces[128];
float scales[128];
- bool isGlyph = (uint)key & 0x80000000;
- int curScript = ((uint)key & 0x7F000000) >> 24;
+ bool isGlyph = ((uint)key & 0x80000000) != 0;
+ //int curScript = ((uint)key & 0x7F000000) >> 24;
unichar testChar = 0;
/*
if(isGlyph)
}
//FT_Set_Char_Size(fontEntry.face, (int)(font.size * 64), (int)(font.size * 64), 96, 96);
fontEntry.scale = FaceSetCharSize(fontEntry.face, font.size);
+ if(!font.scale)
+ font.scale = fontEntry.scale;
if(!c)
{
if(!fontEntry.face->units_per_EM)
{
int total = 0;
int numPixels = 0;
- int max;
+ //int max;
if(slot->bitmap.pixel_mode != FT_PIXEL_MODE_MONO)
{
for(j = y, q = 0; j<yMax; j++)
q += slot->bitmap.pitch;
}
}
- max = numPixels ? (total / numPixels) : 1;
+ //max = numPixels ? (total / numPixels) : 1;
for(j = y, q = 0; j<yMax; j++)
{
}
*numGlyphs = shaper_item.num_glyphs;
- *rightToLeft = shaper_item.item.bidiLevel % 2;
+ *rightToLeft = (bool)(shaper_item.item.bidiLevel % 2);
return shaper_item.glyphs;
}
}
#endif
}
+ public property int ascent
+ {
+ get { return (int)(this ? ascent * scale : 0); }
+ }
};
public class LFBDisplay : struct
{
char entryName[1024];
char fontFileName[1024];
- uint32 type;
- int size = 1024;
- int sizeFileName = 1024;
+ DWORD type;
+ DWORD size = 1024;
+ DWORD sizeFileName = 1024;
char * occurence;
- if(RegEnumValue(key, value++, entryName, (PDWORD)&size, null, (PDWORD)&type, (LPBYTE)fontFileName, (PDWORD)&sizeFileName) != ERROR_SUCCESS)
+ if(RegEnumValue(key, value++, entryName, &size, null, (PDWORD)&type, (LPBYTE)fontFileName, &sizeFileName) != ERROR_SUCCESS)
break;
- if((occurence = SearchString((char *)entryName, 0, (char *)font->elfFullName, false, false)))
+ if((occurence = SearchString(entryName, 0, (const char *)font->elfFullName, false, false)))
{
int c;
for(c = (int)(occurence - entryName) - 1; c >= 0; c--)
}
#endif
+#if !defined(ECERE_NOTRUETYPE)
static int utf16BufferSize = 0;
static uint16 * utf16 = null;
+#endif
public class LFBDisplayDriver : DisplayDriver
{
LFBDisplay lfbDisplay = display ? display.driverData : null;
LFBSurface lfbSurface = surface.driverData;
uint index;
- if(display) color = color /*& 0xFFFFFF*/;
+ //if(display) color = color & 0xFFFFFF;
lfbSurface.foregroundRgb = color;
if(lfbSurface.font && lfbDisplay)
{
LFBDisplay lfbDisplay = display ? display.driverData : null;
LFBSurface lfbSurface = surface.driverData;
- color = color /*& 0xFFFFFF*/;
+ //color = color & 0xFFFFFF;
switch(lfbSurface.bitmap.pixelFormat)
{
case pixelFormat8:
}
else
{
- if(surface.background.a == 255 || lfbSurface.clearing)
+ if(!surface.blend || surface.background.a == 255 || lfbSurface.clearing)
{
switch(GetColorDepthShifts(lfbSurface.bitmap.pixelFormat))
{
int c;
for(c = 0; c < w; c++, dest++)
{
- Color destColor;
+ Color destColor = 0;
if(pixelFormat == pixelFormat565) { destColor = (Color)*(Color565 *)dest; }
else if(pixelFormat == pixelFormat555) { destColor = (Color)*(Color555 *)dest; }
else if(pixelFormat == pixelFormat444) { destColor = (Color)*(Color444 *)dest; }
ColorAlpha * backsrc;
ColorAlpha * source = ((ColorAlpha *) src.picture) + sy * addsource + sx;
ColorAlpha * dest = ((ColorAlpha *) lfbSurface.bitmap.picture) + dy * adddest + dx;
- if(flip < 0) source += sw-1;
+ if(flip) source += sw-1;
adddest -= w;
yerr = 0;
for(y=0; y<sh; y++)
AlphaWriteMode alphaWrite = surface.alphaWrite;
if(src.alphaBlend && surface.blend)
{
- int x, y;
- uint xerr,yerr;
uint adddest = lfbSurface.bitmap.stride, addsource = src.stride;
- ColorAlpha * backsrc;
ColorAlpha * source = ((ColorAlpha *) src.picture) + sy * addsource + sx;
ColorAlpha * dest = ((ColorAlpha *) lfbSurface.bitmap.picture) + dy * adddest + dx;
float scaleX = (float)sw / w;
int x0 = x * sw / w;
int x1 = Min(x0 + 1, sw - 1);
float beta = x * scaleX - x0;
- ColorAlpha color;
ColorAlpha src00, src01, src10, src11;
float a1,r1,g1,b1,a2,r2,g2,b2;
float a,r,g,b;
float a = 0, r = 0, g = 0, b = 0;
int numPixels = 0;
int i, j;
- ColorAlpha color;
for (i = y0; i <= y1; i++)
for (j = x0; j <= x1; j++)
{
g /= numPixels;
b /= numPixels;
{
- ColorAlpha src = *source;
ColorAlpha dst = *dest;
int cr = (int)(a * r / 255 + ((255 - a) * dst.color.r / 255));
int cg = (int)(a * g / 255 + ((255 - a) * dst.color.g / 255));
}
}
- Font LoadFont(DisplaySystem displaySystem, char * faceName, float size, FontFlags flags)
+ Font LoadFont(DisplaySystem displaySystem, const char * faceName, float size, FontFlags flags)
{
void * result = null;
{
char fileName[MAX_LOCATION];
bool fakeItalic = flags.italic;
- char linkCfgPath[MAX_LOCATION];
int fontID = 0;
#if !defined(__WIN32__)
File linkCfg;
#endif
- char * ecereFonts = getenv("ECERE_FONTS");
+ const char * ecereFonts = getenv("ECERE_FONTS");
if(!ecereFonts) ecereFonts = "<:ecere>";
#if !defined(__WIN32__)
- strcpy(linkCfgPath, ecereFonts);
- PathCat(linkCfgPath, "linking.cfg");
- linkCfg = FileOpen(linkCfgPath, read);
+ {
+ char linkCfgPath[MAX_LOCATION];
+
+ strcpy(linkCfgPath, ecereFonts);
+ PathCat(linkCfgPath, "linking.cfg");
+ linkCfg = FileOpen(linkCfgPath, read);
+ }
#endif
strcpy(fileName, faceName);
strcpy(font.faceName, faceName);
strcpy(logFont.lfFaceName, faceName);
fontData.flags = flags;
- EnumFontFamiliesEx(hdc, &logFont, (void *)MyFontProc, (DWORD)&fontData, 0);
+ EnumFontFamiliesEx(hdc, &logFont, (void *)MyFontProc, (LPARAM)&fontData, 0);
if(!fontData.fileName[0] && flags.bold)
{
fontData.forgive = true;
- EnumFontFamiliesEx(hdc, &logFont, (void *)MyFontProc, (DWORD)&fontData, 0);
+ EnumFontFamiliesEx(hdc, &logFont, (void *)MyFontProc, (LPARAM)&fontData, 0);
}
if(!fontData.fileName[0])
{
// Fake italic
fontData.flags.italic = false;
- EnumFontFamiliesEx(hdc, &logFont, (void *)MyFontProc, (DWORD)&fontData, 0);
+ EnumFontFamiliesEx(hdc, &logFont, (void *)MyFontProc, (LPARAM)&fontData, 0);
fakeItalic = true;
}
// printf("Locating %s\n", faceName);
if(matched)
{
- FcPatternGetString(matched, FC_FAMILY, 0, &family);
+ FcPatternGetString(matched, FC_FAMILY, 0, (FcChar8 **)&family);
//printf("Fontconfig returned %s\n", family);
}
if(matched && (result == FcResultMatch /*|| result == FcResultNoId*/) /*&& !strcmpi(family, faceName)*/)
{
double fontSize;
- FcPatternGetString (matched, FC_FILE, 0, &fileName2);
+ FcPatternGetString (matched, FC_FILE, 0, (FcChar8 **)&fileName2);
FcPatternGetInteger(matched, FC_INDEX, 0, &fontID);
FcPatternGetDouble(matched, FC_SIZE, 0, &fontSize);
strcpy(fileName, fileName2);
!RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\FontLink\\SystemLink",0,KEY_READ,&key))
{
// int value = 0;
- uint32 type;
- int size = 1024;
- RegQueryValueEx(key, faceName, null, (LPDWORD)&type, (LPBYTE)links, (LPDWORD)&size);
+ DWORD type;
+ DWORD size = 1024;
+ RegQueryValueEx(key, faceName, null, &type, (LPBYTE)links, &size);
memset(links + size, 0, 1024 - size);
RegCloseKey(key);
}
matched = FcFontMatch (0, pattern, &result);
if(matched)
{
- FcPatternGetString(matched, FC_FAMILY, 0, &family);
+ FcPatternGetString(matched, FC_FAMILY, 0, (FcChar8 **)&family);
// printf("Fontconfig returned %s\n", family);
}
if(matched && (result == FcResultMatch /*|| result == FcResultNoId*/) &&
- FcPatternGetString(matched, FC_FAMILY, 0, &family) == FcResultMatch /*&& !strcmpi(family, links + linksPos + c + 1)*/)
+ FcPatternGetString(matched, FC_FAMILY, 0, (FcChar8 **)&family) == FcResultMatch /*&& !strcmpi(family, links + linksPos + c + 1)*/)
{
double fontSize;
- FcPatternGetString (matched, FC_FILE, 0, &fileName2);
+ FcPatternGetString (matched, FC_FILE, 0, (FcChar8 **)&fileName2);
FcPatternGetInteger(matched, FC_INDEX, 0, &fontID);
FcPatternGetDouble(matched, FC_SIZE, 0, &fontSize);
strcpy(fileName, fileName2);
}
#if !defined(ECERE_NOTRUETYPE)
- void ::ProcessString(Font font, DisplaySystem displaySystem, byte * text, int len,
+ void ::ProcessString(Font font, DisplaySystem displaySystem, const byte * text, int len,
void (* callback)(Surface surface, Display display, int x, int y, GlyphInfo * glyph, Bitmap bitmap),
Surface surface, Display display, int * x, int y)
{
int c, nb, glyphIndex = 0;
unichar lastPack = 0;
GlyphPack pack = font.asciiPack;
- int wc;
- uint * glyphs;
+ int wc = 0;
+ uint * glyphs = null;
int numGlyphs = 0;
bool rightToLeft = false;
int fontEntryNum = 0;
for(c = 0; c < len || (numGlyphs && (rightToLeft ? (glyphIndex >= 0) : (glyphIndex < numGlyphs)));)
{
- uint glyphNo;
+ uint glyphNo = 0;
uint packNo;
if(numGlyphs && (rightToLeft ? (glyphIndex >= 0) : (glyphIndex < numGlyphs)))
{
else
{
HB_Script curScript = HB_Script_Common;
- byte * scriptStart = text + c;
- unichar nonASCIIch = 0;
+ const byte * scriptStart = text + c;
+ //unichar nonASCIIch = 0;
unichar ch;
unichar ahead = 0;
unichar testChar = 0;
- char * testLang = null;
+#if !defined(__WIN32__) && !defined(ECERE_NOFONTCONFIG)
+ const char * testLang = null;
+#endif
while(true)
{
HB_Script script = HB_Script_Common;
- ch = UTF8GetChar((char *)text + c, &nb);
- if(ch > 127) nonASCIIch = ch;
+ ch = UTF8GetChar((const char *)text + c, &nb);
+ //if(ch > 127) nonASCIIch = ch;
if(!nb) break;
if(ch == 32 && curScript)
{
if(a < c + len)
{
int nb;
- unichar ahead = UTF8GetChar((char *)text + a, &nb);
+ unichar ahead = UTF8GetChar((const char *)text + a, &nb);
if((ahead >= 0x590 && ahead <= 0x7C0) || (ahead >= 0xFB1D && ahead <= 0xFB4F) || (ahead >= 0xFB50 && ahead <= 0xFDFF))
script = curScript;
}
utf16 = renew utf16 uint16[max];
utf16BufferSize = max;
}
- wc = UTF8toUTF16BufferLen((char *)scriptStart, utf16, max, len);
+ wc = UTF8toUTF16BufferLen((const char *)scriptStart, utf16, max, len);
theCurrentScript = glyphScript = curScript;
}
switch(curScript)
case HB_Script_Arabic: testChar = 0x621; /*testLang = "ar"; */
//printf("Arabic ");
break;
- case HB_Script_Devanagari: testChar = 0x905; testLang = "sa";
+ case HB_Script_Devanagari: testChar = 0x905;
+#if !defined(__WIN32__) && !defined(ECERE_NOFONTCONFIG)
+ testLang = "sa";
+#endif
//printf("Devanagari ");
break;
case HB_Script_Hebrew: testChar = 0x05EA /*'ת'*/; /*testLang = "he"; */
char * family;
FontEntry fontEntry;
char * fileName = null;
- bool fakeItalic = false;
for(fontEntryNum = 0; fontEntryNum<MAX_FONT_LINK_ENTRIES; fontEntryNum++)
if(!font.fontEntries[fontEntryNum])
break;
matched = FcFontMatch (0, pattern, &result);
if(matched)
{
- FcPatternGetString(matched, FC_FAMILY, 0, &family);
+ FcPatternGetString(matched, FC_FAMILY, 0, (FcChar8 **)&family);
//printf("Fontconfig returned %s\n", family);
}
- if(matched && (result == FcResultMatch) && FcPatternGetString(matched, FC_FAMILY, 0, &family) == FcResultMatch)
+ if(matched && (result == FcResultMatch) && FcPatternGetString(matched, FC_FAMILY, 0, (FcChar8 **)&family) == FcResultMatch)
{
- FcPatternGetString (matched, FC_FILE, 0, &fileName);
+ FcPatternGetString (matched, FC_FILE, 0, (FcChar8 **)&fileName);
FcPatternGetInteger(matched, FC_INDEX, 0, &fontID);
FcPatternGetDouble(matched, FC_SIZE, 0, &fontSize);
// printf("\nMatched to %s, %f\n", fileName, fontSize);
}
#endif
- void FontExtent(DisplaySystem displaySystem, Font font, byte * text, int len, int * width, int * height)
+ void FontExtent(DisplaySystem displaySystem, Font font, const char * text, int len, int * width, int * height)
{
if(displaySystem && displaySystem.flags.text && len)
{
{
int w = 0;
#if !defined(ECERE_NOTRUETYPE)
- ProcessString(font, displaySystem, text, len, null, null, null, &w, 0);
+ ProcessString(font, displaySystem, (const byte *)text, len, null, null, null, &w, 0);
#endif
//*width = (w + 64 - w % 64) >> 6;
*width = w >> 6;
}
#endif
- void WriteText(Display display, Surface surface, int x, int y, byte * text, int len)
+ void WriteText(Display display, Surface surface, int x, int y, const char * text, int len)
{
LFBSurface lfbSurface = surface.driverData;
if(display && display.displaySystem.flags.text)
lfbSurface.writingText = true;
#if !defined(ECERE_NOTRUETYPE)
x <<= 6;
- ProcessString(lfbSurface.font, surface.displaySystem, text, len, OutputGlyph, surface, display, &x, y);
+ ProcessString(lfbSurface.font, surface.displaySystem, (const byte *)text, len, OutputGlyph, surface, display, &x, y);
#endif
lfbSurface.writingText = false;
}
void TextOpacity(Display display, Surface surface, bool opaque)
{
- LFBSurface lfbSurface = surface.driverData;
}
- void TextExtent(Display display, Surface surface, byte * text, int len, int * width, int * height)
+ void TextExtent(Display display, Surface surface, const char * text, int len, int * width, int * height)
{
LFBSurface lfbSurface = surface.driverData;
FontExtent(surface.displaySystem, lfbSurface.font, text, len, width, height);
delete mesh.texCoords;
}
- bool AllocateMesh(DisplaySystem displaySystem, Mesh mesh)
+ bool AllocateMesh(DisplaySystem displaySystem, Mesh mesh, MeshFeatures flags, int nVertices)
{
bool result = false;
-
- if((!mesh.flags.vertices || mesh.vertices || (mesh.vertices = new Vector3Df[mesh.nVertices])) &&
- (!mesh.flags.normals || mesh.normals || (mesh.normals = new Vector3Df[mesh.nVertices])) &&
- (!mesh.flags.texCoords1 || mesh.texCoords || (mesh.texCoords = new Pointf [mesh.nVertices])))
+ if(mesh.nVertices == nVertices)
+ {
result = true;
+ // Same number of vertices, adding features (Leaves the other features pointers alone)
+ if(mesh.flags != flags)
+ {
+ if(!mesh.flags.vertices && flags.vertices)
+ {
+ if(flags.doubleVertices)
+ {
+ mesh.vertices = (Vector3Df *)new Vector3D[nVertices];
+ }
+ else
+ mesh.vertices = new Vector3Df[nVertices];
+ }
+ if(!mesh.flags.normals && flags.normals)
+ {
+ if(flags.doubleNormals)
+ {
+ mesh.normals = (Vector3Df *)new Vector3D[nVertices];
+ }
+ else
+ mesh.normals = new Vector3Df[nVertices];
+ }
+ if(!mesh.flags.texCoords1 && flags.texCoords1)
+ mesh.texCoords = new Pointf[nVertices];
+ if(!mesh.flags.colors && flags.colors)
+ mesh.colors = new ColorRGBAf[nVertices];
+ }
+ }
+ else
+ {
+ result = true;
+ // New number of vertices, reallocate all current and new features
+ flags |= mesh.flags;
+ if(flags.vertices)
+ {
+ if(flags.doubleVertices)
+ {
+ mesh.vertices = (Vector3Df *)renew mesh.vertices Vector3D[nVertices];
+ }
+ else
+ mesh.vertices = renew mesh.vertices Vector3Df[nVertices];
+ }
+ if(flags.normals)
+ {
+ if(flags.doubleNormals)
+ {
+ mesh.normals = (Vector3Df *)renew mesh.normals Vector3D[nVertices];
+ }
+ else
+ mesh.normals = renew mesh.normals Vector3Df[nVertices];
+ }
+ if(flags.texCoords1)
+ mesh.texCoords = renew mesh.texCoords Pointf[nVertices];
+ if(flags.colors)
+ mesh.colors = renew mesh.colors ColorRGBAf[nVertices];
+ }
return result;
}