728x90
반응형
728x170
■ Fonts 클래스의 GetTypefaces 정적 메소드를 사용해 리소스로 포함된 폰트의 타입페이스를 나열하는 방법을 보여준다.
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="800"
Height="600"
Title="TestProject"
FontFamily="나눔고딕코딩"
FontSize="16">
<TextBlock Name="textBlock"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="24" />
</Window>
▶ MainWindow.xaml.cs
using System;
using System.Text;
using System.Windows;
using System.Windows.Media;
namespace TestProject
{
/// <summary>
/// 메인 윈도우
/// </summary>
public partial class MainWindow : Window
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 생성자 - MainWindow()
/// <summary>
/// 생성자
/// </summary>
public MainWindow()
{
InitializeComponent();
StringBuilder stringBuilder = new StringBuilder();
foreach(Typeface typeface in Fonts.GetTypefaces(new Uri("pack://application:,,,/"), "./"))
{
stringBuilder.AppendLine($"{typeface.FontFamily}, {typeface.Weight}, {typeface.Style}");
}
this.textBlock.Text = stringBuilder.ToString();
}
#endregion
}
}
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] Hyperlink 클래스 : MouseEnter/MouseLeave 이벤트를 사용해 마우스 진입시 밑줄 표시하기 (0) | 2022.12.16 |
---|---|
[C#/WPF] Glyphs 엘리먼트 : Indices 속성 사용하기 (0) | 2022.12.15 |
[C#/WPF] Glyphs 엘리먼트 사용하기 (0) | 2022.12.15 |
[C#/WPF] FontSizeConverter 클래스 : ConvertFromString 메소드를 사용해 폰트 크기 구하기 (0) | 2022.12.15 |
[C#/WPF] 리소스 폰트 라이브러리 사용하기 (0) | 2022.12.15 |
[C#/WPF] Fonts 클래스 : GetFontFamilies 정적 메소드를 사용해 리소스 폰트 나열하기 (0) | 2022.12.15 |
[C#/WPF] 리소스 폰트 사용하기 (코드 사용) (0) | 2022.12.15 |
[C#/WPF] 리소스 폰트 사용하기 (0) | 2022.12.15 |
[C#/WPF/.NET6] Typography 엘리먼트 : NumeralAlignment 첨부 속성을 사용해 너비 정렬 설정하기 (0) | 2022.12.15 |
[C#/WPF/.NET6] Typography 엘리먼트 : NumeralStyle 첨부 속성을 사용해 이전 스타일 숫자 표시하기 (0) | 2022.12.15 |
댓글을 달아 주세요