none
FontFamily property on TextBlock does not work.

    Dotaz

  • I have the system font "Times New Roman" installed. The following XAML renders in a sans-serif font, not Time New Roman.

    When I access the FontFamily property of the TextBlock, "FontFamily" is returned.

    alert("The FontFamily is: " + textBlock.FontFamily);

    shows "The FontFamily is: FontFamily".

    <Canvas xmlns="http://schemas.microsoft.com/client/2007"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <TextBlock x:Name="michael" Canvas.Top="93" Canvas.Left="93" FontSize="16pt" FontFamily="Times New Roman;Serif" Foreground="#FF5A5A5A" Text="Michael S. Scherotter" />

    </Canvas>

    Please advise,

    Michael S. Scherotter

    23. prosince 2006 23:12

Odpovědi

  • Correct -- for the CTP, the FontFamily property returns an object that has no valid properties/methods. In the future, FontFamily might return a string or it might return an object that allows further inspection.

    -mark
    Program Manager
    Microsoft
    This post is provided "as-is"

    28. prosince 2006 4:41

Všechny reakce

  • The font stack required for Font-Family to work correclty is not in the CTP (perhaps the team can clarify a ship date). Currently the fonts that are supported are limited, but I couldn't find that specified in the SDK or the Release notes, but I've been told this.  Hopefully Barak can clarify this.
    27. prosince 2006 3:29
  • Correct -- for the CTP, the FontFamily property returns an object that has no valid properties/methods. In the future, FontFamily might return a string or it might return an object that allows further inspection.

    -mark
    Program Manager
    Microsoft
    This post is provided "as-is"

    28. prosince 2006 4:41
  • Shawn is also correct that there is a subset of fonts supported for the CTP. I don't have network access right now to provide you that list, but it is the basic web safe fonts (off the top: Arial, Times New Roman, Verdana, Georgia, Comic Sans Serif and Trebuchet). We perform font fallback to Lucida Sans Unicode/Lucida Grande (depending upon the platform). Also note -- for the CTP we do not perform any algorithmic italic or bold, so the font itself must support the style.

    I'll verify the list of supported fonts in the new year (when I'm back on the network)

    -mark
    Program Manager
    Microsoft
    This post is provided "as-is"

    28. prosince 2006 4:47
  • While mark is correct that algorithmic italics/bold isn't supported...its also important to note that the <TextBlock /> does not support italics at all (unless you specify the font as being italics).  There is no inline support for italics right now. I'd love an answer to a timeline (i.e. "for Release", "After 1.0") on when this will be supported.
    1. ledna 2007 10:56
  • I just noticed that there is a small error in the syntax of the FontFamily in the original markup above - that semicolon should really be a comma, like this:

    FontFamily="Times New Roman, Serif".

    One other detail, although not a problem here, WPF/E does not include a font called Serif, so the ', Serif' will be effectively ignored.

    Best regards -- Dave.

     

    2. ledna 2007 16:13
  • There is no inline support for italics right now
    Actually using a Run element you can easily get inline italics:

    <TextBlock FontFamily="Times New Roman">Some text that has inline <Run FontStyle="Italic">italic</Run></TextBlock>
     
    The <Italic> inline element is mainly syntactical surgar.

    -mark
    Program Manager
    Microsoft
    This post is provided "as-is"

    2. ledna 2007 18:42
  •  Mark Rideout wrote:

    There is no inline support for italics right now
    Actually using a Run element you can easily get inline italics:

    <TextBlock FontFamily="Times New Roman">Some text that has inline <Run FontStyle="Italic">italic</Run></TextBlock>
     
    The <Italic> inline element is mainly syntactical surgar.

    -mark
    Program Manager
    Microsoft
    This post is provided "as-is"

     

    Thanks Mark...didn't notice that.

    3. ledna 2007 4:51
  • I'll verify the list of supported fonts in the new year (when I'm back on the network)
    The list of supported fonts in the December CTP are:

    Macintosh Fonts
    “Arial” (font suitcase)
    “Arial Black” (font suitcase)
    “Comic Sans MS”  (font suitcase)
    “Courier New” (font suitcase)
    “Georgia”  (font suitcase)
    “LucidaGrande.dfont” 
    “Times New Roman” (font suitcase)
    “Trebuchet MS” (font suitcase)
    “Verdana” (font suitcase)

    Windows Fonts (font “family” highlighted for each group of fonts)
    arial.ttf-  Arial (Normal)
    ariali.ttf (Italic)
    arialbd.ttf (bold)
    arialbi.ttf (bold italic)
    ariblk.ttf- Arial Black 
    comic.ttf- Comic Sans (normal)
    comicbd.ttf  (bold)   
    cour.ttf- Courier (Normal)
    couri.ttf (italic)
    courbd.ttf (bold)
    courbi.ttf  (bold italic)
    georgia.ttf- Georgia (Normal)
    georgiab.ttf (bold)
    georgiaz.ttf (bold italic)
    georgiai.ttf  (italic)
    l_10646.ttf -  Lucida Sans Unicode (normal)
    times.ttf- Times New Roman (Normal)
    timesbd.ttf (bold)
    timesbi.ttf (bold italic)
    timesi.ttf  (italic)
    trebuc.ttf-  Trebuchet (Normal)
    trebucbd.ttf (bold)
    trebucbi.ttf  (bold italic)
    trebucit.ttf (italic)
    verdana.ttf Verdana (Normal)
    verdanab.ttf (bold)
    verdanaz.ttf (bold italic)
    verdanai.ttf (italic)

    -mark
    Program Manager
    Microsoft
    This post is provided "as-is"

    3. ledna 2007 21:01