Ejemplo n.º 1
0
        /*
         * int CALLBACK EnumFontFamProc(
         * const LOGFONT FAR* lpelf,
         * const TEXTMETRIC FAR* lpntm,
         * DWORD FontType,
         * LPARAM lParam
         * );
         */
        /// <summary>
        ///
        /// </summary>
        /// <param name="lpelfe">IntPtr LOGFONT structure that contains information about the logical attributes of the font</param>
        /// <param name="lpntme">structure that contains information about the physical attributes of the font, if the font is a TrueType font. If the font is not a TrueType font, this parameter points to a TEXTMETRIC structure</param>
        /// <param name="FontType">[in] DWORD that specifies the type of the font:
        /// DEVICE_FONTTYPE
        /// RASTER_FONTTYPE
        /// TRUETYPE_FONTTYPE</param>
        /// <param name="lParam">Pointer to the application-defined data passed by the EnumFontFamilies function</param>
        /// <returns>Nonzero continues enumeration. Zero stops enumeration</returns>
        private int EnumFontFamiliesExProc(IntPtr lpelfe, IntPtr lpntme, EnumFontsType FontType, int lParam)
        {
            LOGFONT logFont = (LOGFONT)Marshal.PtrToStructure(lpelfe, typeof(LOGFONT));

            if (logFont.lfWeight == lfWeightType.FW_REGULAR && logFont.lfItalic == 0)
            {
                //we dont like duplicate names
                if (!fontNames.Contains(logFont.lfFaceName))
                {
                    fontNames.Add(logFont.lfFaceName);
                }

                System.Diagnostics.Debug.WriteLine(logFont.lfFaceName);
            }
            // Non-zero return continues enumerating
            return(1);
        }
Ejemplo n.º 2
0
        /*
        int CALLBACK EnumFontFamProc(
          const LOGFONT FAR* lpelf, 
          const TEXTMETRIC FAR* lpntm, 
          DWORD FontType, 
          LPARAM lParam
        );
        */
        /// <summary>
        /// 
        /// </summary>
        /// <param name="lpelfe">IntPtr LOGFONT structure that contains information about the logical attributes of the font</param>
        /// <param name="lpntme">structure that contains information about the physical attributes of the font, if the font is a TrueType font. If the font is not a TrueType font, this parameter points to a TEXTMETRIC structure</param>
        /// <param name="FontType">[in] DWORD that specifies the type of the font:
        /// DEVICE_FONTTYPE
        /// RASTER_FONTTYPE
        /// TRUETYPE_FONTTYPE</param>
        /// <param name="lParam">Pointer to the application-defined data passed by the EnumFontFamilies function</param>
        /// <returns>Nonzero continues enumeration. Zero stops enumeration</returns>
        private int EnumFontFamiliesExProc(IntPtr lpelfe, IntPtr lpntme, EnumFontsType FontType, int lParam)
        {
            LOGFONT logFont = (LOGFONT)Marshal.PtrToStructure(lpelfe, typeof(LOGFONT));

            if (logFont.lfWeight == lfWeightType.FW_REGULAR && logFont.lfItalic==0)
            {
                //we dont like duplicate names
                if(!fontNames.Contains(logFont.lfFaceName))
                    fontNames.Add(logFont.lfFaceName);

                System.Diagnostics.Debug.WriteLine(logFont.lfFaceName);
            }
            // Non-zero return continues enumerating
            return 1;
        }