<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Media And Microcode : XNA</title><link>http://blogs.msdn.com/mediaandmicrocode/archive/tags/XNA/default.aspx</link><description>Tags: XNA</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Microcode: PowerShell + XNA: New-SpriteFont</title><link>http://blogs.msdn.com/mediaandmicrocode/archive/2008/12/24/microcode-powershell-xna-new-spritefont.aspx</link><pubDate>Wed, 24 Dec 2008 13:07:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9251648</guid><dc:creator>JamesBrundage</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mediaandmicrocode/comments/9251648.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mediaandmicrocode/commentrss.aspx?PostID=9251648</wfw:commentRss><description>&lt;p class="PostHeader"&gt;As I said in a previous post, I've started to explore the wild world of &lt;a href="http://creators.xna.com"&gt;XNA&lt;/a&gt;. XNA just released version 3, which allows you to make games for Windows, Xbox, and Zune. The SDK is free, and you can download it &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7D70D6ED-1EDD-4852-9883-9A33C0AD8FEE&amp;amp;displaylang=en"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p class="PostHeader"&gt;&lt;a href="http://blogs.msdn.com/mediaandmicrocode/archive/2008/12/24/microcode-powershell-scripting-tricks-get-font.aspx"&gt;The last post introduced Get-Font&lt;/a&gt;, a quick function that lets me see what fonts are on the system. I wrote this function to save me the potential future headache of making a typo in my SpriteFont file, and in this post I'll show you New-SpriteFont, which uses Get-Font and emits a Sprite Font file with a number of parameters for any font on my system.&lt;/p&gt;  &lt;p class="PostHeader"&gt;New-SpriteFont was fairly straightforward. I simply check for any font that is named what I say, and throw an error if one is not found. Then I copied a sprite font file from the sample Platformer project into my function, and added a parameter for each part of the XML I wanted to parameterize in a script. Since font names cannot contain characters that would trouble XML (and I've already checked to make sure the font exists), I don't need to worry about escaping my XML for the font name. Almost everything else was an integer, except for style. The only interesting curve ball that the spritefont XML threw me was that it used a lowercase true. True will read as &amp;quot;True&amp;quot;, and since XML is case-sensitive (even though PowerShell is not), I coerced the switch parameter into a string and then turned the string into a lowercase string.&lt;/p&gt;  &lt;p class="PostHeader"&gt;Then I tacked on some inline help, and I had a New-SpriteFont that did the trick. I'm using &lt;a href="http://blogs.msdn.com/powershell/archive/2008/12/24/write-commandblogpost.aspx"&gt;Write-CommandBlogPost&lt;/a&gt; to write up New-SpriteFont for public consumption. Enjoy!&lt;/p&gt;  &lt;br /&gt;  &lt;p class="CmdletSynopsis"&gt;&lt;b&gt;Synopsis:&lt;/b&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;blockquote&gt;Creates a New XNA SpriteFont &lt;/blockquote&gt;  &lt;p&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;p class="CmdletSyntax"&gt;&lt;b&gt;Syntax:&lt;/b&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;blockquote&gt;New-SpriteFont [[-font] [&amp;lt;Object&amp;gt;]] [[-size] [&amp;lt;Int32&amp;gt;]] [[-spacing] [&amp;lt;Int32&amp;gt;]] [[-style] [&amp;lt;Object&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;] &lt;/blockquote&gt;  &lt;p&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;p class="CmdletDescription"&gt;&lt;b&gt;Detailed Description:&lt;/b&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;blockquote&gt;Generates an XNA SpriteFont file. Allows you to specify the font name, size, spacing, style, and if kerning is used or not &lt;/blockquote&gt;  &lt;p&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;p class="Examples"&gt;Examples: &lt;/p&gt;  &lt;blockquote&gt;   &lt;pre class="CmdletExample"&gt;    -------------------------- EXAMPLE 1 --------------------------





# Create a simple New sprite font
New-SpriteFont
    &lt;/pre&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;pre class="CmdletExample"&gt;    -------------------------- EXAMPLE 2 --------------------------





# Create a sprite font using the font Garamond and a fontsize of 12
New-SpriteFont &amp;quot;Garamond&amp;quot; 12
    &lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;/p&gt;

&lt;br /&gt;

&lt;p class="CmdletParameters"&gt;Command Parameters: &lt;/p&gt;

