コード例 #1
0
		static FontFamily() {
			Container = new awt.Container();
			_installedFonts = new InstalledFontCollection();
			_genericMonospace = new FontFamily(GenericFontFamilies.Monospace);
			_genericSansSerif = new FontFamily(GenericFontFamilies.SansSerif);
			_genericSerif = new FontFamily(GenericFontFamilies.Serif);
		}
コード例 #2
0
	// Constructors.
	public FontFamily(GenericFontFamilies genericFamily)
			{
				this.genericFamily = genericFamily;
				this.fontCollection = null;
				this.metricsStyle = (FontStyle)(-1);
				switch(genericFamily)
				{
					case GenericFontFamilies.Serif:
					default:
					{
						this.name = "Times New Roman";
					}
					break;

					case GenericFontFamilies.SansSerif:
					{
						this.name = "Microsoft Sans Serif";
					}
					break;

					case GenericFontFamilies.Monospace:
					{
						this.name = "Courier New";
					}
					break;
				}
			}
コード例 #3
0
ファイル: CharmapGrid.cs プロジェクト: dbbotkin/PrimeComm
 public void SetFontCollection(FontCollection fontCollection)
 {
     if (fontCollection != null && fontCollection.Families.Length > 0)
     {
         _fontCollection = fontCollection;
         _fontSize = (int)Settings.Default.EditorFontSize;
     }
 }
コード例 #4
0
        public FormCharmapWindow(FormEditor parent, FontCollection fontCollection)
        {
            _parent = parent;
            InitializeComponent();

            charmap.SetFontCollection(fontCollection);
            charmap.SelectedChar = (char)0;
            charmap.CellCountChanged += charmap_CellCountChanged;
            charmap.SelectedCharChanged += charmap_SelectedCharChanged;
            comboBoxPage.SelectedIndexChanged += comboBoxPage_SelectedIndexChanged;
        }
コード例 #5
0
ファイル: FormHelpWindow.cs プロジェクト: dbbotkin/PrimeComm
        public FormHelpWindow(string commands = null, FontCollection fontCollection = null)
        {
            _commands = commands;

            InitializeComponent();

            if (fontCollection != null && fontCollection.Families.Length > 0)
                textBoxHelp.Font = new Font(fontCollection.Families[0], (int)Settings.Default.EditorFontSize);

            _reference = new List<ReferenceDefinition>();
        }
コード例 #6
0
        private void CreateFontFamily(string name, FontCollection fontCollection)
        {
            IntPtr zero = IntPtr.Zero;
            IntPtr handle = (fontCollection == null) ? IntPtr.Zero : fontCollection.nativeFontCollection;
            int status = SafeNativeMethods.Gdip.GdipCreateFontFamilyFromName(name, new HandleRef(fontCollection, handle), out zero);
            if (status != 0)
            {
                if (!this.createDefaultOnFail)
                {
                    switch (status)
                    {
                        case 14:
                            throw new ArgumentException(System.Drawing.SR.GetString("GdiplusFontFamilyNotFound", new object[] { name }));

                        case 0x10:
                            throw new ArgumentException(System.Drawing.SR.GetString("GdiplusNotTrueTypeFont", new object[] { name }));
                    }
                    throw SafeNativeMethods.Gdip.StatusException(status);
                }
                zero = GetGdipGenericSansSerif();
            }
            this.SetNativeFamily(zero);
        }
コード例 #7
0
	public FontFamily(String name, FontCollection fontCollection)
			{
				if(name == null)
				{
					throw new ArgumentNullException("name");
				}
				this.name = name;
				this.fontCollection = fontCollection;
				this.metricsStyle = (FontStyle)(-1);

				// Intuit the generic family based on common font names.
				if(String.Compare(name, "Times", true) == 0 ||
				   String.Compare(name, "Times New Roman", true) == 0)
				{
					this.genericFamily = GenericFontFamilies.Serif;
				}
				else if(String.Compare(name, "Helvetica", true) == 0 ||
				        String.Compare(name, "Helv", true) == 0 ||
				        String.Compare
							(name, "Microsoft Sans Serif", true) == 0 ||
				        String.Compare(name, "Arial", true) == 0 ||
						(name.Length >= 6 &&
				        	String.Compare(name, 0, "Arial ", 0, 6, true) == 0))
				{
					this.genericFamily = GenericFontFamilies.SansSerif;
				}
				else if(String.Compare(name, "Courier", true) == 0 ||
				        String.Compare(name, "Courier New", true) == 0)
				{
					this.genericFamily = GenericFontFamilies.Monospace;
				}
				else
				{
					this.genericFamily = GenericFontFamilies.Serif;
				}
			}
