Inheritance: INativeObject, IDisposable
 public CTFont WithAttributes(float size, CTFontDescriptor attributes)
 {
     if (attributes == null)
     {
         throw new ArgumentNullException("attributes");
     }
     return(CreateFont(CTFontCreateCopyWithAttributes(handle, size, IntPtr.Zero, attributes.Handle)));
 }
 public CTFont WithAttributes(float size, CTFontDescriptor attributes, ref CGAffineTransform matrix)
 {
     if (attributes == null)
     {
         throw new ArgumentNullException("attributes");
     }
     return(CreateFont(CTFontCreateCopyWithAttributes(handle, size, ref matrix, attributes.Handle)));
 }
        public CGFont ToCGFont(CTFontDescriptor attributes)
        {
            var h = CTFontCopyGraphicsFont(handle, attributes == null ? IntPtr.Zero : attributes.Handle);

            if (h == IntPtr.Zero)
            {
                return(null);
            }
            return(new CGFont(h, true));
        }
 public CTFont(CGFont font, float size, CTFontDescriptor descriptor)
 {
     if (font == null)
     {
         throw new ArgumentNullException("font");
     }
     handle = CTFontCreateWithGraphicsFont2(font.Handle, size, IntPtr.Zero, descriptor == null ? IntPtr.Zero : descriptor.Handle);
     if (handle == IntPtr.Zero)
     {
         throw ConstructorError.Unknown(this);
     }
 }
 public CTFont(CTFontDescriptor descriptor, float size, ref CGAffineTransform matrix)
 {
     if (descriptor == null)
     {
         throw ConstructorError.ArgumentNull(this, "descriptor");
     }
     handle = CTFontCreateWithFontDescriptor(descriptor.Handle, size, ref matrix);
     if (handle == IntPtr.Zero)
     {
         throw ConstructorError.Unknown(this);
     }
 }
 public CTFont(CTFontDescriptor descriptor, float size, CTFontOptions options)
 {
     if (descriptor == null)
     {
         throw ConstructorError.ArgumentNull(this, "descriptor");
     }
     handle = CTFontCreateWithFontDescriptorAndOptions(descriptor.Handle,
                                                       size, IntPtr.Zero, options);
     if (handle == IntPtr.Zero)
     {
         throw ConstructorError.Unknown(this);
     }
 }
        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;
                }
            }
        }
		public static bool MatchFontDescriptors (CTFontDescriptor[] descriptors, NSSet mandatoryAttributes, Func<CTFontDescriptorMatchingState, IntPtr, bool> progressHandler)
		{
			var ma = mandatoryAttributes == null ? IntPtr.Zero : mandatoryAttributes.Handle;
			// FIXME: SIGSEGV probably due to mandatoryAttributes mismatch
			using (var ar = CFArray.FromNativeObjects (descriptors)) {
				return CTFontDescriptorMatchFontDescriptorsWithProgressHandler (ar.Handle, ma, progressHandler);
			}
		}
示例#9
0
		public CTFontCollection WithFontDescriptors (CTFontDescriptor[] queryDescriptors, CTFontCollectionOptions options)
		{
			IntPtr h;
			using (var descriptors = queryDescriptors == null 
					? null 
					: CFArray.FromNativeObjects (queryDescriptors)) {
				h = CTFontCollectionCreateCopyWithFontDescriptors (
						Handle,
						descriptors == null ? IntPtr.Zero : descriptors.Handle,
						options == null ? IntPtr.Zero : options.Dictionary.Handle);
			}
			if (h == IntPtr.Zero)
				return null;
			return new CTFontCollection (h, true);
		}
示例#10
0
		public CTFontCollection (CTFontDescriptor[] queryDescriptors, CTFontCollectionOptions options)
		{
			using (var descriptors = queryDescriptors == null
					? null 
					: CFArray.FromNativeObjects (queryDescriptors))
				Handle = CTFontCollectionCreateWithFontDescriptors (
						descriptors == null ? IntPtr.Zero : descriptors.Handle,
						options == null ? IntPtr.Zero : options.Dictionary.Handle);
			if (Handle == IntPtr.Zero)
				throw ConstructorError.Unknown (this);
		}