&lt;blockquote&gt;
  &lt;table&gt;&lt;colgroup&gt;&lt;col /&gt;&lt;col /&gt;&lt;/colgroup&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;th&gt;Name&lt;/th&gt;

        &lt;th&gt;Description&lt;/th&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td&gt;font&lt;/td&gt;

        &lt;td&gt;The font name of the XNA sprite font to use (default Lucida Console)&lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td&gt;size&lt;/td&gt;

        &lt;td&gt;The font size of the XNA Sprite Font (default 14)&lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td&gt;spacing&lt;/td&gt;

        &lt;td&gt;The spacing between the fonts (default 0)&lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td&gt;useKerning&lt;/td&gt;

        &lt;td&gt;If set, the XNA sprite font will use kerning&lt;/td&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td&gt;style&lt;/td&gt;

        &lt;td&gt;The style of the font (e.g. Regular, Bold, Italic)&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;/p&gt;

&lt;br /&gt;

&lt;p&gt;Here's New-SpriteFont: &lt;i&gt;&lt;/i&gt;

  &lt;blockquote&gt;
    &lt;pre class="CmdletDefinition"&gt;function New-SpriteFont {
           
    &amp;lt;#
    .Synopsis
        Creates a New XNA SpriteFont
    .Description
        Generates an XNA SpriteFont file.  Allows you to specify the font name, size, spacing, style, and if kerning is used or not
    .Parameter font
        The font name of the XNA sprite font to use (default Lucida Console)
    .Parameter size
        The font size of the XNA Sprite Font (default 14)
    .Parameter spacing
        The spacing between the fonts (default 0)
    .Parameter useKerning
        If set, the XNA sprite font will use kerning
    .Parameter style
        The style of the font (e.g. Regular, Bold, Italic)
    .Link
        Get-Font
    .Example
        # Create a simple New sprite font
        New-SpriteFont
    .Example
        # Create a sprite font using the font Garamond and a fontsize of 12
        New-SpriteFont &amp;quot;Garamond&amp;quot; 12
    #&amp;gt;
param($font = &amp;quot;Lucida Console&amp;quot;,
    [int]$size = 14,
    [int]$spacing = 0,
    [switch]$useKerning,
    $style = &amp;quot;Regular&amp;quot;)
if (-not (Get-Command Get-Font -ErrorAction SilentlyContinue )) { throw $error[0] }
    $checkedFont = Get-Font $font
    if (-not $checkedFont) {
        throw &amp;quot;The font name $font is not valid. Pick a new one a-hole.&amp;quot;
    }
@&amp;quot;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;
&amp;lt;!--
This file contains an xml description of a font, and will be read by the XNA
Framework Content Pipeline. Follow the comments to customize the appearance
of the font in your game, and to change the characters which are available to draw
with.
--&amp;gt;
&amp;lt;XnaContent xmlns:Graphics=&amp;quot;Microsoft.Xna.Framework.Content.Pipeline.Graphics&amp;quot;&amp;gt;
  &amp;lt;Asset Type=&amp;quot;Graphics:FontDescription&amp;quot;&amp;gt;

    &amp;lt;!--
    Modify this string to change the font that will be imported.
    --&amp;gt;
    &amp;lt;FontName&amp;gt;$font&amp;lt;/FontName&amp;gt;

    &amp;lt;!--
    Size is a float value, measured in points. Modify this value to change
    the size of the font.
    --&amp;gt;
    &amp;lt;Size&amp;gt;$size&amp;lt;/Size&amp;gt;

    &amp;lt;!--
    Spacing is a float value, measured in pixels. Modify this value to change
    the amount of spacing in between characters.
    --&amp;gt;
    &amp;lt;Spacing&amp;gt;$spacing&amp;lt;/Spacing&amp;gt;

    &amp;lt;!--
    UseKerning controls the layout of the font. If this value is true, kerning information
    will be used when placing characters.
    --&amp;gt;
    &amp;lt;UseKerning&amp;gt;$($useKerning.ToString().ToLower())&amp;lt;/UseKerning&amp;gt;

    &amp;lt;!--
    Style controls the style of the font. Valid entries are &amp;quot;Regular&amp;quot;, &amp;quot;Bold&amp;quot;, &amp;quot;Italic&amp;quot;,
    and &amp;quot;Bold, Italic&amp;quot;, and are case sensitive.
    --&amp;gt;
    &amp;lt;Style&amp;gt;$style&amp;lt;/Style&amp;gt;

    &amp;lt;!--
    If you uncomment this line, the default character will be substituted if you draw
    or measure text that contains characters which were not included in the font.
    --&amp;gt;
    &amp;lt;!-- &amp;lt;DefaultCharacter&amp;gt;*&amp;lt;/DefaultCharacter&amp;gt; --&amp;gt;

    &amp;lt;!--
    CharacterRegions control what letters are available in the font. Every
    character from Start to End will be built and made available for drawing. The
    default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
    character set. The characters are ordered according to the Unicode standard.
    See the documentation for more information.
    --&amp;gt;
    &amp;lt;CharacterRegions&amp;gt;
      &amp;lt;CharacterRegion&amp;gt;
        &amp;lt;Start&amp;gt;&amp;amp;#32;&amp;lt;/Start&amp;gt;
        &amp;lt;End&amp;gt;&amp;amp;#126;&amp;lt;/End&amp;gt;
      &amp;lt;/CharacterRegion&amp;gt;
    &amp;lt;/CharacterRegions&amp;gt;
  &amp;lt;/Asset&amp;gt;
&amp;lt;/XnaContent&amp;gt;
&amp;quot;@    

}    &lt;/pre&gt;
  &lt;/blockquote&gt;
