|
@@ -2539,6 +2539,7 @@ tnsFontManager *FM;
|
|
|
|
|
|
void tnsSetuptnsFontManager(){
|
|
|
FM = CreateNew(tnsFontManager);
|
|
|
+ FM->BufferWidth = TNS_FONT_BUFFER_W_DEFAULT;
|
|
|
};
|
|
|
void tnsQuitFontManager(){
|
|
|
tnsInvalidateFontCache();
|
|
@@ -2587,7 +2588,7 @@ int tnsInvalidateFontCache(){
|
|
|
f->MonoAdvance=(real)f->ftfacemono->glyph->advance.x/64.0;
|
|
|
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);
|
|
|
|
|
@@ -2639,7 +2640,7 @@ int tnsLoadSystemFont(char* from, char* name){
|
|
|
f->characters=calloc(1, sizeof(tnsFontSingleCharacter*)*TNS_UNICODE_COUNT);
|
|
|
f->monocharacters=calloc(1, sizeof(tnsFontSingleCharacter*)*TNS_MONO_COUNT);
|
|
|
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;
|
|
|
if (FT_Init_FreeType(&f->ftlib)) SEND_PANIC_ERROR("Freetype Init Failed!");
|
|
|
logPrintNew("Loading fonts...\n");
|
|
@@ -2676,35 +2677,19 @@ int tnsLoadSystemFont(char* from, char* name){
|
|
|
|
|
|
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);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- FM->VectorsGrapghs = f;
|
|
|
-};
|
|
|
|
|
|
int tfntBufferWidthEnough(int total_width, int current_width, int this_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){
|
|
|
- if (!tfntBufferWidthEnough(TNS_FONT_BUFFER_W, f->CurrentX, fsc->width)){
|
|
|
+ if (!tfntBufferWidthEnough(FM->BufferWidth, f->CurrentX, fsc->width)){
|
|
|
f->CurrentY += (f->height+1);
|
|
|
f->CurrentX = 0;
|
|
|
}
|
|
@@ -2713,82 +2698,6 @@ void tfntApplyCharacterBufferOffset(tnsFont *f, tnsFontSingleCharacter *fsc){
|
|
|
f->CurrentX += (fsc->width+1);
|
|
|
}
|
|
|
|
|
|
-tnsFontSingleCharacter *tfntFetchVectorGraphTextureIDW(uint32_t ID){
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
tnsFontSingleCharacter *tfntFetchCharTextureIDW(uint32_t ch, int UseMono){
|
|
|
GLuint revel = 0;
|
|
|
tnsFont *f = FM->UsingFont;
|
|
@@ -2844,6 +2753,13 @@ tnsFontSingleCharacter *tfntFetchCharTextureIDW(uint32_t ch, int UseMono){
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
@@ -3054,10 +2970,10 @@ void tnsDrawStringM(char *content, uint32_t* contentU, real Color[4], int L, int
|
|
|
|
|
|
cx = sx + fsc->deltax;
|
|
|
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);
|
|
|
if (RevY) tnsMakeQuadT2d(VertArr,
|