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|
|
|
|
+ {0,0,0,HF},{0,HF,0,1},{1,0,1,HF},{1,HF,1,1},
|
|
|
|
+};
|
|
|
|
+char TNS_LCD_MAP_7[][7]={
|
|
|
|
+ {1,0,1,1,1,1,1},{0,0,0,0,0,1,1},{1,1,1,0,1,1,0},{1,1,1,0,0,1,1},{0,1,0,1,0,1,1},// 0-4
|
|
|
|
+ {1,1,1,1,0,0,1},{1,1,1,1,1,0,1},{1,0,0,0,0,1,1},{1,1,1,1,1,1,1},{1,1,1,1,0,1,1},// 6-9
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+#undef HF
|
|
|
|
+
|
|
int tKnlAttatchShader(tnsShader *tns);
|
|
int tKnlAttatchShader(tnsShader *tns);
|
|
tnsShader *tKnlFindShader1i(int CustomIndex);
|
|
tnsShader *tKnlFindShader1i(int CustomIndex);
|
|
void tKnlPushMatrix();
|
|
void tKnlPushMatrix();
|
|
@@ -2778,6 +2826,13 @@ int tnsInvalidateFontCache(){
|
|
int GenHeight=LA_RH*MAIN.FontSize;
|
|
int GenHeight=LA_RH*MAIN.FontSize;
|
|
for(int i=0;i<f->NumFaces;i++){
|
|
for(int i=0;i<f->NumFaces;i++){
|
|
FT_Set_Char_Size(f->ftface[i], 0, GenHeight << 6, 96, 96);
|
|
FT_Set_Char_Size(f->ftface[i], 0, GenHeight << 6, 96, 96);
|
|
|
|
+ FT_Glyph glyph; int half_adv=0;
|
|
|
|
+ if(!FT_Get_Advance(f->ftface[i],'a',FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP, &half_adv)){
|
|
|
|
+ if (FT_Load_Char(f->ftface[i], 'a', FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)||
|
|
|
|
+ FT_Get_Glyph(f->ftface[i]->glyph, &glyph)){ SEND_PANIC_ERROR("Monospace font doesn't contain character 'a'"); }
|
|
|
|
+ f->MonoAdvance=(real)f->ftface[i]->glyph->advance.x/64.0;
|
|
|
|
+ if(glyph) FT_Done_Glyph(glyph);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if(f->ftfacemono){
|
|
if(f->ftfacemono){
|
|
FT_Set_Char_Size(f->ftfacemono, 0, (GenHeight << 6)*f->MonoScale, 96, 96); FT_Glyph glyph;
|
|
FT_Set_Char_Size(f->ftfacemono, 0, (GenHeight << 6)*f->MonoScale, 96, 96); FT_Glyph glyph;
|
|
@@ -2837,7 +2892,14 @@ int tnsLoadSystemFont(char* from, char* name){
|
|
if (FT_New_Face(f->ftlib, buf, 0, &f->ftface[f->NumFaces])) continue;
|
|
if (FT_New_Face(f->ftlib, buf, 0, &f->ftface[f->NumFaces])) continue;
|
|
FT_Select_Charmap(f->ftface[f->NumFaces], FT_ENCODING_UNICODE);
|
|
FT_Select_Charmap(f->ftface[f->NumFaces], FT_ENCODING_UNICODE);
|
|
FT_Set_Char_Size(f->ftface[f->NumFaces], 0, GenHeight << 6, 96, 96);
|
|
FT_Set_Char_Size(f->ftface[f->NumFaces], 0, GenHeight << 6, 96, 96);
|
|
- f->NumFaces++;
|
|
|
|
|
|
+ f->NumFaces++; FT_Glyph glyph; int half_adv=0;
|
|
|
|
+ if(!f->MonoAdvance && !FT_Get_Advance(f->ftface[f->NumFaces],'a',FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP, &half_adv)){
|
|
|
|
+ FT_Set_Char_Size(f->ftface[f->NumFaces], 0, (GenHeight << 6)*f->MonoScale, 96, 96);
|
|
|
|
+ if (FT_Load_Char(f->ftface[f->NumFaces], 'a', FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)||
|
|
|
|
+ FT_Get_Glyph(f->ftface[f->NumFaces]->glyph, &glyph)){ SEND_PANIC_ERROR("Monospace font doesn't contain character 'a'"); }
|
|
|
|
+ f->MonoAdvance=(real)f->ftface[f->NumFaces]->glyph->advance.x/64.0;
|
|
|
|
+ if(glyph) FT_Done_Glyph(glyph);
|
|
|
|
+ }
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3081,7 +3143,93 @@ int tnsStringGetWidth(char *content, int Count, int UseMono){
|
|
int tnsStringGetWidthU(uint32_t *contentU, int Count, int UseMono){
|
|
int tnsStringGetWidthU(uint32_t *contentU, int Count, int UseMono){
|
|
return tnsStringGetDimension(0, contentU, Count, 0, 0, UseMono);
|
|
return tnsStringGetDimension(0, contentU, Count, 0, 0, UseMono);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+int tnsDrawLCD7_ProgressX11(real x, real y, real Percent){
|
|
|
|
+ real hgap=LA_RH/15; real vgap=LA_RH/5;
|
|
|
|
+ real MA=FM->UsingFont->MonoAdvance;
|
|
|
|
+ real w=MA-hgap*2, h=LA_RH-vgap*2; y+=vgap; x+=hgap-MA;
|
|
|
|
+ TNS_CLAMP(Percent,0,1);
|
|
|
|
+ char str[10]; sprintf(str,"%d",(int)(Percent*100)); int len=strlen(str);
|
|
|
|
+ for(int i=len-1;i>=0;i--){
|
|
|
|
+ int uc=str[i];
|
|
|
|
+ if(uc>='0' && uc<='9'){ uc-='0'; }
|
|
|
|
+ else { continue; }
|
|
|
|
+ for(int i=0;i<7;i++){
|
|
|
|
+ if(TNS_LCD_MAP_7[uc][i]){
|
|
|
|
+ real* seg=TNS_LCD_SEG_7[i];
|
|
|
|
+ XDrawLine(MAIN.dpy,MAIN.Progress.w,MAIN.Progress.gc,
|
|
|
|
+ tnsInterpolate(x,x+w,seg[0]),tnsInterpolate(y,y+h,seg[1]),tnsInterpolate(x,x+w,seg[2]),tnsInterpolate(y,y+h,seg[3]));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ x-=MA;
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+int tnsMakeLCD7(real x, real y, real w, real h, int ch){
|
|
|
|
+ int uc=ch;
|
|
|
|
+ if(ch>='0' && ch<='9'){ uc-='0'; }
|
|
|
|
+ else {return 0;}
|
|
|
|
+ for(int i=0;i<7;i++){
|
|
|
|
+ if(TNS_LCD_MAP_7[uc][i]){
|
|
|
|
+ real* seg=TNS_LCD_SEG_7[i];
|
|
|
|
+ tnsVertex2d(tnsInterpolate(x,x+w,seg[0]),tnsInterpolate(y,y+h,seg[1]));
|
|
|
|
+ tnsVertex2d(tnsInterpolate(x,x+w,seg[2]),tnsInterpolate(y,y+h,seg[3]));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+int tnsMakeLCD16(real x, real y, real w, real h, int ch){
|
|
|
|
+ int uc=ch;
|
|
|
|
+ if(ch>='0' && ch<='9'){ uc-='0'; }
|
|
|
|
+ elif(ch>='A' && ch<='Z'){ uc-='A'; uc+=10; }
|
|
|
|
+ else {return 0;}
|
|
|
|
+ for(int i=0;i<16;i++){
|
|
|
|
+ if(TNS_LCD_MAP_16[uc][i]){
|
|
|
|
+ real* seg=TNS_LCD_SEG_16[i];
|
|
|
|
+ tnsVertex2d(tnsInterpolate(x,x+w,seg[0]),tnsInterpolate(y,y+h,seg[1]));
|
|
|
|
+ tnsVertex2d(tnsInterpolate(x,x+w,seg[2]),tnsInterpolate(y,y+h,seg[3]));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return 1;
|
|
|
|
+}
|
|
|
|
+void tnsDrawStringLCD(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags){
|
|
|
|
+ real MA=FM->UsingFont->MonoAdvance;
|
|
|
|
+ real sx = L; int sy = T; real dx=MA; real hgap=LA_RH/15; real vgap=LA_RH/5;
|
|
|
|
+ int i,advance=1;
|
|
|
|
+ int len = contentU?strlenU(contentU):strlen(content);
|
|
|
|
+ int RevY=(Flags&LA_TEXT_REVERT_Y);
|
|
|
|
+ int OneLine=(Flags&LA_TEXT_ONE_LINE);
|
|
|
|
+ int Use16=(Flags&LA_TEXT_LCD_16);
|
|
|
|
+
|
|
|
|
+ tnsFlush();
|
|
|
|
+ tnsUseNoTexture();
|
|
|
|
+
|
|
|
|
+ int any=0, UC=1; int BreakNow=0;
|
|
|
|
+ for (i = 0; i < len && UC; i+=advance){
|
|
|
|
+ UC = contentU?contentU[i]:laToUnicode(&content[i], &advance);
|
|
|
|
+
|
|
|
|
+ if (UC == L'\n'){ if(!OneLine){sx = L; sy += LA_RH; continue;}else{ UC=' '; } }
|
|
|
|
+
|
|
|
|
+ if (sx + dx > R+1){
|
|
|
|
+ if(Flags&LA_TEXT_LINE_WRAP){ sx=L; sy+=LA_RH; }else{ break; }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(Use16){
|
|
|
|
+ if(tnsMakeLCD16(sx+hgap, sy+vgap, dx-hgap*2, LA_RH-vgap*2, UC)) any=1;
|
|
|
|
+ }else{
|
|
|
|
+ if(tnsMakeLCD7(sx+hgap, sy+vgap, dx-hgap*2, LA_RH-vgap*2, UC)) any=1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ sx += dx;
|
|
|
|
+
|
|
|
|
+ if(BreakNow){ break; }
|
|
|
|
+ }
|
|
|
|
+ if(any){ tnsColor4dv(Color); tnsPackAs(GL_LINES); glLineWidth(dx/10); tnsFlush(); glLineWidth(1); }
|
|
|
|
+}
|
|
void tnsDrawStringM(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags){
|
|
void tnsDrawStringM(char *content, uint32_t* contentU, real Color[4], int L, int R, int T, int Flags){
|
|
|
|
+ if(Flags&(LA_TEXT_LCD_16|LA_TEXT_LCD_7)){
|
|
|
|
+ tnsDrawStringLCD(content,contentU,Color,L,R,T,Flags); return;
|
|
|
|
+ }
|
|
real sx = L; int sy = (LA_RH!=LA_RH0)?(((((real)FM->UsingFont->height/LA_RH0-0.5)/MAIN.UiScale)+0.5)*LA_RH + T):(FM->UsingFont->height+T);
|
|
real sx = L; int sy = (LA_RH!=LA_RH0)?(((((real)FM->UsingFont->height/LA_RH0-0.5)/MAIN.UiScale)+0.5)*LA_RH + T):(FM->UsingFont->height+T);
|
|
real MA=FM->UsingFont->MonoAdvance;
|
|
real MA=FM->UsingFont->MonoAdvance;
|
|
int i,advance=1;
|
|
int i,advance=1;
|