Bug 869764. Eliminate use of t2embed library in Windows GDI case. r=emk
authorJohn Daggett <jdaggett@mozilla.com>
Tue, 09 Jul 2013 10:40:03 +0900
changeset 138417 d032499bafe18baa637d872cd251691d92cfd154
parent 138416 eb2c4bc8d05103632f01cef0ffc1d1d0f7d949e0
child 138418 57ffaa460a6bb8f0507f119a4b5b62e0c430d99a
push idunknown
push userunknown
push dateunknown
reviewersemk
bugs869764
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 869764. Eliminate use of t2embed library in Windows GDI case. r=emk
gfx/thebes/gfxFontUtils.cpp
gfx/thebes/gfxFontUtils.h
gfx/thebes/gfxGDIFontList.cpp
gfx/thebes/gfxGDIFontList.h
layout/reftests/font-face/reftest.list
--- a/gfx/thebes/gfxFontUtils.cpp
+++ b/gfx/thebes/gfxFontUtils.cpp
@@ -1414,414 +1414,19 @@ gfxFontUtils::ReadNames(hb_blob_t *aName
 
     }
 
     return NS_OK;
 }
 
 #ifdef XP_WIN
 
-// Embedded OpenType (EOT) handling
-// needed for dealing with downloadable fonts on Windows
-//
-// EOT version 0x00020001
-// based on http://www.w3.org/Submission/2008/SUBM-EOT-20080305/
-//
-// EOT header consists of a fixed-size portion containing general font
-// info, followed by a variable-sized portion containing name data,
-// followed by the actual TT/OT font data (non-byte values are always
-// stored in big-endian format)
-//
-// EOT header is stored in *little* endian order!!
-
-#pragma pack(1)
-
-struct EOTFixedHeader {
-
-    uint32_t      eotSize;            // Total structure length in PRUint8s (including string and font data)
-    uint32_t      fontDataSize;       // Length of the OpenType font (FontData) in PRUint8s
-    uint32_t      version;            // Version number of this format - 0x00010000
-    uint32_t      flags;              // Processing Flags
-    uint8_t       panose[10];         // The PANOSE value for this font - See http://www.microsoft.com/typography/otspec/os2.htm#pan
-    uint8_t       charset;            // In Windows this is derived from TEXTMETRIC.tmCharSet. This value specifies the character set of the font. DEFAULT_CHARSET (0x01) indicates no preference. - See http://msdn2.microsoft.com/en-us/library/ms534202.aspx
-    uint8_t       italic;             // If the bit for ITALIC is set in OS/2.fsSelection, the value will be 0x01 - See http://www.microsoft.com/typography/otspec/os2.htm#fss
-    uint32_t      weight;             // The weight value for this font - See http://www.microsoft.com/typography/otspec/os2.htm#wtc
-    uint16_t      fsType;             // Type flags that provide information about embedding permissions - See http://www.microsoft.com/typography/otspec/os2.htm#fst
-    uint16_t      magicNumber;        // Magic number for EOT file - 0x504C. Used to check for data corruption.
-    uint32_t      unicodeRange1;      // OS/2.UnicodeRange1 (bits 0-31) - See http://www.microsoft.com/typography/otspec/os2.htm#ur
-    uint32_t      unicodeRange2;      // OS/2.UnicodeRange2 (bits 32-63) - See http://www.microsoft.com/typography/otspec/os2.htm#ur
-    uint32_t      unicodeRange3;      // OS/2.UnicodeRange3 (bits 64-95) - See http://www.microsoft.com/typography/otspec/os2.htm#ur
-    uint32_t      unicodeRange4;      // OS/2.UnicodeRange4 (bits 96-127) - See http://www.microsoft.com/typography/otspec/os2.htm#ur
-    uint32_t      codePageRange1;     // CodePageRange1 (bits 0-31) - See http://www.microsoft.com/typography/otspec/os2.htm#cpr
-    uint32_t      codePageRange2;     // CodePageRange2 (bits 32-63) - See http://www.microsoft.com/typography/otspec/os2.htm#cpr
-    uint32_t      checkSumAdjustment; // head.CheckSumAdjustment - See http://www.microsoft.com/typography/otspec/head.htm
-    uint32_t      reserved[4];        // Reserved - must be 0
-    uint16_t      padding1;           // Padding to maintain long alignment. Padding value must always be set to 0x0000.
-
-    enum {
-        EOT_VERSION = 0x00020001,
-        EOT_MAGIC_NUMBER = 0x504c,
-        EOT_DEFAULT_CHARSET = 0x01,
-        EOT_EMBED_PRINT_PREVIEW = 0x0004,
-        EOT_FAMILY_NAME_INDEX = 0,    // order of names in variable portion of EOT header
-        EOT_STYLE_NAME_INDEX = 1,
-        EOT_VERSION_NAME_INDEX = 2,
-        EOT_FULL_NAME_INDEX = 3,
-        EOT_NUM_NAMES = 4
-    };
-
-};
-
-#pragma pack()
-
-// EOT headers are only used on Windows
-
-// EOT variable-sized header (version 0x00020001 - contains 4 name
-// fields, each with the structure):
-//
-//   // number of bytes in the name array
-//   uint16_t size;
-//   // array of UTF-16 chars, total length = <size> bytes
-//   // note: english version of name record string
-//   uint8_t  name[size]; 
-//
-// This structure is used for the following names, each separated by two
-// bytes of padding (always 0 with no padding after the rootString):
-//
-//   familyName  - based on name ID = 1
-//   styleName   - based on name ID = 2
-//   versionName - based on name ID = 5
-//   fullName    - based on name ID = 4
-//   rootString  - used to restrict font usage to a specific domain
-//
-
-#if DEBUG
-static void 
-DumpEOTHeader(uint8_t *aHeader, uint32_t aHeaderLen)
-{
-    uint32_t offset = 0;
-    uint8_t *ch = aHeader;
-
-    printf("\n\nlen == %d\n\n", aHeaderLen);
-    while (offset < aHeaderLen) {
-        printf("%7.7x    ", offset);
-        int i;
-        for (i = 0; i < 16; i++) {
-            printf("%2.2x  ", *ch++);
-        }
-        printf("\n");
-        offset += 16;
-    }
-}
-#endif
-
-nsresult
-gfxFontUtils::MakeEOTHeader(const uint8_t *aFontData, uint32_t aFontDataLength,
-                            FallibleTArray<uint8_t> *aHeader,
-                            FontDataOverlay *aOverlay)
-{
-    NS_ASSERTION(aFontData && aFontDataLength != 0, "null font data");
-    NS_ASSERTION(aHeader, "null header");
-    NS_ASSERTION(aHeader->Length() == 0, "non-empty header passed in");
-    NS_ASSERTION(aOverlay, "null font overlay struct passed in");
-
-    aOverlay->overlaySrc = 0;
-    
-    if (!aHeader->AppendElements(sizeof(EOTFixedHeader)))
-        return NS_ERROR_OUT_OF_MEMORY;
-
-    EOTFixedHeader *eotHeader = reinterpret_cast<EOTFixedHeader*>(aHeader->Elements());
-    memset(eotHeader, 0, sizeof(EOTFixedHeader));
-
-    uint32_t fontDataSize = aFontDataLength;
-
-    // set up header fields
-    eotHeader->fontDataSize = fontDataSize;
-    eotHeader->version = EOTFixedHeader::EOT_VERSION;
-    eotHeader->flags = 0;  // don't specify any special processing
-    eotHeader->charset = EOTFixedHeader::EOT_DEFAULT_CHARSET;
-    eotHeader->fsType = EOTFixedHeader::EOT_EMBED_PRINT_PREVIEW;
-    eotHeader->magicNumber = EOTFixedHeader::EOT_MAGIC_NUMBER;
-
-    // read in the sfnt header
-    if (sizeof(SFNTHeader) > aFontDataLength)
-        return NS_ERROR_FAILURE;
-    
-    const SFNTHeader *sfntHeader = reinterpret_cast<const SFNTHeader*>(aFontData);
-    if (!IsValidSFNTVersion(sfntHeader->sfntVersion))
-        return NS_ERROR_FAILURE;
-
-    // iterate through the table headers to find the head, name and OS/2 tables
-    bool foundHead = false, foundOS2 = false, foundName = false, foundGlyphs = false;
-    uint32_t headOffset, headLen, nameOffset, nameLen, os2Offset, os2Len;
-    uint32_t i, numTables;
-
-    numTables = sfntHeader->numTables;
-    if (sizeof(SFNTHeader) + sizeof(TableDirEntry) * numTables > aFontDataLength)
-        return NS_ERROR_FAILURE;
-    
-    uint64_t dataLength(aFontDataLength);
-    
-    // table directory entries begin immediately following SFNT header
-    const TableDirEntry *dirEntry = reinterpret_cast<const TableDirEntry*>(aFontData + sizeof(SFNTHeader));
-    
-    for (i = 0; i < numTables; i++, dirEntry++) {
-    
-        // sanity check on offset, length values
-        if (uint64_t(dirEntry->offset) + uint64_t(dirEntry->length) > dataLength)
-            return NS_ERROR_FAILURE;
-
-        switch (dirEntry->tag) {
-
-        case TRUETYPE_TAG('h','e','a','d'):
-            foundHead = true;
-            headOffset = dirEntry->offset;
-            headLen = dirEntry->length;
-            if (headLen < sizeof(HeadTable))
-                return NS_ERROR_FAILURE;
-            break;
-
-        case TRUETYPE_TAG('n','a','m','e'):
-            foundName = true;
-            nameOffset = dirEntry->offset;
-            nameLen = dirEntry->length;
-            break;
-
-        case TRUETYPE_TAG('O','S','/','2'):
-            foundOS2 = true;
-            os2Offset = dirEntry->offset;
-            os2Len = dirEntry->length;
-            break;
-
-        case TRUETYPE_TAG('g','l','y','f'):  // TrueType-style quadratic glyph table
-            foundGlyphs = true;
-            break;
-
-        case TRUETYPE_TAG('C','F','F',' '):  // PS-style cubic glyph table
-            foundGlyphs = true;
-            break;
-
-        default:
-            break;
-        }
-
-        if (foundHead && foundName && foundOS2 && foundGlyphs)
-            break;
-    }
-
-    // require these three tables on Windows
-    if (!foundHead || !foundName || !foundOS2)
-        return NS_ERROR_FAILURE;
-
-    // at this point, all table offset/length values are within bounds
-    
-    // read in the data from those tables
-
-    // -- head table data
-    const HeadTable  *headData = reinterpret_cast<const HeadTable*>(aFontData + headOffset);
-
-    if (headData->tableVersionNumber != HeadTable::HEAD_VERSION ||
-        headData->magicNumber != HeadTable::HEAD_MAGIC_NUMBER) {
-        return NS_ERROR_FAILURE;
-    }
-
-    eotHeader->checkSumAdjustment = headData->checkSumAdjustment;
-
-    // -- name table data
-
-    // -- first, read name table header
-    const NameHeader *nameHeader = reinterpret_cast<const NameHeader*>(aFontData + nameOffset);
-    uint32_t nameStringsBase = uint32_t(nameHeader->stringOffset);
-
-    uint32_t nameCount = nameHeader->count;
-
-    // -- sanity check the number of name records
-    if (uint64_t(nameCount) * sizeof(NameRecord) + uint64_t(nameOffset) > dataLength)
-        return NS_ERROR_FAILURE;
-
-    // bug 496573 -- dummy names in case the font didn't contain English names
-    const nsString dummyNames[EOTFixedHeader::EOT_NUM_NAMES] = {
-        NS_LITERAL_STRING("Unknown"),
-        NS_LITERAL_STRING("Regular"),
-        EmptyString(),
-        dummyNames[EOTFixedHeader::EOT_FAMILY_NAME_INDEX]
-    };
-
-    // -- iterate through name records, look for specific name ids with
-    //    matching platform/encoding/etc. and store offset/lengths
-    NameRecordData names[EOTFixedHeader::EOT_NUM_NAMES] = {0};
-    const NameRecord *nameRecord = reinterpret_cast<const NameRecord*>(aFontData + nameOffset + sizeof(NameHeader));
-    uint32_t needNames = (1 << EOTFixedHeader::EOT_FAMILY_NAME_INDEX) | 
-                         (1 << EOTFixedHeader::EOT_STYLE_NAME_INDEX) | 
-                         (1 << EOTFixedHeader::EOT_FULL_NAME_INDEX) | 
-                         (1 << EOTFixedHeader::EOT_VERSION_NAME_INDEX);
-
-    for (i = 0; i < nameCount; i++, nameRecord++) {
-
-        // looking for Microsoft English US name strings, skip others
-        if (uint32_t(nameRecord->platformID) != PLATFORM_ID_MICROSOFT || 
-                uint32_t(nameRecord->encodingID) != ENCODING_ID_MICROSOFT_UNICODEBMP || 
-                uint32_t(nameRecord->languageID) != LANG_ID_MICROSOFT_EN_US)
-            continue;
-
-        uint32_t index;
-        switch ((uint32_t)nameRecord->nameID) {
-
-        case NAME_ID_FAMILY:
-            index = EOTFixedHeader::EOT_FAMILY_NAME_INDEX;
-            break;
-
-        case NAME_ID_STYLE:
-            index = EOTFixedHeader::EOT_STYLE_NAME_INDEX;
-            break;
-
-        case NAME_ID_FULL:
-            index = EOTFixedHeader::EOT_FULL_NAME_INDEX;
-            break;
-
-        case NAME_ID_VERSION:
-            index = EOTFixedHeader::EOT_VERSION_NAME_INDEX;
-            break;
-
-        default:
-            continue;
-        }
-
-        names[index].offset = nameRecord->offset;
-        names[index].length = nameRecord->length;
-        needNames &= ~(1 << index);
-
-        if (needNames == 0)
-            break;
-    }
-
-    // -- expand buffer if needed to include variable-length portion
-    uint32_t eotVariableLength = 0;
-    for (i = 0; i < EOTFixedHeader::EOT_NUM_NAMES; i++) {
-        if (!(needNames & (1 << i))) {
-            eotVariableLength += names[i].length & (~1);
-        } else {
-            eotVariableLength += dummyNames[i].Length() * sizeof(PRUnichar);
-        }
-    }
-    eotVariableLength += EOTFixedHeader::EOT_NUM_NAMES * (2 /* size */ 
-                                                          + 2 /* padding */) +
-                         2 /* null root string size */;
-
-    if (!aHeader->AppendElements(eotVariableLength))
-        return NS_ERROR_OUT_OF_MEMORY;
-
-    // append the string data to the end of the EOT header
-    uint8_t *eotEnd = aHeader->Elements() + sizeof(EOTFixedHeader);
-    uint32_t strOffset, strLen;
-
-    for (i = 0; i < EOTFixedHeader::EOT_NUM_NAMES; i++) {
-        if (!(needNames & (1 << i))) {
-            uint32_t namelen = names[i].length;
-            uint32_t nameoff = names[i].offset;  // offset from base of string storage
-
-            // sanity check the name string location
-            if (uint64_t(nameOffset) + uint64_t(nameStringsBase) +
-                uint64_t(nameoff) + uint64_t(namelen) > dataLength) {
-                return NS_ERROR_FAILURE;
-            }
-
-            strOffset = nameOffset + nameStringsBase + nameoff;
-
-            // output 2-byte str size
-            strLen = namelen & (~1);  // UTF-16 string len must be even
-            *((uint16_t*) eotEnd) = uint16_t(strLen);
-            eotEnd += 2;
-
-            // length is number of UTF-16 chars, not bytes
-            CopySwapUTF16(reinterpret_cast<const uint16_t*>(aFontData + strOffset),
-                          reinterpret_cast<uint16_t*>(eotEnd),
-                          (strLen >> 1));
-        } else {
-            // bug 496573 -- English names are not present.
-            // supply an artificial one.
-            strLen = dummyNames[i].Length() * sizeof(PRUnichar);
-            *((uint16_t*) eotEnd) = uint16_t(strLen);
-            eotEnd += 2;
-
-            memcpy(eotEnd, dummyNames[i].BeginReading(), strLen);
-        }
-        eotEnd += strLen;
-
-        // add 2-byte zero padding to the end of each string
-        *eotEnd++ = 0;
-        *eotEnd++ = 0;
-
-        // Note: Microsoft's WEFT tool produces name strings which
-        // include an extra null at the end of each string, in addition
-        // to the 2-byte zero padding that separates the string fields. 
-        // Don't think this is important to imitate...
-    }
-
-    // append null root string size
-    *eotEnd++ = 0;
-    *eotEnd++ = 0;
-
-    NS_ASSERTION(eotEnd == aHeader->Elements() + aHeader->Length(), 
-                 "header length calculation incorrect");
-                 
-    // bug 496573 -- fonts with a fullname that does not begin with the 
-    // family name cause the EOT font loading API to hiccup
-    uint32_t famOff = names[EOTFixedHeader::EOT_FAMILY_NAME_INDEX].offset;
-    uint32_t famLen = names[EOTFixedHeader::EOT_FAMILY_NAME_INDEX].length;
-    uint32_t fullOff = names[EOTFixedHeader::EOT_FULL_NAME_INDEX].offset;
-    uint32_t fullLen = names[EOTFixedHeader::EOT_FULL_NAME_INDEX].length;
-    
-    const uint8_t *nameStrings = aFontData + nameOffset + nameStringsBase;
-
-    // assure that the start of the fullname matches the family name
-    if (famLen <= fullLen 
-        && memcmp(nameStrings + famOff, nameStrings + fullOff, famLen)) {
-        aOverlay->overlaySrc = nameOffset + nameStringsBase + famOff;
-        aOverlay->overlaySrcLen = famLen;
-        aOverlay->overlayDest = nameOffset + nameStringsBase + fullOff;
-    }
-
-    // -- OS/2 table data
-    const OS2Table *os2Data = reinterpret_cast<const OS2Table*>(aFontData + os2Offset);
-
-    memcpy(eotHeader->panose, os2Data->panose, sizeof(eotHeader->panose));
-
-    eotHeader->italic = (uint16_t) os2Data->fsSelection & 0x01;
-    eotHeader->weight = os2Data->usWeightClass;
-    eotHeader->unicodeRange1 = os2Data->unicodeRange1;
-    eotHeader->unicodeRange2 = os2Data->unicodeRange2;
-    eotHeader->unicodeRange3 = os2Data->unicodeRange3;
-    eotHeader->unicodeRange4 = os2Data->unicodeRange4;
-    eotHeader->codePageRange1 = os2Data->codePageRange1;
-    eotHeader->codePageRange2 = os2Data->codePageRange2;
-
-    eotHeader->eotSize = aHeader->Length() + fontDataSize;
-
-    // DumpEOTHeader(aHeader->Elements(), aHeader->Length());
-
-    return NS_OK;
-}
-
 /* static */
 bool
