2010-02-18 2 views
3

내 .net 3.0 Winforms 응용 프로그램에 비표준 글꼴을 사용하고 싶습니다..net winforms 응용 프로그램과 함께 글꼴을 어떻게 묶을 수 있습니까?

이 글꼴은 내 사용자의 컴퓨터 중 일부에 설치 될 수 있지만 일부 글꼴에는 분명히 나타나지 않습니다.

내 프로그램으로 글꼴을 어떻게 배송 할 수 있습니까? 글꼴을 설치해야합니까? 그렇다면 관리자 권한이 부족하여 문제가 될 수 있습니까?

+0

프로그램은 어떻게 배송됩니까? 압축 파일? 설치 프로그램? 양자 모두? – Oded

+0

우리는 클라이언트가 선호하는 것에 따라 두 가지 방법 모두를 지원합니다. 즉, 우리는 쉽게 클라이언트 시작시 글꼴 등록 코드를 직접 실행할 수 있습니다 (물론 관리자 권한은 필요하지 않습니다) – Brann

답변

3

대상 시스템에 등록 된 글꼴을 가져 오려면 설치 프로그램을 사용해야합니다. 하지만 GDI +가 private fonts을 지원할 필요는 없습니다.

1

This page은 어떻게 winforms 프로젝트에 글꼴을 포함시키는 방법을 자세히 설명합니다.

+0

위대한 기사, 감사합니다 – docesam

3

다음은 내가 작성한 블로그 기사로, 응용 프로그램에 글꼴을 리소스로 포함하는 방법을 보여줍니다 (dll 가져 오기 필요 없음 :).

Embedding Fonts in your .Net Application

여기에 모든 마법이 발생 어디 작성하는 클래스입니다. 블로그 기사에는 지침과 사용 예가 포함되어 있습니다.

using System.Drawing; 
using System.Drawing.Text; 
using System.Runtime.InteropServices; 
namespace EmbeddedFontsExample.Fonts 
{ 
    public class ResFonts 
    { 
     private static PrivateFontCollection sFonts; 
     static ResFonts() 
     { 
      sFonts = new PrivateFontCollection(); 
      // The order the fonts are added to the collection 
      // should be the same as the order they are added 
      // to the ResFontFamily enum. 
      AddFont(MyFonts.Consolas); 
     } 
     private static void AddFont(byte[] font) 
     { 
      var buffer = Marshal.AllocCoTaskMem(font.Length); 
      Marshal.Copy(font, 0, buffer, font.Length); 
      sFonts.AddMemoryFont(buffer, font.Length); 
     } 
     public static Font Create(
      ResFontFamily family, 
      float emSize, 
      FontStyle style = FontStyle.Regular, 
      GraphicsUnit unit = GraphicsUnit.Pixel) 
     { 
      var fam = sFonts.Families[(int)family]; 
      return new Font(fam, emSize, style, unit); 
     } 
    } 
    public enum ResFontFamily 
    { 
     /// <summary>Consolas</summary> 
     Consolas = 0 
    } 
} 
+0

글꼴을 일반적으로 리소스로 추가했다고 가정하면 내가 바꾸는 것은'AddFont (MyFonts.Consolas)'는'AddFont (Resources.Consolas)'여야합니다. – nathanchere

+5

링크가 죽었습니다. – Michael

+0

링크가 죽었습니다! – docesam

관련 문제