*/}}
Procházet zdrojové kódy

Improved font searching to include $pwd.

YimingWu před 1 rokem
rodič
revize
c418d8d1a1
2 změnil soubory, kde provedl 11 přidání a 5 odebrání
  1. 1 1
      la_kernel.c
  2. 10 4
      la_tns_kernel.c

+ 1 - 1
la_kernel.c

@@ -583,7 +583,7 @@ int laGetReady(){
 
     la_RegenerateWireColors();
 
-    logPrint("Initialization Completed\n");
+    logPrintNew("Initialization Completed\n");
     MAIN.InitDone=1;
 }
 

+ 10 - 4
la_tns_kernel.c

@@ -2928,7 +2928,7 @@ int tnsInvalidateFontCache(){
 }
 tnsFontSingleCharacter *tfntFetchCharTextureIDW(uint32_t ch, int UseMono);
 
-const char* TNS_FONT_LOAD_OPTIONS[9]={"./","fonts/","lagui/fonts/","../","../fonts/","../lagui/fonts/","../../","../../fonts/","../../lagui/fonts/"};
+const char* TNS_FONT_LOAD_OPTIONS[9]={"","fonts/","lagui/fonts/","../","../fonts/","../lagui/fonts/","../../","../../fonts/","../../lagui/fonts/"};
 const char* TNS_FONT_LOAD_OPTIONS_FROM_HOME[2]={".local/share/fonts/lagui/",".local/share/fonts/"};
 
 int tnsLoadSystemFontMono(char* from, char* mono){
@@ -2940,11 +2940,14 @@ int tnsLoadSystemFontMono(char* from, char* mono){
     for(int i=0;i<f->NumFaces;i++){
         if(!FT_Get_Advance(f->ftface[i],L'我',FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP, &full_adv)) break;
     }
-    for(int i=-1;i<9;i++){
-        char* option=(i<0)?from:TNS_FONT_LOAD_OPTIONS[i]; sprintf(buf,"%s%s",option,mono);
+    for(int i=-1;i<11;i++){
+        char* option;
+        if(i<9){ option=(i<0)?from:TNS_FONT_LOAD_OPTIONS[i]; sprintf(buf,"%s%s%s",&MAIN.WorkingDirectory->Ptr,option,mono); }
+        else{ option=TNS_FONT_LOAD_OPTIONS_FROM_HOME[i-9]; sprintf(buf,"%s/%s%s",getenv("HOME"),option,mono); }
         if (FT_New_Face(f->ftlib, buf, 0, &f->ftfacemono)) continue;
         FT_Select_Charmap(f->ftfacemono, FT_ENCODING_UNICODE);
         FT_Set_Char_Size(f->ftfacemono, 0, GenHeight << 6, 96, 96);
+        logPrint("Loaded monospace font: %s\n",buf);
         if(!FT_Get_Advance(f->ftfacemono,'a',FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP, &half_adv)){
             f->MonoScale=(real)full_adv/(half_adv*2);
             FT_Set_Char_Size(f->ftfacemono, 0, (GenHeight << 6)*f->MonoScale, 96, 96);
@@ -2969,14 +2972,16 @@ int tnsLoadSystemFont(char* from, char* name){
         tnsInit2DTexture(&f->TexBuffer, GL_RED, TNS_FONT_BUFFER_W, TNS_FONT_BUFFER_H, 0);
         lstAppendItem(&FM->Fonts, f); FM->UsingFont=f;
         if (FT_Init_FreeType(&f->ftlib)) SEND_PANIC_ERROR("Freetype Init Failed!");
+        logPrintNew("Loading fonts...\n");
     }
 
     int GenHeight=LA_RH*MAIN.FontSize;
     for(int i=-1;i<11;i++){
         char* option;
-        if(i<9){ option=(i<0)?from:TNS_FONT_LOAD_OPTIONS[i]; sprintf(buf,"%s%s",option,name); }
+        if(i<9){ option=(i<0)?from:TNS_FONT_LOAD_OPTIONS[i]; sprintf(buf,"%s%s%s",MAIN.WorkingDirectory->Ptr,option,name); }
         else{ option=TNS_FONT_LOAD_OPTIONS_FROM_HOME[i-9]; sprintf(buf,"%s/%s%s",getenv("HOME"),option,name); }
         FT_Face face; FT_Long i,num_faces; FT_Open_Args args; args.flags=FT_OPEN_PATHNAME; args.pathname=buf;
+        printf("%s\n",buf);
         if(FT_Open_Face(f->ftlib, &args, -1, &face )) continue;
         num_faces = face->num_faces; FT_Done_Face(face); int found=0;
         for(int fa=0;fa<num_faces;fa++){
@@ -2995,6 +3000,7 @@ int tnsLoadSystemFont(char* from, char* name){
             f->MonoAdvance=(real)f->ftface[f->NumFaces]->glyph->advance.x/64.0;
             if(glyph) FT_Done_Glyph(glyph);
         }
+        logPrint("Loaded font: %s\n",buf);
         return 1;
     }