src/Demo/Classes/FontLoader.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System.Drawing.Text;
using System.Drawing;
using System.Runtime.InteropServices;
using System;
namespace XRails_LoginUI.Demo.Classes
{
internal sealed class FontLoader
{
/// <summary>
/// Provides a collection of font families built from font files that
/// are provided by the client application.
/// </summary>
private static PrivateFontCollection fontCollection;
private static void LoadFontIntoMemory()
{
try
{
// Add a font provided by the client application without installing it
// SNIPPET CREDIT: Shibumi
fontCollection = new PrivateFontCollection();
var fontLength = Properties.Resources.Raleway_Light.Length;
var fontData = Properties.Resources.Raleway_Light;
var memoryPointer = Marshal.AllocCoTaskMem(fontLength);
Marshal.Copy(fontData, 0, memoryPointer, fontLength);
// Add the font contained in system memory to the PrivateFontCollection
fontCollection.AddMemoryFont(memoryPointer, fontLength);
Marshal.FreeCoTaskMem(memoryPointer);
}
catch (Exception up)
{
up = new Exception(up.Message);
throw up;
}
}
/// <summary>
/// Sets the custom font that was defined in <see cref="LoadFontIntoMemory()"/>.
/// </summary>
///
/// <param name="size">
/// The em-size of the font measured in the units specified by the
/// <paramref name="unit"/> property.
/// </param>
///
/// <param name="style">
/// Specifies style information applied to text.
/// </param>
///
/// <param name="unit">
/// Specifies the unit of measure for the given data.
/// </param>
///
/// <param name="gdiCharSet">
/// A byte value that specifies the GDI character set that the font uses.
/// The default is value 1.
后面还有 10 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。