/* * Public.cpp * * Created on: Jul 16, 2013 * Author: yiyu * QQ:1036184468 * Descriptoin: */ #include "Public.h" #include #include #include #include #include #include #include #include #include static QString FontName; Public::Public(){ } // "Zfull-GB";break;/ Public::~Public(){ FontName=""; } // 20160303 : #define FONTV "WenQuanYiCN" ; FONTV1 FONTV2 "WenQuanYiNX" //#define FONTV "DejaVuSansnx"//"DejaVu Sans" #define FONTV "WenQuanYiCN" //#define FONTV "WenQuanYiNX" #define FONTV1 "WenQuanYiNX" //#define FONTV1 "DejaVu Sans" //#define FONTV2 "DejaVu Sans" #define FONTV2 "WenQuanYiNX"//"WenQuanYi Micro Hei" //"Zfull-GB" #define FONTC "wenquanyi" //#define FONTC "WenQuanYi" int Public::getMinFontPixelSize(){ return 5; } QString Public::getFontFamily(int pixelSize){ switch(pixelSize){ #ifdef VNLG case 5: case 6: case 7: case 9: return "biyang";break; case 10: case 11: case 12: return (FontName=="Chinese" || FontName=="English")?FONTC:FONTV;break;//return "UnDotum";break;// //return "UnDotum";break;//Zfull-GB case 14:case 13:case 15: case 16: case 24: case 32: return (FontName=="Chinese" || FontName=="English")?FONTC:FONTV;break;//return "UnDotum";break;//return (FontName=="Chinese")?FONTC:"Zfull-GB";break; case 28: //case 32: case 36: return //(FontName=="Chinese")?FONTC: //FONTV1;// (FontName=="Chinese" || FontName=="English")?FONTV2:FONTV1;break; // "Zfull-GB";break;//return "UnDotum";break;//return (FontName=="Chinese")?FONTC:"Zfull-GB";break; // 16点阵以上直接使用方正字体 default: return (FontName=="Chinese" || FontName=="English")?FONTV2:FONTV1;break; //FONTC; // //"WenQuanYi Micro Hei"; //"WenQuanYiMH"; #else case 5://return "SerifL";break; case 6: case 7: case 9:return "biyang";break; default:return FONTC; #endif break;//return "WenQuanYi Zen Hei"; break; } return FONTV2; } QString Public::getFontFamily(int pixelSize, int vartype){ switch(pixelSize){ case 5: case 6: case 7: case 9: { if(vartype>19&& vartype<30) { return "SerifL"; } else if(vartype>39&& vartype<50) { return "SerifR"; } else if((vartype>29&& vartype<40) || vartype == 90 || vartype==91) { return "bangla"; } else if((vartype>49&& vartype<60) || vartype == 100 || vartype==101) { return "biyangF"; } else if((vartype>59&& vartype<70) || vartype == 110 || vartype==111) { return "Roman"; } else { return "biyang"; } // (vartype>19&& vartype<30)?"SerifL": // (vartype>39&& vartype<50)?"SerifR": // "biyang"; } break; default:return FONTC; break;//return "WenQuanYi Zen Hei"; break; } return FONTV2; } static int pixel_size[] = {5,7,9,12,16,21,24};//,28,32}; #define NUM 6 int Public::derivePixelSizeFromHeight(int value){ static int init_done; static int height[NUM*2]; //static int heightB[NUM]; // 12 -12 16--15 24 --19 28 -22 32 --25 /* HEIL 0 6 HEIL 1 8 HEIL 2 10 HEIL 3 13 HEIL 4 17 HEIL 5 32 HEIL 6 37 HEIL 7 42 */ if(!init_done){ for(int i = 0; i < NUM; i++){ QFont font; font.setFamily(Public::getFontFamily(pixel_size[i])); font.setPixelSize(pixel_size[i]); font.setBold(0); height[2*i] = getNumberHeight(font); font.setBold(1); height[2*i+1] = getNumberHeight(font); //qDebug()<<"HEIL"<2) { len=file1.readLine((char*)buf,256); if(len){ buf[len]='\0'; QString s1 = buf; int n=s1.indexOf("\r\n"); if(n) s1 = s1.mid(0,n); if(s1.endsWith("utf8.txt")) InputTxtFileName = s1; else InputTxtFileName = "WINPY_utf8.txt"; } } if(file1.isOpen()) file1.close(); } return InputTxtFileName; } QString Public::ReadLanguageName() { QFile file1("/home/plg/UseEn"); QString language="Chinese"; char buf[256]; if(file1.exists()) { file1.open(QFile::ReadWrite); int len=file1.readLine((char*)buf,256); buf[len]='\0'; //qDebug()<<"language:"<2) { language = buf; int n=language.indexOf("\r\n"); if(n>0) language = language.mid(0,n); } if(file1.isOpen())file1.close(); } //qDebug()<<"language2:"<drawContents (&painter, image.rect()); /*将text写到pic*/ text1.hide(); #if 0 QString s; s.sprintf("/home/ss%d-%d.jpg",font.pixelSize(),font.bold()?75:50); image.save(s); #endif int imgHeight = image.height(); int imgWidth = image.width(); int FirstValidRow = 0; bool lastFlag=0; int k,j; for(k = 0; k 0 ; k--){ for( j = 0; j < imgWidth; j ++){ QRgb rgb = image.pixel(j,k); //qDebug()<= 60) tmp = vartype-60; else if(tmp >= 50) tmp = vartype-50; else if(tmp >= 40) tmp = vartype-40; else if(tmp >= 30) tmp = vartype-30; else if(tmp >= 20) tmp = vartype-20; return tmp; } /* * #ifdef MMVAR11 // 同一行先排序: ,不同行分开排序,如何实现。 int i,j; for(i=0;istatus.variNum-1;i++){ bool ch_flag=0; for(j=i+1;jstatus.variNum;j++){ if(sysPara->status.vars[j].startColPos < sysPara->status.vars[j-1].startColPos ){ int n=sysPara->status.vars[j].startRowPos; sysPara->status.vars[j].startRowPos = sysPara->status.vars[j-1].startRowPos; sysPara->status.vars[j-1].startRowPos = n; n=sysPara->status.vars[j].startColPos; sysPara->status.vars[j].startColPos = sysPara->status.vars[j-1].startColPos; sysPara->status.vars[j-1].startColPos = n; ch_flag =1; } } if(ch_flag==0) break; } #endif */