static IEnumerable <string> ResolveFontConfig() { var config = fcConfig.Value; using (var pattern = FcPatternCreate()) using (var os = FcObjectSetHandle.Create("family", "style", "file")) using (var fs = FcFontList(config, pattern, os)) { var fset = fs.Read(); for (int index = 0; index < fset.nfont; index++) { var font = Marshal.ReadIntPtr(fset.fonts, index * Marshal.SizeOf <IntPtr>()); var family = GetString(font, "family"); var style = GetString(font, "style"); var file = GetString(font, "file"); if (family is null || style is null || file is null) { continue; } yield return(file); } } }
[DllImport(libfontconfig)] public static extern FcFontSetHandle FcFontList(IntPtr config, FcPatternHandle pattern, FcObjectSetHandle os);
[DllImport(libfontconfig)] public static extern int FcObjectSetAdd(FcObjectSetHandle os, [MarshalAs(UnmanagedType.LPStr)] string obj);