Strange bug on embedded font


  •  Hi folks

     I need a monospaced font on a row details view, so I embedded Consolas into the project. But then I recognized that the font was not used by some databound TextBlock's. After one hour of investigation I found a strange behavior in the font usage.

    Here the code:


    <Grid ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" >
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
    <TextBlock Margin="5,0,5,0"
    Text="{Binding Path=querySeq}"
    TextWrapping="NoWrap" FontFamily="./Fonts/" VerticalAlignment="Center" HorizontalAlignment="Left" d:IsStaticText="True" FontSize="16"/>
    <TextBlock Margin="5,0,5,0"
    Text="{Binding Path=pattern}"
    TextWrapping="NoWrap" FontFamily="./Fonts/" VerticalAlignment="Center" Grid.Row="1" HorizontalAlignment="Left" d:IsStaticText="True" FontSize="16"/>
    <TextBlock Margin="5,0,5,0"
    Text="{Binding Path=matchSeq}"
    TextWrapping="NoWrap" FontFamily="./Fonts/" VerticalAlignment="Center" Grid.Row="2" HorizontalAlignment="Left" FontSize="16"/>
    <TextBlock Margin="5,0,5,0"
    As you can see I included a dummy TextBlock in the  RowDetailsTemplate which will demonstrate the behavior. Each letter which appears in dummy TextBlock will also use the correct Consolas font in the databoubd TextBlocks.
    All letters are not in the dummy are using a fallback font in the databound TextBlock. So in this case Q will be not displayed in the Consolas font but in anothe font. I guess
    it has something to do with time point when the font is allocated.  
    So my current workarund will be a transparent dummy TextBlock with all letter I expect in the real TextBlocks. 
    Monday, October 27, 2008 3:54 PM