diff --git a/EventLogging.cpp b/EventLogging.cpp index 3814a5c..d8e4eaf 100644 --- a/EventLogging.cpp +++ b/EventLogging.cpp @@ -52,4 +52,4 @@ void EventLogging::LogIt(WORD CategoryID, DWORD EventID, LPCTSTR ArrayOfStrings[ ReportEvent(m_hEventLinker,EVENTLOG_INFORMATION_TYPE,CategoryID, EventID,NULL,NumOfArrayStr,RawDataSize,ArrayOfStrings,RawData); -} \ No newline at end of file +} diff --git a/cache.cpp b/cache.cpp index 9401c6f..78ef75a 100644 --- a/cache.cpp +++ b/cache.cpp @@ -1,6 +1,6 @@ #include "override.h" -//CreateDIB计数,将在绘制下列次数后更新DIB区 +//CreateDIB璁℃暟锛屽皢鍦ㄧ粯鍒朵笅鍒楁鏁板悗鏇存柊DIB鍖 #define BITMAP_REDUCE_COUNTER 256//默认1024 @@ -157,7 +157,7 @@ L1: dec ebx jnz L1 } -#else*/ //对于64位系统,使用C语言 +#else*/ //瀵逛簬64浣嶇郴缁燂紝浣跨敤C璇█ for (int yy=Y1; yym_bInitDllMain = bInitDllMain; @@ -30,40 +30,40 @@ BOOL CMemLoadDll::MemLoadLibrary(void* lpFileData, int DataLength, bool bInitDll { return FALSE; //已经加载一个dll,还没有释放,不能加载新的dll } - //检查数据有效性,并初始化 + //妫鏌ユ暟鎹湁鏁堟э紝骞跺垵濮嬪寲 if(!CheckDataValide(lpFileData, DataLength))return FALSE; - //计算所需的加载空间 + //璁$畻鎵闇鐨勫姞杞界┖闂 int ImageSize = CalcTotalImageSize(); if(ImageSize == 0) return FALSE; - // 分配虚拟内存 + // 鍒嗛厤铏氭嫙鍐呭瓨 void *pMemoryAddress = VirtualAlloc((LPVOID)0, ImageSize, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE); if(pMemoryAddress == NULL) return FALSE; else { - CopyDllDatas(pMemoryAddress, lpFileData); //复制dll数据,并对齐每个段 + CopyDllDatas(pMemoryAddress, lpFileData); //澶嶅埗dll鏁版嵁锛屽苟瀵归綈姣忎釜娈 //重定位信息 /*if(pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress >0 && pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].Size>0) { DoRelocation(pMemoryAddress); } - //填充引入地址表 - if(!FillRavAddress(pMemoryAddress) && bFreeOnRavFail) //修正引入地址表失败 + //濉厖寮曞叆鍦板潃琛 + if(!FillRavAddress(pMemoryAddress) && bFreeOnRavFail) //淇寮曞叆鍦板潃琛ㄥけ璐 { VirtualFree(pMemoryAddress,0,MEM_RELEASE); return FALSE; }*/ - //修改页属性。应该根据每个页的属性单独设置其对应内存页的属性。这里简化一下。 + //淇敼椤靛睘鎬с傚簲璇ユ牴鎹瘡涓〉鐨勫睘鎬у崟鐙缃叾瀵瑰簲鍐呭瓨椤电殑灞炴с傝繖閲岀畝鍖栦竴涓嬨 //统一设置成一个属性PAGE_EXECUTE_READWRITE unsigned long old; VirtualProtect(pMemoryAddress, ImageSize, PAGE_EXECUTE_READWRITE,&old); } - //修正基地址 + //淇鍩哄湴鍧 pNTHeader->OptionalHeader.ImageBase = (DWORD)pMemoryAddress; - //接下来要调用一下dll的入口函数,做初始化工作。 + //鎺ヤ笅鏉ヨ璋冪敤涓涓媎ll鐨勫叆鍙e嚱鏁帮紝鍋氬垵濮嬪寲宸ヤ綔銆 pDllMain = (ProcDllMain)(pNTHeader->OptionalHeader.AddressOfEntryPoint +(DWORD_PTR) pMemoryAddress); BOOL InitResult = !bInitDllMain || pDllMain((HINSTANCE)pMemoryAddress,DLL_PROCESS_ATTACH,0); if(!InitResult) //初始化失败 @@ -79,9 +79,9 @@ BOOL CMemLoadDll::MemLoadLibrary(void* lpFileData, int DataLength, bool bInitDll return TRUE; } -//MemGetProcAddress函数从dll中获取指定函数的地址 -//返回值: 成功返回函数地址 , 失败返回NULL -//lpProcName: 要查找函数的名字或者序号 +//MemGetProcAddress鍑芥暟浠巇ll涓幏鍙栨寚瀹氬嚱鏁扮殑鍦板潃 +//杩斿洖鍊硷細 鎴愬姛杩斿洖鍑芥暟鍦板潃 , 澶辫触杩斿洖NULL +//lpProcName: 瑕佹煡鎵惧嚱鏁扮殑鍚嶅瓧鎴栬呭簭鍙 FARPROC CMemLoadDll::MemGetProcAddress(LPCSTR lpProcName) { if(pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress == 0 || @@ -140,55 +140,55 @@ FARPROC CMemLoadDll::MemGetProcAddress(LPCSTR lpProcName) void CMemLoadDll::DoRelocation( void *NewBase) { /* 重定位表的结构: - // DWORD sectionAddress, DWORD size (包括本节需要重定位的数据) - // 例如 1000节需要修正5个重定位数据的话,重定位表的数据是 + // DWORD sectionAddress, DWORD size (鍖呮嫭鏈妭闇瑕侀噸瀹氫綅鐨勬暟鎹) + // 渚嬪 1000鑺傞渶瑕佷慨姝5涓噸瀹氫綅鏁版嵁鐨勮瘽锛岄噸瀹氫綅琛ㄧ殑鏁版嵁鏄 // 00 10 00 00 14 00 00 00 xxxx xxxx xxxx xxxx xxxx 0000 // ----------- ----------- ---- - // 给出节的偏移 总尺寸=8+6*2 需要修正的地址 用于对齐4字节 - // 重定位表是若干个相连,如果address 和 size都是0 表示结束 - // 需要修正的地址是12位的,高4位是形态字,intel cpu下是3 + // 缁欏嚭鑺傜殑鍋忕Щ 鎬诲昂瀵=8+6*2 闇瑕佷慨姝g殑鍦板潃 鐢ㄤ簬瀵归綈4瀛楄妭 + // 閲嶅畾浣嶈〃鏄嫢骞蹭釜鐩歌繛锛屽鏋渁ddress 鍜 size閮芥槸0 琛ㄧず缁撴潫 + // 闇瑕佷慨姝g殑鍦板潃鏄12浣嶇殑锛岄珮4浣嶆槸褰㈡佸瓧锛宨ntel cpu涓嬫槸3 */ - //假设NewBase是0x600000,而文件中设置的缺省ImageBase是0x400000,则修正偏移量就是0x200000 + //鍋囪NewBase鏄0x600000,鑰屾枃浠朵腑璁剧疆鐨勭己鐪両mageBase鏄0x400000,鍒欎慨姝e亸绉婚噺灏辨槸0x200000 DWORD Delta = (DWORD)NewBase - pNTHeader->OptionalHeader.ImageBase; - //注意重定位表的位置可能和硬盘文件中的偏移地址不同,应该使用加载后的地址 + //娉ㄦ剰閲嶅畾浣嶈〃鐨勪綅缃彲鑳藉拰纭洏鏂囦欢涓殑鍋忕Щ鍦板潃涓嶅悓锛屽簲璇ヤ娇鐢ㄥ姞杞藉悗鐨勫湴鍧 PIMAGE_BASE_RELOCATION pLoc = (PIMAGE_BASE_RELOCATION)((DWORD_PTR)NewBase + pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress); - while((pLoc->VirtualAddress + pLoc->SizeOfBlock) != 0) //开始扫描重定位表 + while((pLoc->VirtualAddress + pLoc->SizeOfBlock) != 0) //寮濮嬫壂鎻忛噸瀹氫綅琛 { WORD *pLocData = (WORD *)((DWORD_PTR)pLoc + sizeof(IMAGE_BASE_RELOCATION)); - //计算本节需要修正的重定位项(地址)的数目 + //璁$畻鏈妭闇瑕佷慨姝g殑閲嶅畾浣嶉」锛堝湴鍧锛夌殑鏁扮洰 int NumberOfReloc = (pLoc->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION))/sizeof(WORD); for( int i=0 ; i < NumberOfReloc; i++) { - if( (DWORD)(pLocData[i] & 0xF000) == 0x00003000) //这是一个需要修正的地址 + if( (DWORD)(pLocData[i] & 0xF000) == 0x00003000) //杩欐槸涓涓渶瑕佷慨姝g殑鍦板潃 { - // 举例: + // 涓句緥锛 // pLoc->VirtualAddress = 0x1000; - // pLocData[i] = 0x313E; 表示本节偏移地址0x13E处需要修正 + // pLocData[i] = 0x313E; 琛ㄧず鏈妭鍋忕Щ鍦板潃0x13E澶勯渶瑕佷慨姝 // 因此 pAddress = 基地址 + 0x113E - // 里面的内容是 A1 ( 0c d4 02 10) 汇编代码是: mov eax , [1002d40c] - // 需要修正1002d40c这个地址 + // 閲岄潰鐨勫唴瀹规槸 A1 ( 0c d4 02 10) 姹囩紪浠g爜鏄細 mov eax , [1002d40c] + // 闇瑕佷慨姝1002d40c杩欎釜鍦板潃 DWORD * pAddress = (DWORD *)((DWORD_PTR)NewBase + pLoc->VirtualAddress + (pLocData[i] & 0x0FFF)); *pAddress += Delta; } } - //转移到下一个节进行处理 + //杞Щ鍒颁笅涓涓妭杩涜澶勭悊 pLoc = (PIMAGE_BASE_RELOCATION)((DWORD)pLoc + pLoc->SizeOfBlock); } } -//填充引入地址表 +//濉厖寮曞叆鍦板潃琛 BOOL CMemLoadDll::FillRavAddress(void *pImageBase) { - // 引入表实际上是一个 IMAGE_IMPORT_DESCRIPTOR 结构数组,全部是0表示结束 - // 数组定义如下: + // 寮曞叆琛ㄥ疄闄呬笂鏄竴涓 IMAGE_IMPORT_DESCRIPTOR 缁撴瀯鏁扮粍锛屽叏閮ㄦ槸0琛ㄧず缁撴潫 + // 鏁扮粍瀹氫箟濡備笅锛 // - // DWORD OriginalFirstThunk; // 0表示结束,否则指向未绑定的IAT结构数组 + // DWORD OriginalFirstThunk; // 0琛ㄧず缁撴潫锛屽惁鍒欐寚鍚戞湭缁戝畾鐨処AT缁撴瀯鏁扮粍 // DWORD TimeDateStamp; // DWORD ForwarderChain; // -1 if no forwarders // DWORD Name; // 给出dll的名字 - // DWORD FirstThunk; // 指向IAT结构数组的地址(绑定后,这些IAT里面就是实际的函数地址) + // DWORD FirstThunk; // 鎸囧悜IAT缁撴瀯鏁扮粍鐨勫湴鍧(缁戝畾鍚庯紝杩欎簺IAT閲岄潰灏辨槸瀹為檯鐨勫嚱鏁板湴鍧) unsigned long Offset = pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress ; if(Offset == 0) return TRUE; //No Import Table PIMAGE_IMPORT_DESCRIPTOR pID = (PIMAGE_IMPORT_DESCRIPTOR)((DWORD_PTR) pImageBase + Offset); @@ -209,25 +209,25 @@ BOOL CMemLoadDll::FillRavAddress(void *pImageBase) else buf[i] = 0; HMODULE hDll = GetModuleHandle(buf); if(hDll == NULL)return FALSE; //NOT FOUND DLL - //获取DLL中每个导出函数的地址,填入IAT + //鑾峰彇DLL涓瘡涓鍑哄嚱鏁扮殑鍦板潃锛屽~鍏AT //每个IAT结构是 : // union { PBYTE ForwarderString; // PDWORD Function; // DWORD Ordinal; // PIMAGE_IMPORT_BY_NAME AddressOfData; // } u1; - // 长度是一个DWORD ,正好容纳一个地址。 + // 闀垮害鏄竴涓狣WORD 锛屾濂藉绾充竴涓湴鍧銆 for(i=0; ;i++) { if(pOriginalIAT[i].u1.Function == 0)break; FARPROC lpFunction = NULL; - if(pOriginalIAT[i].u1.Ordinal & IMAGE_ORDINAL_FLAG) //这里的值给出的是导出序号 + if(pOriginalIAT[i].u1.Ordinal & IMAGE_ORDINAL_FLAG) //杩欓噷鐨勫肩粰鍑虹殑鏄鍑哄簭鍙 { lpFunction = GetProcAddress(hDll, (LPCSTR)(pOriginalIAT[i].u1.Ordinal & 0x0000FFFF)); } - else //按照名字导入 + else //鎸夌収鍚嶅瓧瀵煎叆 { - //获取此IAT项所描述的函数名称 + //鑾峰彇姝AT椤规墍鎻忚堪鐨勫嚱鏁板悕绉 PIMAGE_IMPORT_BY_NAME pByName = (PIMAGE_IMPORT_BY_NAME) ((DWORD_PTR)pImageBase + (DWORD)(pOriginalIAT[i].u1.AddressOfData)); // if(pByName->Hint !=0) @@ -248,34 +248,34 @@ BOOL CMemLoadDll::FillRavAddress(void *pImageBase) return TRUE; } -//CheckDataValide函数用于检查缓冲区中的数据是否有效的dll文件 +//CheckDataValide鍑芥暟鐢ㄤ簬妫鏌ョ紦鍐插尯涓殑鏁版嵁鏄惁鏈夋晥鐨刣ll鏂囦欢 //返回值: 是一个可执行的dll则返回TRUE,否则返回FALSE。 -//lpFileData: 存放dll数据的内存缓冲区 -//DataLength: dll文件的长度 +//lpFileData: 瀛樻斁dll鏁版嵁鐨勫唴瀛樼紦鍐插尯 +//DataLength: dll鏂囦欢鐨勯暱搴 BOOL CMemLoadDll::CheckDataValide(void* lpFileData, int DataLength) { - //检查长度 + //妫鏌ラ暱搴 if(DataLength < sizeof(IMAGE_DOS_HEADER)) return FALSE; pDosHeader = (PIMAGE_DOS_HEADER)lpFileData; // DOS头 - //检查dos头的标记 + //妫鏌os澶寸殑鏍囪 if(pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) return FALSE; //0x5A4D : MZ - //检查长度 + //妫鏌ラ暱搴 if((DWORD)DataLength < (pDosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS32)) ) return FALSE; //取得pe头 pNTHeader = (PIMAGE_NT_HEADERS32)( (DWORD_PTR)lpFileData + (DWORD_PTR)pDosHeader->e_lfanew); // PE头 - //检查pe头的合法性 + //妫鏌e澶寸殑鍚堟硶鎬 if(pNTHeader->Signature != IMAGE_NT_SIGNATURE) return FALSE; //0x00004550 : PE00 if((pNTHeader->FileHeader.Characteristics & IMAGE_FILE_DLL) == 0) //0x2000 : File is a DLL return FALSE; - if((pNTHeader->FileHeader.Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE) == 0) //0x0002 : 指出文件可以运行 + if((pNTHeader->FileHeader.Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE) == 0) //0x0002 : 鎸囧嚭鏂囦欢鍙互杩愯 return FALSE; if(pNTHeader->FileHeader.SizeOfOptionalHeader != sizeof(IMAGE_OPTIONAL_HEADER32)) return FALSE; //取得节表(段表) pSectionHeader = (PIMAGE_SECTION_HEADER)((DWORD_PTR)pNTHeader + sizeof(IMAGE_NT_HEADERS32)); - //验证每个节表的空间 + //楠岃瘉姣忎釜鑺傝〃鐨勭┖闂 for(int i=0; i< pNTHeader->FileHeader.NumberOfSections; i++) { if((pSectionHeader[i].PointerToRawData + pSectionHeader[i].SizeOfRawData) > (DWORD)DataLength)return FALSE; @@ -283,19 +283,19 @@ BOOL CMemLoadDll::CheckDataValide(void* lpFileData, int DataLength) return TRUE; } -//计算对齐边界 +//璁$畻瀵归綈杈圭晫 int CMemLoadDll::GetAlignedSize(int Origin, int Alignment) { return (Origin + Alignment - 1) / Alignment * Alignment; } -//计算整个dll映像文件的尺寸 +//璁$畻鏁翠釜dll鏄犲儚鏂囦欢鐨勫昂瀵 int CMemLoadDll::CalcTotalImageSize() { int Size; if(pNTHeader == NULL)return 0; - int nAlign = pNTHeader->OptionalHeader.SectionAlignment; //段对齐字节数 + int nAlign = pNTHeader->OptionalHeader.SectionAlignment; //娈靛榻愬瓧鑺傛暟 - // 计算所有头的尺寸。包括dos, coff, pe头 和 段表的大小 + // 璁$畻鎵鏈夊ご鐨勫昂瀵搞傚寘鎷琩os, coff, pe澶 鍜 娈佃〃鐨勫ぇ灏 Size = GetAlignedSize(pNTHeader->OptionalHeader.SizeOfHeaders, nAlign); // 计算所有节的大小 for(int i=0; i < pNTHeader->FileHeader.NumberOfSections; ++i) @@ -311,12 +311,12 @@ int CMemLoadDll::CalcTotalImageSize() } return Size; } -//CopyDllDatas函数将dll数据复制到指定内存区域,并对齐所有节 -//pSrc: 存放dll数据的原始缓冲区 -//pDest:目标内存地址 +//CopyDllDatas鍑芥暟灏哾ll鏁版嵁澶嶅埗鍒版寚瀹氬唴瀛樺尯鍩燂紝骞跺榻愭墍鏈夎妭 +//pSrc: 瀛樻斁dll鏁版嵁鐨勫師濮嬬紦鍐插尯 +//pDest:鐩爣鍐呭瓨鍦板潃 void CMemLoadDll::CopyDllDatas(void* pDest, void* pSrc) { - // 计算需要复制的PE头+段表字节数 + // 璁$畻闇瑕佸鍒剁殑PE澶+娈佃〃瀛楄妭鏁 int HeaderSize = pNTHeader->OptionalHeader.SizeOfHeaders; int SectionSize = pNTHeader->FileHeader.NumberOfSections * sizeof(IMAGE_SECTION_HEADER); int MoveSize = HeaderSize + SectionSize; @@ -329,13 +329,13 @@ void CMemLoadDll::CopyDllDatas(void* pDest, void* pSrc) if(pSectionHeader[i].VirtualAddress == 0 || pSectionHeader[i].SizeOfRawData == 0)continue; // 定位该节在内存中的位置 void *pSectionAddress = (void *)((DWORD_PTR)pDest + pSectionHeader[i].VirtualAddress); - // 复制段数据到虚拟内存 + // 澶嶅埗娈垫暟鎹埌铏氭嫙鍐呭瓨 memmove((void *)pSectionAddress, (void *)((DWORD_PTR)pSrc + pSectionHeader[i].PointerToRawData), pSectionHeader[i].SizeOfRawData); } - //修正指针,指向新分配的内存 + //淇鎸囬拡锛屾寚鍚戞柊鍒嗛厤鐨勫唴瀛 //新的dos头 pDosHeader = (PIMAGE_DOS_HEADER)pDest; //新的pe头地址 @@ -343,4 +343,4 @@ void CMemLoadDll::CopyDllDatas(void* pDest, void* pSrc) //新的节表地址 pSectionHeader = (PIMAGE_SECTION_HEADER)((DWORD_PTR)pNTHeader + sizeof(IMAGE_NT_HEADERS32)); return ; -} \ No newline at end of file +} diff --git a/dll.h b/dll.h index 05190d9..860c88e 100644 --- a/dll.h +++ b/dll.h @@ -28,4 +28,4 @@ private: PIMAGE_DOS_HEADER pDosHeader; PIMAGE_NT_HEADERS32 pNTHeader; PIMAGE_SECTION_HEADER pSectionHeader; -}; \ No newline at end of file +}; diff --git a/dynCodeHelper.cpp b/dynCodeHelper.cpp index 1fbc65e..7e24640 100644 --- a/dynCodeHelper.cpp +++ b/dynCodeHelper.cpp @@ -108,4 +108,4 @@ AutoEnableDynamicCodeGen::~AutoEnableDynamicCodeGen() enabled = false; } -} \ No newline at end of file +} diff --git a/dynCodeHelper.h b/dynCodeHelper.h index 544d1c8..3e4ae27 100644 --- a/dynCodeHelper.h +++ b/dynCodeHelper.h @@ -31,4 +31,4 @@ private: static PGET_THREAD_INFORMATION_PROC GetThreadInformationProc; static PROCESS_MITIGATION_DYNAMIC_CODE_POLICY processPolicy; static volatile bool processPolicyObtained; -}; \ No newline at end of file +}; diff --git a/easyhook.h b/easyhook.h index 0661632..f4b79e7 100644 --- a/easyhook.h +++ b/easyhook.h @@ -441,4 +441,4 @@ DRIVER_SHARED_API(NTSTATUS, LhBarrierCallStackTrace( }; #endif -#endif \ No newline at end of file +#endif diff --git a/expfunc.cpp b/expfunc.cpp index 091e47a..82f3f79 100644 --- a/expfunc.cpp +++ b/expfunc.cpp @@ -142,7 +142,7 @@ EXTERN_C void SafeUnload() { static BOOL bInited = false; if (bInited) - return; //防重入 + return; //闃查噸鍏 bInited = true; while (CThreadCounter::Count()) Sleep(0); @@ -252,7 +252,7 @@ FARPROC K32GetProcAddress(LPCSTR lpProcName) //kernel32偺儀乕僗傾僪儗僗庢摼 WCHAR sysdir[MAX_PATH]; GetWindowsDirectory(sysdir, MAX_PATH); - if (GetModuleHandle(_T("kernelbase.dll"))) //查看自己是否加载了Kernelbase.dll文件,存在则说明是win7系统 + if (GetModuleHandle(_T("kernelbase.dll"))) //鏌ョ湅鑷繁鏄惁鍔犺浇浜咾ernelbase.dll鏂囦欢锛屽瓨鍦ㄥ垯璇存槑鏄痺in7绯荤粺 wcscat(sysdir, L"\\SysWow64\\kernelbase.dll"); else wcscat(sysdir, L"\\SysWow64\\kernel32.dll"); //不存在就是vista @@ -260,8 +260,8 @@ FARPROC K32GetProcAddress(LPCSTR lpProcName) if (hFile == INVALID_HANDLE_VALUE) return NULL; DWORD dwSize = GetFileSize(hFile, NULL); - BYTE* pMem = new BYTE[dwSize]; //分配内存 - ReadFile(hFile, pMem, dwSize, &dwSize, NULL);//读取文件 + BYTE* pMem = new BYTE[dwSize]; //鍒嗛厤鍐呭瓨 + ReadFile(hFile, pMem, dwSize, &dwSize, NULL);//璇诲彇鏂囦欢 CloseHandle(hFile); CMemLoadDll MemDll; @@ -680,7 +680,7 @@ VOID SafeGetNativeSystemInfo(__out LPSYSTEM_INFO lpSystemInfo) } } -// 获取操作系统位数 +// 鑾峰彇鎿嶄綔绯荤粺浣嶆暟 int GetSystemBits() { SYSTEM_INFO si; diff --git a/ft - non-ref.cpp b/ft - non-ref.cpp index 2b107d5..18445a3 100644 --- a/ft - non-ref.cpp +++ b/ft - non-ref.cpp @@ -61,7 +61,7 @@ ControlIder CID; #endif -//更新 +//鏇存柊 #define RGBA(r,g,b,a) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)|(((DWORD)(BYTE)(a))<<24))) //!!Snowie @@ -147,7 +147,7 @@ static CAlphaBlend s_AlphaBlendTable; void CAlphaBlend::gettunetbl(int paramalpha, BOOL lcd, BOOL dark, const int * &tblR, const int * &tblG, const int * &tblB) const { - if (paramalpha == 1) { //获取文字混合表 + if (paramalpha == 1) { //鑾峰彇鏂囧瓧娣峰悎琛 if (lcd) { tblR = tunetblR; tblG = tunetblG; @@ -155,7 +155,7 @@ void CAlphaBlend::gettunetbl(int paramalpha, BOOL lcd, BOOL dark, const int * &t } else { tblR = tblG = tblB = tunetbl; } - } else { //获取阴影混合表 + } else { //鑾峰彇闃村奖娣峰悎琛 if (dark) { if (lcd) { @@ -250,12 +250,12 @@ void CAlphaBlend::init() tunetblS[i] = Bound(0, alphatbl[Bound(table[i] * paramalpha /100, 0, 255)], CAlphaBlend::BASE); tunetblRS[i] = Bound(0, alphatbl[Bound(tableR[i] * paramalpha/100, 0, 255)], CAlphaBlend::BASE); tunetblGS[i] = Bound(0, alphatbl[Bound(tableG[i] * paramalpha/100, 0, 255)], CAlphaBlend::BASE); - tunetblBS[i] =Bound(0, alphatbl[Bound(tableB[i] * paramalpha/100, 0, 255)], CAlphaBlend::BASE); //浅色混合表 + tunetblBS[i] =Bound(0, alphatbl[Bound(tableB[i] * paramalpha/100, 0, 255)], CAlphaBlend::BASE); //娴呰壊娣峰悎琛 tunetblLS[i] = Bound(0, alphatbl[Bound(table[i] * lightparamalpha/100, 0, 255)], CAlphaBlend::BASE); tunetblLRS[i] = Bound(0, alphatbl[Bound(tableR[i] * lightparamalpha/100, 0, 255)], CAlphaBlend::BASE); tunetblLGS[i] = Bound(0, alphatbl[Bound(tableG[i] * lightparamalpha/100, 0, 255)], CAlphaBlend::BASE); - tunetblLBS[i] =Bound(0, alphatbl[Bound(tableB[i] * lightparamalpha/100, 0, 255)], CAlphaBlend::BASE); //深色混合表 + tunetblLBS[i] =Bound(0, alphatbl[Bound(tableB[i] * lightparamalpha/100, 0, 255)], CAlphaBlend::BASE); //娣辫壊娣峰悎琛 } } @@ -1177,7 +1177,7 @@ BOOL FreeTypePrepare(FreeTypeDrawInfo& FTInfo) return FALSE; } - FTInfo.params->lplf->lfWeight = FTInfo.params->otm->otmTextMetrics.tmWeight; //更新到标准weight + FTInfo.params->lplf->lfWeight = FTInfo.params->otm->otmTextMetrics.tmWeight; //鏇存柊鍒版爣鍑唚eight pfs = &pfi->GetFontSettings(); cmap_index = -1; @@ -1313,7 +1313,7 @@ BOOL FreeTypePrepare(FreeTypeDrawInfo& FTInfo) break; } - //如果含有内置hinting则启用default模式,否则使用autohint模式,以保证效果 + //濡傛灉鍚湁鍐呯疆hinting鍒欏惎鐢╠efault妯″紡锛屽惁鍒欎娇鐢╝utohint妯″紡锛屼互淇濊瘉鏁堟灉 // 傾儞僠僄僀儕傾僗 if (FTInfo.IsMono()) { font_type.flags |= FT_LOAD_TARGET_MONO; @@ -1348,7 +1348,7 @@ BOOL FreeTypePrepare(FreeTypeDrawInfo& FTInfo) if (pSettings->HintSmallFont() && font_type.flags & FT_LOAD_TARGET_LIGHT && font_type.height!=-1 && font_type.height<12) //通用设置不使用hinting,但是打开了小字体hinting开关 { /* - if (!(freetype_face->face_flags & FT_FACE_FLAG_TRICKY)) //如果不是tricky字体 + if (!(freetype_face->face_flags & FT_FACE_FLAG_TRICKY)) //濡傛灉涓嶆槸tricky瀛椾綋 font_type.flags = font_type.flags & (~FT_LOAD_NO_HINTING) | (pfi->FontHasHinting() ? FT_LOAD_NO_AUTOHINT : FT_LOAD_FORCE_AUTOHINT); else*/ @@ -1472,7 +1472,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, BOOL bWindowsLink = pSettings->FontLink()==2; //!!Snowie - /*const*/ FT_Face freetype_face = FTInfo.freetype_face; //去掉常量属性,下面要改他 + /*const*/ FT_Face freetype_face = FTInfo.freetype_face; //鍘绘帀甯搁噺灞炴э紝涓嬮潰瑕佹敼浠 const FT_Int cmap_index = FTInfo.cmap_index; const FT_Bool useKerning = FTInfo.useKerning; FT_Render_Mode render_mode = FTInfo.render_mode; @@ -1520,13 +1520,13 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, ZeroMemory(lpfontlink[i], sizeof(WORD)*cbString); //初始化为无链接 } // - hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //加载第一个字体 + hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //鍔犺浇绗竴涓瓧浣 } //fontlink int* Dx= FTInfo.Dx; if (!bAllowDefaultLink && FTInfo.face_id_list_num > 1) - FTInfo.face_id_list_num--; //如果是symbol页那就不链接到宋体 + FTInfo.face_id_list_num--; //濡傛灉鏄痵ymbol椤甸偅灏变笉閾炬帴鍒板畫浣 bool bUnicodePlane = false; for (int i=0 ; lpString < lpEnd; ++lpString, ++gi, ++GlyphArray, ++drState, ++AAList, /*ggdi32++,*/ i++){ @@ -1576,7 +1576,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, f_glyph = !!wch; glyph_index = wch; *AAList = AAMode; - GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index的文字必须计算宽度 + GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index鐨勬枃瀛楀繀椤昏绠楀搴 if (FTInfo.font_type.height<=pSettings->BitmapHeight() && pfi->EmbeddedBmpExist(FTInfo.font_type.height)) { f_glyph=false; //使用点阵,不绘图 @@ -1586,11 +1586,11 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, if (wch && !CID.myiswcntrl(lpString[0])) { for (int j = 0; j < FTInfo.face_id_list_num; ++j) { - if (bWindowsLink) //使用Windows函数进行fontlink + if (bWindowsLink) //浣跨敤Windows鍑芥暟杩涜fontlink { if (!lpfontlink[j][i]) //还没初始化该字体的fontlink { - SelectFont(FTInfo.hdc, FTInfo.ggo_font_list[j]); //加载ggo字体 + SelectFont(FTInfo.hdc, FTInfo.ggo_font_list[j]); //鍔犺浇ggo瀛椾綋 GetGlyphIndices(FTInfo.hdc, lpString, cbString-i, &lpfontlink[j][i], GGI_MARK_NONEXISTING_GLYPHS); //进行fontlink SelectFont(FTInfo.hdc, hOldFont); } @@ -1607,8 +1607,8 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, GetCharWidth32W(FTInfo.hdc, wch, wch, &gdi32x); //有效文字,计算宽度 f_glyph = true; FTInfo.font_type.face_id = FTInfo.face_id_list[j]; - freetype_face = FTInfo.GetFace(j); //同时更新对应faceid的实际face - //接下来更新对应的fontsetting + freetype_face = FTInfo.GetFace(j); //鍚屾椂鏇存柊瀵瑰簲faceid鐨勫疄闄協ace + //鎺ヤ笅鏉ユ洿鏂板搴旂殑fontsetting FTInfo.font_type.flags = FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; // 僸儞僥傿儞僌 //extern CFontSetCache g_fsetcache; @@ -1617,7 +1617,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, { switch (FTInfo.font_type.height) { - case 11:{FTInfo.font_type.height=12; FTInfo.font_type.width++; break;} //对宋体进行特殊处理 + case 11:{FTInfo.font_type.height=12; FTInfo.font_type.width++; break;} //瀵瑰畫浣撹繘琛岀壒娈婂鐞 case 13:{FTInfo.font_type.height=15; FTInfo.font_type.width+=2; break;} } } @@ -1672,7 +1672,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, AAMode = *AAList/*pfs->GetAntiAliasMode()*/; bLcdMode = render_mode == FT_RENDER_MODE_LCD; bLightLcdMode = (AAMode == 4) || (AAMode == 5); - //更新完成 + //鏇存柊瀹屾垚 } if (FTInfo.font_type.height<=pSettings->BitmapHeight() && pfi->EmbeddedBmpExist(FTInfo.font_type.height)) { @@ -1686,7 +1686,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, - if (!f_glyph) { //glyphindex的文字上面已经计算过了 + if (!f_glyph) { //glyphindex鐨勬枃瀛椾笂闈㈠凡缁忚绠楄繃浜 #ifdef _DEBUG GdiSetBatchLimit(0); #endif @@ -1716,7 +1716,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, int dxWidth = clpdx.get(cx); if (isc == CNTRL_COMPLEX_TEXT) //控制字 { - cx = dxWidth; //服从windows的宽度调度 + cx = dxWidth; //鏈嶄粠windows鐨勫搴﹁皟搴 //if (!dxWidth) // CID.setcntrlAttribute(wch, CNTRL_ZERO_WIDTH); } @@ -1731,7 +1731,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, GetCharABCWidthsI(FTInfo.hdc, wch, 1, NULL, &abc); else GetCharABCWidths(FTInfo.hdc, wch, wch, &abc);*/ - //FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //无效文字的情况下,绘图宽度=鼠标位置 + //FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //鏃犳晥鏂囧瓧鐨勬儏鍐典笅锛岀粯鍥惧搴=榧犳爣浣嶇疆 FTInfo.px = FTInfo.x + cx; FTInfo.x += dxWidth;//Max(clpdx.get(cx), cx);/*(int)abc.abcB+abc.abcC*///Max(clpdx.get(cx), abc.abcB? abc.abcA:0); //} @@ -1774,7 +1774,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, } }else{ if (bVertical) - swap(FTInfo.font_type.height, FTInfo.font_type.width); //交换无法旋转的文字宽高 + swap(FTInfo.font_type.height, FTInfo.font_type.width); //浜ゆ崲鏃犳硶鏃嬭浆鐨勬枃瀛楀楂 FTInfo.font_type.flags &=~FT_LOAD_VERTICAL_LAYOUT; if(bLcdMode){ if(!bLightLcdMode){ @@ -1789,8 +1789,8 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, bool bRequiredownsize; - bIsIndivBold = freetype_face->style_flags & FT_STYLE_FLAG_BOLD; //是独立粗体 - bIsBold = (IsFontBold(lf) && !bIsIndivBold); //是仿粗体 + bIsIndivBold = freetype_face->style_flags & FT_STYLE_FLAG_BOLD; //鏄嫭绔嬬矖浣 + bIsBold = (IsFontBold(lf) && !bIsIndivBold); //鏄豢绮椾綋 bRequiredownsize = bIsBold && /*(pSettings->BolderMode()==2 || (*/pSettings->BolderMode()!=1 /*&& FTInfo.height>FT_BOLD_LOW))*/; if (bRequiredownsize) { @@ -1877,7 +1877,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, int dx = clpdx.get(bWidthGDI32 ? gdi32x : cx); //获得宽度 int left = FT_BitmapGlyph((*glyph_bitmap))->left; if (FTInfo.x + left< FTInfo.xBase) - FTInfo.xBase = FTInfo.x + left; //如果有字符是负数起始位置的(合成符号), 调整文字的起始位置 + FTInfo.xBase = FTInfo.x + left; //濡傛灉鏈夊瓧绗︽槸璐熸暟璧峰浣嶇疆鐨勶紙鍚堟垚绗﹀彿锛夛紝 璋冩暣鏂囧瓧鐨勮捣濮嬩綅缃 if (lpString < lpEnd - 1) { FTInfo.x += dx; @@ -1885,7 +1885,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, int bx = FT_BitmapGlyph((*glyph_bitmap))->bitmap.width; if (render_mode == FT_RENDER_MODE_LCD) bx /= 3; bx += left; - FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //有文字的情况下,绘图宽度=ft计算的宽度,鼠标位置=win宽度 + FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //鏈夋枃瀛楃殑鎯呭喌涓,缁樺浘瀹藉害=ft璁$畻鐨勫搴︼紝榧犳爣浣嶇疆=win瀹藉害 FTInfo.x += dx;//Max(dx, gdi32x);//Max(Max(dx, bx), cx); } @@ -1931,7 +1931,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString BOOL bWindowsLink = pSettings->FontLink()==2; //!!Snowie - /*const*/ FT_Face freetype_face = FTInfo.freetype_face; //去掉常量属性,下面要改他 + /*const*/ FT_Face freetype_face = FTInfo.freetype_face; //鍘绘帀甯搁噺灞炴э紝涓嬮潰瑕佹敼浠 const FT_Int cmap_index = FTInfo.cmap_index; const FT_Bool useKerning = FTInfo.useKerning; FT_Render_Mode render_mode = FTInfo.render_mode; @@ -1988,7 +1988,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString ZeroMemory(lpfontlink[i], sizeof(WORD)*cbString); //初始化为无链接 } // - hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //加载第一个字体 + hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //鍔犺浇绗竴涓瓧浣 } //fontlink @@ -2020,7 +2020,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString } }*/ - if (!bGlyphIndex) //仅对win32情况进行优化,ft情况另议 + if (!bGlyphIndex) //浠呭win32鎯呭喌杩涜浼樺寲锛宖t鎯呭喌鍙﹁ if (GetGlyphIndices(FTInfo.hdc, lpString, cbString, gi, GGI_MARK_NONEXISTING_GLYPHS)!=cbString) { nRet = false; @@ -2029,7 +2029,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString //!!Snowie int* Dx= FTInfo.Dx; if (!bAllowDefaultLink && FTInfo.face_id_list_num > 1) - FTInfo.face_id_list_num--; //如果是symbol页那就不链接到宋体 + FTInfo.face_id_list_num--; //濡傛灉鏄痵ymbol椤甸偅灏变笉閾炬帴鍒板畫浣 for (int i=0 ; lpString < lpEnd; ++lpString, gi++, GlyphArray++, drState++, ++AAList,/*ggdi32++,*/ i++){ WCHAR wch = *lpString; @@ -2078,7 +2078,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString *AAList = AAMode; glyph_index = wch; ggoformat |= GGO_GLYPH_INDEX; - GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index的文字必须计算宽度 + GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index鐨勬枃瀛楀繀椤昏绠楀搴 } else { if (*(gi) != 0xffff) { @@ -2104,7 +2104,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString } - if (!f_glyph) { //glyphindex的文字上面已经计算过了 + if (!f_glyph) { //glyphindex鐨勬枃瀛椾笂闈㈠凡缁忚绠楄繃浜 #ifdef _DEBUG GdiSetBatchLimit(0); #endif @@ -2139,7 +2139,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString GetCharABCWidthsI(FTInfo.hdc, wch, 1, NULL, &abc); else GetCharABCWidths(FTInfo.hdc, wch, wch, &abc);*/ - //FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //无效文字的情况下,绘图宽度=鼠标位置 + //FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //鏃犳晥鏂囧瓧鐨勬儏鍐典笅锛岀粯鍥惧搴=榧犳爣浣嶇疆 FTInfo.px = FTInfo.x + cx; FTInfo.x += clpdx.get(cx); } @@ -2171,7 +2171,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString } }else{ if (bVertical) - swap(FTInfo.font_type.height, FTInfo.font_type.width); //交换无法旋转的文字宽高 + swap(FTInfo.font_type.height, FTInfo.font_type.width); //浜ゆ崲鏃犳硶鏃嬭浆鐨勬枃瀛楀楂 FTInfo.font_type.flags &=~FT_LOAD_VERTICAL_LAYOUT; if(bLcdMode){ if(!bLightLcdMode){ @@ -2264,7 +2264,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString int dx = clpdx.get(bWidthGDI32 ? gdi32x : cx); //获得宽度 int left = FT_BitmapGlyph((*glyph_bitmap))->left; if (FTInfo.x + left< FTInfo.xBase) - FTInfo.xBase = FTInfo.x + left; //如果有字符是负数起始位置的(合成符号), 调整文字的起始位置 + FTInfo.xBase = FTInfo.x + left; //濡傛灉鏈夊瓧绗︽槸璐熸暟璧峰浣嶇疆鐨勶紙鍚堟垚绗﹀彿锛夛紝 璋冩暣鏂囧瓧鐨勮捣濮嬩綅缃 if (lpString < lpEnd - 1) { FTInfo.x += dx; @@ -2272,7 +2272,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString int bx = FT_BitmapGlyph((*glyph_bitmap))->bitmap.width; if (render_mode == FT_RENDER_MODE_LCD) bx /= 3; bx += left; - FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //有文字的情况下,绘图宽度=ft计算的宽度,鼠标位置=win宽度 + FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //鏈夋枃瀛楃殑鎯呭喌涓,缁樺浘瀹藉害=ft璁$畻鐨勫搴︼紝榧犳爣浣嶇疆=win瀹藉害 FTInfo.x += dx;//Max(dx, gdi32x);//Max(Max(dx, bx), cx); } @@ -2340,7 +2340,7 @@ BOOL CALLBACK TextOutCallback(FreeTypeGlyphInfo& FTGInfo) if (!FTGInfo.FTGlyph->bitmap.buffer) { //if (FTInfo->params->alpha == 1) { -// if (!(FTInfo->GetETO() & ETO_GLYPH_INDEX) && wch==32) //空格 +// if (!(FTInfo->GetETO() & ETO_GLYPH_INDEX) && wch==32) //绌烘牸 // ORIG_ExtTextOutW(FTInfo->hdc, FTInfo->x, FTInfo->yTop, FTInfo->GetETO() & ETO_IGNORELANGUAGE, NULL, &wch, 1, NULL); // else ORIG_ExtTextOutW(FTInfo->hdc, FTInfo->x, FTInfo->yTop, FTInfo->GetETO(), NULL, &FTGInfo.wch, 1, NULL); @@ -2381,10 +2381,10 @@ int IsColorDark(DWORD Color, double Gamma) //return (GetRValue(Color)*0.299 + GetGValue(Color)*0.587 + GetBValue(Color)*0.114); //原始算法 //=============================================================== //采用Photoshop sRGB的RGB->Lab算法进行换算,L为色彩视觉亮度 - //感谢 西安理工大学 贾婉丽 的分析 + //鎰熻阿 瑗垮畨鐞嗗伐澶у 璐惧〾涓 鐨勫垎鏋 //=============================================================== - static double s_multipler = 116/pow(100,(double)1.0/3.0); //预计算常数,强制使用double版本 - double* RGBTable = s_AlphaBlendTable.GetRGBTable(); //获得显示器转换表 + static double s_multipler = 116/pow(100,(double)1.0/3.0); //棰勮绠楀父鏁,寮哄埗浣跨敤double鐗堟湰 + double* RGBTable = s_AlphaBlendTable.GetRGBTable(); //鑾峰緱鏄剧ず鍣ㄨ浆鎹㈣〃 double ret = pow(23.9746*RGBTable[GetRValue(Color)] + 73.0653*RGBTable[GetGValue(Color)] + 6.13799*RGBTable[GetBValue(Color)] , 1.0/3.0)*s_multipler-16; return max(int(ret + 0.499),0); @@ -2475,7 +2475,7 @@ BOOL FreeTypeTextOut( const TEXTMETRIC& tm = FTInfo.params->otm->otmTextMetrics; FTInfo.yBase = tm.tmAscent; -//===============计算颜色缓存====================== +//===============璁$畻棰滆壊缂撳瓨====================== const CGdippSettings* pSettings = CGdippSettings::GetInstance(); int lightdiff, darkdiff, bDarkColor=0, ShadowColor=0; @@ -2523,7 +2523,7 @@ BOOL FreeTypeTextOut( break; } -//===============计算完成========================== +//===============璁$畻瀹屾垚========================== FreeTypeGlyphInfo FTGInfo = {&FTInfo, 0, 0, 0, solid, shadow}; for (int i=0; ilplf->lfWeight = FTInfo.params->otm->otmTextMetrics.tmWeight; //更新到标准weight + FTInfo.params->lplf->lfWeight = FTInfo.params->otm->otmTextMetrics.tmWeight; //鏇存柊鍒版爣鍑唚eight pfs = &pfi->GetFontSettings(); cmap_index = -1; @@ -1464,7 +1464,7 @@ BOOL FreeTypePrepare(FreeTypeDrawInfo& FTInfo) break; } - //如果含有内置hinting则启用default模式,否则使用autohint模式,以保证效果 + //濡傛灉鍚湁鍐呯疆hinting鍒欏惎鐢╠efault妯″紡锛屽惁鍒欎娇鐢╝utohint妯″紡锛屼互淇濊瘉鏁堟灉 // 傾儞僠僄僀儕傾僗 if (FTInfo.IsMono()) { font_type.flags |= FT_LOAD_TARGET_MONO; @@ -1500,7 +1500,7 @@ BOOL FreeTypePrepare(FreeTypeDrawInfo& FTInfo) if (pSettings->HintSmallFont() /*&& font_type.flags & FT_LOAD_TARGET_LIGHT*/ && font_type.height != -1 && font_type.height<12) //通用设置不使用hinting,但是打开了小字体hinting开关 { /* - if (!(freetype_face->face_flags & FT_FACE_FLAG_TRICKY)) //如果不是tricky字体 + if (!(freetype_face->face_flags & FT_FACE_FLAG_TRICKY)) //濡傛灉涓嶆槸tricky瀛椾綋 font_type.flags = font_type.flags & (~FT_LOAD_NO_HINTING) | (pfi->FontHasHinting() ? FT_LOAD_NO_AUTOHINT : FT_LOAD_FORCE_AUTOHINT); else*/ @@ -1636,7 +1636,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, BOOL bWindowsLink = pSettings->FontLink() == 2; //!!Snowie - /*const*/ FT_Face freetype_face = FTInfo.freetype_face; //去掉常量属性,下面要改他 + /*const*/ FT_Face freetype_face = FTInfo.freetype_face; //鍘绘帀甯搁噺灞炴э紝涓嬮潰瑕佹敼浠 const FT_Int cmap_index = FTInfo.cmap_index; const FT_Bool useKerning = FTInfo.useKerning; FT_Render_Mode render_mode = FTInfo.render_mode; @@ -1685,14 +1685,14 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, ZeroMemory(lpfontlink[i], sizeof(WORD)*cbString); //初始化为无链接 } // - hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //加载第一个字体 + hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //鍔犺浇绗竴涓瓧浣 } //fontlink int* Dx = FTInfo.Dx; int* Dy = FTInfo.Dy; if (!bAllowDefaultLink && FTInfo.face_id_list_num > 1) - FTInfo.face_id_list_num--; //如果是symbol页那就不链接到宋体 + FTInfo.face_id_list_num--; //濡傛灉鏄痵ymbol椤甸偅灏变笉閾炬帴鍒板畫浣 bool bUnicodePlane = false; for (int i = 0; lpString < lpEnd; ++lpString, ++gi, ++GlyphArray, ++drState, ++AAList, /*ggdi32++,*/ i++) { @@ -1752,7 +1752,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, f_glyph = !!wch; glyph_index = wch; *AAList = AAMode; - GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index的文字必须计算宽度 + GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index鐨勬枃瀛楀繀椤昏绠楀搴 if (FTInfo.font_type.height <= pSettings->BitmapHeight() && pfi->EmbeddedBmpExist(FTInfo.font_type.height)) { f_glyph = false; //使用点阵,不绘图 @@ -1763,11 +1763,11 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, if (wch && !CID.myiswcntrl(lpString[0])) { // need to draw a non-control character for (int j = 0; j < FTInfo.face_id_list_num; ++j) { freetype_face = NULL; // reinitialize it in case no fontlinking is available. - if (bWindowsLink) //使用Windows函数进行fontlink + if (bWindowsLink) //浣跨敤Windows鍑芥暟杩涜fontlink { if (!lpfontlink[j][i]) //还没初始化该字体的fontlink { - SelectFont(FTInfo.hdc, FTInfo.ggo_font_list[j]); //加载ggo字体 + SelectFont(FTInfo.hdc, FTInfo.ggo_font_list[j]); //鍔犺浇ggo瀛椾綋 GetGlyphIndices(FTInfo.hdc, lpString, cbString - i, &lpfontlink[j][i], GGI_MARK_NONEXISTING_GLYPHS); //进行fontlink SelectFont(FTInfo.hdc, hOldFont); } @@ -1785,8 +1785,8 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, GetCharWidth32W(FTInfo.hdc, wch, wch, &gdi32x); //有效文字,计算宽度 f_glyph = true; FTInfo.font_type.face_id = FTInfo.face_id_list[j]; - freetype_face = FTInfo.GetFace(j); //同时更新对应faceid的实际face - //接下来更新对应的fontsetting + freetype_face = FTInfo.GetFace(j); //鍚屾椂鏇存柊瀵瑰簲faceid鐨勫疄闄協ace + //鎺ヤ笅鏉ユ洿鏂板搴旂殑fontsetting FTInfo.font_type.flags = FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; // 僸儞僥傿儞僌 //extern CFontSetCache g_fsetcache; @@ -1795,7 +1795,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, { switch (FTInfo.font_type.height) { - case 11: {FTInfo.font_type.height = 12; FTInfo.font_type.width++; break; } //对宋体进行特殊处理 + case 11: {FTInfo.font_type.height = 12; FTInfo.font_type.width++; break; } //瀵瑰畫浣撹繘琛岀壒娈婂鐞 case 13: {FTInfo.font_type.height = 15; FTInfo.font_type.width += 2; break; } } } @@ -1851,7 +1851,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, AAMode = *AAList/*pfs->GetAntiAliasMode()*/; bLcdMode = render_mode == FT_RENDER_MODE_LCD; bLightLcdMode = (AAMode == 4) || (AAMode == 5); - //更新完成 + //鏇存柊瀹屾垚 } if (FTInfo.font_type.height <= pSettings->BitmapHeight() && pfi->EmbeddedBmpExist(FTInfo.font_type.height)) { @@ -1906,7 +1906,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, if (isc == CNTRL_COMPLEX_TEXT) //控制字 { - cx = dxWidth; //服从windows的宽度调度 + cx = dxWidth; //鏈嶄粠windows鐨勫搴﹁皟搴 //if (!dxWidth) // CID.setcntrlAttribute(wch, CNTRL_ZERO_WIDTH); } @@ -1923,7 +1923,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, GetCharABCWidthsI(FTInfo.hdc, wch, 1, NULL, &abc); else GetCharABCWidths(FTInfo.hdc, wch, wch, &abc);*/ - //FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //无效文字的情况下,绘图宽度=鼠标位置 + //FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //鏃犳晥鏂囧瓧鐨勬儏鍐典笅锛岀粯鍥惧搴=榧犳爣浣嶇疆 FTInfo.px = FTInfo.x + cx; FTInfo.x += dxWidth;//Max(clpdx.get(cx), cx);/*(int)abc.abcB+abc.abcC*///Max(clpdx.get(cx), abc.abcB? abc.abcA:0); //} @@ -1954,7 +1954,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, } - // 縦横 + // 绺︽í if (bVertical && IsVerticalChar(wch)) { FTInfo.font_type.flags |= FT_LOAD_VERTICAL_LAYOUT; if (bLcdMode) { @@ -1967,7 +1967,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, } else { if (bVertical) - swap(FTInfo.font_type.height, FTInfo.font_type.width); //交换无法旋转的文字宽高 + swap(FTInfo.font_type.height, FTInfo.font_type.width); //浜ゆ崲鏃犳硶鏃嬭浆鐨勬枃瀛楀楂 FTInfo.font_type.flags &= ~FT_LOAD_VERTICAL_LAYOUT; if (bLcdMode) { if (FTInfo.font_type.flags&FT_LOAD_TARGET_LCD_V == FT_LOAD_TARGET_LCD_V) { @@ -1982,8 +1982,8 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, bool bRequiredownsize; - bIsIndivBold = freetype_face->style_flags & FT_STYLE_FLAG_BOLD; //是独立粗体 - bIsBold = (IsFontBold(lf) && !bIsIndivBold); //是仿粗体 + bIsIndivBold = freetype_face->style_flags & FT_STYLE_FLAG_BOLD; //鏄嫭绔嬬矖浣 + bIsBold = (IsFontBold(lf) && !bIsIndivBold); //鏄豢绮椾綋 bRequiredownsize = bIsBold && /*(pSettings->BolderMode()==2 || (*/pSettings->BolderMode() != 1 /*&& FTInfo.height>FT_BOLD_LOW))*/; if (bRequiredownsize) { @@ -2092,7 +2092,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, } else { if (FTInfo.x + left < FTInfo.xBase) - FTInfo.xBase = FTInfo.x + left; //如果有字符是负数起始位置的(合成符号), 调整文字的起始位置 + FTInfo.xBase = FTInfo.x + left; //濡傛灉鏈夊瓧绗︽槸璐熸暟璧峰浣嶇疆鐨勶紙鍚堟垚绗﹀彿锛夛紝 璋冩暣鏂囧瓧鐨勮捣濮嬩綅缃 } if (lpString < lpEnd - 1) { @@ -2103,7 +2103,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, int bx = FT_BitmapGlyph((*glyph_bitmap)->ft_glyph)->bitmap.width; if (render_mode == FT_RENDER_MODE_LCD && FT_BitmapGlyph((*glyph_bitmap)->ft_glyph)->bitmap.pixel_mode != FT_PIXEL_MODE_BGRA) bx /= 3; bx += left; - FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //有文字的情况下,绘图宽度=ft计算的宽度,鼠标位置=win宽度 + FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //鏈夋枃瀛楃殑鎯呭喌涓,缁樺浘瀹藉害=ft璁$畻鐨勫搴︼紝榧犳爣浣嶇疆=win瀹藉害 FTInfo.x += dx;//Max(dx, gdi32x);//Max(Max(dx, bx), cx); } @@ -2124,7 +2124,7 @@ BOOL ForEachGetGlyphFT(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString, cont: *Dx = FTInfo.x; //Dx的位置是下一个字符开始的基准位置,并不是下一个字符开始画的位置 - *Dy = FTInfo.y; //Dy的位置是下一个字符的y坐标 + *Dy = FTInfo.y; //Dy鐨勪綅缃槸涓嬩竴涓瓧绗︾殑y鍧愭爣 ++Dx; ++Dy; } @@ -2152,7 +2152,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString BOOL bWindowsLink = pSettings->FontLink() == 2; //!!Snowie - /*const*/ FT_Face freetype_face = FTInfo.freetype_face; //去掉常量属性,下面要改他 + /*const*/ FT_Face freetype_face = FTInfo.freetype_face; //鍘绘帀甯搁噺灞炴э紝涓嬮潰瑕佹敼浠 const FT_Int cmap_index = FTInfo.cmap_index; const FT_Bool useKerning = FTInfo.useKerning; FT_Render_Mode render_mode = FTInfo.render_mode; @@ -2209,7 +2209,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString ZeroMemory(lpfontlink[i], sizeof(WORD)*cbString); //初始化为无链接 } // - hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //加载第一个字体 + hOldFont = (HFONT)GetCurrentObject(FTInfo.hdc, OBJ_FONT); //鍔犺浇绗竴涓瓧浣 } //fontlink @@ -2241,7 +2241,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString } }*/ - if (!bGlyphIndex) //仅对win32情况进行优化,ft情况另议 + if (!bGlyphIndex) //浠呭win32鎯呭喌杩涜浼樺寲锛宖t鎯呭喌鍙﹁ if (GetGlyphIndices(FTInfo.hdc, lpString, cbString, gi, GGI_MARK_NONEXISTING_GLYPHS) != cbString) { nRet = false; @@ -2251,7 +2251,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString int* Dx = FTInfo.Dx; int* Dy = FTInfo.Dy; if (!bAllowDefaultLink && FTInfo.face_id_list_num > 1) - FTInfo.face_id_list_num--; //如果是symbol页那就不链接到宋体 + FTInfo.face_id_list_num--; //濡傛灉鏄痵ymbol椤甸偅灏变笉閾炬帴鍒板畫浣 for (int i = 0; lpString < lpEnd; ++lpString, gi++, GlyphArray++, drState++, ++AAList,/*ggdi32++,*/ i++) { WCHAR wch = *lpString; @@ -2300,7 +2300,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString *AAList = AAMode; glyph_index = wch; ggoformat |= GGO_GLYPH_INDEX; - GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index的文字必须计算宽度 + GetCharWidthI(FTInfo.hdc, wch, 1, (LPWORD)&wch, &gdi32x); //index鐨勬枃瀛楀繀椤昏绠楀搴 } else { @@ -2328,7 +2328,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString } - if (!f_glyph) { //glyphindex的文字上面已经计算过了 + if (!f_glyph) { //glyphindex鐨勬枃瀛椾笂闈㈠凡缁忚绠楄繃浜 #ifdef _DEBUG GdiSetBatchLimit(0); #endif @@ -2365,7 +2365,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString GetCharABCWidthsI(FTInfo.hdc, wch, 1, NULL, &abc); else GetCharABCWidths(FTInfo.hdc, wch, wch, &abc);*/ - //FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //无效文字的情况下,绘图宽度=鼠标位置 + //FTInfo.px = FTInfo.x+Max(clpdx.get(cx), abc.abcA+(int)abc.abcB+abc.abcC); //鏃犳晥鏂囧瓧鐨勬儏鍐典笅锛岀粯鍥惧搴=榧犳爣浣嶇疆 FTInfo.px = FTInfo.x + cx; FTInfo.x += clpdx.get(cx); } @@ -2398,7 +2398,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString } else { if (bVertical) - swap(FTInfo.font_type.height, FTInfo.font_type.width); //交换无法旋转的文字宽高 + swap(FTInfo.font_type.height, FTInfo.font_type.width); //浜ゆ崲鏃犳硶鏃嬭浆鐨勬枃瀛楀楂 FTInfo.font_type.flags &= ~FT_LOAD_VERTICAL_LAYOUT; if (bLcdMode) { if (FTInfo.font_type.flags&FT_LOAD_TARGET_LCD_V == FT_LOAD_TARGET_LCD_V) { @@ -2492,7 +2492,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString int dx = clpdx.get(bWidthGDI32 ? gdi32x : cx); //获得宽度 int left = FT_BitmapGlyph((*glyph_bitmap)->ft_glyph)->left; if (FTInfo.x + left< FTInfo.xBase) - FTInfo.xBase = FTInfo.x + left; //如果有字符是负数起始位置的(合成符号), 调整文字的起始位置 + FTInfo.xBase = FTInfo.x + left; //濡傛灉鏈夊瓧绗︽槸璐熸暟璧峰浣嶇疆鐨勶紙鍚堟垚绗﹀彿锛夛紝 璋冩暣鏂囧瓧鐨勮捣濮嬩綅缃 if (lpString < lpEnd - 1) { FTInfo.x += dx; @@ -2502,7 +2502,7 @@ BOOL ForEachGetGlyphGGO(FreeTypeDrawInfo& FTInfo, LPCTSTR lpString, int cbString int bx = FT_BitmapGlyph((*glyph_bitmap)->ft_glyph)->bitmap.width; if (render_mode == FT_RENDER_MODE_LCD) bx /= 3; bx += left; - FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //有文字的情况下,绘图宽度=ft计算的宽度,鼠标位置=win宽度 + FTInfo.px = FTInfo.x + Max(Max(dx, bx), cx); //鏈夋枃瀛楃殑鎯呭喌涓,缁樺浘瀹藉害=ft璁$畻鐨勫搴︼紝榧犳爣浣嶇疆=win瀹藉害 FTInfo.x += dx;//Max(dx, gdi32x);//Max(Max(dx, bx), cx); } @@ -2573,7 +2573,7 @@ BOOL CALLBACK TextOutCallback(FreeTypeGlyphInfo& FTGInfo) if (!FTGInfo.FTGlyph->bitmap.buffer) { //if (FTInfo->params->alpha == 1) { - // if (!(FTInfo->GetETO() & ETO_GLYPH_INDEX) && wch==32) //空格 + // if (!(FTInfo->GetETO() & ETO_GLYPH_INDEX) && wch==32) //绌烘牸 // ORIG_ExtTextOutW(FTInfo->hdc, FTInfo->x, FTInfo->yTop, FTInfo->GetETO() & ETO_IGNORELANGUAGE, NULL, &wch, 1, NULL); // else ORIG_ExtTextOutW(FTInfo->hdc, FTInfo->x, FTInfo->yTop, FTInfo->GetETO(), NULL, &FTGInfo.wch, 1, NULL); @@ -2624,10 +2624,10 @@ int IsColorDark(DWORD Color, double Gamma) //return (GetRValue(Color)*0.299 + GetGValue(Color)*0.587 + GetBValue(Color)*0.114); //原始算法 //=============================================================== //采用Photoshop sRGB的RGB->Lab算法进行换算,L为色彩视觉亮度 - //感谢 西安理工大学 贾婉丽 的分析 + //鎰熻阿 瑗垮畨鐞嗗伐澶у 璐惧〾涓 鐨勫垎鏋 //=============================================================== - static double s_multipler = 116 / pow(100, (double)1.0 / 3.0); //预计算常数,强制使用double版本 - double* RGBTable = s_AlphaBlendTable.GetRGBTable(); //获得显示器转换表 + static double s_multipler = 116 / pow(100, (double)1.0 / 3.0); //棰勮绠楀父鏁,寮哄埗浣跨敤double鐗堟湰 + double* RGBTable = s_AlphaBlendTable.GetRGBTable(); //鑾峰緱鏄剧ず鍣ㄨ浆鎹㈣〃 double ret = pow(23.9746*RGBTable[GetRValue(Color)] + 73.0653*RGBTable[GetGValue(Color)] + 6.13799*RGBTable[GetBValue(Color)], 1.0 / 3.0)*s_multipler - 16; return max(int(ret + 0.499), 0); @@ -2718,7 +2718,7 @@ BOOL FreeTypeTextOut( const TEXTMETRIC& tm = FTInfo.params->otm->otmTextMetrics; FTInfo.yBase = tm.tmAscent; - //===============计算颜色缓存====================== + //===============璁$畻棰滆壊缂撳瓨====================== const CGdippSettings* pSettings = CGdippSettings::GetInstance(); int lightdiff, darkdiff, bDarkColor = 0, ShadowColor = 0; @@ -2766,7 +2766,7 @@ BOOL FreeTypeTextOut( break; } - //计算下划线或删除线的信息 + //璁$畻涓嬪垝绾挎垨鍒犻櫎绾跨殑淇℃伅 int decorationInfo_height; int decorationInfo_thickness; OUTLINETEXTMETRIC &decorationInfo_otm = *FTInfo.params->otm; @@ -2803,7 +2803,7 @@ BOOL FreeTypeTextOut( } } - //===============计算完成========================== + //===============璁$畻瀹屾垚========================== FreeTypeGlyphInfo FTGInfo = { &FTInfo, 0, 0, 0, solid, shadow, pSettings->InvertColor() }; for (int i = 0; isecond->Erase(); delete it->second; @@ -282,7 +282,7 @@ void FreeTypeFontCache::AddCharData(WCHAR wch, UINT glyphindex, int width, int g if (glyphindex & 0xffff0000 /*|| !g_ccbCache*/) { return; } - if (AddIncrement() >= FREETYPE_REQCOUNTMAX) { //先压缩,避免压缩后丢失的问题 + if (AddIncrement() >= FREETYPE_REQCOUNTMAX) { //鍏堝帇缂╋紝閬垮厤鍘嬬缉鍚庝涪澶辩殑闂 Compact(); } @@ -295,7 +295,7 @@ void FreeTypeFontCache::AddCharData(WCHAR wch, UINT glyphindex, int width, int g } #else GlyphCache::iterator it=m_GlyphCache.find(wch); - if (it!=m_GlyphCache.end()) //找到了旧数据 + if (it!=m_GlyphCache.end()) //鎵惧埌浜嗘棫鏁版嵁 { FreeTypeCharData* ppChar = it->second; if (ppChar) { @@ -341,7 +341,7 @@ void FreeTypeFontCache::AddGlyphData(UINT glyphindex, int width, int gdiWidth, F } #else GlyphCache::iterator it=m_GlyphCache.find(-(int)glyphindex); - if (it!=m_GlyphCache.end()) //找到了旧数据 + if (it!=m_GlyphCache.end()) //鎵惧埌浜嗘棫鏁版嵁 { FreeTypeCharData* ppChar = it->second; if (ppChar) { @@ -392,12 +392,12 @@ void FreeTypeFontInfo::Createlink() memset(&lf, 0, sizeof(LOGFONT)); lf.lfCharSet=DEFAULT_CHARSET; const CGdippSettings* pSettings = CGdippSettings::GetInstance(); - for (fn.next() ; !fn.atend(); fn.next()) { //跳过第一个链接 + for (fn.next() ; !fn.atend(); fn.next()) { //璺宠繃绗竴涓摼鎺 //FreeTypeFontInfo* pfitemp = g_pFTEngine->FindFont(fn, m_weight, m_italic); //if (pfitemp && pfitemp->m_isSimSun) // IsSimSun = true; if (!m_SimSunID) - IsSimSun = (_wcsicmp(fn,L"宋体")==0 || _wcsicmp(fn,L"SimSun")==0); + IsSimSun = (_wcsicmp(fn,L"瀹嬩綋")==0 || _wcsicmp(fn,L"SimSun")==0); StringCchCopy(lf.lfFaceName, LF_FACESIZE, fn); if (!_wcsicmp(fn, m_familyname.c_str())) // allow font link to itself pSettings->CopyForceFont(lf,lf); @@ -419,19 +419,19 @@ bool FreeTypeFontInfo::EmbeddedBmpExist(int px) if (m_ebmps[px]!=-1) return !!m_ebmps[px]; CCriticalSectionLock __lock(CCriticalSectionLock::CS_MANAGER); - FTC_ImageTypeRec imgtype={(FTC_FaceID)m_id, px, px, FT_LOAD_DEFAULT}; //构造一个当前大小的imagetype + FTC_ImageTypeRec imgtype={(FTC_FaceID)m_id, px, px, FT_LOAD_DEFAULT}; //鏋勯犱竴涓綋鍓嶅ぇ灏忕殑imagetype FT_Glyph temp_glyph=NULL; - FT_UInt gindex = FTC_CMapCache_Lookup(cmap_cache, (FTC_FaceID)m_id, -1, FT_UInt32(L'0')); //获得0的索引值 + FT_UInt gindex = FTC_CMapCache_Lookup(cmap_cache, (FTC_FaceID)m_id, -1, FT_UInt32(L'0')); //鑾峰緱0鐨勭储寮曞 FTC_ImageCache_Lookup(image_cache, &imgtype, gindex, &temp_glyph, NULL); - if (temp_glyph && temp_glyph->format==FT_GLYPH_FORMAT_BITMAP) //如果可以读到0的点阵 - m_ebmps[px]=1; //则该字号存在点阵 + if (temp_glyph && temp_glyph->format==FT_GLYPH_FORMAT_BITMAP) //濡傛灉鍙互璇诲埌0鐨勭偣闃 + m_ebmps[px]=1; //鍒欒瀛楀彿瀛樺湪鐐归樀 else { - gindex = FTC_CMapCache_Lookup(cmap_cache, (FTC_FaceID)m_id, -1, FT_UInt32(L'的')); //获得"的"的索引值 + gindex = FTC_CMapCache_Lookup(cmap_cache, (FTC_FaceID)m_id, -1, FT_UInt32(L'鐨')); //鑾峰緱"鐨"鐨勭储寮曞 if (gindex) - FTC_ImageCache_Lookup(image_cache, &imgtype, gindex, &temp_glyph, NULL); //读取“的”的点阵 - if (temp_glyph && temp_glyph->format==FT_GLYPH_FORMAT_BITMAP) //如果可以读到0的点阵 - m_ebmps[px]=1; //则该字号存在点阵 + FTC_ImageCache_Lookup(image_cache, &imgtype, gindex, &temp_glyph, NULL); //璇诲彇鈥滅殑鈥濈殑鐐归樀 + if (temp_glyph && temp_glyph->format==FT_GLYPH_FORMAT_BITMAP) //濡傛灉鍙互璇诲埌0鐨勭偣闃 + m_ebmps[px]=1; //鍒欒瀛楀彿瀛樺湪鐐归樀 else m_ebmps[px]=0; } @@ -442,7 +442,7 @@ FreeTypeFontCache* FreeTypeFontInfo::GetCache(FTC_ScalerRec& scaler, const LOGFO { CCriticalSectionLock __lock(CCriticalSectionLock::CS_FONTCACHE); - if (AddIncrement() > m_nMaxSizes) { //先压缩 + if (AddIncrement() > m_nMaxSizes) { //鍏堝帇缂 Compact(); } int weight = lf.lfWeight; @@ -472,7 +472,7 @@ FreeTypeFontCache* FreeTypeFontInfo::GetCache(FTC_ScalerRec& scaler, const LOGFO OK: Assert(p != NULL); if (p && p->Activate()) { - DecIncrement(); //重复使用则减计数值 + DecIncrement(); //閲嶅浣跨敤鍒欏噺璁℃暟鍊 } return p; } @@ -485,7 +485,7 @@ void FreeTypeFontEngine::Compact() TRACE(_T("FreeTypeFontEngine::Compact: %d > %d\n"), m_mfontMap.size(), m_nMaxFaces); ResetGCCounter(); - //memset(m_arrFace, 0, sizeof(FT_Face)*m_nFaceCount); //超过最大face数了,老的face会被ft释放掉,所以需要全部重新获取 + //memset(m_arrFace, 0, sizeof(FT_Face)*m_nFaceCount); //瓒呰繃鏈澶ace鏁颁簡锛岃佺殑face浼氳ft閲婃斁鎺夛紝鎵浠ラ渶瑕佸叏閮ㄩ噸鏂拌幏鍙 //FontListArray& arr = m_arrFontList; //::Compact(arr.GetData(), arr.GetSize(), m_nMaxFaces); } @@ -499,7 +499,7 @@ BOOL FreeTypeFontEngine::RemoveFont(FreeTypeFontInfo* fontinfo) { FreeTypeFontInfo* p = iter->second; if (p==fontinfo) - m_mfontMap.erase(iter++); //删除引用 + m_mfontMap.erase(iter++); //鍒犻櫎寮曠敤 else ++iter; } @@ -510,7 +510,7 @@ BOOL FreeTypeFontEngine::RemoveFont(FreeTypeFontInfo* fontinfo) { FreeTypeFontInfo* p = iter->second; if (p==fontinfo) - m_mfullMap.erase(iter++); //删除引用 + m_mfullMap.erase(iter++); //鍒犻櫎寮曠敤 else { iter->second->UpdateFontSetting(); @@ -528,12 +528,12 @@ BOOL FreeTypeFontEngine::RemoveThisFont(FreeTypeFontInfo* fontinfo, LOGFONT* lg) { FontMap::const_iterator iter=m_mfontMap.find(myfont(lg->lfFaceName, CalcBoldWeight(lg->lfWeight), lg->lfItalic)); //遍历fontmap if (iter!=m_mfontMap.end()) - m_mfontMap.erase(iter); //删除引用 + m_mfontMap.erase(iter); //鍒犻櫎寮曠敤 } { FullNameMap::const_iterator iter=m_mfullMap.find(fontinfo->GetFullName()); //遍历fullmap if (iter!=m_mfullMap.end()) - m_mfullMap.erase(iter); //删除引用 + m_mfullMap.erase(iter); //鍒犻櫎寮曠敤 } delete fontinfo; return true; @@ -543,11 +543,11 @@ BOOL FreeTypeFontEngine::RemoveFont(LPCWSTR FontName) { if (!FontName) return false; LOGFONTW* fontarray = GetFontNameFromFile(FontName); - LOGFONTW* c_fontarray = fontarray; //记录原始指针 + LOGFONTW* c_fontarray = fontarray; //璁板綍鍘熷鎸囬拡 if (!fontarray) return false; FTC_FaceID fid = NULL; BOOL bIsFontLoaded, bIsFontFileLoaded = false; - COwnedCriticalSectionLock __lock2(2, COwnedCriticalSectionLock::OCS_DC); //获取所有权,现在要处理DC,禁止所有绘图函数访问 + COwnedCriticalSectionLock __lock2(2, COwnedCriticalSectionLock::OCS_DC); //鑾峰彇鎵鏈夋潈锛岀幇鍦ㄨ澶勭悊DC锛岀姝㈡墍鏈夌粯鍥惧嚱鏁拌闂 CCriticalSectionLock __lock(CCriticalSectionLock::CS_MANAGER); while (*(char*)fontarray) { @@ -556,10 +556,10 @@ BOOL FreeTypeFontEngine::RemoveFont(LPCWSTR FontName) if (result) { fid = (FTC_FaceID)result->GetId(); - if (bIsFontLoaded) //该字体已经被使用过 + if (bIsFontLoaded) //璇ュ瓧浣撳凡缁忚浣跨敤杩 { - RemoveFont(result); //枚举字体信息全部删除 - bIsFontFileLoaded = true; //设置字体文件也被使用过 + RemoveFont(result); //鏋氫妇瀛椾綋淇℃伅鍏ㄩ儴鍒犻櫎 + bIsFontFileLoaded = true; //璁剧疆瀛椾綋鏂囦欢涔熻浣跨敤杩 } else RemoveThisFont(result, fontarray); @@ -569,13 +569,13 @@ BOOL FreeTypeFontEngine::RemoveFont(LPCWSTR FontName) } fontarray++; } - free(c_fontarray); //利用原始指针释放 - if (bIsFontFileLoaded) //若字体文件被使用过,则需要清楚所有DC + free(c_fontarray); //鍒╃敤鍘熷鎸囬拡閲婃斁 + if (bIsFontFileLoaded) //鑻ュ瓧浣撴枃浠惰浣跨敤杩囷紝鍒欓渶瑕佹竻妤氭墍鏈塂C { CTLSDCArray::iterator iter = TLSDCArray.begin(); while (iter!=TLSDCArray.end()) { - ((CBitmapCache*)*iter)->~CBitmapCache(); //清除掉所有使用中的DC + ((CBitmapCache*)*iter)->~CBitmapCache(); //娓呴櫎鎺夋墍鏈変娇鐢ㄤ腑鐨凞C ++iter; } } @@ -623,22 +623,22 @@ FreeTypeFontInfo* FreeTypeFontEngine::AddFont(void* lpparams) }*/ FullNameMap::const_iterator it = m_mfullMap.find(pfi->GetFullName()); - if (it!=m_mfullMap.end()) //是已经存在的字体了,原因是字体替换使两种名字指向一个字体 + if (it!=m_mfullMap.end()) //鏄凡缁忓瓨鍦ㄧ殑瀛椾綋浜,鍘熷洜鏄瓧浣撴浛鎹娇涓ょ鍚嶅瓧鎸囧悜涓涓瓧浣 { - delete pfi; //删除刚才创建的字体 + delete pfi; //鍒犻櫎鍒氭墠鍒涘缓鐨勫瓧浣 ReleaseFaceID(); - pfi = it->second;//指向原字体 + pfi = it->second;//鎸囧悜鍘熷瓧浣 } else { - m_mfullMap[pfi->GetFullName()]=pfi; //不存在,添加到map表 + m_mfullMap[pfi->GetFullName()]=pfi; //涓嶅瓨鍦紝娣诲姞鍒癿ap琛 m_mfontList.push_back(pfi); } - if (pfi->GetFullName()!=params->strFullName) //如果目标字体的真实名称和需要的名称不一样,说明是字体替换 + if (pfi->GetFullName()!=params->strFullName) //濡傛灉鐩爣瀛椾綋鐨勭湡瀹炲悕绉板拰闇瑕佺殑鍚嶇О涓嶄竴鏍凤紝璇存槑鏄瓧浣撴浛鎹 { - pfi->AddRef(); //增加引用计数 - m_mfullMap[params->strFullName] = pfi; //双重引用,指向同一个字体 + pfi->AddRef(); //澧炲姞寮曠敤璁℃暟 + m_mfullMap[params->strFullName] = pfi; //鍙岄噸寮曠敤锛屾寚鍚戝悓涓涓瓧浣 } //bool ret = !!arr.Add(pfi); @@ -694,16 +694,16 @@ FreeTypeFontInfo* FreeTypeFontEngine::AddFont(LPCTSTR lpFaceName, int weight, bo FullNameMap::const_iterator it = m_mfullMap.find(pfi->GetFullName()); //是否在主map表中存在了 if (it!=m_mfullMap.end()) //已经存在 { - delete pfi; //删除创建出来的字体 + delete pfi; //鍒犻櫎鍒涘缓鍑烘潵鐨勫瓧浣 ReleaseFaceID(); - pfi = it->second; //指向已经存在的字体 + pfi = it->second; //鎸囧悜宸茬粡瀛樺湪鐨勫瓧浣 if (bIsFontLoaded) *bIsFontLoaded = true; //pfi->AddRef(); } else { - m_mfullMap[pfi->GetFullName()]=pfi; //不存在,添加到map表 + m_mfullMap[pfi->GetFullName()]=pfi; //涓嶅瓨鍦紝娣诲姞鍒癿ap琛 m_mfontList.push_back(pfi); if (bIsFontLoaded) *bIsFontLoaded = false; @@ -712,7 +712,7 @@ FreeTypeFontInfo* FreeTypeFontEngine::AddFont(LPCTSTR lpFaceName, int weight, bo //bool ret = !!arr.Add(pfi); //weight = weight < FW_BOLD ? 0: FW_BOLD; myfont font(lpFaceName, weight, italic); - m_mfontMap[font]=pfi; //添加在次要map表 + m_mfontMap[font]=pfi; //娣诲姞鍦ㄦ瑕乵ap琛 /* if (!ret) { delete pfi; @@ -763,7 +763,7 @@ FreeTypeFontInfo* FreeTypeFontEngine::FindFont(void* lpparams) if (iter!=m_mfullMap.end()) { FreeTypeFontInfo* p = iter->second; - if (p->GetFullName()!=params->strFullName) //属于替换字体 + if (p->GetFullName()!=params->strFullName) //灞炰簬鏇挎崲瀛椾綋 return FindFont(params->lplf->lfFaceName, params->lplf->lfWeight, !!params->lplf->lfItalic); p->SetMruCounter(this); return p; diff --git a/fteng.h b/fteng.h index 0757572..c2edc1e 100644 --- a/fteng.h +++ b/fteng.h @@ -314,7 +314,7 @@ private: wstring m_fullname, m_familyname; typedef map CacheArray; CacheArray m_cache; - //快速链接 + //蹇熼摼鎺 FTC_FaceID face_id_link[CFontLinkInfo::FONTMAX * 2 + 1]; HFONT ggo_link[CFontLinkInfo::FONTMAX * 2 + 1]; bool m_linkinited; @@ -397,7 +397,7 @@ public: if (nSize==0) m_fullname = L""; else - //if (m_fullname.size()==0) //构造函数中不提供,自己获取 + //if (m_fullname.size()==0) //鏋勯犲嚱鏁颁腑涓嶆彁渚涳紝鑷繁鑾峰彇 { LPOUTLINETEXTMETRIC otm = (LPOUTLINETEXTMETRIC)malloc(nSize); memset(otm, 0, nSize); @@ -410,7 +410,7 @@ public: TCHAR buff[LF_FACESIZE+1]; GetFontLocalName(localname, buff); - m_nFontFamily = otm->otmTextMetrics.tmPitchAndFamily & 0xF0; //获取字体家族,家族对应使用什么默认链接字体 + m_nFontFamily = otm->otmTextMetrics.tmPitchAndFamily & 0xF0; //鑾峰彇瀛椾綋瀹舵棌锛屽鏃忓搴斾娇鐢ㄤ粈涔堥粯璁ら摼鎺ュ瓧浣 m_familyname = (wstring)buff; m_set = pSettings->FindIndividual(m_familyname.c_str()); m_ftWeight = CalcBoldWeight(/*weight*/700); @@ -422,7 +422,7 @@ public: SelectFont(hdc, old); DeleteDC(hdc); - //完成 + //瀹屾垚 // g_EngineCreateFont = false; face_id_link[0]=(FTC_FaceID)NULL; ggo_link[0] = NULL; @@ -472,7 +472,7 @@ public: void UpdateFontSetting() { m_ftWeight = CalcBoldWeight(700/*m_weight*/); - //清除字体链接 + //娓呴櫎瀛椾綋閾炬帴 face_id_link[0]=NULL; ggo_link[0]=NULL; m_linknum = 0; @@ -617,7 +617,7 @@ public: } void ReloadAll() { - //重新载入全部字体,即清空所有字体缓存 + //閲嶆柊杞藉叆鍏ㄩ儴瀛椾綋锛屽嵆娓呯┖鎵鏈夊瓧浣撶紦瀛 COwnedCriticalSectionLock __olock(2); CCriticalSectionLock __lock; CGdippSettings* pSettings = CGdippSettings::GetInstance(); @@ -629,9 +629,9 @@ public: if (p) { /* - if (p->GetFullName()!=iter->first) //是替换字体 + if (p->GetFullName()!=iter->first) //鏄浛鎹㈠瓧浣 { - p->Release(); //释放掉多重引用 + p->Release(); //閲婃斁鎺夊閲嶅紩鐢 m_mfullMap.erase(iter++); continue; }*/ diff --git a/ftref.h b/ftref.h index 89d4454..675656d 100644 --- a/ftref.h +++ b/ftref.h @@ -24,4 +24,4 @@ FT_Referenced_Glyph New_FT_Ref_Glyph(); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/gdiPlusFlat2.cpp b/gdiPlusFlat2.cpp index d0cde1c..59ea2d5 100644 --- a/gdiPlusFlat2.cpp +++ b/gdiPlusFlat2.cpp @@ -36,4 +36,4 @@ bool InitGdiplusFuncs(){ } else return true; -} \ No newline at end of file +} diff --git a/gdiPlusFlat2.h b/gdiPlusFlat2.h index 3d4bc33..cf9d85a 100644 --- a/gdiPlusFlat2.h +++ b/gdiPlusFlat2.h @@ -20,7 +20,7 @@ GdipDrawString)( GDIPCONST RectF *layoutRect, GDIPCONST GpStringFormat *stringFormat, GDIPCONST GpBrush *brush - );//绘制文字的函数 + );//缁樺埗鏂囧瓧鐨勫嚱鏁 typedef GpStatus (WINGDIPAPI* GdipGetLogFontW)(GpFont * font, GpGraphics *graphics, LOGFONTW * logfontW);//从GPFont获取Logfont @@ -39,11 +39,11 @@ typedef GpStatus (WINGDIPAPI* GdipGetStringFormatTrimming)( GDIPCONST GpStringFormat *format, StringTrimming *trimming - ); //获取字符串的缩略方式。当字符串长度超过矩形长度时,将使用设置的方式删除中间的部分文字。 + ); //鑾峰彇瀛楃涓茬殑缂╃暐鏂瑰紡銆傚綋瀛楃涓查暱搴﹁秴杩囩煩褰㈤暱搴︽椂锛屽皢浣跨敤璁剧疆鐨勬柟寮忓垹闄や腑闂寸殑閮ㄥ垎鏂囧瓧銆 //转换成GDI后应使用DrawText来模拟。 typedef GpStatus (WINGDIPAPI* GdipGetStringFormatHotkeyPrefix)(GDIPCONST GpStringFormat *format, - INT *hotkeyPrefix); //获取&符号的显示方式,隐藏,显示下划线或者不处理&。由DrawText模拟。 + INT *hotkeyPrefix); //鑾峰彇&绗﹀彿鐨勬樉绀烘柟寮忥紝闅愯棌锛屾樉绀轰笅鍒掔嚎鎴栬呬笉澶勭悊&銆傜敱DrawText妯℃嫙銆 typedef GpStatus (WINGDIPAPI* GdipGetBrushType)(GpBrush *brush, GpBrushType *type); @@ -63,4 +63,4 @@ extern GdipReleaseDC pfnGdipReleaseDC ; bool InitGdiplusFuncs(); -#endif \ No newline at end of file +#endif diff --git a/gdipp.vcxproj b/gdipp.vcxproj index 40ee527..bf8b26e 100644 --- a/gdipp.vcxproj +++ b/gdipp.vcxproj @@ -694,4 +694,4 @@ - \ No newline at end of file + diff --git a/gdipp.vcxproj.filters b/gdipp.vcxproj.filters index c4a546e..3c81bf7 100644 --- a/gdipp.vcxproj.filters +++ b/gdipp.vcxproj.filters @@ -160,4 +160,4 @@ Resource Files - \ No newline at end of file + diff --git a/hash_list.cpp b/hash_list.cpp index 4945ca1..e4ebbe8 100644 --- a/hash_list.cpp +++ b/hash_list.cpp @@ -34,4 +34,4 @@ TCHAR * CHashedStringList::Find(TCHAR * String) return it->second; else return NULL; -} \ No newline at end of file +} diff --git a/hash_list.h b/hash_list.h index 6f6f73c..b43d0b8 100644 --- a/hash_list.h +++ b/hash_list.h @@ -26,4 +26,4 @@ protected: private: strmap stringmap; BOOL m_bCaseSense; -}; \ No newline at end of file +}; diff --git a/hook.cpp b/hook.cpp index 0c9b248..4f44c10 100644 --- a/hook.cpp +++ b/hook.cpp @@ -567,7 +567,7 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID lpReserved) //delete AACacheFull; //delete AACache; // for (int i=0;i //修改这个函数,使它在失败的时候返回false,由调用者负责调用Windows原函数,实现线程安全。 +template //淇敼杩欎釜鍑芥暟锛屼娇瀹冨湪澶辫触鐨勬椂鍊欒繑鍥瀎alse锛岀敱璋冪敤鑰呰礋璐h皟鐢╓indows鍘熷嚱鏁帮紝瀹炵幇绾跨▼瀹夊叏銆 BOOL _GetTextExtentPoint32AorW(HDC hdc, _TCHAR* lpString, int cbString, LPSIZE lpSize) { const CGdippSettings* pSettings = CGdippSettings::GetInstance(); @@ -230,8 +230,8 @@ LONG WINAPI IMPL_LdrLoadDll(IN PWCHAR PathToFile OPTIONAL, IN ULONG Flags OPTION wstring filename = wstring(ModuleFileName->Buffer); int last_slash=filename.find_last_of('\\'); if (last_slash!=-1) - filename.erase(0,last_slash+1); //删除路径 - if (_wcsicmp(filename.c_str(), L"d2d1.dll")==0) //正在载入d2d1.dll + filename.erase(0,last_slash+1); //鍒犻櫎璺緞 + if (_wcsicmp(filename.c_str(), L"d2d1.dll")==0) //姝e湪杞藉叆d2d1.dll { bD2D1Loaded = true; LONG result = ORIG_LdrLoadDll(PathToFile, Flags, ModuleFileName, ModuleHandle); @@ -411,15 +411,15 @@ LPCWSTR GetCachedFontLocale(HFONT lFont) void AddToCachedFont(HFONT lfont, LPWSTR lpFaceName, LPWSTR lpGDIName) { - if (!lfont) return; //不可以添加空节点 + if (!lfont) return; //涓嶅彲浠ユ坊鍔犵┖鑺傜偣 CCriticalSectionLock __lock(CCriticalSectionLock::CS_CACHEDFONT); - if (GetCachedFont(lfont)) return; //已经存在的字体 + if (GetCachedFont(lfont)) return; //宸茬粡瀛樺湪鐨勫瓧浣 FontCache[lfont] = new CFontSubResult(lpFaceName, lpGDIName); } void DeleteCachedFont(HFONT lfont) { - if (!lfont) return; //不可以删除头结点 + if (!lfont) return; //涓嶅彲浠ュ垹闄ゅご缁撶偣 CCriticalSectionLock __lock(CCriticalSectionLock::CS_CACHEDFONT); CFontCache::iterator it= FontCache.find(lfont); if (it!=FontCache.end()) @@ -755,7 +755,7 @@ HFONT WINAPI IMPL_CreateFontIndirectExW(CONST ENUMLOGFONTEXDV *penumlfex) BOOL WINAPI IMPL_DeleteObject(HGDIOBJ hObject) { //CThreadCounter __counter; - if (hObject == g_alterGUIFont) //我的系统字体,不可以释放掉 + if (hObject == g_alterGUIFont) //鎴戠殑绯荤粺瀛椾綋锛屼笉鍙互閲婃斁鎺 return true; BOOL bResult = ORIG_DeleteObject(hObject); if (bResult) DeleteCachedFont((HFONT)hObject); @@ -763,7 +763,7 @@ BOOL WINAPI IMPL_DeleteObject(HGDIOBJ hObject) } -HFONT WINAPI IMPL_CreateFontIndirectW(CONST LOGFONTW *lplf) //重新启用这个hook,只为兼容搜狗输入法 +HFONT WINAPI IMPL_CreateFontIndirectW(CONST LOGFONTW *lplf) //閲嶆柊鍚敤杩欎釜hook锛屽彧涓哄吋瀹规悳鐙楄緭鍏ユ硶 { ENUMLOGFONTEXDVW envlf = {0}; memcpy(&envlf.elfEnumLogfontEx.elfLogFont, lplf, sizeof(LOGFONTW)); @@ -1061,14 +1061,14 @@ extern ControlIder CID; // 取代Windows的ExtTextOutW BOOL WINAPI IMPL_ExtTextOutW(HDC hdc, int nXStart, int nYStart, UINT fuOptions, CONST RECT *lprc, LPCWSTR lpString, UINT cbString, CONST INT *SyslpDx) { - //CThreadCounter __counter; //用于安全退出的计数器 + //CThreadCounter __counter; //鐢ㄤ簬瀹夊叏閫鍑虹殑璁℃暟鍣 INT* lpDx = const_cast(SyslpDx); if (!hdc || !lpString || !cbString || !g_ccbRender || cbString>8192) { //no valid param or rendering is disabled from control center. return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions, lprc, lpString, cbString, lpDx); } - if (!(fuOptions & ETO_GLYPH_INDEX) && cbString==1 && *lpString==32) //空格 - return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions | ETO_IGNORELANGUAGE, lprc, lpString, cbString, lpDx); //空格就不用处理了。。。反正都一样 + if (!(fuOptions & ETO_GLYPH_INDEX) && cbString==1 && *lpString==32) //绌烘牸 + return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions | ETO_IGNORELANGUAGE, lprc, lpString, cbString, lpDx); //绌烘牸灏变笉鐢ㄥ鐞嗕簡銆傘傘傚弽姝i兘涓鏍 CThreadLocalInfo* pTLInfo = g_TLInfo.GetPtr(); if(!pTLInfo) { @@ -1099,14 +1099,14 @@ BOOL WINAPI IMPL_ExtTextOutW(HDC hdc, int nXStart, int nYStart, UINT fuOptions, if (!(fuOptions & ETO_GLYPH_INDEX) && !(fuOptions & ETO_IGNORELANGUAGE) && !lpDx && CID.myiscomplexscript(lpString,cbString)) //complex script return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions, lprc, lpString, cbString, lpDx); - CGdippSettings* pSettings = CGdippSettings::GetInstance(); //获得一个配置文件实例 + CGdippSettings* pSettings = CGdippSettings::GetInstance(); //鑾峰緱涓涓厤缃枃浠跺疄渚 /* -#ifndef _DEBUG //debug模式下此参数有问题 +#ifndef _DEBUG //debug妯″紡涓嬫鍙傛暟鏈夐棶棰 if (pSettings->FontLoader()==SETTING_FONTLOADER_WIN32) { - if (!(fuOptions & ETO_GLYPH_INDEX) //复杂文件,不进行渲染 + if (!(fuOptions & ETO_GLYPH_INDEX) //澶嶆潅鏂囦欢锛屼笉杩涜娓叉煋 && !(fuOptions & ETO_IGNORELANGUAGE) && ScriptIsComplex(lpString, cbString, SIC_COMPLEX) == S_OK) { return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions, lprc, lpString, cbString, lpDx); } @@ -1121,7 +1121,7 @@ BOOL WINAPI IMPL_ExtTextOutW(HDC hdc, int nXStart, int nYStart, UINT fuOptions, - if (pTLInfo->InExtTextOut()) { //是异常之后的自动还原执行 + if (pTLInfo->InExtTextOut()) { //鏄紓甯镐箣鍚庣殑鑷姩杩樺師鎵ц return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions, lprc, lpString, cbString, lpDx); } @@ -1132,9 +1132,9 @@ BOOL WINAPI IMPL_ExtTextOutW(HDC hdc, int nXStart, int nYStart, UINT fuOptions, if (GetTransform) { GetTransform(hdc, GT_WORLD_TO_DEVICE, &xfm); - if (memcmp(&xfm, &stdXfm, sizeof(XFORM)-sizeof(FLOAT)*2)) //(xfm.eM11!=1.0 || xfm.eM22!=1.0) //如果存在坐标转换 + if (memcmp(&xfm, &stdXfm, sizeof(XFORM)-sizeof(FLOAT)*2)) //(xfm.eM11!=1.0 || xfm.eM22!=1.0) //濡傛灉瀛樺湪鍧愭爣杞崲 { - bool bZoomInOut = (xfm.eM12==0 && xfm.eM21==0 && xfm.eM11>0 && xfm.eM22>0); //只是缩放,且是正数缩放 + bool bZoomInOut = (xfm.eM12==0 && xfm.eM21==0 && xfm.eM11>0 && xfm.eM22>0); //鍙槸缂╂斁,涓旀槸姝f暟缂╂斁 if (!bZoomInOut) return ORIG_ExtTextOutW(hdc, nXStart, nYStart, fuOptions, lprc, lpString, cbString, lpDx); //放弃渲染 else @@ -1194,7 +1194,7 @@ BOOL WINAPI IMPL_ExtTextOutW(HDC hdc, int nXStart, int nYStart, UINT fuOptions, OUTLINETEXTMETRIC* otm = NULL; ETO_TRY(); - //设置标志, + //璁剧疆鏍囧織锛 pTLInfo->InExtTextOut(true); POINT curPos = { nXStart, nYStart }; //记录开始的位置 diff --git a/ownedcs.cpp b/ownedcs.cpp index 903c0e5..beb182a 100644 --- a/ownedcs.cpp +++ b/ownedcs.cpp @@ -31,15 +31,15 @@ void WINAPI EnterOwnedCritialSection(POWNED_CRITIAL_SECTION cs, WORD Owner) } else { - if (InterlockedIncrementInt(cs->nRequests)>0) //等待获取所有权 + if (InterlockedIncrementInt(cs->nRequests)>0) //绛夊緟鑾峰彇鎵鏈夋潈 { LeaveCriticalSection(&cs->threadLock); WaitForSingleObject(cs->hEvent, INFINITE); } else LeaveCriticalSection(&cs->threadLock); - InterlockedExchangeInt(cs->nOwner, Owner);//更改所有者 - InterlockedExchangeInt(cs->nRecursiveCount, 1);//增加占用计数 + InterlockedExchangeInt(cs->nOwner, Owner);//鏇存敼鎵鏈夎 + InterlockedExchangeInt(cs->nRecursiveCount, 1);//澧炲姞鍗犵敤璁℃暟 } } @@ -58,4 +58,4 @@ void WINAPI LeaveOwnedCritialSection(POWNED_CRITIAL_SECTION cs, WORD Owner) else InterlockedDecrementInt(cs->nRecursiveCount); LeaveCriticalSection(&cs->threadLock); -} \ No newline at end of file +} diff --git a/ownedcs.h b/ownedcs.h index b91b4ca..1f3581b 100644 --- a/ownedcs.h +++ b/ownedcs.h @@ -6,9 +6,9 @@ typedef struct _OWNED_CRITIAL_SECTION HANDLE hEvent; CRITICAL_SECTION threadLock; }OWNED_CRITIAL_SECTION, *POWNED_CRITIAL_SECTION; - //用于自定义临界区 + //鐢ㄤ簬鑷畾涔変复鐣屽尯 void WINAPI InitializeOwnedCritialSection(POWNED_CRITIAL_SECTION cs); void WINAPI DeleteOwnedCritialSection(POWNED_CRITIAL_SECTION cs); void WINAPI EnterOwnedCritialSection(POWNED_CRITIAL_SECTION cs, WORD Owner); -void WINAPI LeaveOwnedCritialSection(POWNED_CRITIAL_SECTION cs, WORD Owner); \ No newline at end of file +void WINAPI LeaveOwnedCritialSection(POWNED_CRITIAL_SECTION cs, WORD Owner); diff --git a/settings.cpp b/settings.cpp index 0a436ca..02b8789 100644 --- a/settings.cpp +++ b/settings.cpp @@ -429,7 +429,7 @@ bool CGdippSettings::LoadAppSettings(LPCTSTR lpszFile) PathRemoveFileSpec(szDir); PathCombine(szAlternative, szDir, szAlternative); } - StringCchCopy(szMainFile, MAX_PATH, lpszFile); //把原始文件名保存下来 + StringCchCopy(szMainFile, MAX_PATH, lpszFile); //鎶婂師濮嬫枃浠跺悕淇濆瓨涓嬫潵 StringCchCopy(m_szFileName, MAX_PATH, szAlternative); lpszFile = m_szFileName; m_Config.Clear(); @@ -642,7 +642,7 @@ SKIP: // [ExcludeSub]不进行字体替换的模縼E AddListFromSection(L"ExcludeSub", lpszFile, m_arrUnFontSubModule); //AddListFromSection(L"ExcludeSub", szMainFile, m_arrUnFontSubModule); - //如果是排除的模块,则关闭字体替换 + //濡傛灉鏄帓闄ょ殑妯″潡锛屽垯鍏抽棴瀛椾綋鏇挎崲 if (m_nFontSubstitutes) { ModuleHashMap::const_iterator it=m_arrUnFontSubModule.begin(); @@ -736,7 +736,7 @@ bool CGdippSettings::AddLcdFilterFromSection(LPCTSTR lpszKey, LPCTSTR lpszFile, for (int i = 0; i < 5; i++) { LPCTSTR arg = token.GetArgument(i); if (!arg) - return false; //参数少于5个则视为不使用此参数 + return false; //鍙傛暟灏戜簬5涓垯瑙嗕负涓嶄娇鐢ㄦ鍙傛暟 arr[i] = _StrToInt(arg, arr[i]); } @@ -998,7 +998,7 @@ bool CGdippSettings::IsExeUnload(LPCTSTR lpApp) const // return false; ModuleHashMap::const_iterator it = m_arrUnloadModule.begin(); for(; it != m_arrUnloadModule.end(); ++it) { - if (!lstrcmpi(lpApp, it->c_str())) { //匹配排除蟻E + if (!lstrcmpi(lpApp, it->c_str())) { //鍖归厤鎺掗櫎锜籈 return true; } } @@ -1015,7 +1015,7 @@ bool CGdippSettings::IsExeInclude(LPCTSTR lpApp) const // return false; ModuleHashMap::const_iterator it = m_arrIncludeModule.begin(); for(; it != m_arrIncludeModule.end(); ++it) { - if (!lstrcmpi(lpApp, it->c_str())) { //匹配排除蟻E + if (!lstrcmpi(lpApp, it->c_str())) { //鍖归厤鎺掗櫎锜籈 return true; } } @@ -1293,7 +1293,7 @@ void CFontLinkInfo::init() if (rc == ERROR_NO_MORE_ITEMS) break; if (rc != ERROR_SUCCESS) break; if (regtype != REG_SZ) continue; - if (lstrcmpi(value2, linep) != 0) continue; //寻找字体链接中字体文件对应的字体脕E + if (lstrcmpi(value2, linep) != 0) continue; //瀵绘壘瀛椾綋閾炬帴涓瓧浣撴枃浠跺搴旂殑瀛椾綋鑴旹 StringCchCopyW(buf, sizeof(buf)/sizeof(buf[0]), name); if (buf[wcslen(buf) - 1] == L')') { //去掉括号 @@ -1330,7 +1330,7 @@ void CFontLinkInfo::init() { //对字体链接柄篥逆向处纴E LPWSTR swapbuff[32]; - memcpy(swapbuff, info[row], 32*sizeof(LPWSTR)); //整个柄源制过来 + memcpy(swapbuff, info[row], 32*sizeof(LPWSTR)); //鏁翠釜鏌勬簮鍒惰繃鏉 for (int i=1; im_bUseCustomLcdFilter = false; //传NULL过来就是关闭自定义过滤器 + pSettings->m_bUseCustomLcdFilter = false; //浼燦ULL杩囨潵灏辨槸鍏抽棴鑷畾涔夎繃婊ゅ櫒 else { - pSettings->m_bUseCustomLcdFilter = true; //否则打开过滤器 - if (!IsBadReadPtr((void*)nValue, sizeof(pSettings->m_arrLcdFilterWeights))) //如果指针有效 - memcpy(pSettings->m_arrLcdFilterWeights, (void*)nValue, sizeof(pSettings->m_arrLcdFilterWeights)); //复制数据 + pSettings->m_bUseCustomLcdFilter = true; //鍚﹀垯鎵撳紑杩囨护鍣 + if (!IsBadReadPtr((void*)nValue, sizeof(pSettings->m_arrLcdFilterWeights))) //濡傛灉鎸囬拡鏈夋晥 + memcpy(pSettings->m_arrLcdFilterWeights, (void*)nValue, sizeof(pSettings->m_arrLcdFilterWeights)); //澶嶅埗鏁版嵁 } - UpdateLcdFilter(); //刷新过滤器 + UpdateLcdFilter(); //鍒锋柊杩囨护鍣 break; case ATTR_HintSmallFont: pSettings->m_bHintSmallFont = !!nValue; @@ -689,7 +689,7 @@ public: pSettings->m_nBitmapHeight = nValue; break; case ATTR_ShadowBuffer: - if (nValue && !IsBadReadPtr((void*)nValue, sizeof(pSettings->m_nShadow))) //指针有效 + if (nValue && !IsBadReadPtr((void*)nValue, sizeof(pSettings->m_nShadow))) //鎸囬拡鏈夋晥 { LPCTSTR szShadow = (LPCTSTR)nValue; CStringTokenizer token; @@ -849,7 +849,7 @@ public: argc = token.Parse(value); } TCHAR buff[LF_FACESIZE+1]; - GetFontLocalName(p, buff); //转换字体名 + GetFontLocalName(p, buff); //杞崲瀛椾綋鍚 CFontIndividual fi(buff); const CFontSettings& fsCommon = pSettings->m_FontSettings; diff --git a/supinfo.h b/supinfo.h index b39ca0d..c1ceb69 100644 --- a/supinfo.h +++ b/supinfo.h @@ -157,7 +157,7 @@ static wstring GetExeName(LPCTSTR lpApp, LPTSTR lpCmd) // DWORD aa=0; // if (GetFileSize(logfile, NULL)==0) // WriteFile(logfile, "\xff\xfe", 2, &aa, NULL); - LPTSTR vlpApp = (LPTSTR)lpApp; //变成可以操作的参数 + LPTSTR vlpApp = (LPTSTR)lpApp; //鍙樻垚鍙互鎿嶄綔鐨勫弬鏁 if (lpApp) { do @@ -172,7 +172,7 @@ static wstring GetExeName(LPCTSTR lpApp, LPTSTR lpCmd) // WriteFile(logfile, ret.c_str(), ret.length()*2, &aa, NULL); // WriteFile(logfile, _T("\n"), 2, &aa, NULL); DWORD fa = GetFileAttributes(ret.c_str()); - if (fa!=INVALID_FILE_ATTRIBUTES && fa!=FILE_ATTRIBUTE_DIRECTORY) //文件是否存在 + if (fa!=INVALID_FILE_ATTRIBUTES && fa!=FILE_ATTRIBUTE_DIRECTORY) //鏂囦欢鏄惁瀛樺湪 { int p = ret.find_last_of(_T("\\")); if (p!=-1) @@ -210,13 +210,13 @@ static wstring GetExeName(LPCTSTR lpApp, LPTSTR lpCmd) int p=0; if ((*lpCmd)==_T('\"')) { - ret.erase(0,1); //删除第一个引号 - p=ret.find_first_of(_T("\"")); //查找下一个引号 + ret.erase(0,1); //鍒犻櫎绗竴涓紩鍙 + p=ret.find_first_of(_T("\"")); //鏌ユ壘涓嬩竴涓紩鍙 } else p=ret.find_first_of(_T(" ")); if (p>0) - ret.resize(p); //获得Cmd里面的文件名 + ret.resize(p); //鑾峰緱Cmd閲岄潰鐨勬枃浠跺悕 // WriteFile(logfile, ret.c_str(), ret.length()*2, &aa, NULL); // WriteFile(logfile, _T("\n"), 2, &aa, NULL); p = ret.find_last_of(_T("\\")); @@ -302,4 +302,4 @@ BOOL _CreateProcessInternalW(HANDLE hToken, LPCTSTR lpApp, LPTSTR lpCmd, LPSECUR #endif return TRUE; -} \ No newline at end of file +} diff --git a/undocAPI.h b/undocAPI.h index 1838ebc..15b8464 100644 --- a/undocAPI.h +++ b/undocAPI.h @@ -93,4 +93,4 @@ static TGetTextFA GetTextFaceAliasW= (TGetTextFA)GetProcAddress(LoadLibrary(_T(" static PFNCreateProcessInternalW CreateProcessInternalW_KernelBase = (PFNCreateProcessInternalW)GetProcAddress(GetModuleHandle(_T("kernelbase.dll")),"CreateProcessInternalW"); static PFNCreateProcessInternalW CreateProcessInternalW = CreateProcessInternalW_KernelBase ? CreateProcessInternalW_KernelBase:(PFNCreateProcessInternalW)GetProcAddress(GetModuleHandle(_T("kernel32.dll")),"CreateProcessInternalW"); //static PFNIsWow64Process IsWow64Process=(PFNIsWow64Process)GetProcAddress(LoadLibrary(L"Kernel32.dll"), "IsWow64Process"); -static PFNGetFontResourceInfo GetFontResourceInfo=(PFNGetFontResourceInfo)GetProcAddress(LoadLibrary(L"gdi32.dll"), "GetFontResourceInfoW"); \ No newline at end of file +static PFNGetFontResourceInfo GetFontResourceInfo=(PFNGetFontResourceInfo)GetProcAddress(LoadLibrary(L"gdi32.dll"), "GetFontResourceInfoW"); diff --git a/wow64layer.h b/wow64layer.h index 988b6c0..413f538 100644 --- a/wow64layer.h +++ b/wow64layer.h @@ -226,4 +226,4 @@ BOOL XP_GetThreadWow64Context( CloseHandle( Process ); return TRUE; -} \ No newline at end of file +}