summaryrefslogtreecommitdiff
path: root/psprint/source
diff options
context:
space:
mode:
authorPhilipp Lohmann <pl@openoffice.org>2001-06-08 15:32:30 +0000
committerPhilipp Lohmann <pl@openoffice.org>2001-06-08 15:32:30 +0000
commit0d3fedbe2411f63340d90cb4854f4153169b9d8c (patch)
tree28f4e464c2dde0d7ef8b6790173c5d7c6123c9a5 /psprint/source
parent8034cd4e020521e849973bb209b92fa1e136371d (diff)
#87985# honor copyright flags for TrueType fonts
Diffstat (limited to 'psprint/source')
-rw-r--r--psprint/source/fontmanager/fontmanager.cxx49
-rw-r--r--psprint/source/fontsubset/sft.c7
-rw-r--r--psprint/source/fontsubset/sft.h7
-rw-r--r--psprint/source/printergfx/common_gfx.cxx23
-rw-r--r--psprint/source/printergfx/text_gfx.cxx60
5 files changed, 111 insertions, 35 deletions
diff --git a/psprint/source/fontmanager/fontmanager.cxx b/psprint/source/fontmanager/fontmanager.cxx
index ffee0761fa94..c57413bef069 100644
--- a/psprint/source/fontmanager/fontmanager.cxx
+++ b/psprint/source/fontmanager/fontmanager.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fontmanager.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: pl $ $Date: 2001-06-06 13:32:22 $
+ * last change: $Author: pl $ $Date: 2001-06-08 16:32:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -1166,8 +1166,7 @@ bool PrintFontManager::analyzeTrueTypeFile( PrintFont* pFont ) const
TrueTypeFont* pTTFont = NULL;
TrueTypeFontFile* pTTFontFile = static_cast< TrueTypeFontFile* >(pFont);
- int nFace = pTTFontFile->m_nCollectionEntry;
- if( OpenTTFont( aFile.GetBuffer(), nFace < 0 ? 0 : nFace, &pTTFont ) == SF_OK )
+ if( OpenTTFont( aFile.GetBuffer(), pTTFontFile->m_nCollectionEntry < 0 ? 0 : pTTFontFile->m_nCollectionEntry, &pTTFont ) == SF_OK )
{
TTGlobalFontInfo aInfo;
GetTTGlobalFontInfo( pTTFont, & aInfo );
@@ -1253,6 +1252,12 @@ bool PrintFontManager::analyzeTrueTypeFile( PrintFont* pFont ) const
if( pFont->m_nAscend && pFont->m_nDescend )
pFont->m_aGlobalMetricX.height = pFont->m_aGlobalMetricY.height = pFont->m_nAscend + pFont->m_nDescend;
+ // get type flags
+ pTTFontFile->m_nTypeFlags = (unsigned int)aInfo.typeFlags;
+#ifdef DEBUG
+ fprintf( stderr, "font %s has style flags %x\n", aFile.GetBuffer(), pTTFontFile->m_nTypeFlags );
+#endif
+
CloseTTFont( pTTFont );
bSuccess = true;
}
@@ -2017,6 +2022,42 @@ const ::std::list< KernPair >& PrintFontManager::getKernPairs( fontID nFontID, b
// -------------------------------------------------------------------------
+bool PrintFontManager::isFontDownloadingAllowed( fontID nFont ) const
+{
+ bool bRet = true;
+ PrintFont* pFont = getFont( nFont );
+ if( pFont && pFont->m_eType == fonttype::TrueType )
+ {
+ TrueTypeFontFile* pTTFontFile = static_cast<TrueTypeFontFile*>(pFont);
+ if( pTTFontFile->m_nTypeFlags & 0x80000000 )
+ {
+ TrueTypeFont* pTTFont = NULL;
+ ByteString aFile = getFontFile( pFont );
+ if( OpenTTFont( aFile.GetBuffer(), pTTFontFile->m_nCollectionEntry < 0 ? 0 : pTTFontFile->m_nCollectionEntry, &pTTFont ) == SF_OK )
+ {
+ // get type flags
+ TTGlobalFontInfo aInfo;
+ GetTTGlobalFontInfo( pTTFont, & aInfo );
+ pTTFontFile->m_nTypeFlags = (unsigned int)aInfo.typeFlags;
+#ifdef DEBUG
+ fprintf( stderr, "font %s has style flags %x\n", aFile.GetBuffer(), pTTFontFile->m_nTypeFlags );
+#endif
+ CloseTTFont( pTTFont );
+ }
+ }
+
+ unsigned int nCopyrightFlags = pTTFontFile->m_nTypeFlags & 0x0e;
+
+ // font embedding is allowed if either
+ // no restriction at all (bit 1 clear)
+ // printing allowed (bit 1 set, bit 2 set )
+ bRet = ! ( nCopyrightFlags & 0x02 ) || ( nCopyrightFlags & 0x04 );
+ }
+ return bRet;
+}
+
+// -------------------------------------------------------------------------
+
bool PrintFontManager::getMetrics( fontID nFontID, const sal_Unicode* pString, int nLen, CharacterMetric* pArray, bool bVertical ) const
{
PrintFont* pFont = getFont( nFontID );
diff --git a/psprint/source/fontsubset/sft.c b/psprint/source/fontsubset/sft.c
index 2a930cd14c97..763826af513f 100644
--- a/psprint/source/fontsubset/sft.c
+++ b/psprint/source/fontsubset/sft.c
@@ -2,9 +2,9 @@
*
* $RCSfile: sft.c,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: cp $ $Date: 2001-06-08 11:13:19 $
+ * last change: $Author: pl $ $Date: 2001-06-08 16:32:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,7 +59,7 @@
*
************************************************************************/
-/* $Id: sft.c,v 1.3 2001-06-08 11:13:19 cp Exp $
+/* $Id: sft.c,v 1.4 2001-06-08 16:32:30 pl Exp $
* Sun Font Tools
*
* Author: Alexander Gelfenbain
@@ -2463,6 +2463,7 @@ void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info)
info->ur4 = GetUInt32(table, 54, 1);
}
memcpy(info->panose, table + 32, 10);
+ info->typeFlags = GetUInt16( table, 8, 1 );
}
diff --git a/psprint/source/fontsubset/sft.h b/psprint/source/fontsubset/sft.h
index 801ef490ce31..6d53c68e441d 100644
--- a/psprint/source/fontsubset/sft.h
+++ b/psprint/source/fontsubset/sft.h
@@ -2,9 +2,9 @@
*
* $RCSfile: sft.h,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: pl $ $Date: 2001-05-28 09:58:53 $
+ * last change: $Author: pl $ $Date: 2001-06-08 16:32:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,7 +59,7 @@
*
************************************************************************/
-/* $Id: sft.h,v 1.2 2001-05-28 09:58:53 pl Exp $ */
+/* $Id: sft.h,v 1.3 2001-06-08 16:32:30 pl Exp $ */
/**
*
@@ -320,6 +320,7 @@ extern "C" {
uint32 ur3; /**< bits 64 - 95 of Unicode Range flags */
uint32 ur4; /**< bits 96 - 127 of Unicode Range flags */
byte panose[10]; /**< PANOSE classification number */
+ uint16 typeFlags;
} TTGlobalFontInfo;
/** Structure used by KernGlyphs() */
diff --git a/psprint/source/printergfx/common_gfx.cxx b/psprint/source/printergfx/common_gfx.cxx
index 5ea49a63a64b..4384feefe468 100644
--- a/psprint/source/printergfx/common_gfx.cxx
+++ b/psprint/source/printergfx/common_gfx.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: common_gfx.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: pl $ $Date: 2001-05-21 17:18:03 $
+ * last change: $Author: pl $ $Date: 2001-06-08 16:32:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -946,6 +946,25 @@ PrinterGfx::PSShowText (const sal_uChar* pStr, sal_Int16 nGlyphs, sal_Int16 nByt
PSGRestore ();
}
+void
+PrinterGfx::PSComment( const sal_Char* pComment )
+{
+ const sal_Char* pLast = pComment;
+ while( pComment && *pComment )
+ {
+ while( *pComment && *pComment != '\n' && *pComment != '\r' )
+ pComment++;
+ if( pComment - pLast > 1 )
+ {
+ WritePS( mpPageBody, "% ", 2 );
+ WritePS( mpPageBody, pLast, pComment - pLast );
+ WritePS( mpPageBody, "\n", 1 );
+ }
+ if( *pComment )
+ pLast = ++pComment;
+ }
+}
+
sal_Bool
PrinterGfx::DrawEPS( const Rectangle& rBoundingBox, void* pPtr, sal_uInt32 nSize )
{
diff --git a/psprint/source/printergfx/text_gfx.cxx b/psprint/source/printergfx/text_gfx.cxx
index 9f99b01cb86c..f112fb95e8ae 100644
--- a/psprint/source/printergfx/text_gfx.cxx
+++ b/psprint/source/printergfx/text_gfx.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: text_gfx.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: cp $ $Date: 2001-06-07 16:11:22 $
+ * last change: $Author: pl $ $Date: 2001-06-08 16:32:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -434,6 +434,41 @@ PrinterGfx::drawText(
}
/* no break */
+ case fonttype::TrueType:
+ if( mrFontMgr.isFontDownloadingAllowed( mnFontID ) )
+ {
+ // search for a glyph set matching the set font
+ std::list< GlyphSet >::iterator aIter;
+ for (aIter = maPS3Font.begin(); aIter != maPS3Font.end(); aIter++)
+ if ( ((*aIter).GetFontID() == mnFontID)
+ && ((*aIter).IsVertical() == mbTextVertical))
+ {
+ (*aIter).DrawText (*this, rPoint, pStr, nLen, pDeltaArray);
+ break;
+ }
+
+ // not found ? create a new one
+ if (aIter == maPS3Font.end())
+ {
+ maPS3Font.push_back (GlyphSet(mnFontID, mbTextVertical));
+ maPS3Font.back().DrawText (*this, rPoint, pStr, nLen, pDeltaArray);
+ }
+ break;
+ }
+ else
+ {
+ // treat it like a builtin font in case a user has that font
+ // also in the printer. This is not so unlikely as it may seem;
+ // no print embedding licensed fonts are often used (or so
+ // they say) in companies:
+ // they are installed on displays and printers, but get not
+ // embedded in print files or documents because they are not
+ // licensed for use outside the company.
+ rtl::OString aMessage( "The font " );
+ aMessage += rtl::OUStringToOString( mrFontMgr.getPSName(mnFontID), RTL_TEXTENCODING_ASCII_US );
+ aMessage += " could not be downloaded\nbecause its license does not allow for that";
+ PSComment( aMessage.getStr() );
+ }
case fonttype::Builtin:
{
rtl::OString aFontName = rtl::OUStringToOString(
@@ -452,27 +487,6 @@ PrinterGfx::drawText(
}
break;
- case fonttype::TrueType:
- {
- // search for a glyph set matching the set font
- std::list< GlyphSet >::iterator aIter;
- for (aIter = maPS3Font.begin(); aIter != maPS3Font.end(); aIter++)
- if ( ((*aIter).GetFontID() == mnFontID)
- && ((*aIter).IsVertical() == mbTextVertical))
- {
- (*aIter).DrawText (*this, rPoint, pStr, nLen, pDeltaArray);
- break;
- }
-
- // not found ? create a new one
- if (aIter == maPS3Font.end())
- {
- maPS3Font.push_back (GlyphSet(mnFontID, mbTextVertical));
- maPS3Font.back().DrawText (*this, rPoint, pStr, nLen, pDeltaArray);
- }
- }
- break;
-
default:
{
WritePS (mpPageBody, "%%%% Error: unsupported font ");