&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;br /&gt;

&lt;p class="Postfooter"&gt;Hope this Helps,&lt;/p&gt;

&lt;p class="Postfooter"&gt;James Brundage [MSFT]&lt;/p&gt;

&lt;p style="font-size: xx-small"&gt;Automatically generated with &lt;a href="http://blogs.msdn.com/powershell/archive/tags/Write-CommandBlogPost/default.aspx"&gt;Write-CommandBlogPost&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9251648" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/Microcode/default.aspx">Microcode</category><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/XNA/default.aspx">XNA</category><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/Get-Font/default.aspx">Get-Font</category><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/New-SpriteFont/default.aspx">New-SpriteFont</category></item><item><title>Microcode: PowerShell Scripting Tricks: Get-Font</title><link>http://blogs.msdn.com/mediaandmicrocode/archive/2008/12/24/microcode-powershell-scripting-tricks-get-font.aspx</link><pubDate>Wed, 24 Dec 2008 12:33:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9251628</guid><dc:creator>JamesBrundage</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mediaandmicrocode/comments/9251628.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mediaandmicrocode/commentrss.aspx?PostID=9251628</wfw:commentRss><description>&lt;p class="PostHeader"&gt;I've started to explore the wild world of &lt;a href="http://creators.xna.com"&gt;XNA&lt;/a&gt;. XNA just released version 3, which allows you to make games for Windows, Xbox, and Zune. The SDK is free, and you can download it &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=7D70D6ED-1EDD-4852-9883-9A33C0AD8FEE&amp;amp;displaylang=en"&gt;here&lt;/a&gt;. It comes with a nifty little platformer game (think a 3-screen Super Mario Brothers), which helps a lot with the process of learning XNA.&lt;/p&gt;  &lt;p class="PostHeader"&gt;XNA involves a lot of little resource files, including one called a SpriteFont. The format for a SpriteFont file is really simple XML, so I decided to make a quick PowerShell function that would create a sprite font file. I could be very lazy, and simply accept whatever font name they gave me on faith, but I'm sure I would be very frustrated the first time I typed New-SpriteFont Arrial, and spent the next 15 minutes of my life wondering why my project wasn't compiling when all that was wrong was an extra 'r'. To save myself this future pain, I've made Get-Font, so New-SpriteFont can check what fonts exist before creating the file.&lt;/p&gt;  &lt;p class="PostHeader"&gt;Making Get-Font wasn't all that hard. I simply used my Get-Type function to find all of the types named fonts (Get-Type | Where-Object { .Name -eq &amp;quot;Fonts&amp;quot; } | Select FullName) and then explored static member properties. I wrote Get-Font in the Windows PowerShell Integrated Scripting Editor, so I added a check to load up the right assembly (which I also found out by using Get-Type) in case I was trying to use Get-Font from the PowerShell console. All told, Get-Font took about 5 minutes to write, and ended up being a quick PowerShell lesson for my girlfriend. I added inline help, and then I was done. Here's Get-Font. I'll show New-SpriteFont in a separate post.&lt;/p&gt;  &lt;br /&gt;  &lt;p class="CmdletName"&gt;Get-Font&lt;/p&gt;  &lt;br /&gt;  &lt;p class="CmdletSynopsis"&gt;&lt;b&gt;Synopsis:&lt;/b&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;blockquote&gt;Gets the fonts currently loaded on the system &lt;/blockquote&gt;  &lt;p&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;p class="CmdletSyntax"&gt;&lt;b&gt;Syntax:&lt;/b&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;blockquote&gt;Get-Font [[-font] [&amp;lt;Object&amp;gt;]] [&amp;lt;CommonParameters&amp;gt;] &lt;/blockquote&gt;  &lt;p&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;p class="CmdletDescription"&gt;&lt;b&gt;Detailed Description:&lt;/b&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;blockquote&gt;Uses the type System.Windows.Media.Fonts static property SystemFontFamilies,    &lt;br /&gt;to retrieve all of the fonts loaded by the system. If the Fonts type is not found,     &lt;br /&gt;the PresentationCore assembly will be automatically loaded &lt;/blockquote&gt;  &lt;p&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;p class="Examples"&gt;Examples: &lt;/p&gt;  &lt;blockquote&gt;   &lt;pre class="CmdletExample"&gt;    -------------------------- EXAMPLE 1 --------------------------





