项目中,需要实现字体相关操作,收集了一些相关参数,可以引用的。

 

using System.Collections.Generic;

using System.Drawing;

using System.Drawing.Text;

using System.Linq;

using System.Net;

using System.Net.Http;

using System.Web.Http;

namespace Insus.NET.APIs

{

public class FontController : ApiController

{

[HttpPost]

public IEnumerable FontFamilys()

{

InstalledFontCollection fonts = new InstalledFontCollection();

foreach (FontFamily font in fonts.Families)

{

yield return font.Name;

}

}

[HttpPost]

public IEnumerable FontStyles()

{

return new List() { "normal", "italic", "oblique", "inherit", "initial", "unset" };

}

[HttpPost]

public IEnumerable FontSizes()

{

return new List() { "larger", "smaller", "xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "inherit", "initial", "unset" };

}

[HttpPost]

public IEnumerable FontWeights()

{

return new List() { "normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900", "inherit", "initial", "unset" };

}

[HttpPost]

public IEnumerable FontVariants()

{

return new List() { "normal", "small-caps", "inherit", "initial", "unset" };

}

[HttpPost]

public IEnumerable LineHeights()

{

return new List() { "normal", "inherit", "initial", "unset" };

}

[HttpPost]

public IEnumerable FontUnits()

{

return new List() { "%", "in", "cm", "mm", "em", "rem", "ex", "pt", "pc", "px" };

}

}

}

Source Code

 

查看原文