title: Windows 8.1 apps - RichEditBox baseline-based super- subscript
body: <p>I've got a panel for text formatting and I've got to get sub- and superscript work but it can't be done by inserting \sub or \super into RTF (RTF is what I need in the end).
  This is how I would set superscript by inserting \sub:</p>
  
  <pre><code>public void SetSuperscript()
  {
      ITextSelection selectedText = _textbox.Document.Selection;
      if (selectedText != null)
      {
          ITextCharacterFormat charFormatting = selectedText.CharacterFormat;
          charFormatting.Superscript= FormatEffect.On;
          selectedText.CharacterFormat = charFormatting;
      }
  }
  </code></pre>
  
  <p>Now I know I can do it like that as well:</p>
  
  <pre><code>public void SetSuperscript()
  {
      ITextSelection selectedText = _textbox.Document.Selection;
      if (selectedText != null)
      {
          ITextCharacterFormat charFormatting = selectedText.CharacterFormat;
          charFormatting.Size /= 2;
          charFormatting.Position = charFormatting.Size;
          selectedText.CharacterFormat = charFormatting;
      }
  }
  </code></pre>
  
  <p>and it works just as fine. The problem is when it comes to creating a subscript:</p>
  
  <pre><code>public void SetSubscript()
  {
      ITextSelection selectedText = _textbox.Document.Selection;
      if (selectedText != null)
      {
          ITextCharacterFormat charFormatting = selectedText.CharacterFormat;
          charFormatting.Size /= 2;
          charFormatting.Position = -charFormatting.Size;
          selectedText.CharacterFormat = charFormatting;
      }
  }
  </code></pre>
  
  <p>This code above throws an exception "Value does not fall within the expected range." and it's caused by this line:
  <code>charFormatting.Position = -charFormatting.Size;</code>
  I'm assigning there a negative value (which is allright according to the documentation) because I need the selected text to be lower than normal text by half of its height. What am I doing wrong?</p>
  
  <p>Daniel</p>