当前位置: 首页>>代码示例>>C#>>正文


C# Typeface.TryGetGlyphTypeface方法代码示例

本文整理汇总了C#中System.Windows.Media.Typeface.TryGetGlyphTypeface方法的典型用法代码示例。如果您正苦于以下问题:C# Typeface.TryGetGlyphTypeface方法的具体用法?C# Typeface.TryGetGlyphTypeface怎么用?C# Typeface.TryGetGlyphTypeface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.Typeface的用法示例。


在下文中一共展示了Typeface.TryGetGlyphTypeface方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFontData

        public FontData GetFontData(string fontFamilyName, bool isItalic, bool isBold)
        {
            FontData data = new FontData()
            {
                IsValid = false,
                Bytes = null,
                FontFamilyName = fontFamilyName,
                IsItalic = isItalic,
                IsBold = isBold
            };

            FontFamily fontFamily = new FontFamily(fontFamilyName);
            FontStyle fontStyle = isItalic ? FontStyles.Italic : FontStyles.Normal;
            FontWeight fontWeight = isBold ? FontWeights.Bold : FontWeights.Normal;
            Typeface typeface = new Typeface(fontFamily, fontStyle, fontWeight, FontStretches.Normal);
            GlyphTypeface glyphTypeface;
            if (typeface.TryGetGlyphTypeface(out glyphTypeface))
            {
                using (var memoryStream = new MemoryStream())
                {
                    glyphTypeface.GetFontStream().CopyTo(memoryStream);
                    data.Bytes = memoryStream.ToArray();
                    data.IsValid = true;
                }
            }

            return data;
        }
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:28,代码来源:PdfFontsService.svc.cs

示例2: Convert

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var list = value as IReadOnlyCollection<FontFamily>;

            if (list == null)
                return DependencyProperty.UnsetValue;

            var returnList = new List<FontFamily>();
            foreach (FontFamily font in list)
            {
                try
                {
                    // Instantiate a TypeFace object with the font settings you want to use
                    Typeface ltypFace = new Typeface(font, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);

                    // Try to create a GlyphTypeface object from the TypeFace object
                    GlyphTypeface lglyphTypeFace;
                    if (ltypFace.TryGetGlyphTypeface(out lglyphTypeFace))
                    {
                        returnList.Add(font);
                    }
                }
                catch (Exception) {}
            }

            return returnList;
        }
开发者ID:dbremner,项目名称:ScreenToGif,代码行数:27,代码来源:FontToSupportedGliph.cs

示例3: MeasureText

        internal Size MeasureText(string text, FontFamily fontFamily, FontStyle fontStyle,
            FontWeight fontWeight,
            FontStretch fontStretch, double fontSize)
        {
            var typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch);
            GlyphTypeface glyphTypeface;

            if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
            {
                return MeasureTextSize(text, fontFamily, fontStyle, fontWeight, fontStretch, fontSize);
            }

            double totalWidth = 0;
            double height = 0;

            foreach (var t in text)
            {
                var glyphIndex = glyphTypeface.CharacterToGlyphMap[t];
                var width = glyphTypeface.AdvanceWidths[glyphIndex] * fontSize;
                var glyphHeight = glyphTypeface.AdvanceHeights[glyphIndex] * fontSize;

                if (glyphHeight > height)
                {
                    height = glyphHeight;
                }
                totalWidth += width;
            }
            return new Size(totalWidth, height);
        }
开发者ID:LionFree,项目名称:Cush,代码行数:29,代码来源:MRUTextHelper.cs

