.NET/Windows API for .NET

AddFontResource - Font(글꼴) 추가하기

클리엘 2019. 8. 9. 16:21
728x90

AddFontResource함수는 현재 System에 지정된 Font(글꼴)를 추가시키는 함수입니다.

Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Integer

▶VB.NET 선언

[DllImport("gdi32")]
public static extern int AddFontResource(string lpFileName);

▶C# 선언

AddFontResource(path)

▶VB.NET 호출

AddFontResource(path);

▶C# 호출


함수의 path인수에는 추가할 Font File을 지정합니다. 예를 들어 abc.TTF(true type) 라는 글꼴 File이 C:\ 에 위치해 있을경우 다음과 같이 함수를 호출할 수 있습니다.

AddFontResource("C:\abc.TTF")

▶VB.NET 호출

AddFontResource("C:\\abc.TTF");

▶C# 호출


글꼴이 추가되면 다른 Program에서도 추가된 글꼴을 사용할 수 있게 됩니다. 하지만 글꼴이 추가된 이후 해당 글꼴이 다른 위치로 이동되거나 삭제되는 일은 없어야 합니다.

AddFontResource함수가 성공적으로 글꼴을 추가시키면 추가된 글꼴의 수를 반환하지만 실패한 경우 0을 반환합니다.

728x90