SixLabors.Fonts.MonoGame
Add color parameter to SpriteBatch.DrawText
조심하십시오. 그렇기 때문에이 리포지기가 보관 된 이유입니다.
.NET 6 이상으로 단일 이름에 대한 비공식 포트.
이것은 창에서만 테스트되었습니다. 다른 시스템에서 작동해야하지만 그렇지 않은 경우 문제를 열어주십시오. 이 라이브러리는 새롭고 최적화되지 않았습니다. 풀 요청을 환영합니다!
전제는 간단합니다. 우리는 FontEngine 가지고 있으며, 우리는 글꼴을 저장하는 데 사용합니다. 그런 다음 FontEngine 사용하여로드 된 글꼴을 얻습니다.
// Load up our very epic fonts!!!
FontEngine engine = new ( ) ;
engine . LoadFont ( "path/to/some-cool-font.ttf" ) ;
// The font name from the truetype file is what we need to use here.
MonoGameFont font = engine . GetFont ( "some-cool-font" , 24f ) ;
// We've got the font! Now we can draw.
// We have an extension method on SpriteBatch just for that.
// It's in SixLabors.Fonts.MonoGame.Utils
batch . DrawText ( font , "Hello, world!" , new Vector2 ( 10 , 10 ) , Color . White ) ;아마도, 당신은 하나의 글꼴이 있고 당신은 그 이름을 계속해서 계속해서 입력하고 싶지 않습니다. 또는 게임에 MOD 시스템이 있고 모드는 자체 글꼴로로드하여 전체 게임의 기본값으로 사용할 수 있습니다. 따라서 기본 글꼴 이름을 수정할 수 있습니다.
// We are using the code from the above example.
// We're setting the DefaultFontName to the font we'll be using
engine . DefaultFontName = "some-cool-font" ;
// Now we can forget about the name at all!
MonoGameFont defaultFont = engine . GetDefaultFont ( 24f ) ; Glyphs가 누락 된 경우 SixLabors.Fonts는 폴백 글꼴을 제공합니다. 이 라이브러리도 그들을 구현합니다. FontEngine 의 FallbackFontFamilies 목록에 추가하여 폴백 글꼴을 추가 할 수 있습니다.
// We are using the code from the above examples.
fontEngine . FallbackFontFamilies . Add ( font ) ; FontEngine 생성자의 addSystemFonts True (기본값)로 설정된 경우 글꼴 Arial , Courier 및 Helvetica 폴백 글꼴 목록에 추가됩니다.