Index: source/glyphs/gcach_ftyp.cxx =================================================================== RCS file: /cvs/gsl/vcl/source/glyphs/gcach_ftyp.cxx,v retrieving revision 1.98 diff -u -r1.98 gcach_ftyp.cxx --- source/glyphs/gcach_ftyp.cxx 16 Jul 2003 17:46:21 -0000 1.98 +++ source/glyphs/gcach_ftyp.cxx 7 Sep 2003 15:09:08 -0000 @@ -348,7 +348,7 @@ const unsigned char* p = pBuffer + 12; if( nFormat == 0x74746366 ) // TTC_MAGIC p += GetUInt( p + 4 * mnFaceNum ); - else if( nFormat != 0x00010000 ) // TTF_MAGIC + else if( (nFormat!=0x00010000) && (nFormat!=0x74727565) ) // TTF_MAGIC and Apple TTF Magic return NULL; // walk table directory until match @@ -495,8 +495,21 @@ // TODO: prefer unicode names if available // TODO: prefer locale specific names if available? - aFontData.maName = String::CreateFromAscii( aFaceFT->family_name ); - aFontData.maStyleName = String::CreateFromAscii( aFaceFT->style_name ); +/* DAN - some fonts returned NULL names, resulting in crash here. */ + if ( aFaceFT->family_name ) + aFontData.maName = String::CreateFromAscii( aFaceFT->family_name ); + else + aFontData.maName = String::CreateFromAscii( "\0" ); + + if ( aFaceFT->style_name ) + aFontData.maStyleName = String::CreateFromAscii( aFaceFT->style_name ); + else + aFontData.maStyleName = String::CreateFromAscii( "\0" ); + +/* DAN - old non-modified code here + aFontData.maName = String::CreateFromAscii( aFaceFT->family_name ); + aFontData.maStyleName = String::CreateFromAscii( aFaceFT->style_name ); +*/ aFontData.mnWidth = 0; aFontData.mnHeight = 0; @@ -1442,71 +1455,154 @@ const FT_Byte* pBuffer = pKern; USHORT nVersion = GetUShort( pBuffer+0 ); USHORT nTableCnt = GetUShort( pBuffer+2 ); - pBuffer += 4; - if( nVersion != 0 ) // ignore Apple's versions for now - nTableCnt = 0; - for( USHORT nTableIdx = 0; nTableIdx < nTableCnt; ++nTableIdx ) - { - USHORT nSubVersion = GetUShort( pBuffer+0 ); - USHORT nSubLength = GetUShort( pBuffer+2 ); - USHORT nSubCoverage = GetUShort( pBuffer+4 ); - pBuffer += 6; - if( (nSubCoverage&0x03) != 0x01 ) // no interest in minimum info here - continue; - switch( nSubCoverage >> 8 ) + + // Microsoft/Old TrueType style kern table + if ( nVersion == 0 ) + { + pBuffer += 4; + + for( USHORT nTableIdx = 0; nTableIdx < nTableCnt; ++nTableIdx ) { - case 0: // version 0, kerning format 0 + USHORT nSubVersion = GetUShort( pBuffer+0 ); + USHORT nSubLength = GetUShort( pBuffer+2 ); + USHORT nSubCoverage = GetUShort( pBuffer+4 ); + pBuffer += 6; + if( (nSubCoverage&0x03) != 0x01 ) // no interest in minimum info here + continue; + switch( nSubCoverage >> 8 ) { - USHORT nPairs = GetUShort( pBuffer ); - pBuffer += 8; // skip search hints - aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); - for( int i = 0; i < nPairs; ++i ) + case 0: // version 0, kerning format 0 + { + USHORT nPairs = GetUShort( pBuffer ); + pBuffer += 8; // skip search hints + aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); + for( int i = 0; i < nPairs; ++i ) + { + aKernPair.mnChar1 = GetUShort( pBuffer+0 ); + aKernPair.mnChar2 = GetUShort( pBuffer+2 ); + //long nUnscaledKern= GetSShort( pBuffer ); + pBuffer += 6; + aKernGlyphVector.push_back( aKernPair ); + } + } + break; + + case 2: // version 0, kerning format 2 { - aKernPair.mnChar1 = GetUShort( pBuffer+0 ); - aKernPair.mnChar2 = GetUShort( pBuffer+2 ); - //long nUnscaledKern= GetSShort( pBuffer ); - pBuffer += 6; - aKernGlyphVector.push_back( aKernPair ); + const FT_Byte* pSubTable = pBuffer; + //USHORT nRowWidth = GetUShort( pBuffer+0 ); + USHORT nOfsLeft = GetUShort( pBuffer+2 ); + USHORT nOfsRight = GetUShort( pBuffer+4 ); + USHORT nOfsArray = GetUShort( pBuffer+6 ); + pBuffer += 8; + + const FT_Byte* pTmp = pSubTable + nOfsLeft; + USHORT nFirstLeft = GetUShort( pTmp+0 ); + USHORT nLastLeft = GetUShort( pTmp+2 ) + nFirstLeft - 1; + + pTmp = pSubTable + nOfsRight; + USHORT nFirstRight = GetUShort( pTmp+0 ); + USHORT nLastRight = GetUShort( pTmp+2 ) + nFirstRight - 1; + + ULONG nPairs = (ULONG)(nLastLeft - nFirstLeft + 1) * (nLastRight - nFirstRight + 1); + aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); + + pTmp = pSubTable + nOfsArray; + for( int nLeft = nFirstLeft; nLeft < nLastLeft; ++nLeft ) + { + aKernPair.mnChar1 = nLeft; + for( int nRight = 0; nRight < nLastRight; ++nRight ) + { + if( GetUShort( pTmp ) != 0 ) + { + aKernPair.mnChar2 = nRight; + aKernGlyphVector.push_back( aKernPair ); + } + pTmp += 2; + } + } } + break; } - break; + } + } - case 2: // version 0, kerning format 2 - { - const FT_Byte* pSubTable = pBuffer; - //USHORT nRowWidth = GetUShort( pBuffer+0 ); - USHORT nOfsLeft = GetUShort( pBuffer+2 ); - USHORT nOfsRight = GetUShort( pBuffer+4 ); - USHORT nOfsArray = GetUShort( pBuffer+6 ); - pBuffer += 8; - - const FT_Byte* pTmp = pSubTable + nOfsLeft; - USHORT nFirstLeft = GetUShort( pTmp+0 ); - USHORT nLastLeft = GetUShort( pTmp+2 ) + nFirstLeft - 1; - - pTmp = pSubTable + nOfsRight; - USHORT nFirstRight = GetUShort( pTmp+0 ); - USHORT nLastRight = GetUShort( pTmp+2 ) + nFirstRight - 1; + // Apple New style kern table + pBuffer = pKern; + nVersion = NEXT_ULong( pBuffer ); + nTableCnt = NEXT_ULong( pBuffer ); + if ( nVersion == 0x00010000 ) + { + for( USHORT nTableIdx = 0; nTableIdx < nTableCnt; ++nTableIdx ) + { + ULONG nLength = NEXT_ULong( pBuffer ); + USHORT nCoverage = NEXT_UShort( pBuffer ); + USHORT nTupleIndex = NEXT_UShort( pBuffer ); + + // Get kerning type + sal_Bool bKernVertical = nCoverage & 0x8000; + sal_Bool bKernCrossStream = nCoverage & 0x4000; + sal_Bool bKernVariation = nCoverage & 0x2000; - ULONG nPairs = (ULONG)(nLastLeft - nFirstLeft + 1) * (nLastRight - nFirstRight + 1); - aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); + // Kerning sub-table format, 0 through 3 + sal_uInt8 nSubTableFormat = nCoverage & 0x00FF; - pTmp = pSubTable + nOfsArray; - for( int nLeft = nFirstLeft; nLeft < nLastLeft; ++nLeft ) + switch( nSubTableFormat ) + { + case 0: // version 0, kerning format 0 { - aKernPair.mnChar1 = nLeft; - for( int nRight = 0; nRight < nLastRight; ++nRight ) + USHORT nPairs = NEXT_UShort( pBuffer ); + pBuffer += 6; // skip search hints + aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); + for( int i = 0; i < nPairs; ++i ) { - if( GetUShort( pTmp ) != 0 ) + aKernPair.mnChar1 = NEXT_UShort( pBuffer ); + aKernPair.mnChar2 = NEXT_UShort( pBuffer ); + /*long nUnscaledKern=*/ NEXT_Short( pBuffer ); + aKernGlyphVector.push_back( aKernPair ); + } + } + break; + + case 2: // version 0, kerning format 2 + { + const FT_Byte* pSubTable = pBuffer; + /*USHORT nRowWidth =*/ NEXT_UShort( pBuffer ); + USHORT nOfsLeft = NEXT_UShort( pBuffer ); + USHORT nOfsRight = NEXT_UShort( pBuffer ); + USHORT nOfsArray = NEXT_UShort( pBuffer ); + + const FT_Byte* pTmp = pSubTable + nOfsLeft; + USHORT nFirstLeft = NEXT_UShort( pTmp ); + USHORT nLastLeft = NEXT_UShort( pTmp ) + nFirstLeft - 1; + + pTmp = pSubTable + nOfsRight; + USHORT nFirstRight = NEXT_UShort( pTmp ); + USHORT nLastRight = NEXT_UShort( pTmp ) + nFirstRight - 1; + + ULONG nPairs = (ULONG)(nLastLeft - nFirstLeft + 1) * (nLastRight - nFirstRight + 1); + aKernGlyphVector.reserve( aKernGlyphVector.size() + nPairs ); + + pTmp = pSubTable + nOfsArray; + for( int nLeft = nFirstLeft; nLeft < nLastLeft; ++nLeft ) + { + aKernPair.mnChar1 = nLeft; + for( int nRight = 0; nRight < nLastRight; ++nRight ) { - aKernPair.mnChar2 = nRight; - aKernGlyphVector.push_back( aKernPair ); + if( NEXT_Short( pTmp ) != 0 ) + { + aKernPair.mnChar2 = nRight; + aKernGlyphVector.push_back( aKernPair ); + } } - pTmp += 2; } } + break; + + default: + fprintf( stderr, "gcach_ftyp.cxx: Found unsupported Apple-style kern subtable type %d.\n", nSubTableFormat ); + break; } - break; } } Index: unx/source/app/i18n_im.cxx =================================================================== RCS file: /cvs/gsl/vcl/unx/source/app/i18n_im.cxx,v retrieving revision 1.23.110.1 diff -u -r1.23.110.1 i18n_im.cxx --- unx/source/app/i18n_im.cxx 15 Aug 2003 11:25:04 -0000 1.23.110.1 +++ unx/source/app/i18n_im.cxx 7 Sep 2003 15:09:10 -0000 @@ -82,6 +82,11 @@ #include #endif +#ifdef MACOSX +#include +#include +#endif + using namespace vcl; #ifndef _SAL_I18N_CALLBACK_HXX @@ -223,12 +228,54 @@ SetSystemLocale( const char* p_inlocale ) { char *p_outlocale; + +#ifdef MACOSX + // If p_inlocale is NULL, use current locale from libsal since + // setlocale() always returns NULL when you pass NULL on Mac OS X + if ( p_inlocale == NULL || *p_inlocale == NULL ) + { + rtl_Locale* pLocale = NULL; + osl_getProcessLocale( &pLocale ); + if ( pLocale ) + { + ByteString aLocaleString( String( pLocale->Language ), RTL_TEXTENCODING_ASCII_US ); + ByteString aCountry( String( pLocale->Country ), RTL_TEXTENCODING_ASCII_US ); + ByteString aVariant( String( pLocale->Variant ), RTL_TEXTENCODING_ASCII_US ); + + if( aCountry.Len() ) + { + aLocaleString += "_"; + aLocaleString += aCountry; + } + if( aVariant.Len() ) + { + aLocaleString += "."; + aLocaleString += aVariant; + } + + p_inlocale = aLocaleString.GetBuffer(); + } + } + + // FIXME + // setlocale() doesn't do much on Darwin 5 or 6. Here, since setlocale() is + // #defined to _Xsetlocale() by our , it still doesn't work. + // NOTE: On MacOS X, we can't set the locale anyway because its set in + // the System Preferences application, under the International control panel. + // Thus, the locale that we get from osl_getProcessLocale() is always valid as + // its the locale that's already set. + // NOTE 2: This setlocale() is still valid for Darwin though. if ( (p_outlocale = setlocale(LC_ALL, p_inlocale)) == NULL ) + p_outlocale = p_inlocale; // Hack it so we return a good locale anyway + +#else + if ( (p_outlocale = setlocale(LC_ALL, p_inlocale)) == NULL ) { fprintf( stderr, "I18N: Operating system doesn't support locale \"%s\"\n", p_inlocale ); } +#endif return p_outlocale; } @@ -437,6 +484,15 @@ if ( XGetIMValues(maMethod, XNMultiLingualInput, &mbMultiLingual, NULL ) != NULL ) mbMultiLingual = False; + + #ifdef MACOSX + // FIXME + // For whatever reason, the XvaOpenIM call always returns NULL + // on MacOS X/Darwin. ÊWe know we've got multi-lingual support + // anyway so hack it to true so we can type international characters. + mbMultiLingual = True; + #endif + if( mbMultiLingual ) { XIMUnicodeCharacterSubsets* subsets; Index: unx/source/gdi/salgdi3.cxx =================================================================== RCS file: /cvs/gsl/vcl/unx/source/gdi/salgdi3.cxx,v retrieving revision 1.105 diff -u -r1.105 salgdi3.cxx --- unx/source/gdi/salgdi3.cxx 30 Jun 2003 14:32:24 -0000 1.105 +++ unx/source/gdi/salgdi3.cxx 7 Sep 2003 15:09:12 -0000 @@ -1349,10 +1349,16 @@ if( aX11GlyphPeer.GetGlyphSet( rFont ) ) DrawServerAAFontString( rLayout ); - else if( aX11GlyphPeer.ForcedAntialiasing( rFont ) ) + else +#ifdef MACOSX + /* Simply draw everything antialiased, even the UI */ + DrawServerAAForcedString( rLayout ); +#else + if( aX11GlyphPeer.ForcedAntialiasing( rFont ) ) DrawServerAAForcedString( rLayout ); else DrawServerSimpleFontString( rLayout ); +#endif } } Index: unx/source/gdi/salprnpsp.cxx =================================================================== RCS file: /cvs/gsl/vcl/unx/source/gdi/salprnpsp.cxx,v retrieving revision 1.27 diff -u -r1.27 salprnpsp.cxx --- unx/source/gdi/salprnpsp.cxx 2 Jul 2003 13:40:55 -0000 1.27 +++ unx/source/gdi/salprnpsp.cxx 7 Sep 2003 15:09:13 -0000 @@ -101,6 +101,11 @@ #include #endif +#ifdef MACOSX +#include +#include +#endif + #ifndef _PSPRINT_PRINTERINFOMANAGER_HXX_ #include #endif @@ -112,6 +117,7 @@ * static helpers */ +#ifndef MACOSX // NETBSD has no RTLD_GLOBAL #ifndef RTLD_GLOBAL #define DLOPEN_MODE (RTLD_LAZY) @@ -119,6 +125,7 @@ #define DLOPEN_MODE (RTLD_GLOBAL | RTLD_LAZY) #endif #include +#endif #include static void* driverLib = NULL; @@ -150,23 +157,57 @@ if( ! driverLib ) { - driverLib = dlopen( _XSALSET_LIBNAME, DLOPEN_MODE ); - pErr = dlerror(); - if ( !driverLib ) - { - fprintf( stderr, "%s: when opening %s\n", pErr, _XSALSET_LIBNAME ); - return; - } + #ifdef MACOSX + // Use OSL module loading for MacOS X + OUString printerDriverLibName( RTL_CONSTASCII_USTRINGPARAM(_XSALSET_LIBNAME) ); + oslModule pPrinterDriverLib = osl_loadModule( printerDriverLibName.pData, SAL_LOADMODULE_DEFAULT ); + if( !pPrinterDriverLib ) + { + fprintf( stderr, "salprnpsp.cxx: Cannot load printer setup library %s.\n", printerDriverLibName.pData ); + return; + } + + // Get the address of Sal_SetupPrinterDriver + OUString setupPrinterDriverFuncName( RTL_CONSTASCII_USTRINGPARAM("Sal_SetupPrinterDriver") ); + void *pSetupPrinterDriverFunc; + pSetupPrinterDriverFunc = osl_getSymbol( pPrinterDriverLib, setupPrinterDriverFuncName.pData ); + if( !pSetupPrinterDriverFunc ) + { + fprintf( stderr, "salprnpsp.cxx: Cannot get address of symbol 'Sal_SetupPrinterDriver'.\n" ); + return; + } + pSetupFunction = (int(*)(PrinterInfo&))pSetupPrinterDriverFunc; + + // Get the address of Sal_queryFaxNumber + OUString queryFaxNumFuncName( RTL_CONSTASCII_USTRINGPARAM("Sal_queryFaxNumber") ); + void *pQueryFaxNumFunc; + pQueryFaxNumFunc = osl_getSymbol( pPrinterDriverLib, queryFaxNumFuncName.pData ); + if( !pQueryFaxNumFunc ) + { + fprintf( stderr, "salprnpsp.cxx: Cannot get address of symbol 'Sal_queryFaxNumber'.\n" ); + return; + } + pFaxNrFunction = (int(*)(String&))pQueryFaxNumFunc; - pSetupFunction = (int(*)(PrinterInfo&))dlsym( driverLib, "Sal_SetupPrinterDriver" ); - pErr = dlerror(); - if ( !pSetupFunction ) - fprintf( stderr, "%s: when getting Sal_SetupPrinterDriver\n", pErr ); - - pFaxNrFunction = (int(*)(String&))dlsym( driverLib, "Sal_queryFaxNumber" ); - pErr = dlerror(); - if ( !pFaxNrFunction ) - fprintf( stderr, "%s: when getting Sal_queryFaxNumber\n", pErr ); + #else + driverLib = dlopen( _XSALSET_LIBNAME, DLOPEN_MODE ); + pErr = dlerror(); + if ( !driverLib ) + { + fprintf( stderr, "%s: when opening %s\n", pErr, _XSALSET_LIBNAME ); + return; + } + + pSetupFunction = (int(*)(PrinterInfo&))dlsym( driverLib, "Sal_SetupPrinterDriver" ); + pErr = dlerror(); + if ( !pSetupFunction ) + fprintf( stderr, "%s: when getting Sal_SetupPrinterDriver\n", pErr ); + + pFaxNrFunction = (int(*)(String&))dlsym( driverLib, "Sal_queryFaxNumber" ); + pErr = dlerror(); + if ( !pFaxNrFunction ) + fprintf( stderr, "%s: when getting Sal_queryFaxNumber\n", pErr ); + #endif } } @@ -680,12 +721,59 @@ nHeight = pJobSetup->mnPaperWidth; } String aPaper; - if( pJobSetup->mePaperFormat == PAPER_USER ) - aPaper = aData.m_pParser->matchPaper( - TenMuToPt( pJobSetup->mnPaperWidth ), - TenMuToPt( pJobSetup->mnPaperHeight ) ); + +#ifdef MACOSX + // For Mac OS X, many printers are directly attached + // USB/Serial printers with a stripped-down PPD that gives us + // problems. We need to do PS->PDF conversion for these printers + // but they are not able to handle multiple page sizes in the same + // document at all, since we must pass -o media=... to them to get + // a good printout. + // So, we must find a match between the paper size from OOo and what + // the PPD of the printer has, and pass that paper size to -o media=... + // If a match cannot be found (ie the paper size from Format->Page is + // nowhere near anything in the PPD), we default to what has been + // chosen in File->Print->Properties. + // + // For printers capable of directly accepting PostScript data, none + // of this occurs and we default to the normal OOo behavior. + const PPDKey *pCupsFilterKey; + const PPDValue *pCupsFilterValue; + BOOL bIsCUPSPrinter = TRUE; + + // Printers that need PS->PDF conversion have a "cupsFilter" key and + // a value of "application/pdf" in that key + pCupsFilterKey = aData.m_pParser->getKey( String(RTL_CONSTASCII_USTRINGPARAM("cupsFilter")) ); + pCupsFilterValue = pCupsFilterKey != NULL ? aData.m_aContext.getValue( pCupsFilterKey ) : NULL; + if ( pCupsFilterValue ) + { + // PPD had a cupsFilter key, check for PS->PDF conversion requirement + ByteString aCupsFilterString( pCupsFilterValue->m_aOption, RTL_TEXTENCODING_ISO_8859_1 ); + if ( aCupsFilterString.Search("application/pdf") == 0 ) + bIsCUPSPrinter = FALSE; + } else - aPaper = String( ByteString( aPaperTab[ pJobSetup->mePaperFormat ].name ), RTL_TEXTENCODING_ISO_8859_1 ); + bIsCUPSPrinter = FALSE; + + if ( TRUE == bIsCUPSPrinter ) + { + // If its a directly attached printer, with a + // stripped down PPD (most OS X printers are) always + // match the paper size. + aPaper = aData.m_pParser->matchPaper( + TenMuToPt( pJobSetup->mnPaperWidth ), + TenMuToPt( pJobSetup->mnPaperHeight ) ); + } + else +#endif + { + if( pJobSetup->mePaperFormat == PAPER_USER ) + aPaper = aData.m_pParser->matchPaper( + TenMuToPt( pJobSetup->mnPaperWidth ), + TenMuToPt( pJobSetup->mnPaperHeight ) ); + else + aPaper = String( ByteString( aPaperTab[ pJobSetup->mePaperFormat ].name ), RTL_TEXTENCODING_ISO_8859_1 ); + } pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) ); pValue = pKey ? pKey->getValue( aPaper ) : NULL; if( ! ( pKey && pValue && aData.m_aContext.setValue( pKey, pValue, false ) == pValue ) ) Index: unx/source/window/salframe.cxx =================================================================== RCS file: /cvs/gsl/vcl/unx/source/window/salframe.cxx,v retrieving revision 1.163 diff -u -r1.163 salframe.cxx --- unx/source/window/salframe.cxx 1 Jul 2003 14:49:01 -0000 1.163 +++ unx/source/window/salframe.cxx 7 Sep 2003 15:09:16 -0000 @@ -2745,9 +2745,12 @@ rtl_TextEncoding nEncoding; + // encoding is always platform encoding on OS X window managers at this point +#ifndef MACOSX if (mpInputContext != NULL && mpInputContext->IsMultiLingual() ) nEncoding = RTL_TEXTENCODING_UTF8; else +#endif nEncoding = osl_getThreadTextEncoding(); sal_Unicode *pBuffer;