The rendering equation

The rendering equation, the keystone of computer graphics rendering:

$$L_o(x, \vec{w}) = L_e(x, \vec{w}) + \int_\Omega f_r(x, \vec w', \vec w) L_i(x, \vec w') (\vec w' \cdot \vec n) \mathrm{d}\vec w'$$

(This is at the same time also a test for MathJax support on my weblog in order to provide correct mathematical typesetting using proper typography instead of some lame pixelated image.)

MathML and SVG in HTML 5 with Firefox

I've been using MathML for a while now for some of my documentation work on 3D graphics. Unfortunately the only way at the moment is to use XHTML 1.1 modular doctype to include either or both of MathML and SVG. In HTML 5 these have become embedded content parts of the specification. So for example, using MathML would be as simple as doing:

<!DOCTYPE HTML>
<html>
  <head>
    <meta charset="utf-8">
    <title>MathML test</title>
  </head>
  <body>
    <math>
      <mrow>
        <mi>y</mi>
        <mo>=</mo>
        <msup>
          <mi>x</mi>
          <mn>2</mn>
        </msup>
      </mrow>
    </math>
  </body>
</html>

Unfortunately the only browser to support either MathML or (parts of) HTML 5 at this moment is Firefox 3.5. However, the MathML or SVG embedded content did not render under 3.5. After reading John Resig's post about a new HTML parsing engine in Mozilla's Gecko engine I set out to test this engine's support by downloading the latest nightly and setting html5.enable to true in about:config and 'lo and behold, it renders as expected.

True Type fonts, X.org, and MathML

I use MathML. Why? Because it just makes sense for mathematics on the websites.

On my DragonFly I had to do the following:

Installed X.org 6.8.1 or .2. Enable xfs (the X font server) by adding xfs_enable="YES" to rc.conf.

From ports install x11-fonts/ttmkfdir and x11-fonts/urwfonts-ttf.

(Note: download doesn't exist anymore.)

New and better instructions: https://developer.mozilla.org/en-US/docs/Mozilla/MathML_Project/Fonts

In /usr/X11R6/lib/X11/fonts/TTF do:

# ttmkfdir > fonts.scale
# mkfontdir

This will update fonts.scale and fonts.dir, check them with cat or more to see if they contain references to the extracted new .ttf files.

Change /usr/X11R6/lib/X11/fs/config to have /usr/X11R6/lib/X11/fonts/urwfonts-ttf added to catalogue.

Also add /usr/X11R6/lib/X11/fonts/urwfonts-ttf as a FontPath to /etc/X11/xorg.conf:

# xset fp+ /usr/X11R6/lib/X11/fonts/urwfonts-ttf
# xset fp rehash

Edited $HOME/.fonts.conf and added:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="pattern">
    <test name="family">
      <string>symbol</string>
    </test>
    <edit name="family" mode="append" binding="strong">
      <string>Standard Symbols L</string>
    </edit>
  </match>
</fontconfig>

Added user_pref("font.mathfont-family", "Math1, Math2, Math4"); to $HOME/.mozilla/firefox/<profile.default>/user.js.

There seem to be some bugs still, at least in displaying the W3C test suite.