From 246b28e75227cd36f62d900c1fed02fe5417de74 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 5 Feb 2007 11:48:02 +0000 Subject: [PATCH] From Gordon Tomlinson, "I have attached the 3 files we had to change to fix a proble we were seeing with using Symbol Fonts // GT: fix for symbol fonts (i.e. the Webdings font) as the wrong character are being // returned, for symbol fonts in windows (FT_ENCONDING_MS_SYMBOL in freetype) the correct // values are from 0xF000 to 0xF0FF not from 0x000 to 0x00FF (0 to 255) as you would expect. // becuase Microsoft uses a private field for its symbol fonts ........ " --- src/osgPlugins/freetype/FreeTypeFont.cpp | 25 +++++++++++--- src/osgPlugins/freetype/FreeTypeLibrary.cpp | 37 +++++++++++++++++++-- src/osgPlugins/freetype/FreeTypeLibrary.h | 3 ++ 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/src/osgPlugins/freetype/FreeTypeFont.cpp b/src/osgPlugins/freetype/FreeTypeFont.cpp index 1e678e29c..3d0448518 100644 --- a/src/osgPlugins/freetype/FreeTypeFont.cpp +++ b/src/osgPlugins/freetype/FreeTypeFont.cpp @@ -38,7 +38,7 @@ FreeTypeFont::~FreeTypeFont() FreeTypeLibrary* freeTypeLibrary = FreeTypeLibrary::instance(); if (freeTypeLibrary) { - // remove myself from the local regsitry to ensure that + // remove myself from the local registry to ensure that // not dangling pointers remain freeTypeLibrary->removeFontImplmentation(this); @@ -69,9 +69,9 @@ void FreeTypeFont::setFontResolution(unsigned int width, unsigned int height) osg::notify(osg::WARN)<<" sizes capped ("<charmap != NULL) + { + if (_face->charmap->encoding == FT_ENCODING_MS_SYMBOL) + { + charindex |= 0xF000; + } + } + + FT_Error error = FT_Load_Char( _face, charindex, FT_LOAD_RENDER|FT_LOAD_NO_BITMAP ); if (error) { osg::notify(osg::WARN) << "FT_Load_Char(...) error "< +#include +#include FT_TRUETYPE_IDS_H FreeTypeLibrary::FreeTypeLibrary() { FT_Error error = FT_Init_FreeType( &_ftlibrary ); if (error) { - osg::notify(osg::WARN)<<"Warning: an error occured during FT_Init_FreeType(..) initialisation .. "<charmap == NULL) + { + for (int n = 0; n < face->num_charmaps; n++) + { + charmap = face->charmaps[n]; + if (charmap->platform_id == TT_PLATFORM_MICROSOFT) + { + FT_Set_Charmap(face, charmap); + break; + } + } + } +} diff --git a/src/osgPlugins/freetype/FreeTypeLibrary.h b/src/osgPlugins/freetype/FreeTypeLibrary.h index e71c583ea..18b8b870e 100644 --- a/src/osgPlugins/freetype/FreeTypeLibrary.h +++ b/src/osgPlugins/freetype/FreeTypeLibrary.h @@ -36,6 +36,9 @@ public: protected: + /** Verify the correct character mapping for MS windows */ + void verifyCharacterMap(FT_Face face); + /** protected constructor to ensure the only way to create the * library is via the singleton instance method.*/ FreeTypeLibrary();