728x90
728x170
■ C# 코드를 사용해 리소스로 포함된 폰트를 사용하는 방법을 보여준다.
▶ 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">
<Grid>
<Label Name="label"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="48"
FontWeight="Bold"
Content="테스트 문자열 입니다." />
</Grid>
</Window>
▶ MainWindow.xaml.cs
using System;
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();
this.label.FontFamily = new FontFamily(new Uri("pack://application:,,,/", UriKind.Absolute), "./#독립서체 윤봉길 GS");
}
#endregion
}
}
728x90
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] Glyphs 엘리먼트 사용하기 (0) | 2022.12.15 |
---|---|
[C#/WPF] FontSizeConverter 클래스 : ConvertFromString 메소드를 사용해 폰트 크기 구하기 (0) | 2022.12.15 |
[C#/WPF] 리소스 폰트 라이브러리 사용하기 (0) | 2022.12.15 |
[C#/WPF] Fonts 클래스 : GetTypefaces 정적 메소드를 사용해 리소스 타입페이스 나열하기 (0) | 2022.12.15 |
[C#/WPF] Fonts 클래스 : GetFontFamilies 정적 메소드를 사용해 리소스 폰트 나열하기 (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 |
[C#/WPF/.NET6] Typography 엘리먼트 : Fraction 첨부 속성을 사용해 분수 숫자 스타일 설정하기 (0) | 2022.12.15 |
[C#/WPF/.NET6] Typography 엘리먼트 : HistoricalForms 첨부 속성을 사용해 역사적 합자 글리프 설정하기 (0) | 2022.12.15 |