Search

FormattedText.BuildGeometry cannot build correct Geometry for some custom fonts by Allen Chen - MSFT

Closed

2
0
Sign in
to vote
Type: Bug
ID: 773504
Opened: 12/5/2012 1:18:26 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
FormattedText.BuildGeometry cannot build correct Geometry for some custom fonts. Using bold font weight can render the geometry so it seems the algorithm doesn't take single line font into consideration.

This issue is firstly reported on forum:
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/9e5ed309-91a1-4159-8a5d-c00bc562e5c9
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

.NET Framework 4.0

Steps to reproduce

1. Download custom fonts http://www.mrrace.com/CamBam_Fonts/CamBam%20Stick%20Fonts.zip

2. Create a new WPF project in Visual Studio. Create a new folder called "Fonts" under project root folder and put all the .ttf files in it. Build these .ttf as resource. Use below test code (replace "WpfApplication13" with the project name in your test):

    <StackPanel x:Name="panel">
            <TextBlock x:Name="myTextBlock" Text="Hello World" FontSize="32"></TextBlock>
            <Path Stroke="Black" StrokeThickness="1" x:Name="myPath" ></Path>
        </StackPanel>

public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            System.Windows.FontStyle fontStyle = FontStyles.Normal;
         // FontWeight fontWeight = FontWeights.Bold;
            FontWeight fontWeight = FontWeights.Normal;

            var family = new FontFamily(
    new Uri("pack://application:,,,/WpfApplication13;component/Fonts/"),
    "./1CamBam_Stick_4.ttf#1CamBam_Stick_4"
);
            // Create the formatted text based on the properties set.
            FormattedText formattedText = new FormattedText(
                "Hello World",
                CultureInfo.GetCultureInfo("en-us"),
                FlowDirection.LeftToRight,
                new Typeface(family,
                    fontStyle,
                    fontWeight,
                    FontStretches.Normal),
                32,
                System.Windows.Media.Brushes.Black                 );
         this.myTextBlock.FontFamily = family;
            // Build the geometry object that represents the text.
            var geo = formattedText.BuildGeometry(new System.Windows.Point(0, 0));
    
            myPath.Data = geo;

        }
    }

Product Language

English

Operating System

Windows Server 2008 R2

Operating System Language

English

Actual results

The geometry is not build for most of the letters

Expected results

The geometry should be built correctly
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 12/7/2012 at 1:54 PM
The WPF team has recently reviewed this issue and will not be addressing this issue as at this time the team is focusing on the bugs impacting the highest number of WPF developers. If you believe that this was resolved in error, please reactivate this bug with any necessary supporting details.

We appreciate the feedback. However, this issue will not be addressed in the next version of WPF. Thank you.
–WPF Team.
Posted by Microsoft on 12/5/2012 at 1:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.