addfont
RemoveFontResource(L"C:\\Windows\\Fonts\\simfang.ttf");
AddFontResource(L"C:\\Windows\\Fonts\\simfang.ttf");
int r = AddFontResource(TEXT("C:\\WINDOWS\\FONTS\\simfang.ttf"));
PostMessage(HWND_BROADCAST, WM_FONTCHANGE, NULL, NULL);
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, NULL, NULL);
???
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | // flush.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <stdio.h> #include <Windows.h> #include <iostream> #include <fstream> #include <vector> #include <stdlib.h> #include <string> using namespace std; int initLogFont( LOGFONT& lf , const wchar_t * familyName, int fontSize ) { lf.lfHeight = fontSize; lf.lfWidth = 0; lf.lfEscapement = 0; lf.lfOrientation = 0; lf.lfWeight = 0; lf.lfItalic = 0; lf.lfUnderline = 0; lf.lfStrikeOut = 0; lf.lfCharSet = 1; lf.lfOutPrecision = 0; lf.lfClipPrecision = 0; lf.lfQuality = 0; lf.lfPitchAndFamily = 0; wcscpy( lf.lfFaceName, familyName ); return 0; } void loadBinaryFile( std::vector< char >& vec, std::string filePath ){ std::ifstream file( filePath, std::ifstream::binary ); if ( !file.eof() && !file.fail() ) { file.seekg( 0, std::ios_base::end ); std::streampos fileSize = file.tellg(); vec.resize( fileSize ); file.seekg( 0, std::ios_base::beg ); file.read( &vec[0], fileSize ); } } int _tmain( int argc, _TCHAR* argv[]) { std::vector< char > fontData; loadBinaryFile( fontData, "C:\\Windows\\Fonts\\simfang.ttf" ); //Add font to the system (so 'CreateFontIndirect' is aware of the font) DWORD count = 0; HANDLE fontHandle = AddFontMemResourceEx( ( void * )fontData.data(), fontData.size(), 0, &count ); if ( !fontHandle ) { std::cout << "Failed 'AddFontMemResourceEx' operation" << std::endl; return 0; } LOGFONT lf; initLogFont( lf, L "FangSong" , 10000000 ); //ask windows for font HFONT hfont = CreateFontIndirect( &lf ); if ( !hfont ) { std::cout << "Failed 'CreateFontIndirect' operation" << std::endl; return 0; } //initialise DC HDC displayDC = GetDC( 0 ); HDC hdc = CreateCompatibleDC( displayDC ); HGDIOBJ oldobj = SelectObject( hdc, hfont ); //ask DC for metrics TEXTMETRIC textMetrics; bool res = GetTextMetrics( hdc, &textMetrics ); if ( !res ) { std::cout << "Failed 'GetTextMetrics' operation" << std::endl; return 0; } std::cout << "textMetrics.tmHeight : " << textMetrics.tmHeight << std::endl; std::cout << "textMetrics.tmDescent : " << textMetrics.tmDescent << std::endl; std::cout << "textMetrics.tmAscent : " << textMetrics.tmAscent << std::endl; system ( "PAUSE" ); return 0; } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2019-06-24 rabbitmq exchange
2019-06-24 rabbitmq队列
2019-06-24 Fastdfs文件存储系统
2019-06-24 rabbitmq的一些坑
2019-06-24 rabbitmq订阅模式
2019-06-24 qt如何去掉文件路径最后一个反斜杠的内容
2019-06-24 rabbitmq队列消息持久化