summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorHerbert Duerr <hdu@openoffice.org>2001-09-18 14:44:36 +0000
committerHerbert Duerr <hdu@openoffice.org>2001-09-18 14:44:36 +0000
commitcaee5de082dc96b7002ab3a289b12ca3fc721895 (patch)
treeb6e7c1b6ec84a94d33afe03af58f59724357fcf4 /vcl
parentb285ba435e8b55c328f09f8c96e56e46e36810b2 (diff)
#90548# allow non-unicode encoded fonts
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/glyphs/gcach_ftyp.cxx73
-rw-r--r--vcl/source/glyphs/gcach_ftyp.hxx6
2 files changed, 74 insertions, 5 deletions
diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx
index e84c50fea9a2..ca0ed14e0911 100644
--- a/vcl/source/glyphs/gcach_ftyp.cxx
+++ b/vcl/source/glyphs/gcach_ftyp.cxx
@@ -2,8 +2,8 @@
*
* $RCSfile: gcach_ftyp.cxx,v $
*
- * $Revision: 1.55 $
- * last change: $Author: hdu $ $Date: 2001-08-02 17:21:09 $
+ * $Revision: 1.56 $
+ * last change: $Author: hdu $ $Date: 2001-09-18 15:44:36 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -488,7 +488,8 @@ FreetypeServerFont* FreetypeManager::CreateFont( const ImplFontSelectData& rFSD
FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontInfo* pFI )
: ServerFont(rFSD),
mpFontInfo(pFI),
- maFaceFT(NULL)
+ maFaceFT(NULL),
+ maRecodeConverter(NULL)
{
if( !pFI->MapFile() )
return;
@@ -512,6 +513,50 @@ FreetypeServerFont::FreetypeServerFont( const ImplFontSelectData& rFSD, FtFontIn
}
rc = FT_Select_Charmap( maFaceFT, eEncoding );
+ // no standard encoding applies => we need an encoding converter
+ if( rc != FT_Err_Ok )
+ {
+ rtl_TextEncoding eRecodeFrom = RTL_TEXTENCODING_UNICODE;
+ for( int i = maFaceFT->num_charmaps; --i >= 0; )
+ {
+ const FT_CharMap aCM = maFaceFT->charmaps[i];
+ if( aCM->platform_id == TT_PLATFORM_MICROSOFT)
+ {
+ switch( aCM->encoding_id )
+ {
+ case TT_MS_ID_SJIS:
+ eEncoding = ft_encoding_sjis;
+ eRecodeFrom = RTL_TEXTENCODING_SHIFT_JIS;
+ break;
+ case TT_MS_ID_GB2312:
+ eEncoding = ft_encoding_gb2312;
+ eRecodeFrom = RTL_TEXTENCODING_GB_2312;
+ break;
+ case TT_MS_ID_BIG_5:
+ eEncoding = ft_encoding_big5;
+ eRecodeFrom = RTL_TEXTENCODING_BIG5;
+ break;
+ case TT_MS_ID_WANSUNG:
+ eEncoding = ft_encoding_wansung;
+ eRecodeFrom = RTL_TEXTENCODING_MS_949;
+ break;
+ case TT_MS_ID_JOHAB:
+ eEncoding = ft_encoding_johab;
+ eRecodeFrom = RTL_TEXTENCODING_MS_1361;
+ break;
+ }
+ }
+ }
+
+ if( FT_Err_Ok != FT_Select_Charmap( maFaceFT, eEncoding ) )
+ {
+ maFaceFT->num_glyphs = 0;
+ return;
+ }
+
+ maRecodeConverter = rtl_createUnicodeToTextConverter( eRecodeFrom );
+ }
+
mnWidth = rFSD.mnWidth;
if( !mnWidth )
mnWidth = rFSD.mnHeight;
@@ -667,6 +712,7 @@ static void SetTransform( int nSin, int nCos, int nHeight, int nGlyphFlags, FT_G
int FreetypeServerFont::GetGlyphIndex( sal_Unicode aChar ) const
{
if( mpFontInfo->GetFontData().meCharSet == RTL_TEXTENCODING_SYMBOL )
+ {
if( FT_IS_SFNT( maFaceFT ) )
aChar |= 0xF000; // emulate W2K high/low mapping of symbols
else
@@ -676,6 +722,27 @@ int FreetypeServerFont::GetGlyphIndex( sal_Unicode aChar ) const
else if( aChar > 0xFF )
return 0;
}
+ }
+
+ // need to recode from unicode to font encoding?
+ if( maRecodeConverter )
+ {
+ sal_Char aTempArray[2];
+ sal_Size nTempSize;
+ sal_uInt32 nCvtInfo;
+
+ rtl_UnicodeToTextContext aContext = rtl_createUnicodeToTextContext( maRecodeConverter );
+ int nChars = rtl_convertUnicodeToText( maRecodeConverter, aContext,
+ &aChar, 1, aTempArray, sizeof(aTempArray),
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_QUESTIONMARK
+ | RTL_UNICODETOTEXT_FLAGS_INVALID_QUESTIONMARK,
+ &nCvtInfo, &nTempSize );
+ rtl_destroyUnicodeToTextContext( maRecodeConverter, aContext );
+
+ aChar = 0;
+ for( int i = 0; i < nChars; ++i )
+ aChar = aChar*256 + (aTempArray[i] & 0xFF);
+ }
int nGlyphIndex = FT_Get_Char_Index( maFaceFT, aChar );
diff --git a/vcl/source/glyphs/gcach_ftyp.hxx b/vcl/source/glyphs/gcach_ftyp.hxx
index 2b138c2413ba..ae8378b054da 100644
--- a/vcl/source/glyphs/gcach_ftyp.hxx
+++ b/vcl/source/glyphs/gcach_ftyp.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: gcach_ftyp.hxx,v $
*
- * $Revision: 1.14 $
+ * $Revision: 1.15 $
*
- * last change: $Author: hdu $ $Date: 2001-07-06 13:49:30 $
+ * last change: $Author: hdu $ $Date: 2001-09-18 15:44:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,6 +62,7 @@
#ifndef NO_FREETYPE_FONTS
#include <glyphcache.hxx>
+#include <rtl/textcvt.h>
typedef int FT_Int;
// -----------------------------------------------------------------------
@@ -184,6 +185,7 @@ private:
typedef ::std::hash_map<int,int> GlyphSubstitution;
GlyphSubstitution aGlyphSubstitution;
+ rtl_UnicodeToTextConverter maRecodeConverter;
};
// -----------------------------------------------------------------------