Beispiel #1
0
        /// <summary>
        /// Get the name of the default font for the given language tag.
        /// </summary>
        /// <param name="lang">ISO 3066 tag for the language (e.g., "en", "es", "zh-CN", etc.)</param>
        /// <returns>Name of the font, or <c>null</c> if not found.</returns>
        public static string GetFontNameForLanguage(string lang)
        {
            if (MiscUtils.IsWindows)
            {
                throw new PlatformNotSupportedException();
            }

            string fontName;

            if (m_mapLangToFont.TryGetValue(lang, out fontName))
            {
                return(fontName);
            }
            IntPtr pattern = FcPatternCreate();
            int    isOk    = FcPatternAddString(pattern, FC_LANG, lang);

            if (isOk == 0)
            {
                FcPatternDestroy(pattern);
                return(null);
            }
            isOk = FcConfigSubstitute(IntPtr.Zero, pattern, FcMatchKind.FcMatchPattern);
            if (isOk == 0)
            {
                FcPatternDestroy(pattern);
                return(null);
            }
            FcDefaultSubstitute(pattern);
            FcResult result;
            IntPtr   fullPattern = FcFontMatch(IntPtr.Zero, pattern, out result);

            if (result != FcResult.FcResultMatch)
            {
                FcPatternDestroy(pattern);
                FcPatternDestroy(fullPattern);
                return(null);
            }
            FcPatternDestroy(pattern);
            IntPtr   res;
            FcResult fcRes = FcPatternGetString(fullPattern, FC_FAMILY, 0, out res);

            if (fcRes == FcResult.FcResultMatch)
            {
                fontName = Marshal.PtrToStringAuto(res);
                m_mapLangToFont.Add(lang, fontName);
            }
            FcPatternDestroy(fullPattern);
            return(fontName);
        }
Beispiel #2
0
 public FcPattern Match(FcConfig config, out FcResult result)
 {
     return(new FcPattern(Native.FcFontMatch(config.Handle, Handle, out result)));
 }
Beispiel #3
0
 public static extern System.IntPtr FcFontMatch(System.IntPtr config, System.IntPtr p, out FcResult result);
Beispiel #4
0
 static extern IntPtr FcFontMatch(IntPtr config, IntPtr pattern, out FcResult result);
Beispiel #5
0
		static extern IntPtr FcFontMatch(IntPtr config, IntPtr pattern, out FcResult result);
Beispiel #6
0
 private static extern IntPtr FcFontMatch_Base(IntPtr config, IntPtr pattern, out FcResult result);