示例4: ToFontAwesomeIcon

        public static ImageSource ToFontAwesomeIcon(this string text, Brush foreBrush, FontStyle fontStyle, FontWeight fontWeight, FontStretch fontStretch)
        {
            var fontFamily = new FontFamily("/GitWorkItems;component/Resources/#FontAwesome");
            if (fontFamily != null && !String.IsNullOrEmpty(text))
            {
                //premier essai, on charge la police directement
                Typeface typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch);

                GlyphTypeface glyphTypeface;
                if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
                {
                    //si ça ne fonctionne pas (et pour le mode design dans certains cas) on ajoute l'uri pack://application
                    typeface = new Typeface(new FontFamily(new Uri("pack://application:,,,"), fontFamily.Source), fontStyle, fontWeight, fontStretch);
                    if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
                        throw new InvalidOperationException("No glyphtypeface found");
                }

                //détermination des indices/tailles des caractères dans la police
                ushort[] glyphIndexes = new ushort[text.Length];
                double[] advanceWidths = new double[text.Length];

                for (int n = 0; n < text.Length; n++)
                {
                    ushort glyphIndex;
                    try
                    {
                        glyphIndex = glyphTypeface.CharacterToGlyphMap[text[n]];

                    }
                    catch (Exception)
                    {
                        glyphIndex = 42;
                    }
                    glyphIndexes[n] = glyphIndex;

                    double width = glyphTypeface.AdvanceWidths[glyphIndex] * 1.0;
                    advanceWidths[n] = width;
                }

                try
                {

                    //création de l'objet DrawingImage (compatible avec Imagesource) à partir d'un glyphrun
                    GlyphRun gr = new GlyphRun(glyphTypeface, 0, false, 1.0, glyphIndexes,
                                                                         new Point(0, 0), advanceWidths, null, null, null, null, null, null);

                    GlyphRunDrawing glyphRunDrawing = new GlyphRunDrawing(foreBrush, gr);
                    return new DrawingImage(glyphRunDrawing);
                }
                catch (Exception ex)
                {
                    // ReSharper disable LocalizableElement
                    Console.WriteLine("Error in generating Glyphrun : " + ex.Message);
                    // ReSharper restore LocalizableElement
                }
            }
            return null;
        }
开发者ID:run00,项目名称:GitToWork,代码行数:58,代码来源:ExtensionsForString.cs

