Skip to content

Commit

Permalink
Some compile fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
taviso committed Apr 16, 2009
1 parent 4ccadf0 commit 3670fa0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
8 changes: 5 additions & 3 deletions OpenTypeUtilities.cpp
Expand Up @@ -25,11 +25,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <stdint.h>
#include <vector>

#include "OpenTypeUtilities.h"

using std::vector;

typedef unsigned Fixed;

#define DEFAULT_CHARSET 1
Expand Down Expand Up @@ -160,7 +162,7 @@ static void appendBigEndianStringToEOTHeader(vector<uint8_t>&eotHeader, const Bi
{
size_t size = eotHeader.size();
eotHeader.resize(size + length + 2 * sizeof(unsigned short));
unsigned short* dst = reinterpret_cast<unsigned short*>(eotHeader.data() + size);
unsigned short* dst = reinterpret_cast<unsigned short*>(&eotHeader[0] + size);
unsigned i = 0;
dst[i++] = length;
unsigned numCharacters = length / 2;
Expand All @@ -179,7 +181,7 @@ bool getEOTHeader(unsigned char* fontData, size_t fontSize, vector<uint8_t>& eot
const char* data = (const char *) fontData;

eotHeader.resize(sizeof(EOTPrefix));
EOTPrefix* prefix = reinterpret_cast<EOTPrefix*>(eotHeader.data());
EOTPrefix* prefix = reinterpret_cast<EOTPrefix*>(&eotHeader[0]);

prefix->fontDataSize = dataLength;
prefix->version = 0x00020001;
Expand Down Expand Up @@ -318,7 +320,7 @@ bool getEOTHeader(unsigned char* fontData, size_t fontSize, vector<uint8_t>& eot
eotHeader.push_back(padding);
eotHeader.push_back(padding);

prefix = reinterpret_cast<EOTPrefix*>(eotHeader.data());
prefix = reinterpret_cast<EOTPrefix*>(&eotHeader[0]);
prefix->eotSize = eotHeader.size() + fontSize;

return true;
Expand Down
19 changes: 12 additions & 7 deletions README
@@ -1,15 +1,20 @@
Very quick commandline wrapper around OpenTypeUtilities.cpp from Chromium, used to
make EOT (Embeddable Open Type) files from TTF (TrueType/OpenType Font) files.
For some reason this is the only file format TTLoadEmbeddedFont() accepts,
which is the what Internet Explorer uses for css @font-face declarations.
Very quick commandline wrapper around OpenTypeUtilities.cpp from Chromium, used
to make EOT (Embeddable Open Type) files from TTF (TrueType/OpenType Font)
files. This is the format TTLoadEmbeddedFont() accepts, which is what Internet
Explorer uses for css @font-face declarations.

I've only tested this on Linux.

EOT: http://www.w3.org/Submission/2008/SUBM-EOT-20080305/
EOT was documented by Microsoft here:
<http://www.w3.org/Submission/2008/SUBM-EOT-20080305/>

Chromium: http://src.chromium.org/viewvc/chrome/trunk/deps/third_party/WebKit/WebCore/platform/graphics/win/OpenTypeUtilities.cpp?view=log&pathrev=7591
TTLoadEmbeddedFont is described here:
<http://msdn.microsoft.com/en-us/library/dd145155(VS.85).aspx>

Build:
Chromium:
<http://src.chromium.org/viewvc/chrome/trunk/deps/third_party/WebKit/WebCore/platform/graphics/win/OpenTypeUtilities.cpp?view=log&pathrev=7591>

To build:

$ make

Expand Down
2 changes: 1 addition & 1 deletion ttf2eot.cpp
Expand Up @@ -61,7 +61,7 @@ int main(int argc, char **argv)
} while (true);

if (getEOTHeader(fontData, fontSize, eotHeader, overlayDst, overlaySrc, overlayLength)) {
fwrite(eotHeader.data(), eotHeader.size(), 1, stdout);
fwrite(&eotHeader[0], eotHeader.size(), 1, stdout);
fwrite(fontData, fontSize, 1, stdout);
return 0;
} else {
Expand Down

0 comments on commit 3670fa0

Please sign in to comment.