-gfxFontUtils::IsCffFont(const uint8_t* aFontData, bool& hasVertical)
+gfxFontUtils::IsCffFont(const uint8_t* aFontData)
 {
     // this is only called after aFontData has passed basic validation,
     // so we know there is enough data present to allow us to read the version!
     const SFNTHeader *sfntHeader = reinterpret_cast<const SFNTHeader*>(aFontData);
-
-    uint32_t i;
-    uint32_t numTables = sfntHeader->numTables;
-    const TableDirEntry *dirEntry = 
-        reinterpret_cast<const TableDirEntry*>(aFontData + sizeof(SFNTHeader));
-    hasVertical = false;
-    for (i = 0; i < numTables; i++, dirEntry++) {
-        if (dirEntry->tag == TRUETYPE_TAG('v','h','e','a')) {
-            hasVertical = true;
-            break;
-        }
-    }
-
     return (sfntHeader->sfntVersion == TRUETYPE_TAG('O','T','T','O'));
 }
 
-#endif
+#endif
\ No newline at end of file
--- a/gfx/thebes/gfxFontUtils.h
+++ b/gfx/thebes/gfxFontUtils.h
@@ -795,31 +795,20 @@ public:
     static uint16_t
     MapUVSToGlyphFormat14(const uint8_t *aBuf, uint32_t aCh, uint32_t aVS);
 
     static uint32_t
     MapCharToGlyph(const uint8_t *aCmapBuf, uint32_t aBufLength,
                    uint32_t aUnicode, uint32_t aVarSelector = 0);
 
 #ifdef XP_WIN