# Get All Fonts
Get-Font
    &lt;/pre&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;pre class="CmdletExample"&gt;    -------------------------- EXAMPLE 2 --------------------------





# Get All Lucida Fonts
Get-Font *Lucida*
    &lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;/p&gt;

&lt;br /&gt;

&lt;p class="CmdletParameters"&gt;Command Parameters: &lt;/p&gt;

&lt;blockquote&gt;
  &lt;table&gt;&lt;colgroup&gt;&lt;col /&gt;&lt;col /&gt;&lt;/colgroup&gt;&lt;tbody&gt;
      &lt;tr&gt;
        &lt;th&gt;Name&lt;/th&gt;

        &lt;th&gt;Description&lt;/th&gt;
      &lt;/tr&gt;

      &lt;tr&gt;
        &lt;td&gt;font&lt;/td&gt;

        &lt;td&gt;A wildcard to search for font names&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;&lt;/table&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;/p&gt;

&lt;br /&gt;

&lt;p&gt;Here's Get-Font: &lt;i&gt;&lt;/i&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="CmdletDefinition"&gt;function Get-Font {
           
    &amp;lt;#
    .Synopsis
        Gets the fonts currently loaded on the system
    .Description
        Uses the type System.Windows.Media.Fonts static property SystemFontFamilies,
        to retrieve all of the fonts loaded by the system.  If the Fonts type is not found,
        the PresentationCore assembly will be automatically loaded
    .Parameter font
        A wildcard to search for font names
    .Example
        # Get All Fonts
        Get-Font
    .Example
        # Get All Lucida Fonts
        Get-Font *Lucida*
    #&amp;gt;
    param($font = &amp;quot;*&amp;quot;)
if (-not (&amp;quot;Windows.Media.Fonts&amp;quot; -as [Type])) {
        Add-Type -AssemblyName &amp;quot;PresentationCore&amp;quot;
    }       

    [Windows.Media.Fonts]::SystemFontFamilies |
        Where-Object { $_.Source -like &amp;quot;$font&amp;quot; } 

}
    &lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;br /&gt;

&lt;p class="Postfooter"&gt;Hope this Helps,&lt;/p&gt;

&lt;p class="Postfooter"&gt;James Brundage [MSFT]&lt;/p&gt;

&lt;p style="font-size: xx-small"&gt;Automatically generated with &lt;a href="http://blogs.msdn.com/powershell/archive/tags/Write-CommandBlogPost/default.aspx"&gt;Write-CommandBlogPost&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9251628" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/Microcode/default.aspx">Microcode</category><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/XNA/default.aspx">XNA</category><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/Get-Font/default.aspx">Get-Font</category></item><item><title>Media: xBox 360: 70 XNA Games in 24 Days</title><link>http://blogs.msdn.com/mediaandmicrocode/archive/2008/12/13/media-xbox-360-70-xna-games-in-24-days.aspx</link><pubDate>Sat, 13 Dec 2008 14:26:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9208502</guid><dc:creator>JamesBrundage</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mediaandmicrocode/comments/9208502.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mediaandmicrocode/commentrss.aspx?PostID=9208502</wfw:commentRss><description>&lt;p&gt;It’s the weekend.&amp;#160; I love my video games, and I really love my xBox 360.&amp;#160; I’ve had one since just after they first came out, and I’ve slowly but surely accumulated about 70 physical games for the 360 made by major producers.&amp;#160; I remember seeing the total xBox 360 games climb past one hundred, and I remember losing count.&amp;#160; But until now, it’s been rare to see more than a few games come out each month.&lt;/p&gt;  &lt;p&gt;But now there’s &lt;a href="http://www.xna.com/"&gt;XNA&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;XNA is a way for Joe Schmoe to write (and now profit) off of writing video games.&amp;#160; Using XNA, you can write video games in C#.&amp;#160; It’s been possible to write XNA games for a couple of years, but it was only November 19th that XNA games went out on xBox Live and were up for sale.&lt;/p&gt;  &lt;p&gt;It’s been 24 days since then, and there are 70 community games on Xbox Live.&amp;#160; They range from 200-800 points (~$3-~$10) and a large chunk of the cash goes to the one or two people that develop the games.&amp;#160; They all have free trial versions.&lt;/p&gt;  &lt;p&gt;So support poor game developers.&amp;#160; Fire up your xbox 360 and check some XNA games out.&lt;/p&gt;  &lt;p&gt;Enjoy,&lt;/p&gt;  &lt;p&gt;James Brundage [MSFT]&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9208502" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/Media/default.aspx">Media</category><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/XNA/default.aspx">XNA</category><category domain="http://blogs.msdn.com/mediaandmicrocode/archive/tags/Xbox+360/default.aspx">Xbox 360</category></item></channel></rss>