簡體   English   中英

如何獲取 Windows 資源管理器使用的默認字體 (TTF)?

[英]How do I get the default font(TTF) Windows Explorer is using?

使用非英文字符的國家/地區使用支持其語言的字體。 中國 Windows 用戶使用中文字體,韓國用戶使用韓文字體。

我想要做的是顯示一個任意目錄,但我不知道哪個字符串會進入該目錄。 它可能是英文的,也可能是包含中文或日文的路徑。

在我正在編寫的程序中,我需要讀取與此路徑匹配的 ttf 文件並打印文本。

我想如果我能知道用戶PC上安裝的Windows資源管理器中使用的字體和字體支持的語言,問題就可以解決。

用代碼表示,它看起來像這樣。

FontInfo f = System.Control.Desktop.captionFont;

const char *ttfPath = f.ttfPath;
// ttfPath => C:\windows\Font\myFont.ttf

const char *language = f.design;
// ttfPath => "Korean" or "Thai"

我寫下我是如何找到它的。 如果你有更好的方法,請分享。

  1. 檢索系統字體系列名稱。

    按鈕 btncsharp = new Button(); btncsharp.Content = "SystemFonts"; btncsharp.Background = SystemColors.ControlDarkDarkBrush; btncsharp.FontSize = SystemFonts.IconFontSize; btncsharp.FontWeight = SystemFonts.MessageFontWeight; btncsharp.FontFamily = SystemFonts.CaptionFontFamily; cv1.Children.Add(btncsharp);

  2. 通過字體系列名稱注冊表檢索 ttf 文件名:\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM