在选择框中列出所有 Font Awesome 图标
List all Font Awesome Icons in selectbox
我想在向我的项目添加 link 时让用户 select 一个 Font Awesome 图标。有没有办法输出一个 select 框,其中包含所有可用的 Font Awesome 图标和名称?
我正在使用 C#.NET,也许这有帮助。
从位于 https://github.com/FortAwesome/Font-Awesome/blob/master/scss/_variables.scss
的 SCSS 文件中获取名称
using System.Web.Compilation;
using System.Collections;
var dir = Directory.GetFiles(string.Format("{0}/The folder where the font-awesome file is in", HostingEnvironment.ApplicationPhysicalPath), "font-awesome.css", SearchOption.AllDirectories); var dir1 = dir.ToArray(); var tt = new List<string>();
foreach (var file in dir)
{
using (var reader = new System.IO.StreamReader(file))
{
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
if (line.Contains(":before"))
{
var index = line.IndexOf(":before"); var text = line.Substring(1, (index - 1)); tt.Add(text);
}
}
reader.Close();
}
}
ViewData["fontList"] = tt.AsEnumerable();
我用 C# FontAwesome 图标列表制作了一个 git 集线器回购协议
给你
https://github.com/McHeff/FontAwesome_IconList/blob/main/MyFontAwesomeIconsList
至于你想如何渲染它,那取决于你。你问过使用选择框,我假设它是一个下拉列表,我只是担心性能,因为这个列表中有超过 6000 个图标。
我想在向我的项目添加 link 时让用户 select 一个 Font Awesome 图标。有没有办法输出一个 select 框,其中包含所有可用的 Font Awesome 图标和名称?
我正在使用 C#.NET,也许这有帮助。
从位于 https://github.com/FortAwesome/Font-Awesome/blob/master/scss/_variables.scss
的 SCSS 文件中获取名称using System.Web.Compilation;
using System.Collections;
var dir = Directory.GetFiles(string.Format("{0}/The folder where the font-awesome file is in", HostingEnvironment.ApplicationPhysicalPath), "font-awesome.css", SearchOption.AllDirectories); var dir1 = dir.ToArray(); var tt = new List<string>();
foreach (var file in dir)
{
using (var reader = new System.IO.StreamReader(file))
{
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
if (line.Contains(":before"))
{
var index = line.IndexOf(":before"); var text = line.Substring(1, (index - 1)); tt.Add(text);
}
}
reader.Close();
}
}
ViewData["fontList"] = tt.AsEnumerable();
我用 C# FontAwesome 图标列表制作了一个 git 集线器回购协议
给你
https://github.com/McHeff/FontAwesome_IconList/blob/main/MyFontAwesomeIconsList
至于你想如何渲染它,那取决于你。你问过使用选择框,我假设它是一个下拉列表,我只是担心性能,因为这个列表中有超过 6000 个图标。