示例5: GetShapeableText

        internal void GetShapeableText(
            Typeface                    typeface, 
            CharacterBufferReference    characterBufferReference,
            int                         stringLength,
            TextRunProperties           textRunProperties,
            CultureInfo                 digitCulture, 
            bool                        isRightToLeftParagraph,
            IList<TextShapeableSymbols> shapeableList, 
            IShapeableTextCollector     collector, 
            TextFormattingMode              textFormattingMode
            ) 
        {
            if (!typeface.Symbol)
            {
                Lookup(typeface).GetShapeableText( 
                    characterBufferReference,
                    stringLength, 
                    textRunProperties, 
                    digitCulture,
                    isRightToLeftParagraph, 
                    shapeableList,
                    collector,
                    textFormattingMode
                    ); 
            }
            else 
            { 
                // It's a non-Unicode ("symbol") font, where code points have non-standard meanings. We
                // therefore want to bypass the usual itemization and font linking. Instead, just map 
                // everything to the default script and first GlyphTypeface.

                ShapeTypeface shapeTypeface = new ShapeTypeface(
                    typeface.TryGetGlyphTypeface(), 
                    null // device font
                    ); 
 
                collector.Add(
                    shapeableList, 
                    new CharacterBufferRange(characterBufferReference, stringLength),
                    textRunProperties,
                    new MS.Internal.Text.TextInterface.ItemProps(),
                    shapeTypeface, 
                    1.0,   // scale in Em
                    false,  // null shape 
                    textFormattingMode 
                    );
            } 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:48,代码来源:GlyphingCache.cs

示例6: Create

        public static GlyphRun Create(string text, Typeface typeface, double emSize, Point baselineOrigin = new Point())
        {
            GlyphTypeface glyphTypeface;

            if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
            {
                throw new ArgumentException(string.Format("{0}: no GlyphTypeface found", typeface.FontFamily));
            }

            var glyphIndices = new ushort[text.Length];
            var advanceWidths = new double[text.Length];

            for (int i = 0; i < text.Length; i++)
            {
                var glyphIndex = glyphTypeface.CharacterToGlyphMap[text[i]];
                glyphIndices[i] = glyphIndex;
                advanceWidths[i] = glyphTypeface.AdvanceWidths[glyphIndex] * emSize;
            }

            return new GlyphRun(glyphTypeface, 0, false, emSize, glyphIndices, baselineOrigin, advanceWidths, null, null, null, null, null, null);
        }
开发者ID:bhanu475,项目名称:XamlMapControl,代码行数:21,代码来源:GlyphRunText.cs

示例7: FontAdapter

        /// <summary>
        /// Init.
        /// </summary>
        public FontAdapter(Typeface font, double size)
        {
            _font = font;
            _size = size;
            _height = 96d / 72d * _size * _font.FontFamily.LineSpacing;
            _underlineOffset = 96d / 72d * _size * (_font.FontFamily.LineSpacing + font.UnderlinePosition);

            GlyphTypeface typeface;
            if (font.TryGetGlyphTypeface(out typeface))
            {
                _glyphTypeface = typeface;
            }
            else
            {
                foreach (var sysTypeface in Fonts.SystemTypefaces)
                {
                    if (sysTypeface.TryGetGlyphTypeface(out typeface))
                        break;
                }
            }
        }
开发者ID:CapitalCoder,项目名称:HTML-Renderer,代码行数:24,代码来源:FontAdapter.cs

示例8: CheckGlyphRun

        private bool CheckGlyphRun()
        {
            if (glyphRun == null)
            {
                if (string.IsNullOrEmpty(Text))
                {
                    return false;
                }

                var typeface = new Typeface(FontFamily, FontStyle, FontWeight, FontStretch);
                GlyphTypeface glyphTypeface;

                if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
                {
                    return false;
                }

                var glyphIndices = new ushort[Text.Length];
                var advanceWidths = new double[Text.Length];

                for (int i = 0; i < Text.Length; i++)
                {
                    var glyphIndex = glyphTypeface.CharacterToGlyphMap[Text[i]];
                    glyphIndices[i] = glyphIndex;
                    advanceWidths[i] = glyphTypeface.AdvanceWidths[glyphIndex] * FontSize;
                }

                glyphRun = new GlyphRun(glyphTypeface, 0, false, FontSize, glyphIndices, new Point(), advanceWidths, null, null, null, null, null, null);

                outline = glyphRun.BuildGeometry().GetWidenedPathGeometry(new Pen(null, OutlineThickness * 2d));
            }

            return true;
        }
开发者ID:huoxudong125,项目名称:XamlMapControl,代码行数:34,代码来源:OutlinedText.cs

示例9: InitializeInternalState

        private void InitializeInternalState()
        {
            // Font text
            if (_glyphTypeface == null)
            {
                Typeface typeface = new Typeface(new FontFamily("Segoe UI"),
                                                FontStyles.Normal,
                                                FontWeights.Normal,
                                                FontStretches.Normal);

                if (!typeface.TryGetGlyphTypeface(out _glyphTypeface))
                {
                    throw new InvalidOperationException("No glyphtypeface found");
                }
            }

            // Time bar display
            _timeBar = new TimeBar(TimeBarCanvas);

            //events
            this.Loaded += FASTBuildMonitorControl_Loaded;

            EventsScrollViewer.PreviewMouseWheel += MainWindow_MouseWheel;
            EventsScrollViewer.MouseWheel += MainWindow_MouseWheel;
            MouseWheel += MainWindow_MouseWheel;
            EventsCanvas.MouseWheel += MainWindow_MouseWheel;

            EventsScrollViewer.PreviewMouseLeftButtonDown += EventsScrollViewer_MouseDown;
            EventsScrollViewer.MouseDown += EventsScrollViewer_MouseDown;
            MouseDown += EventsScrollViewer_MouseDown;
            EventsCanvas.MouseDown += EventsScrollViewer_MouseDown;

            EventsScrollViewer.PreviewMouseLeftButtonUp += EventsScrollViewer_MouseUp;
            EventsScrollViewer.MouseUp += EventsScrollViewer_MouseUp;
            MouseUp += EventsScrollViewer_MouseUp;
            EventsCanvas.MouseUp += EventsScrollViewer_MouseUp;

            EventsScrollViewer.PreviewMouseDoubleClick += EventsScrollViewer_MouseDoubleClick;
            EventsScrollViewer.MouseDoubleClick += EventsScrollViewer_MouseDoubleClick;

            OutputTextBox.PreviewMouseDoubleClick += OutputTextBox_PreviewMouseDoubleClick;
            OutputTextBox.MouseDoubleClick += OutputTextBox_PreviewMouseDoubleClick;
            OutputTextBox.PreviewKeyDown += OutputTextBox_KeyDown;
            OutputTextBox.KeyDown += OutputTextBox_KeyDown;
            OutputTextBox.LayoutUpdated += OutputTextBox_LayoutUpdated;

            OutputWindowComboBox.SelectionChanged += OutputWindowComboBox_SelectionChanged;

            Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() =>
            {
                //update timer
                _timer = new DispatcherTimer();
                _timer.Tick += HandleTick;
                _timer.Interval = new TimeSpan(TimeSpan.TicksPerMillisecond * 16);
                _timer.Start();
            }));
        }