コード例 #8
0
        private void CreateNativeFontFamily(string name, FontCollection fontCollection, bool createDefaultIfNotExists)
        {
            if (fontCollection != null)
            {
                if (fontCollection.nativeFontDescriptors.ContainsKey (name))
                    nativeFontDescriptor = fontCollection.nativeFontDescriptors [name];

                if (nativeFontDescriptor == null && createDefaultIfNotExists)
                {
                    nativeFontDescriptor = new CTFontDescriptor (SANS_SERIF, 0);
                }
            }
            else
            {
                nativeFontDescriptor = new CTFontDescriptor (name, 0);

                if (nativeFontDescriptor == null && createDefaultIfNotExists)
                {
                    nativeFontDescriptor = new CTFontDescriptor (SANS_SERIF, 0);
                }
            }

            if (nativeFontDescriptor == null)
                throw new ArgumentException ("name specifies a font that is not installed on the computer running the application.");
            else
            {
                var attrs = nativeFontDescriptor.GetAttributes ();
                familyName = attrs.FamilyName;
                // if the font description attributes do not contain a value for FamilyName then we
                // need to try and create the font to get the family name from the actual font.
                if (string.IsNullOrEmpty (familyName))
                {
                    var font = new CTFont (nativeFontDescriptor, 0);
                    familyName = font.FamilyName;
                }
            }
        }
コード例 #9
0
ファイル: FontFamily.cs プロジェクト: nlhepler/mono
		public FontFamily (string name, FontCollection fontCollection) 
		{
			IntPtr handle = (fontCollection == null) ? IntPtr.Zero : fontCollection.nativeFontCollection;
			Status status = GDIPlus.GdipCreateFontFamilyFromName (name, handle, out nativeFontFamily);
			GDIPlus.CheckStatus (status);
		}
コード例 #10
0
ファイル: FontHelper.cs プロジェクト: viticm/pap2
 public Font GetFontByID(int nID, int nSize, FontCollection fc)
 {
     //StringBuilder sb = new StringBuilder(128);
     //FileFolderHelper.ReadIniFile(nID.ToString(), "Name", "", sb, 128, file);
     //string Name = sb.ToString();
     //FileFolderHelper.ReadIniFile(nID.ToString(), "Size", "", sb, 128, file);
     //float fSize = float.Parse(sb.ToString());
     FontFamily family = new FontFamily(fc.Families[0].Name, fc);
     Font CurFont = new Font(family, nSize);
     return CurFont;
 }
コード例 #11
0
        private void CreateFontFamily(string name, FontCollection fontCollection)  
        {
            IntPtr fontfamily = IntPtr.Zero;
            IntPtr nativeFontCollection = (fontCollection == null) ? IntPtr.Zero : fontCollection.nativeFontCollection;
           
            int status = SafeNativeMethods.Gdip.GdipCreateFontFamilyFromName(name, new HandleRef(fontCollection, nativeFontCollection), out fontfamily);

            if (status != SafeNativeMethods.Gdip.Ok)
            {
                if (createDefaultOnFail)
                {
                    fontfamily = GetGdipGenericSansSerif();  // This throws if failed.
                }
                else
                {
                    // Special case this incredibly common error message to give more information
                    if (status == SafeNativeMethods.Gdip.FontFamilyNotFound)
                    {
                        throw new ArgumentException(SR.GetString(SR.GdiplusFontFamilyNotFound, name));
                    }
                    else if (status == SafeNativeMethods.Gdip.NotTrueTypeFont)
                    {
                        throw new ArgumentException(SR.GetString(SR.GdiplusNotTrueTypeFont, name));
                    }
                    else
                    {
                        throw SafeNativeMethods.Gdip.StatusException(status);
                    }
                }
            }

            SetNativeFamily( fontfamily );
        }
コード例 #12
0
 public FontFamily(string name, FontCollection fontCollection)
 {
     CreateFontFamily(name, fontCollection);
 }
コード例 #13
0
		public FontFamily(string name, FontCollection fontCollection) {
			if (name == null)
				throw new ArgumentNullException("name");

			if (fontCollection == null)
				fontCollection = _installedFonts;

			if (fontCollection.Contains(name))
				_name = name;
			else {
				_name = ToGenericFontName(GenericFontFamilies.SansSerif);
				fontCollection = _installedFonts;
			}

			_font = fontCollection.GetInitialFont( _name );
		}
コード例 #14
0
 public FontFamily(string name, FontCollection fontCollection)
 {
     CreateNativeFontFamily (name, fontCollection, false);
 }