Ejemplo n.º 1
0
        public override void Dispose()
        {
            foreach (var textLayout in TextFormats.Values)
            {
                textLayout.Dispose();
            }

            FontCollection.Dispose();
            FontLoader.Dispose();
            SolidColorBrush.Dispose();

            DirectWriteFactory.Dispose();
        }
Ejemplo n.º 2
0
        public void SetTextFormat(TextFormat textFormat)
        {
            // Initializes properties using a text format, like font family, font size,
            // and reading direction. For simplicity, this custom layout supports
            // minimal formatting. No mixed formatting or alignment modes are supported.
            readingDirection_ = textFormat.ReadingDirection;
            fontEmSize_       = textFormat.FontSize;
            localName_        = textFormat.LocaleName;

            // Map font and style to fontFace.
            FontCollection fontCollection = textFormat.FontCollection;// Need the font collection to map from font name to actual font.

            if (fontCollection == null)
            {
                fontCollection = dwriteFactory_.GetSystemFontCollection(false);// No font collection was set in the format, so use the system default.
            }
            // Find matching family name in collection.
            String fontFamilyName = textFormat.FontFamilyName;

            int fontIndex;

            // If the given font does not exist, take what we can get
            // (displaying something instead nothing), choosing the foremost
            // font in the collection.
            if (!fontCollection.FindFamilyName(fontFamilyName, out fontIndex))
            {
                fontIndex = 0;
            }

            FontFamily fontFamily = fontCollection.GetFontFamily(fontIndex);
            Font       font       = fontFamily.GetFirstMatchingFont(textFormat.FontWeight, textFormat.FontStretch, textFormat.FontStyle);

            fontFace_ = new FontFace(font);

            font.Dispose();
            fontFamily.Dispose();
            fontCollection.Dispose();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                _hudTextFormat.Dispose();
                _hudYellow.Dispose();
                _hudWhite.Dispose();

                _fontCollection.Dispose();
                _fontLoader.Dispose();
                _dwFactory.Dispose();

                _texResMan.Dispose();
                _spriteResMan.Dispose();

                _swapChain.Dispose();
                _d2dTarget.Dispose();
                _d2dFactory.Dispose();
                _d3dContext.Dispose();
                _d2dContext.Dispose();
                _device.Dispose();
            }
        }
Ejemplo n.º 4
0
 public override void Dispose()
 {
     _systemFonts.Dispose();
     base.Dispose();
 }