开发者ID:ClxS,项目名称:FASTBuildMonitor,代码行数:57,代码来源:FASTBuildMonitorControl.xaml.cs

示例10: InitializeDescriptiveTextTab

        void InitializeDescriptiveTextTab()
        {
            var selectedTypeface = new Typeface(
                SelectedFontFamily,
                SelectedFontStyle,
                SelectedFontWeight,
                SelectedFontStretch
                );

            GlyphTypeface glyphTypeface;
            if (selectedTypeface.TryGetGlyphTypeface(out glyphTypeface))
            {
                // Create a table with two columns.
                var table = new Table();
                table.CellSpacing = 5;
                var leftColumn = new TableColumn();
                leftColumn.Width = new GridLength(2.0, GridUnitType.Star);
                table.Columns.Add(leftColumn);
                var rightColumn = new TableColumn();
                rightColumn.Width = new GridLength(3.0, GridUnitType.Star);
                table.Columns.Add(rightColumn);

                var rowGroup = new TableRowGroup();
                AddTableRow(rowGroup, "Family:", glyphTypeface.FamilyNames);
                AddTableRow(rowGroup, "Face:", glyphTypeface.FaceNames);
                AddTableRow(rowGroup, "Description:", glyphTypeface.Descriptions);
                AddTableRow(rowGroup, "Version:", glyphTypeface.VersionStrings);
                AddTableRow(rowGroup, "Copyright:", glyphTypeface.Copyrights);
                AddTableRow(rowGroup, "Trademark:", glyphTypeface.Trademarks);
                AddTableRow(rowGroup, "Manufacturer:", glyphTypeface.ManufacturerNames);
                AddTableRow(rowGroup, "Designer:", glyphTypeface.DesignerNames);
                AddTableRow(rowGroup, "Designer URL:", glyphTypeface.DesignerUrls);
                AddTableRow(rowGroup, "Vendor URL:", glyphTypeface.VendorUrls);
                AddTableRow(rowGroup, "Win32 Family:", glyphTypeface.Win32FamilyNames);
                AddTableRow(rowGroup, "Win32 Face:", glyphTypeface.Win32FaceNames);

                try
                {
                    AddTableRow(rowGroup, "Font File URI:", glyphTypeface.FontUri.ToString());
                }
                catch (System.Security.SecurityException)
                {
                    // Font file URI is privileged information; just skip it if we don't have access.
                }

                table.RowGroups.Add(rowGroup);

                fontDescriptionBox.Document = new FlowDocument(table);

                fontLicenseBox.Text = NameDictionaryHelper.GetDisplayName(glyphTypeface.LicenseDescriptions);
            }
            else
            {
                fontDescriptionBox.Document = new FlowDocument();
                fontLicenseBox.Text = String.Empty;
            }
        }
开发者ID:mhusen,项目名称:Eto,代码行数:57,代码来源:fontchooser.xaml.cs

示例11: CreateDrawTextList


