// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. using System; namespace SharpDX.DirectWrite { public partial class TextFormat { /// /// Creates a text format object used for text layout with normal weight, style and stretch. /// /// an instance of /// An array of characters that contains the name of the font family /// The logical size of the font in DIP ("device-independent pixel") units. A DIP equals 1/96 inch. /// HRESULT CreateTextFormat([In] const wchar* fontFamilyName,[None] IDWriteFontCollection* fontCollection,[None] DWRITE_FONT_WEIGHT fontWeight,[None] DWRITE_FONT_STYLE fontStyle,[None] DWRITE_FONT_STRETCH fontStretch,[None] FLOAT fontSize,[In] const wchar* localeName,[Out] IDWriteTextFormat** textFormat) public TextFormat(Factory factory, string fontFamilyName, float fontSize) : this(factory, fontFamilyName, null, DirectWrite.FontWeight.Normal, DirectWrite.FontStyle.Normal, DirectWrite.FontStretch.Normal, fontSize, "") { } /// /// Creates a text format object used for text layout with normal stretch. /// /// an instance of /// An array of characters that contains the name of the font family /// A value that indicates the font weight for the text object created by this method. /// A value that indicates the font style for the text object created by this method. /// The logical size of the font in DIP ("device-independent pixel") units. A DIP equals 1/96 inch. /// HRESULT CreateTextFormat([In] const wchar* fontFamilyName,[None] IDWriteFontCollection* fontCollection,[None] DWRITE_FONT_WEIGHT fontWeight,[None] DWRITE_FONT_STYLE fontStyle,[None] DWRITE_FONT_STRETCH fontStretch,[None] FLOAT fontSize,[In] const wchar* localeName,[Out] IDWriteTextFormat** textFormat) public TextFormat(Factory factory, string fontFamilyName, SharpDX.DirectWrite.FontWeight fontWeight, SharpDX.DirectWrite.FontStyle fontStyle, float fontSize) : this(factory, fontFamilyName, null, fontWeight, fontStyle, DirectWrite.FontStretch.Normal, fontSize, "") { } /// /// Creates a text format object used for text layout. /// /// an instance of /// An array of characters that contains the name of the font family /// A value that indicates the font weight for the text object created by this method. /// A value that indicates the font style for the text object created by this method. /// A value that indicates the font stretch for the text object created by this method. /// The logical size of the font in DIP ("device-independent pixel") units. A DIP equals 1/96 inch. /// HRESULT CreateTextFormat([In] const wchar* fontFamilyName,[None] IDWriteFontCollection* fontCollection,[None] DWRITE_FONT_WEIGHT fontWeight,[None] DWRITE_FONT_STYLE fontStyle,[None] DWRITE_FONT_STRETCH fontStretch,[None] FLOAT fontSize,[In] const wchar* localeName,[Out] IDWriteTextFormat** textFormat) public TextFormat(Factory factory, string fontFamilyName, SharpDX.DirectWrite.FontWeight fontWeight, SharpDX.DirectWrite.FontStyle fontStyle, SharpDX.DirectWrite.FontStretch fontStretch, float fontSize) : this(factory, fontFamilyName, null, fontWeight, fontStyle, fontStretch, fontSize, "") { } /// /// Creates a text format object used for text layout. /// /// an instance of /// An array of characters that contains the name of the font family /// A pointer to a font collection object. When this is NULL, indicates the system font collection. /// A value that indicates the font weight for the text object created by this method. /// A value that indicates the font style for the text object created by this method. /// A value that indicates the font stretch for the text object created by this method. /// The logical size of the font in DIP ("device-independent pixel") units. A DIP equals 1/96 inch. /// HRESULT CreateTextFormat([In] const wchar* fontFamilyName,[None] IDWriteFontCollection* fontCollection,[None] DWRITE_FONT_WEIGHT fontWeight,[None] DWRITE_FONT_STYLE fontStyle,[None] DWRITE_FONT_STRETCH fontStretch,[None] FLOAT fontSize,[In] const wchar* localeName,[Out] IDWriteTextFormat** textFormat) public TextFormat(Factory factory, string fontFamilyName, SharpDX.DirectWrite.FontCollection fontCollection, SharpDX.DirectWrite.FontWeight fontWeight, SharpDX.DirectWrite.FontStyle fontStyle, SharpDX.DirectWrite.FontStretch fontStretch, float fontSize) : this(factory, fontFamilyName, fontCollection, fontWeight, fontStyle, fontStretch, fontSize,"") { } /// /// Creates a text format object used for text layout. /// /// an instance of /// An array of characters that contains the name of the font family /// A pointer to a font collection object. When this is NULL, indicates the system font collection. /// A value that indicates the font weight for the text object created by this method. /// A value that indicates the font style for the text object created by this method. /// A value that indicates the font stretch for the text object created by this method. /// The logical size of the font in DIP ("device-independent pixel") units. A DIP equals 1/96 inch. /// An array of characters that contains the locale name. /// HRESULT CreateTextFormat([In] const wchar* fontFamilyName,[None] IDWriteFontCollection* fontCollection,[None] DWRITE_FONT_WEIGHT fontWeight,[None] DWRITE_FONT_STYLE fontStyle,[None] DWRITE_FONT_STRETCH fontStretch,[None] FLOAT fontSize,[In] const wchar* localeName,[Out] IDWriteTextFormat** textFormat) public TextFormat(Factory factory, string fontFamilyName, SharpDX.DirectWrite.FontCollection fontCollection, SharpDX.DirectWrite.FontWeight fontWeight, SharpDX.DirectWrite.FontStyle fontStyle, SharpDX.DirectWrite.FontStretch fontStretch, float fontSize, string localeName) : base(IntPtr.Zero) { factory.CreateTextFormat(fontFamilyName, fontCollection, fontWeight, fontStyle, fontStretch, fontSize, localeName, this); } /// /// Gets a copy of the font family name. /// /// the current font family name. /// HRESULT IDWriteTextFormat::GetFontFamilyName([Out, Buffer] wchar_t* fontFamilyName,[None] int nameSize) public string FontFamilyName { get { unsafe { int fontFamilyNameLength = GetFontFamilyNameLength(); char* fontFamilyName = stackalloc char[fontFamilyNameLength + 1]; GetFontFamilyName(new IntPtr(fontFamilyName), fontFamilyNameLength + 1); return new string(fontFamilyName, 0, fontFamilyNameLength); } } } /// /// Gets a copy of the locale name. /// /// the current locale name. /// HRESULT IDWriteTextFormat::GetLocaleName([Out, Buffer] wchar_t* localeName,[None] int nameSize) public string LocaleName { get { unsafe { int localNameLength = GetLocaleNameLength(); char* localName = stackalloc char[localNameLength + 1]; GetLocaleName(new IntPtr(localName), localNameLength + 1); return new string(localName, 0, localNameLength); } } } } }