在Visual Basic中更改字体 [英] Changing fonts in Visual Basic

查看:149
本文介绍了在Visual Basic中更改字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我当前使用Segoe UI字体作为默认文本字体.如果用户决定使用我的应用程序而尚未在其系统上安装Segoe UI字体,则该字体会自动更改,但是使用的字体却不适用于特定的应用程序.

我想知道是否可以在我的应用程序中使用Segoe UI字体,以便最终用户在安装或未安装字体的情况下都能看到它,或者是否有一种方法可以检测用户是否已安装Segoe UI字体,如果不更改为更合适的字体?

谢谢
问候
威廉



..............

好的,如果说要这样做,那么William,您是否违反Microsoft的任何条款,因为我使用的是Windows XP和更低版本的操作系统上未安装的Microsoft Segoe UI字体?

谢谢:-)
问候
William

In my application, I am currently using the Segoe UI font as my default text font. If a user decides to use my application and hasn''t got the Segoe UI font installed on their system that the font is automatically changed, however its a font that is used instead doesn''t look right for the particular application.

I wonder if there is a way of using the Segoe UI font with my application so the end users see it with or without the font installed or is there a way of detecting whether the user has the Segoe UI font installed and if not change it to a more suitable font?

Thanks
Regards
William



..............

Okay, so say if you were to do that William, would you be breaking any terms of Microsoft, since I am using Microsoft''s Segoe UI font which is not installed on Windows XP and below OS?

Thanks :-)
Regards
William

推荐答案

公共函数CheckFontPresence(ByVal s_fontname As String)As Integer
将所有字体变暗为新的InstalledFontCollection
对于所有s_font作为FontFamily在所有字体中.Families
如果UCase(s_font.Name)= UCase(s_fontname)那么
''找到了想要的字体
返回1
如果结束
下一个
返回0''没有匹配
结束功能
Public Function CheckFontPresence(ByVal s_fontname As String) As Integer
Dim allfonts As New InstalledFontCollection
For Each s_font As FontFamily In allfonts.Families
If UCase(s_font.Name) = UCase(s_fontname) Then
''found the wanted font
Return 1
End If
Next
Return 0 ''no match
End Function


因此,tiggerc让您开始检查是否安装了字体,但这并不是您真正的问题.

在这里看看:

将字体嵌入到您的应用程序中. [
So, tiggerc gave you a start to check if your font is installed, but that wasn''t really your question.

Have a look here:

Embedding fonts into your application.[^]

What that page shows you is that you can embed your font as a Resource, and then it gives you code on how to add the font to the user''s system.

You can use tiggerc''s answer, though, to first check to see if you need to add it. Then, if you do, then, you''ll need to set the fonts to the first font in your newly created PrivateFontCollection.

Not the most direct way, but that''s how I know to do it.


这篇关于在Visual Basic中更改字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