2011-04-13 3 views
4

레이블, 텍스트 상자 및 페인트 이벤트에서 드로잉 할 때 모두 개방형 글꼴을 사용해 보았습니다. 그러나 그것은 효과가 없습니다. Open Type 글꼴을 작동시키는 방법이 있습니까?winforms에서 otf 글꼴을 사용할 수 있습니까?

+0

글꼴 textFont = 새로운 Font ("굴림 굵게", 18F)를; g.DrawString ("12", textFont, solidbrush, 109, 40); 왜 이런 식으로 사용할 수 없어요. –

+0

할 수는 있지만 트루 타입 글꼴에서만 작동합니다. 나는. Myriad Pro는 작동하지 않습니다. – Bildsoe

+0

어떤 방식으로 작동하지 않습니까? –

답변

8

Winforms에서 가능하지 않지만 GDI +는 트루 타입 글꼴 만 지원합니다. OpenType 지원을 받으려면 WPF로 이동해야합니다. 당신이 WPF에서하는 것처럼

4

당신은 System.Windows.Media 네임 스페이스를 사용할 수 있으며, 여기에 당신은 예를 들어 있습니다

public static string GetFontList(String ElementSeparator) 
    { 
     string r = ""; 

     // WPF incl Adobe and OpenType 
     foreach (System.Windows.Media.FontFamily fontFam in System.Windows.Media.Fonts.SystemFontFamilies) 
     { 
      r += fontFam.Source; 
      r += ElementSeparator; 
     } 

     // True type, incl Type face names e.g. Arial Rounded MT Bold 
     foreach (System.Drawing.FontFamily f in System.Drawing.FontFamily.Families) 
     { 
      if(!r.Contains(f.Name)) 
      { 
      r += f.Name; 
      r += ElementSeparator; 
      } 
     }    

     return r; 
    } 
관련 문제