-
-    // given a TrueType/OpenType data file, produce a EOT-format header
-    // for use with Windows T2Embed API AddFontResource type API's
-    // effectively hide existing fonts with matching names aHeaderLen is
-    // the size of the header buffer on input, the actual size of the
-    // EOT header on output
-    static nsresult
-    MakeEOTHeader(const uint8_t *aFontData, uint32_t aFontDataLength,
-                  FallibleTArray<uint8_t> *aHeader, FontDataOverlay *aOverlay);
-
     // determine whether a font (which has already been sanitized, so is known
     // to be a valid sfnt) is CFF format rather than TrueType
     static bool
-    IsCffFont(const uint8_t* aFontData, bool& hasVertical);
-
+    IsCffFont(const uint8_t* aFontData);
 #endif
 
     // determine the format of font data
     static gfxUserFontType
     DetermineFontDataType(const uint8_t *aFontData, uint32_t aFontDataLength);
 
     // Read the fullname from the sfnt data (used to save the original name
     // prior to renaming the font for installation).
--- a/gfx/thebes/gfxGDIFontList.cpp
+++ b/gfx/thebes/gfxGDIFontList.cpp
@@ -26,17 +26,16 @@
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIWindowsRegKey.h"
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Telemetry.h"
 
 #include <usp10.h>