//.........这里部分代码省略.........
                }
            }

            Typeface typefaceNormal = null;
            Typeface typefaceTitle = null;
            GlyphTypeface glyphTypefaceNormal = null;
            GlyphTypeface glyphTypefaceTitle = null;
            try
            {
                if (Settings.Instance.FontName.Length > 0)
                {
                    typefaceNormal = new Typeface(new FontFamily(Settings.Instance.FontName),
                                                 FontStyles.Normal,
                                                 FontWeights.Normal,
                                                 FontStretches.Normal);
                }
                if (Settings.Instance.FontNameTitle.Length > 0)
                {
                    if (Settings.Instance.FontBoldTitle == true)
                    {
                        typefaceTitle = new Typeface(new FontFamily(Settings.Instance.FontNameTitle),
                                                     FontStyles.Normal,
                                                     FontWeights.Bold,
                                                     FontStretches.Normal);
                    }
                    else
                    {
                        typefaceTitle = new Typeface(new FontFamily(Settings.Instance.FontNameTitle),
                                                     FontStyles.Normal,
                                                     FontWeights.Normal,
                                                     FontStretches.Normal);
                    }
                }
                if (!typefaceNormal.TryGetGlyphTypeface(out glyphTypefaceNormal))
                {
                    typefaceNormal = null;
                }
                if (!typefaceTitle.TryGetGlyphTypeface(out glyphTypefaceTitle))
                {
                    typefaceTitle = null;
                }

                if (typefaceNormal == null)
                {
                    typefaceNormal = new Typeface(new FontFamily("MS UI Gothic"),
                                                 FontStyles.Normal,
                                                 FontWeights.Normal,
                                                 FontStretches.Normal);
                    if (!typefaceNormal.TryGetGlyphTypeface(out glyphTypefaceNormal))
                    {
                        MessageBox.Show("フォント指定が不正です");
                        return;
                    }
                }
                if (typefaceTitle == null)
                {
                    typefaceTitle = new Typeface(new FontFamily("MS UI Gothic"),
                                                 FontStyles.Normal,
                                                 FontWeights.Bold,
                                                 FontStretches.Normal);
                    if (!typefaceTitle.TryGetGlyphTypeface(out glyphTypefaceTitle))
                    {
                        MessageBox.Show("フォント指定が不正です");
                        return;
                    }
                }
开发者ID:epgdatacapbon,项目名称:EDCB,代码行数:67,代码来源:EpgViewPanel.cs

示例12: CalculateTextProperty

        private void CalculateTextProperty()
        {
            double  availableWidth = ActualWidth - Padding.Width();
            double  ellipsesWidth, totalWidth;
            double  fontSize = FontSize;
            int     i, lastSlashPos;
            string  str = FilePath;

            if( string.IsNullOrEmpty( str ) )
            {
                Text = null;
                IsTextClipped = false;
                return;
            }

            if( _glyphTypeface == null )
            {
                Typeface typeface = new Typeface( FontFamily, FontStyle, FontWeight, FontStretch );

                if( !typeface.TryGetGlyphTypeface( out _glyphTypeface ) )
                {
                    throw new InvalidOperationException( "Glyph typeface is not found!!" );
                }
            }

            ellipsesWidth = _glyphTypeface.AdvanceWidths[
                                    _glyphTypeface.CharacterToGlyphMap[ '.' ] ] * fontSize * 3;
            totalWidth = ellipsesWidth;

            if( availableWidth <= totalWidth ) str = string.Empty;

            lastSlashPos = str.LastIndexOf( '\\' );
            if( lastSlashPos == -1 ) lastSlashPos = str.Length;

            totalWidth += ellipsesWidth;

            for( i = lastSlashPos; i < str.Length; i++ )
            {
                if( !AddCharToTotalWidth( str[i], fontSize, availableWidth, ref totalWidth ) ) break;
            }

            if( i < str.Length )
            {
                Text = "..." + str.Substring( lastSlashPos, i - lastSlashPos ) + "...";
                IsTextClipped = true;
            }
            else
            {
                totalWidth -= ellipsesWidth;

                for( i = lastSlashPos - 1; i >= 0; i-- )
                {
                    if( !AddCharToTotalWidth( str[i], fontSize, availableWidth, ref totalWidth ) ) break;
                }

                if( i == -1 )
                {
                    Text = str;
                    IsTextClipped = false;
                }
                else
                {
                    Text = "..." + str.Substring( i + 1 );
                    IsTextClipped = true;
                }
            }
        }
开发者ID:dxm007,项目名称:Droppy,代码行数:67,代码来源:FilePathTextBlock.cs

示例13: GetFontFamilies

        /// <summary>
        /// Gets the font families.
        /// </summary>
        /// <returns>
        /// List of font families.
        /// </returns>
        private static IEnumerable<FontFamily> GetFontFamilies()
        {
            if (cachedFontFamilies == null)
            {
                var list = new List<FontFamily>();
                foreach (var fontFamily in Fonts.SystemFontFamilies)
                {
                    // Instantiate a TypeFace object with the font settings you want to use
                    var ltypFace = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);

                    try
                    {
                        GlyphTypeface gtf;
                        if (ltypFace.TryGetGlyphTypeface(out gtf))
                        {
                            list.Add(fontFamily);
                        }
                    }
                    catch (FileFormatException)
                    {
                        Debug.WriteLine(fontFamily + " failed.");
                    }
                }

                cachedFontFamilies = list.OrderBy(f => f.ToString()).ToArray();
            }

            return cachedFontFamilies;
        }
