# How To Set Up Surrogate Fonts

If you encounter display problem with Unicode characters where a single Unicode character appears as two empty square boxes, you should read this article to find out how to fix it. Specifically, this problem occurs when your Unicode character is greater than U+FFFF (65635 decimal) and your Unicode font can handle only characters that are less than 64K in value.

## 1. What is a surrogate character?

Unicode characters can range in scalar values from 0 to over a million. Characters above 64K (greater than U+FFFF or 65635) are called supplementary Unicode characters. The entire range of Unicode characters is divided into 17 blocks of 64K values each. Each block is referred to as a plane and is numbered starting from 0 as follows:

- Plane 0: contains U+0000 thru U+FFFF. This is commonly known as the Basic Multilingual Plane (BMP).
- Plane 1: contains U+10000 thru U+1FFFF.
- Plane 2: contains U+20000 thru U+2FFFF. The majority of characters in this plane are Unicode Extension B (Hán/Hàn/Nh?t/Nôm).
- Plane 3: contains U+30000 thru U+3FFFF.
- ...............
- Plane 16: contains U+100000 thru U+10FFFF.

Note that all characters in Plane 0 can be represented as a single 16-bit value. Characters in other planes are greater than 64K and can be represented as a single 32-bit value (UCS-4) or a pair of two 16-bit values (UTF-16). In the latter representation the pair is commonly called surrogate pair, which consists of a high-order 16-bit surrogate and a low-order 16-bit surrogate.

Unfortunately Windows knows and processes only 16-bit Unicode characters by default. When Windows encounters a surrogate pair, it thinks there are two distinct 16-bit characters and simply displays as such. This turns out to be always two empty square boxes. The reason is that each of the 16-bit surrogate piece is a forbidden 16-bit character in the Unicode standards and is represented as an empty square box in Unicode fonts; only the combination of the two surrogate pieces together yields a single Unicode character.

To make the long story short:

- Surrogate characters are representations of Unicode characters greater than 64K. In practical terms, when a Unicode character is 5 or 6 significant hex digits long such as U+1FFAB or U+2AB45, it is represented by a surrogate pair.

- If your text contains surrogates, they simply appear as two empty square boxes unless you tell Windows to use surrogate fonts by appropriate settings in Windows registry.

## 2. How to set up Windows to display surrogate characters?

There are three steps:

### 3.1 Install SURREG.EXE

The first step is to install surreg.exe (1.3 MB), which is downloadable from Microsoft website:

http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=1A8B048F-C76F-4E55-A0CF-E695CEF87C81

or specifically click here to download the file:

http://download.microsoft.com/download/OfficeXPStandard/Patch/1.0/NT45XP/CN/surreg.exe

### 3.2 Install Surrogate Fonts

If you have no fonts for supplementary characters, you can download some from the Internet for free. At the present time the author of WinVNKey knows a few fonts:

- Plane 1: CODE2001.ZIP (207,345 bytes), which covers a number of characters in Plane 1 (U+10000 through U+1FFFF):
  http://home.att.net/~jameskass/code2001.htm

- Plane 2: HannomH.zip (27 MB, high resolution) and Hannom.zip (19 MB, low resolution), both of which contain two fonts:
  - Font "HAN NOM A", containing Han Nom characters in Extension A (Plane 0)
  - Font "HAN NOM B", containing Han Nom characters in Extension B (Plane 2)
  These fonts and a number of Vietnamese Unicode fonts can be downloaded from

  http://sourceforge.net/project/showfiles.php?group_id=41991

### 3.3 Set Up Windows Registry

The last step is to set up Windows registry. According to Microsoft

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/unicode_192r.asp

users have to set up Windows registry as follows:

              [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\LanguagePack]
                  SURROGATE=(REG_DWORD)0x00000002

              [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\International\Scripts\42]
                   IEFixedFontName=(Surrogate Font Face Name)
                   IEPropFontName=(Surrogate Font Face Name)

Additional information is available at

- http://www.i18nguy.com/surrogates.html: detailed explanation of these registry entries
- http://www.daouyen.com/NomDoc/CJKVB.htm: instructions in Vietnamese

Based on the information obtained from the websites above, WinVNKey provides a user-interface to help users change the registry easily:

### Setting 1

This setting tells Windows to load Uniscribe, which is an engine to process surrogate characters

        [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\LanguagePack]
        SURROGATE=(REG_DWORD)0x00000002

### Setting 2

This setting specifies the names of fixed and proportional fonts for Internet Explorer to use to display surrogate characters

        [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\International\Scripts\42]
        IEFixedFontName=[Surrogate Font Face Name]
        IEPropFontName=[Surrogate Font Face Name]

### Setting 3

This setting is for Windows XP systems only and is optional. Basically, this setting specifies the fallback fonts for characters in supplementary planes. You can specify as many planes as you like.

         [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\LanguagePack\SurrogateFallback]
         Plane1=(Name for fallback font for characters in Plane 1)
         Plane2=(Name for fallback font for characters in Plane 2)
         ... etc. ...

## 3. How to use WinVNKey to change surrogate registry?

The three registry settings above can be changed by using WinVNKey as follows:

Click on Run button ==> Preferences ==> Surrogate Fonts

Note there are no OK/Cancel buttons on the "Surrogate Fonts" page. Any change you make to the page will become effective immediately.

After setting up surrogate registry with supplementary fonts, you can test if the system works. You can browse several websites that use supplementary characters and check if you can see them. These sites are listed in

- http://www.i18nguy.com/surrogates.html
- http://www.daouyen.com/NomDoc/CJKVB.htm

Specifically,

- http://www.daouyen.com/NomDoc/CuTranLacDao.htm
- http://www.i18nguy.com/unicode/plane1-utf-16.html
- http://www.i18nguy.com/unicode-plane1-utf8.html
- http://www.i18nguy.com/unicode-example-plane1.html
- http://www.i18nguy.com/unicode/unicode-example-intro.html
- http://homepage.mac.com/thgewecke/BeyondBMP.html