-#include <t2embapi.h>
 
 using namespace mozilla;
 
 #define ROUND(x) floor((x) + 0.5)
 
 
 #ifndef CLEARTYPE_QUALITY
 #define CLEARTYPE_QUALITY 5
@@ -61,68 +60,36 @@ BuildKeyNameFromFontName(nsAString &aNam
     if (aName.Length() >= LF_FACESIZE)
         aName.Truncate(LF_FACESIZE - 1);
     ToLowerCase(aName);
 }
 
 // Implementation of gfxPlatformFontList for Win32 GDI,
 // using GDI font enumeration APIs to get the list of fonts
 
-typedef LONG
-(WINAPI *TTLoadEmbeddedFontProc)(HANDLE* phFontReference, ULONG ulFlags,
-                                 ULONG* pulPrivStatus, ULONG ulPrivs,
-                                 ULONG* pulStatus,
-                                 READEMBEDPROC lpfnReadFromStream,
-                                 LPVOID lpvReadStream,
-                                 LPWSTR szWinFamilyName, 
-                                 LPSTR szMacFamilyName,
-                                 TTLOADINFO* pTTLoadInfo);
-
-typedef LONG
-(WINAPI *TTDeleteEmbeddedFontProc)(HANDLE hFontReference, ULONG ulFlags,
-                                   ULONG* pulStatus);
-
-
-static TTLoadEmbeddedFontProc TTLoadEmbeddedFontPtr = nullptr;
-static TTDeleteEmbeddedFontProc TTDeleteEmbeddedFontPtr = nullptr;
-
 class WinUserFontData : public gfxUserFontData {
 public:
-    WinUserFontData(HANDLE aFontRef, bool aIsEmbedded)
-        : mFontRef(aFontRef), mIsEmbedded(aIsEmbedded)
+    WinUserFontData(HANDLE aFontRef)
+        : mFontRef(aFontRef)
     { }
 
     virtual ~WinUserFontData()
     {
-        if (mIsEmbedded) {
-            ULONG pulStatus;
-            LONG err;
-            err = TTDeleteEmbeddedFontPtr(mFontRef, 0, &pulStatus);
+        DebugOnly<BOOL> success;
+        success = RemoveFontMemResourceEx(mFontRef);
 #if DEBUG
-            if (err != E_NONE) {
-                char buf[256];
-                sprintf(buf, "error deleting embedded font handle (%p) - TTDeleteEmbeddedFont returned %8.8x", mFontRef, err);
-                NS_ASSERTION(err == E_NONE, buf);
-            }
+        if (!success) {
+            char buf[256];
+            sprintf(buf, "error deleting font handle (%p) - RemoveFontMemResourceEx failed", mFontRef);
+            NS_ASSERTION(success, buf);
+        }
 #endif
-        } else {
-            DebugOnly<BOOL> success;
-            success = RemoveFontMemResourceEx(mFontRef);
-#if DEBUG
-            if (!success) {
-                char buf[256];
-                sprintf(buf, "error deleting font handle (%p) - RemoveFontMemResourceEx failed", mFontRef);
-                NS_ASSERTION(success, buf);
-            }
-#endif
-        }
     }
     
     HANDLE mFontRef;
-    bool mIsEmbedded;
 };
 
 BYTE 
 FontTypeToOutPrecision(uint8_t fontType)
 {
     BYTE ret;
     switch (fontType) {
     case GFX_FONT_TYPE_TT_OPENTYPE:
@@ -594,18 +561,16 @@ GDIFontFamily::FindStyleVariations()
  *
  * gfxGDIFontList
  *
  */
 
 gfxGDIFontList::gfxGDIFontList()
 {
     mFontSubstitutes.Init(50);
-
-    InitializeFontEmbeddingProcs();
 }
 
 static void
 RemoveCharsetFromFontSubstitute(nsAString &aName)
 {
     int32_t comma = aName.FindChar(PRUnichar(','));
     if (comma >= 0)
         aName.Truncate(comma);
@@ -785,219 +750,74 @@ gfxGDIFontList::LookupLocalFont(const gf
 
     // make the new font entry match the proxy entry style characteristics
     fe->mWeight = (aProxyEntry->mWeight == 0 ? 400 : aProxyEntry->mWeight);
     fe->mItalic = aProxyEntry->mItalic;
 
     return fe;
 }
 
-void gfxGDIFontList::InitializeFontEmbeddingProcs()
-{
-    static HMODULE fontlib = LoadLibraryW(L"t2embed.dll");
-    if (!fontlib)
-        return;
-    TTLoadEmbeddedFontPtr = (TTLoadEmbeddedFontProc)
-        GetProcAddress(fontlib, "TTLoadEmbeddedFont");
-    TTDeleteEmbeddedFontPtr = (TTDeleteEmbeddedFontProc)
-        GetProcAddress(fontlib, "TTDeleteEmbeddedFont");
-}
-
-// used to control stream read by Windows TTLoadEmbeddedFont API
-
-class EOTFontStreamReader {
-public:
-    EOTFontStreamReader(const uint8_t *aFontData, uint32_t aLength, uint8_t *aEOTHeader, 
-                           uint32_t aEOTHeaderLen, FontDataOverlay *aNameOverlay)
-        : mCurrentChunk(0), mChunkOffset(0)
-    {
-        NS_ASSERTION(aFontData, "null font data ptr passed in");
-        NS_ASSERTION(aEOTHeader, "null EOT header ptr passed in");
-        NS_ASSERTION(aNameOverlay, "null name overlay struct passed in");
-
-        if (aNameOverlay->overlaySrc) {
-            mNumChunks = 4;
-            // 0 : EOT header
-            mDataChunks[0].mData = aEOTHeader;
-            mDataChunks[0].mLength = aEOTHeaderLen;
-            // 1 : start of font data to overlayDest
-            mDataChunks[1].mData = aFontData;
-            mDataChunks[1].mLength = aNameOverlay->overlayDest;
-            // 2 : overlay data
-            mDataChunks[2].mData = aFontData + aNameOverlay->overlaySrc;
-            mDataChunks[2].mLength = aNameOverlay->overlaySrcLen;
-            // 3 : rest of font data
-            mDataChunks[3].mData = aFontData + aNameOverlay->overlayDest + aNameOverlay->overlaySrcLen;
-            mDataChunks[3].mLength = aLength - aNameOverlay->overlayDest - aNameOverlay->overlaySrcLen;
-        } else {
-            mNumChunks = 2;
-            // 0 : EOT header
-            mDataChunks[0].mData = aEOTHeader;
-            mDataChunks[0].mLength = aEOTHeaderLen;
-            // 1 : font data
-            mDataChunks[1].mData = aFontData;
-            mDataChunks[1].mLength = aLength;
-        }
-    }
-
-    ~EOTFontStreamReader() 
-    { 
-
-    }
-
-    struct FontDataChunk {
-        const uint8_t *mData;
-        uint32_t       mLength;
-    };
-
-    uint32_t                mNumChunks;
-    FontDataChunk           mDataChunks[4];
-    uint32_t                mCurrentChunk;
-    uint32_t                mChunkOffset;
-
-    unsigned long Read(void *outBuffer, const unsigned long aBytesToRead)
-    {
-        uint32_t bytesLeft = aBytesToRead;  // bytes left in the out buffer
-        uint8_t *out = static_cast<uint8_t*> (outBuffer);
-
-        while (mCurrentChunk < mNumChunks && bytesLeft) {
-            FontDataChunk& currentChunk = mDataChunks[mCurrentChunk];
-            uint32_t bytesToCopy = std::min(bytesLeft, 
-                                          currentChunk.mLength - mChunkOffset);
-            memcpy(out, currentChunk.mData + mChunkOffset, bytesToCopy);
-            bytesLeft -= bytesToCopy;
-            mChunkOffset += bytesToCopy;
-            out += bytesToCopy;
-
-            NS_ASSERTION(mChunkOffset <= currentChunk.mLength, "oops, buffer overrun");
-
-            if (mChunkOffset == currentChunk.mLength) {
-                mCurrentChunk++;
-                mChunkOffset = 0;
-            }
-        }
-
-        return aBytesToRead - bytesLeft;
-    }
-
-    static unsigned long ReadEOTStream(void *aReadStream, void *outBuffer, 
-                                       const unsigned long aBytesToRead) 
-    {
-        EOTFontStreamReader *eotReader = 
-                               static_cast<EOTFontStreamReader*> (aReadStream);
-        return eotReader->Read(outBuffer, aBytesToRead);
-    }        
-        
-};
-
 gfxFontEntry* 
 gfxGDIFontList::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry, 
                                  const uint8_t *aFontData,
                                  uint32_t aLength)
 {
     // MakePlatformFont is responsible for deleting the font data with NS_Free
     // so we set up a stack object to ensure it is freed even if we take an
     // early exit
     struct FontDataDeleter {
         FontDataDeleter(const uint8_t *aFontData)
             : mFontData(aFontData) { }
         ~FontDataDeleter() { NS_Free((void*)mFontData); }
         const uint8_t *mFontData;
     };
     FontDataDeleter autoDelete(aFontData);
 
-    bool hasVertical;
-    bool isCFF = gfxFontUtils::IsCffFont(aFontData, hasVertical);
+    bool isCFF = gfxFontUtils::IsCffFont(aFontData);
 
     nsresult rv;
     HANDLE fontRef = nullptr;
-    bool isEmbedded = false;
 
     nsAutoString uniqueName;
     rv = gfxFontUtils::MakeUniqueUserFontName(uniqueName);
     if (NS_FAILED(rv))
         return nullptr;
 
-    // for TTF fonts, first try using the t2embed library if available
-    if (!isCFF && TTLoadEmbeddedFontPtr && TTDeleteEmbeddedFontPtr) {
-        // TrueType-style glyphs, use EOT library
-        AutoFallibleTArray<uint8_t,2048> eotHeader;
-        uint8_t *buffer;
-        uint32_t eotlen;
+    FallibleTArray<uint8_t> newFontData;
 
-        isEmbedded = true;
-        uint32_t nameLen = std::min<uint32_t>(uniqueName.Length(), LF_FACESIZE - 1);
-        nsAutoString fontName(Substring(uniqueName, 0, nameLen));
-        
-        FontDataOverlay overlayNameData = {0, 0, 0};
+    rv = gfxFontUtils::RenameFont(uniqueName, aFontData, aLength, &newFontData);
 
-        rv = gfxFontUtils::MakeEOTHeader(aFontData, aLength, &eotHeader, 
-                                         &overlayNameData);
-        if (NS_SUCCEEDED(rv)) {
+    if (NS_FAILED(rv))
+        return nullptr;
+        
+    DWORD numFonts = 0;
 
-            // load in embedded font data
-            eotlen = eotHeader.Length();
-            buffer = reinterpret_cast<uint8_t*> (eotHeader.Elements());
-            
-            int32_t ret;
-            ULONG privStatus, pulStatus;
-            EOTFontStreamReader eotReader(aFontData, aLength, buffer, eotlen,
-                                          &overlayNameData);
+    uint8_t *fontData = reinterpret_cast<uint8_t*> (newFontData.Elements());
+    uint32_t fontLength = newFontData.Length();
+    NS_ASSERTION(fontData, "null font data after renaming");
 
-            ret = TTLoadEmbeddedFontPtr(&fontRef, TTLOAD_PRIVATE, &privStatus,
-                                        LICENSE_PREVIEWPRINT, &pulStatus,
-                                        EOTFontStreamReader::ReadEOTStream,
-                                        &eotReader,
-                                        (PRUnichar*)(fontName.get()), 0, 0);
-            if (ret != E_NONE) {
-                fontRef = nullptr;
-                char buf[256];
-                sprintf(buf, "font (%s) not loaded using TTLoadEmbeddedFont - error %8.8x",
-                        NS_ConvertUTF16toUTF8(aProxyEntry->Name()).get(), ret);
-                NS_WARNING(buf);
-            }
-        }
-    }
-
-    // load CFF fonts or fonts that failed with t2embed loader
-    if (fontRef == nullptr) {
-        // Postscript-style glyphs, swizzle name table, load directly
-        FallibleTArray<uint8_t> newFontData;
-
-        isEmbedded = false;
-        rv = gfxFontUtils::RenameFont(uniqueName, aFontData, aLength, &newFontData);
+    // http://msdn.microsoft.com/en-us/library/ms533942(VS.85).aspx
+    // "A font that is added by AddFontMemResourceEx is always private 
+    //  to the process that made the call and is not enumerable."
+    fontRef = AddFontMemResourceEx(fontData, fontLength, 
+                                    0 /* reserved */, &numFonts);
+    if (!fontRef)
+        return nullptr;
 
-        if (NS_FAILED(rv))
-            return nullptr;
-        
-        DWORD numFonts = 0;
-
-        uint8_t *fontData = reinterpret_cast<uint8_t*> (newFontData.Elements());
-        uint32_t fontLength = newFontData.Length();
-        NS_ASSERTION(fontData, "null font data after renaming");
-
-        // http://msdn.microsoft.com/en-us/library/ms533942(VS.85).aspx
-        // "A font that is added by AddFontMemResourceEx is always private 
-        //  to the process that made the call and is not enumerable."
-        fontRef = AddFontMemResourceEx(fontData, fontLength, 
-                                       0 /* reserved */, &numFonts);
-        if (!fontRef)
-            return nullptr;
-
-        // only load fonts with a single face contained in the data
-        // AddFontMemResourceEx generates an additional face name for
-        // vertical text if the font supports vertical writing
-        if (fontRef && numFonts != 1 + !!hasVertical) {
-            RemoveFontMemResourceEx(fontRef);
-            return nullptr;
-        }
+    // only load fonts with a single face contained in the data
+    // AddFontMemResourceEx generates an additional face name for
+    // vertical text if the font supports vertical writing but since
+    // the font is referenced via the name this can be ignored
+    if (fontRef && numFonts > 2) {
+        RemoveFontMemResourceEx(fontRef);
+        return nullptr;
     }
 
     // make a new font entry using the unique name
-    WinUserFontData *winUserFontData = new WinUserFontData(fontRef, isEmbedded);
+    WinUserFontData *winUserFontData = new WinUserFontData(fontRef);
     uint16_t w = (aProxyEntry->mWeight == 0 ? 400 : aProxyEntry->mWeight);
 
     GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(uniqueName, 
         gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/, 
         uint32_t(aProxyEntry->mItalic ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL), 
         w, aProxyEntry->mStretch, winUserFontData, false);
 
     if (!fe)
--- a/gfx/thebes/gfxGDIFontList.h
+++ b/gfx/thebes/gfxGDIFontList.h
@@ -327,18 +327,16 @@ public:
     virtual void SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                                      FontListSizes*    aSizes) const;
 
 private:
     friend class gfxWindowsPlatform;
 
     gfxGDIFontList();
 
-    void InitializeFontEmbeddingProcs();
-
     nsresult GetFontSubstitutes();
 
     static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXW *lpelfe,
                                           NEWTEXTMETRICEXW *lpntme,
                                           DWORD fontType,
                                           LPARAM lParam);
 
     typedef nsRefPtrHashtable<nsStringHashKey, gfxFontFamily> FontTable;
--- a/layout/reftests/font-face/reftest.list
+++ b/layout/reftests/font-face/reftest.list
@@ -107,18 +107,16 @@ HTTP(..) load 486974-1.html
 # compare fonts with and without bad head checksum
 HTTP(..) == load-badchecksum.html load-badchecksum-ref.html
 
 # @font-face names take precedence over names of platform fonts (bug 494360)
 skip-if(B2G) HTTP(..) == name-collision.html name-collision-ref.html # bug 773482
 skip-if(B2G) HTTP(..) == name-collision-bad-url.html name-collision-bad-url-ref.html # bug 773482
 
 HTTP(..) == name-collision-with-prefs-font.html name-collision-with-prefs-font-ref.html # bug 668758
-
-# t2embed lib on windows is picky about fullname
 HTTP(..) == load-badfullname.html load-badfullname-ref.html
 
 # 507960-1-* : a collection of tests using DeLarge from openfontlibrary.org
 # check that the original DeLarge face (ttf) loads; if this fails,
 # none of the following tests are meaningful
 HTTP(..) != 507960-1-nofont.html 507960-1-ref.html
 # check that the WOFF version loads, with and without a format hint
 HTTP(..) == 507960-1-woff.html 507960-1-ref.html