|
@@ -2539,6 +2539,7 @@ tnsFontManager *FM;
|
|
|
|
|
|
void tnsSetuptnsFontManager(){
|
|
void tnsSetuptnsFontManager(){
|
|
FM = CreateNew(tnsFontManager);
|
|
FM = CreateNew(tnsFontManager);
|
|
|
|
+ FM->BufferWidth = TNS_FONT_BUFFER_W_DEFAULT;
|
|
};
|
|
};
|
|
void tnsQuitFontManager(){
|
|
void tnsQuitFontManager(){
|
|
tnsInvalidateFontCache();
|
|
tnsInvalidateFontCache();
|
|
@@ -2587,7 +2588,7 @@ int tnsInvalidateFontCache(){
|
|
f->MonoAdvance=(real)f->ftfacemono->glyph->advance.x/64.0;
|
|
f->MonoAdvance=(real)f->ftfacemono->glyph->advance.x/64.0;
|
|
if(glyph) FT_Done_Glyph(glyph);
|
|
if(glyph) FT_Done_Glyph(glyph);
|
|
}
|
|
}
|
|
- glClearTexImage(f->TexBuffer.GLTexHandle, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
|
|
|
|
|
+ if(glClearTexImage) glClearTexImage(f->TexBuffer.GLTexHandle, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
|
}
|
|
}
|
|
tnsFontSingleCharacter *tfntFetchCharTextureIDW(uint32_t ch, int UseMono);
|
|
tnsFontSingleCharacter *tfntFetchCharTextureIDW(uint32_t ch, int UseMono);
|
|
|
|
|
|
@@ -2639,7 +2640,7 @@ int tnsLoadSystemFont(char* from, char* name){
|
|
f->characters=calloc(1, sizeof(tnsFontSingleCharacter*)*TNS_UNICODE_COUNT);
|
|
f->characters=calloc(1, sizeof(tnsFontSingleCharacter*)*TNS_UNICODE_COUNT);
|
|
f->monocharacters=calloc(1, sizeof(tnsFontSingleCharacter*)*TNS_MONO_COUNT);
|
|
f->monocharacters=calloc(1, sizeof(tnsFontSingleCharacter*)*TNS_MONO_COUNT);
|
|
f->height = LA_RH*(MAIN.FontSize/2.0f+0.5f);
|
|
f->height = LA_RH*(MAIN.FontSize/2.0f+0.5f);
|
|
- tnsInit2DTexture(&f->TexBuffer, GL_RED, TNS_FONT_BUFFER_W, TNS_FONT_BUFFER_H, 0);
|
|
|
|
|
|
+ tnsInit2DTexture(&f->TexBuffer, GL_RED, FM->BufferWidth, FM->BufferWidth, 0);
|
|
lstAppendItem(&FM->Fonts, f); FM->UsingFont=f;
|
|
lstAppendItem(&FM->Fonts, f); FM->UsingFont=f;
|
|
if (FT_Init_FreeType(&f->ftlib)) SEND_PANIC_ERROR("Freetype Init Failed!");
|
|
if (FT_Init_FreeType(&f->ftlib)) SEND_PANIC_ERROR("Freetype Init Failed!");
|
|
logPrintNew("Loading fonts...\n");
|
|
logPrintNew("Loading fonts...\n");
|
|
@@ -2676,35 +2677,19 @@ int tnsLoadSystemFont(char* from, char* name){
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
};
|
|
};
|
|
-int tnsLoadVectorGraphPackage(const char *name, unsigned int size){
|
|
|
|
- char i;
|
|
|
|
-
|
|
|
|
- tnsFont *f = CreateNew(tnsFont);
|
|
|
|
-
|
|
|
|
- f->height = (int)((real)size * 1.4);
|
|
|
|
- f->fontName = name;
|
|
|
|
-
|
|
|
|
- if (FT_Init_FreeType(&f->ftlib)) SEND_PANIC_ERROR("Can't Load Main Font:Freetype Init Failed!");
|
|
|
|
- if (FT_New_Face(f->ftlib, name, 0, &f->ftface)) SEND_PANIC_ERROR("Can't Load Main Font:Freetype Can't Init Face");
|
|
|
|
-
|
|
|
|
- FT_Select_Charmap(f->ftface, FT_ENCODING_UNICODE);
|
|
|
|
- FT_Set_Char_Size(f->ftface, size << 6, size << 6, 96, 96);
|
|
|
|
-
|
|
|
|
- //tnsInit2DTexture(&f->TexBuffer, GL_ALPHA, TNS_FONT_BUFFER_W, TNS_FONT_BUFFER_H, 0);
|
|
|
|
-
|
|
|
|
- //lstAppendItem(&FM->Fonts, f);
|
|
|
|
-
|
|
|
|
- //tnsUseFont(name);
|
|
|
|
-
|
|
|
|
- FM->VectorsGrapghs = f;
|
|
|
|
-};
|
|
|
|
|
|
|
|
int tfntBufferWidthEnough(int total_width, int current_width, int this_width){
|
|
int tfntBufferWidthEnough(int total_width, int current_width, int this_width){
|
|
return (current_width + this_width +1 < total_width);
|
|
return (current_width + this_width +1 < total_width);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void tfntResizeFontTexture(tnsFont* f, int size){
|
|
|
|
+ FM->BufferWidth=size;
|
|
|
|
+ f->TexBuffer.Width=f->TexBuffer.Height=FM->BufferWidth;
|
|
|
|
+ tnsConfigure2DTexture(&f->TexBuffer);
|
|
|
|
+}
|
|
|
|
+
|
|
void tfntApplyCharacterBufferOffset(tnsFont *f, tnsFontSingleCharacter *fsc){
|
|
void tfntApplyCharacterBufferOffset(tnsFont *f, tnsFontSingleCharacter *fsc){
|
|
- if (!tfntBufferWidthEnough(TNS_FONT_BUFFER_W, f->CurrentX, fsc->width)){
|
|
|
|
|
|
+ if (!tfntBufferWidthEnough(FM->BufferWidth, f->CurrentX, fsc->width)){
|
|
f->CurrentY += (f->height+1);
|
|
f->CurrentY += (f->height+1);
|
|
f->CurrentX = 0;
|
|
f->CurrentX = 0;
|
|
}
|
|
}
|
|
@@ -2713,82 +2698,6 @@ void tfntApplyCharacterBufferOffset(tnsFont *f, tnsFontSingleCharacter *fsc){
|
|
f->CurrentX += (fsc->width+1);
|
|
f->CurrentX += (fsc->width+1);
|
|
}
|
|
}
|
|
|
|
|
|
-tnsFontSingleCharacter *tfntFetchVectorGraphTextureIDW(uint32_t ID){
|
|
|
|
- //GLuint revel = 0;
|
|
|
|
- //tnsFont *f = FM->VectorsGrapghs;
|
|
|
|
- //tnsFontSingleCharacter *fsc = 0;
|
|
|
|
- //FT_Glyph glyph = 0;
|
|
|
|
- //FT_BitmapGlyph bitmap_glyph;
|
|
|
|
- //FT_Bitmap bm;
|
|
|
|
- //FT_Face face;
|
|
|
|
- //int w, h, i, j;
|
|
|
|
- //GLubyte *buf = 0;
|
|
|
|
- //int a;
|
|
|
|
- //int Size = ((int)(_ICON_SYMBOL_SIZE[ID - 0)) << 6;
|
|
|
|
- //int ret;
|
|
|
|
-
|
|
|
|
- //if (!f)
|
|
|
|
- // return 0;
|
|
|
|
-
|
|
|
|
- //if (revel = f->icons[ID].Generated)
|
|
|
|
- // return &f->icons[ID];
|
|
|
|
-
|
|
|
|
- //FT_Set_Char_Size(f->ftface, Size, Size, 96, 96);
|
|
|
|
-
|
|
|
|
- //if (ret = FT_Load_Char(f->ftface, ID, FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP))
|
|
|
|
- // return 0;
|
|
|
|
-
|
|
|
|
- //fsc = &f->icons[ID];
|
|
|
|
-
|
|
|
|
- //face = f->ftface;
|
|
|
|
-
|
|
|
|
- //if (FT_Get_Glyph(face->glyph, &glyph))
|
|
|
|
- // return 0;
|
|
|
|
-
|
|
|
|
- //FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
|
|
|
|
-
|
|
|
|
- //FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1);
|
|
|
|
- //bitmap_glyph = glyph;
|
|
|
|
- //bm = bitmap_glyph->bitmap;
|
|
|
|
-
|
|
|
|
- //w = bm.width;
|
|
|
|
- //h = bm.rows;
|
|
|
|
- //fsc->width = w;
|
|
|
|
- //fsc->height = h;
|
|
|
|
- //fsc->advx = face->glyph->advance.x / 64.0f;
|
|
|
|
- //fsc->advy = face->size->metrics.y_ppem;
|
|
|
|
- //fsc->deltax = bitmap_glyph->left;
|
|
|
|
- //fsc->deltay = bitmap_glyph->top - h;
|
|
|
|
-
|
|
|
|
- ////tfntApplyCharacterBufferOffset(f, fsc);
|
|
|
|
-
|
|
|
|
- ////glBindTexture(GL_TEXTURE_2D, f->TexBuffer.GLTexHandle);
|
|
|
|
-
|
|
|
|
- //buf = CreateNewBuffer(GLubyte, w * h);
|
|
|
|
-
|
|
|
|
- //for (j = 0; j < h; j++)
|
|
|
|
- //{
|
|
|
|
- // for (i = 0; i < w; i++)
|
|
|
|
- // {
|
|
|
|
- // char _vl = bm.buffer[i + w * j];
|
|
|
|
- // buf[i + (h - j - 1) * w] = _vl;
|
|
|
|
- // }
|
|
|
|
- //}
|
|
|
|
-
|
|
|
|
- //glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
|
|
-
|
|
|
|
- //fsc->Tex = tnsCreate2DTexture(GL_ALPHA, w, h, buf);
|
|
|
|
-
|
|
|
|
- //glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
-
|
|
|
|
- ////glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, buf);
|
|
|
|
- //glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
-
|
|
|
|
- //FreeMem(buf);
|
|
|
|
-
|
|
|
|
- //fsc->Generated = 1;
|
|
|
|
- //return fsc;
|
|
|
|
-}
|
|
|
|
tnsFontSingleCharacter *tfntFetchCharTextureIDW(uint32_t ch, int UseMono){
|
|
tnsFontSingleCharacter *tfntFetchCharTextureIDW(uint32_t ch, int UseMono){
|
|
GLuint revel = 0;
|
|
GLuint revel = 0;
|
|
tnsFont *f = FM->UsingFont;
|
|
tnsFont *f = FM->UsingFont;
|
|
@@ -2844,6 +2753,13 @@ tnsFontSingleCharacter *tfntFetchCharTextureIDW(uint32_t ch, int UseMono){
|
|
|
|
|
|
tfntApplyCharacterBufferOffset(f, fsc);
|
|
tfntApplyCharacterBufferOffset(f, fsc);
|
|
|
|
|
|
|
|
+ if(fsc->buffery+h>=FM->BufferWidth){
|
|
|
|
+ tfntResizeFontTexture(f,FM->BufferWidth*2); tnsInvalidateFontCache();
|
|
|
|
+ FreeMem(buf); FT_Done_Glyph(glyph);
|
|
|
|
+ return tfntFetchCharTextureIDW(ch,UseMono);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
tnsBindTexture(&f->TexBuffer);
|
|
tnsBindTexture(&f->TexBuffer);
|
|
//glBindTexture(GL_TEXTURE_2D, f->TexBuffer.GLTexHandle);
|
|
//glBindTexture(GL_TEXTURE_2D, f->TexBuffer.GLTexHandle);
|
|
|
|
|
|
@@ -3054,10 +2970,10 @@ void tnsDrawStringM(char *content, uint32_t* contentU, real Color[4], int L, int
|
|
|
|
|
|
cx = sx + fsc->deltax;
|
|
cx = sx + fsc->deltax;
|
|
cy = sy - fsc->deltay;
|
|
cy = sy - fsc->deltay;
|
|
- xo = (real)fsc->bufferx / (real)TNS_FONT_BUFFER_W;
|
|
|
|
- yo = (real)fsc->buffery / (real)TNS_FONT_BUFFER_H;
|
|
|
|
- xl = (real)(fsc->bufferx + fsc->width) / (real)TNS_FONT_BUFFER_W;
|
|
|
|
- yl = (real)(fsc->buffery + fsc->height) / (real)TNS_FONT_BUFFER_H;
|
|
|
|
|
|
+ xo = (real)fsc->bufferx / (real)FM->BufferWidth;
|
|
|
|
+ yo = (real)fsc->buffery / (real)FM->BufferWidth;
|
|
|
|
+ xl = (real)(fsc->bufferx + fsc->width) / (real)FM->BufferWidth;
|
|
|
|
+ yl = (real)(fsc->buffery + fsc->height) / (real)FM->BufferWidth;
|
|
|
|
|
|
tnsMakeQuadT2d(TexCoord, xo, yl, xo, yo, xl, yl, xl, yo);
|
|
tnsMakeQuadT2d(TexCoord, xo, yl, xo, yo, xl, yl, xl, yo);
|
|
if (RevY) tnsMakeQuadT2d(VertArr,
|
|
if (RevY) tnsMakeQuadT2d(VertArr,
|