开发者ID:hasol81,项目名称:PropertyTools,代码行数:35,代码来源:DefaultPropertyControlFactory.cs

示例14: MeasureTextByGlyphTypeface

        /// <summary>
        /// Measures the size of the specified text by a faster method (using GlyphTypefaces).
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="fontFamily">
        /// The font family.
        /// </param>
        /// <param name="fontSize">
        /// The font size.
        /// </param>
        /// <param name="fontWeight">
        /// The font weight.
        /// </param>
        /// <returns>
        /// The size of the text.
        /// </returns>
        protected OxySize MeasureTextByGlyphTypeface(string text, string fontFamily, double fontSize, double fontWeight)
        {
            if (string.IsNullOrEmpty(text))
            {
                return OxySize.Empty;
            }

            var typeface = new Typeface(
                new FontFamily(fontFamily), FontStyles.Normal, GetFontWeight(fontWeight), FontStretches.Normal);

            GlyphTypeface glyphTypeface;
            if (!typeface.TryGetGlyphTypeface(out glyphTypeface))
            {
                throw new InvalidOperationException("No glyph typeface found");
            }

            return MeasureTextSize(glyphTypeface, fontSize, text);
        }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:36,代码来源:ShapesRenderContext.cs

示例15: CreateTypeface

        // Create a Typeface, taking into account a nasty WPF bugs regarding Arial Narrow.
        private Typeface CreateTypeface(string fontName, bool bold, bool italic)
        {
            if (!Util.FontExists(fontName))
                fontName = "Arial";          // Map non-existant fonts to "Arial".

            if (fontName == "Arial Narrow") {
                // Arial Narrow doesn't work right in WPF. We can work around by going directly to the font file.
                string fontfileName;
                if (!bold && !italic)
                    fontfileName = "arialn.ttf";
                else if (bold && !italic)
                    fontfileName = "arialnb.ttf";
                else if (!bold && italic)
                    fontfileName = "arialni.ttf";
                else
                    fontfileName = "arialnbi.ttf";

                // Get font folder
                StringBuilder fontPath = new StringBuilder(260);
                if (SHGetSpecialFolderPath(IntPtr.Zero, fontPath, CSIDL_FONTS, false)) {
                    // Get path to font name.
                    string fontfile = Path.Combine(fontPath.ToString(), fontfileName);
                    UriBuilder fontfileUriBuilder = new UriBuilder(new Uri(fontfile));
                    fontfileUriBuilder.Fragment = "Arial";
                    Typeface typeface = new Typeface(new FontFamily(fontfileUriBuilder.Uri.ToString()), italic ? FontStyles.Italic : FontStyles.Normal, bold ? FontWeights.Bold : FontWeights.Normal, FontStretches.Condensed);
                    GlyphTypeface gtf;
                    if (typeface.TryGetGlyphTypeface(out gtf))
                        return typeface;           // Make sure that the font file really exists, by getting the glyph typeface.
                }
            }

            return new Typeface(new FontFamily(fontName), italic ? FontStyles.Italic : FontStyles.Normal, bold ? FontWeights.Bold : FontWeights.Normal, FontStretches.Normal);
        }
开发者ID:jonc,项目名称:carto,代码行数:34,代码来源:SymDef.cs


注:本文中的System.Windows.Media.Typeface.TryGetGlyphTypeface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。