summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Lohmann <pl@openoffice.org>2002-02-19 15:28:53 +0000
committerPhilipp Lohmann <pl@openoffice.org>2002-02-19 15:28:53 +0000
commit9754ad8d979557ea03cbfe04708b62b698d1276c (patch)
tree118e803ab54e1faa8966c5062bff65fb5da605bb
parentcf67b55af38cd17ff7dca40a046b6a02290eadec (diff)
#97492# add: DrawGlyphs
-rw-r--r--psprint/inc/psprint/printergfx.hxx11
-rw-r--r--psprint/source/printergfx/glyphset.cxx302
-rw-r--r--psprint/source/printergfx/glyphset.hxx124
-rw-r--r--psprint/source/printergfx/text_gfx.cxx67
4 files changed, 408 insertions, 96 deletions
diff --git a/psprint/inc/psprint/printergfx.hxx b/psprint/inc/psprint/printergfx.hxx
index 6db16a0f69c6..a5388ff10ce0 100644
--- a/psprint/inc/psprint/printergfx.hxx
+++ b/psprint/inc/psprint/printergfx.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: printergfx.hxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: cp $ $Date: 2001-07-06 16:06:03 $
+ * last change: $Author: pl $ $Date: 2002-02-19 16:28:53 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -435,6 +435,13 @@ public:
sal_uInt32 GetGlyphOutline (sal_Unicode c,
sal_uInt16 **ppPolySizes, Point **ppPoints,
sal_uInt8 **ppFlags);
+
+ // for CTL
+ void DrawGlyphs( const Point& rPoint,
+ sal_uInt32* pGlyphIds,
+ sal_Unicode* pUnicodes,
+ sal_Int16 nLen,
+ sal_Int32* pDeltaArray );
};
} /* namespace psp */
diff --git a/psprint/source/printergfx/glyphset.cxx b/psprint/source/printergfx/glyphset.cxx
index a701ac25edcf..a4e122c7da64 100644
--- a/psprint/source/printergfx/glyphset.cxx
+++ b/psprint/source/printergfx/glyphset.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: glyphset.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: cp $ $Date: 2002-01-24 16:50:30 $
+ * last change: $Author: pl $ $Date: 2002-02-19 16:28:53 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -152,18 +152,67 @@ GlyphSet::SetFont (sal_Int32 nFontID, sal_Bool bVertical)
}
sal_Bool
-GlyphSet::GetGlyphID (sal_Unicode nChar,
- sal_uChar* nOutGlyphID, sal_Int32* nOutGlyphSetID)
+GlyphSet::GetCharID (
+ sal_Unicode nChar,
+ sal_uChar* nOutGlyphID,
+ sal_Int32* nOutGlyphSetID
+ )
{
- return LookupGlyphID (nChar, nOutGlyphID, nOutGlyphSetID)
- || AddGlyphID (nChar, nOutGlyphID, nOutGlyphSetID);
+ return LookupCharID (nChar, nOutGlyphID, nOutGlyphSetID)
+ || AddCharID (nChar, nOutGlyphID, nOutGlyphSetID);
}
sal_Bool
-GlyphSet::LookupGlyphID (sal_Unicode nChar,
- sal_uChar* nOutGlyphID, sal_Int32* nOutGlyphSetID)
+GlyphSet::GetGlyphID (
+ sal_uInt32 nGlyph,
+ sal_Unicode nUnicode,
+ sal_uChar* nOutGlyphID,
+ sal_Int32* nOutGlyphSetID
+ )
{
- glyphlist_t::iterator aGlyphSet;
+ return LookupGlyphID (nGlyph, nOutGlyphID, nOutGlyphSetID)
+ || AddGlyphID (nGlyph, nUnicode, nOutGlyphID, nOutGlyphSetID);
+}
+
+sal_Bool
+GlyphSet::LookupCharID (
+ sal_Unicode nChar,
+ sal_uChar* nOutGlyphID,
+ sal_Int32* nOutGlyphSetID
+ )
+{
+ char_list_t::iterator aGlyphSet;
+ sal_Int32 nGlyphSetID;
+
+ // loop thru all the font subsets
+ for (aGlyphSet = maCharList.begin(), nGlyphSetID = 1;
+ aGlyphSet != maCharList.end();
+ ++aGlyphSet, nGlyphSetID++)
+ {
+ // check every subset if it contains the queried unicode char
+ char_map_t::const_iterator aGlyph = (*aGlyphSet).find (nChar);
+ if (aGlyph != (*aGlyphSet).end())
+ {
+ // success: found the unicode char, return the glyphid and the glyphsetid
+ *nOutGlyphSetID = nGlyphSetID;
+ *nOutGlyphID = (*aGlyph).second;
+ return sal_True;
+ }
+ }
+
+ *nOutGlyphSetID = -1;
+ *nOutGlyphID = 0;
+ return sal_False;
+}
+
+sal_Bool
+GlyphSet::LookupGlyphID (
+ sal_uInt32 nGlyph,
+ sal_uChar* nOutGlyphID,
+ sal_Int32* nOutGlyphSetID
+ )
+{
+ glyph_list_t::iterator aGlyphSet;
sal_Int32 nGlyphSetID;
// loop thru all the font subsets
@@ -172,10 +221,10 @@ GlyphSet::LookupGlyphID (sal_Unicode nChar,
++aGlyphSet, nGlyphSetID++)
{
// check every subset if it contains the queried unicode char
- glyph_mapping_t::const_iterator aGlyph = (*aGlyphSet).find (nChar);
+ glyph_map_t::const_iterator aGlyph = (*aGlyphSet).find (nGlyph);
if (aGlyph != (*aGlyphSet).end())
{
- // success: found the unicode char, return the glyphid and the glyphsetid
+ // success: found the glyph id, return the mapped glyphid and the glyphsetid
*nOutGlyphSetID = nGlyphSetID;
*nOutGlyphID = (*aGlyph).second;
return sal_True;
@@ -220,8 +269,11 @@ GlyphSet::GetSymbolMapping (sal_Unicode nUnicodeChar)
}
sal_Bool
-GlyphSet::AddGlyphID (sal_Unicode nChar,
- sal_uChar* nOutGlyphID, sal_Int32* nOutGlyphSetID)
+GlyphSet::AddCharID (
+ sal_Unicode nChar,
+ sal_uChar* nOutGlyphID,
+ sal_Int32* nOutGlyphSetID
+ )
{
sal_uChar nMappedChar;
@@ -233,25 +285,25 @@ GlyphSet::AddGlyphID (sal_Unicode nChar,
// create an empty glyphmap that is reserved for iso1252 encoded glyphs
// (or -- unencoded -- symbol glyphs) and a second map that takes any other
- if (maGlyphList.empty())
+ if (maCharList.empty())
{
- glyph_mapping_t aMap, aMapp;
+ char_map_t aMap, aMapp;
- maGlyphList.push_back (aMap);
- maGlyphList.push_back (aMapp);
+ maCharList.push_back (aMap);
+ maCharList.push_back (aMapp);
}
// if the last map is full, create a new one
- if ((!nMappedChar) && (maGlyphList.back().size() == 255))
+ if ((!nMappedChar) && (maCharList.back().size() == 255))
{
- glyph_mapping_t aMap;
- maGlyphList.push_back (aMap);
+ char_map_t aMap;
+ maCharList.push_back (aMap);
}
// insert a new glyph in the font subset
if (nMappedChar)
{
// always put iso1252 chars into the first map, map them on itself
- glyph_mapping_t& aGlyphSet = maGlyphList.front();
+ char_map_t& aGlyphSet = maCharList.front();
aGlyphSet [nChar] = nMappedChar;
*nOutGlyphSetID = 1;
*nOutGlyphID = nMappedChar;
@@ -259,20 +311,76 @@ GlyphSet::AddGlyphID (sal_Unicode nChar,
else
{
// other chars are just appended to the list
- glyph_mapping_t& aGlyphSet = maGlyphList.back();
+ char_map_t& aGlyphSet = maCharList.back();
int nSize = aGlyphSet.size();
aGlyphSet [nChar] = nSize;
- *nOutGlyphSetID = maGlyphList.size();
+ *nOutGlyphSetID = maCharList.size();
*nOutGlyphID = aGlyphSet [nChar];
}
return sal_True;
}
+sal_Bool
+GlyphSet::AddGlyphID (
+ sal_uInt32 nGlyph,
+ sal_Unicode nUnicode,
+ sal_uChar* nOutGlyphID,
+ sal_Int32* nOutGlyphSetID
+ )
+{
+ sal_uChar nMappedChar;
+
+ // XXX important: avoid to reencode type1 symbol fonts
+ if (mnBaseEncoding == RTL_TEXTENCODING_SYMBOL)
+ nMappedChar = GetSymbolMapping (nUnicode);
+ else
+ nMappedChar = GetAnsiMapping (nUnicode);
+
+ // create an empty glyphmap that is reserved for iso1252 encoded glyphs
+ // (or -- unencoded -- symbol glyphs) and a second map that takes any other
+ if (maGlyphList.empty())
+ {
+ glyph_map_t aMap, aMapp;
+
+ maGlyphList.push_back (aMap);
+ maGlyphList.push_back (aMapp);
+ }
+ // if the last map is full, create a new one
+ if ((!nMappedChar) && (maCharList.back().size() == 255))
+ {
+ glyph_map_t aMap;
+ maGlyphList.push_back (aMap);
+ }
+
+ // insert a new glyph in the font subset
+ if (nMappedChar)
+ {
+ // always put iso1252 chars into the first map, map them on itself
+ glyph_map_t& aGlyphSet = maGlyphList.front();
+ aGlyphSet [nGlyph] = nMappedChar;
+ *nOutGlyphSetID = 1;
+ *nOutGlyphID = nMappedChar;
+ }
+ else
+ {
+ // other chars are just appended to the list
+ glyph_map_t& aGlyphSet = maGlyphList.back();
+
+ int nSize = aGlyphSet.size();
+
+ aGlyphSet [nGlyph] = nSize;
+ *nOutGlyphSetID = maGlyphList.size();
+ *nOutGlyphID = aGlyphSet [nGlyph];
+ }
+
+ return sal_True;
+}
+
rtl::OString
-GlyphSet::GetGlyphSetName (sal_Int32 nGlyphSetID)
+GlyphSet::GetCharSetName (sal_Int32 nGlyphSetID)
{
if (meBaseType == fonttype::TrueType)
{
@@ -287,6 +395,22 @@ GlyphSet::GetGlyphSetName (sal_Int32 nGlyphSetID)
}
}
+rtl::OString
+GlyphSet::GetGlyphSetName (sal_Int32 nGlyphSetID)
+{
+ if (meBaseType == fonttype::TrueType)
+ {
+ return maBaseName
+ + (mbVertical ? rtl::OString ("VGSet") : rtl::OString ("HGSet") )
+ + rtl::OString::valueOf (nGlyphSetID);
+ }
+ else
+ /* (meBaseType == fonttype::Type1 || meBaseType == fonttype::Builtin) */
+ {
+ return maBaseName;
+ }
+}
+
sal_Int32
GlyphSet::GetGlyphSetEncoding (sal_Int32 nGlyphSetID)
{
@@ -383,6 +507,76 @@ GlyphSet::GetReencodedFontName (sal_Int32 nGlyphSetID)
return GetReencodedFontName (GetGlyphSetEncoding(nGlyphSetID), maBaseName);
}
+void GlyphSet::DrawGlyphs(
+ PrinterGfx& rGfx,
+ const Point& rPoint,
+ const sal_uInt32* pGlyphIds,
+ const sal_Unicode* pUnicodes,
+ sal_Int16 nLen,
+ const sal_Int32* pDeltaArray )
+{
+ sal_uChar *pGlyphID = (sal_uChar*)alloca (nLen * sizeof(sal_uChar));
+ sal_Int32 *pGlyphSetID = (sal_Int32*)alloca (nLen * sizeof(sal_Int32));
+ std::set< sal_Int32 > aGlyphSet;
+
+ // convert unicode to font glyph id and font subset
+ for (int nChar = 0; nChar < nLen; nChar++)
+ {
+ GetGlyphID (pGlyphIds[nChar], pUnicodes[nChar], pGlyphID + nChar, pGlyphSetID + nChar);
+ aGlyphSet.insert (pGlyphSetID[nChar]);
+ }
+
+ // loop over all glyph sets to detect substrings that can be xshown together
+ // without changing the postscript font
+ sal_Int32 *pDeltaSubset = (sal_Int32*)alloca (nLen * sizeof(sal_Int32));
+ sal_uChar *pGlyphSubset = (sal_uChar*)alloca (nLen * sizeof(sal_uChar));
+
+ std::set< sal_Int32 >::iterator aSet;
+ for (aSet = aGlyphSet.begin(); aSet != aGlyphSet.end(); ++aSet)
+ {
+ Point aPoint = rPoint;
+ sal_Int32 nOffset = 0;
+ sal_Int32 nGlyphs = 0;
+ sal_Int32 nChar;
+
+ // get offset to first glyph
+ for (nChar = 0; (nChar < nLen) && (pGlyphSetID[nChar] != *aSet); nChar++)
+ {
+ nOffset = pDeltaArray [nChar];
+ }
+
+ // loop over all chars to extract those that share the current glyph set
+ for (nChar = 0; nChar < nLen; nChar++)
+ {
+ if (pGlyphSetID[nChar] == *aSet)
+ {
+ pGlyphSubset [nGlyphs] = pGlyphID [nChar];
+ // the offset to the next glyph is determined by the glyph in
+ // front of the next glyph with the same glyphset id
+ // most often, this will be the current glyph
+ while ((nChar + 1) < nLen)
+ {
+ if (pGlyphSetID[nChar + 1] == *aSet)
+ break;
+ else
+ nChar += 1;
+ }
+ pDeltaSubset [nGlyphs] = pDeltaArray[nChar] - nOffset;
+
+ nGlyphs += 1;
+ }
+ }
+
+ // show the text using the PrinterGfx text api
+ aPoint.Move (nOffset, 0);
+
+ rtl::OString aGlyphSetName(GetGlyphSetName(*aSet));
+ rGfx.PSSetFont (aGlyphSetName, GetGlyphSetEncoding(*aSet));
+ rGfx.PSMoveTo (aPoint);
+ rGfx.PSShowText (pGlyphSubset, nGlyphs, nGlyphs, nGlyphs > 1 ? pDeltaSubset : NULL);
+ }
+}
+
void
GlyphSet::DrawText (PrinterGfx &rGfx, const Point& rPoint,
const sal_Unicode* pStr, sal_Int16 nLen, const sal_Int32* pDeltaArray)
@@ -403,9 +597,9 @@ GlyphSet::ImplDrawText (PrinterGfx &rGfx, const Point& rPoint,
sal_uChar *pGlyphID = (sal_uChar*)alloca (nLen * sizeof(sal_uChar));
sal_Int32 *pGlyphSetID = (sal_Int32*)alloca (nLen * sizeof(sal_Int32));
- // convert unicode to glyph id and glyphset (font subset)
+ // convert unicode to glyph id and char set (font subset)
for (nChar = 0; nChar < nLen; nChar++)
- GetGlyphID (pStr[nChar], pGlyphID + nChar, pGlyphSetID + nChar);
+ GetCharID (pStr[nChar], pGlyphID + nChar, pGlyphSetID + nChar);
rGfx.PSMoveTo (rPoint);
@@ -424,7 +618,7 @@ GlyphSet::ImplDrawText (PrinterGfx &rGfx, const Point& rPoint,
}
// show the text using the PrinterGfx text api
- rtl::OString aGlyphSetName(GetGlyphSetName(nGlyphSetID));
+ rtl::OString aGlyphSetName(GetCharSetName(nGlyphSetID));
rGfx.PSSetFont (aGlyphSetName, GetGlyphSetEncoding(nGlyphSetID));
rGfx.PSShowText (pGlyphID + nChar, nGlyphs, nGlyphs);
@@ -443,7 +637,7 @@ GlyphSet::ImplDrawText (PrinterGfx &rGfx, const Point& rPoint,
// convert unicode to font glyph id and font subset
for (int nChar = 0; nChar < nLen; nChar++)
{
- GetGlyphID (pStr[nChar], pGlyphID + nChar, pGlyphSetID + nChar);
+ GetCharID (pStr[nChar], pGlyphID + nChar, pGlyphSetID + nChar);
aGlyphSet.insert (pGlyphSetID[nChar]);
}
@@ -491,7 +685,7 @@ GlyphSet::ImplDrawText (PrinterGfx &rGfx, const Point& rPoint,
// show the text using the PrinterGfx text api
aPoint.Move (nOffset, 0);
- rtl::OString aGlyphSetName(GetGlyphSetName(*aSet));
+ rtl::OString aGlyphSetName(GetCharSetName(*aSet));
rGfx.PSSetFont (aGlyphSetName, GetGlyphSetEncoding(*aSet));
rGfx.PSMoveTo (aPoint);
rGfx.PSShowText (pGlyphSubset, nGlyphs, nGlyphs, nGlyphs > 1 ? pDeltaSubset : NULL);
@@ -511,8 +705,8 @@ GlyphSet::PSUploadEncoding(osl::File* pOutFile, PrinterGfx &rGfx)
// loop thru all the font subsets
sal_Int32 nGlyphSetID = 0;
- glyphlist_t::iterator aGlyphSet;
- for (aGlyphSet = maGlyphList.begin(); aGlyphSet != maGlyphList.end(); aGlyphSet++)
+ char_list_t::iterator aGlyphSet;
+ for (aGlyphSet = maCharList.begin(); aGlyphSet != maCharList.end(); aGlyphSet++)
{
++nGlyphSetID;
@@ -543,7 +737,7 @@ GlyphSet::PSUploadEncoding(osl::File* pOutFile, PrinterGfx &rGfx)
typedef ps_mapping_t::value_type ps_value_t;
ps_mapping_t aSortedGlyphSet;
- glyph_mapping_t::const_iterator aUnsortedGlyph;
+ char_map_t::const_iterator aUnsortedGlyph;
for (aUnsortedGlyph = (*aGlyphSet).begin();
aUnsortedGlyph != (*aGlyphSet).end();
++aUnsortedGlyph)
@@ -616,8 +810,41 @@ GlyphSet::PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42 )
sal_uInt16 pTTGlyphMapping[256];
// loop thru all the font subsets
+ sal_Int32 nCharSetID;
+ char_list_t::iterator aCharSet;
+ for (aCharSet = maCharList.begin(), nCharSetID = 1;
+ aCharSet != maCharList.end();
+ ++aCharSet, nCharSetID++)
+ {
+ if ((*aCharSet).size() == 0)
+ continue;
+
+ // loop thru all the chars in the subset
+ char_map_t::const_iterator aChar;
+ sal_Int32 n = 0;
+ for (aChar = (*aCharSet).begin(); aChar != (*aCharSet).end(); aChar++)
+ {
+ pUChars [n] = (*aChar).first;
+ pEncoding [n] = (*aChar).second;
+ n++;
+ }
+ // create a mapping from the unicode chars to the char encoding in
+ // source TrueType font
+ MapString (pTTFont, pUChars, (*aCharSet).size(), pTTGlyphMapping, mbVertical);
+
+ // create the current subset
+ if( bAsType42 )
+ CreateT42FromTTGlyphs (pTTFont, pTmpFile, GetCharSetName(nCharSetID),
+ pTTGlyphMapping, pEncoding, (*aCharSet).size() );
+ else
+ CreateT3FromTTGlyphs (pTTFont, pTmpFile, GetCharSetName(nCharSetID),
+ pTTGlyphMapping, pEncoding, (*aCharSet).size(),
+ 0 /* 0 = horizontal, 1 = vertical */ );
+ }
+
+ // loop thru all the font glyph subsets
sal_Int32 nGlyphSetID;
- glyphlist_t::iterator aGlyphSet;
+ glyph_list_t::iterator aGlyphSet;
for (aGlyphSet = maGlyphList.begin(), nGlyphSetID = 1;
aGlyphSet != maGlyphList.end();
++aGlyphSet, nGlyphSetID++)
@@ -626,17 +853,14 @@ GlyphSet::PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42 )
continue;
// loop thru all the glyphs in the subset
- glyph_mapping_t::const_iterator aGlyph;
+ glyph_map_t::const_iterator aGlyph;
sal_Int32 n = 0;
for (aGlyph = (*aGlyphSet).begin(); aGlyph != (*aGlyphSet).end(); aGlyph++)
{
- pUChars [n] = (*aGlyph).first;
- pEncoding [n] = (*aGlyph).second;
+ pTTGlyphMapping [n] = (*aGlyph).first;
+ pEncoding [n] = (*aGlyph).second;
n++;
}
- // create a mapping from the unicode chars to the glyph encoding in
- // source TrueType font
- MapString (pTTFont, pUChars, (*aGlyphSet).size(), pTTGlyphMapping, mbVertical);
// create the current subset
if( bAsType42 )
diff --git a/psprint/source/printergfx/glyphset.hxx b/psprint/source/printergfx/glyphset.hxx
index 255a5b73a591..51193037707b 100644
--- a/psprint/source/printergfx/glyphset.hxx
+++ b/psprint/source/printergfx/glyphset.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: glyphset.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: cp $ $Date: 2001-11-01 16:23:29 $
+ * last change: $Author: pl $ $Date: 2002-02-19 16:28:53 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -88,65 +88,83 @@ class PrintFontManager;
class GlyphSet
{
- private:
+private:
- sal_Int32 mnFontID;
- sal_Bool mbVertical;
- rtl::OString maBaseName;
- fonttype::type meBaseType;
- rtl_TextEncoding mnBaseEncoding;
+ sal_Int32 mnFontID;
+ sal_Bool mbVertical;
+ rtl::OString maBaseName;
+ fonttype::type meBaseType;
+ rtl_TextEncoding mnBaseEncoding;
- typedef std::hash_map< sal_Unicode, sal_uInt8 > glyph_mapping_t;
- typedef std::list< glyph_mapping_t > glyphlist_t;
+ typedef std::hash_map< sal_Unicode, sal_uInt8 > char_map_t;
+ typedef std::list< char_map_t > char_list_t;
+ typedef std::hash_map< sal_uInt32, sal_uInt8 > glyph_map_t;
+ typedef std::list< glyph_map_t > glyph_list_t;
- glyphlist_t maGlyphList;
+ char_list_t maCharList;
+ glyph_list_t maGlyphList;
- rtl::OString GetGlyphSetName (sal_Int32 nGlyphSetID);
- sal_Int32 GetGlyphSetEncoding (sal_Int32 nGlyphSetID);
- rtl::OString GetGlyphSetEncodingName (sal_Int32 nGlyphSetID);
+ rtl::OString GetGlyphSetName (sal_Int32 nGlyphSetID);
+ rtl::OString GetCharSetName (sal_Int32 nGlyphSetID);
+ sal_Int32 GetGlyphSetEncoding (sal_Int32 nGlyphSetID);
+ rtl::OString GetGlyphSetEncodingName (sal_Int32 nGlyphSetID);
- rtl::OString GetReencodedFontName (sal_Int32 nGlyphSetID);
- void PSDefineReencodedFont (osl::File* pOutFile,
- sal_Int32 nGlyphSetID);
+ rtl::OString GetReencodedFontName (sal_Int32 nGlyphSetID);
+ void PSDefineReencodedFont (osl::File* pOutFile,
+ sal_Int32 nGlyphSetID);
- sal_Bool GetGlyphID (sal_Unicode nChar,
+ sal_Bool GetCharID (sal_Unicode nChar,
sal_uChar* nOutGlyphID, sal_Int32* nOutGlyphSetID);
- sal_Bool LookupGlyphID (sal_Unicode nChar,
+ sal_Bool LookupCharID (sal_Unicode nChar,
+ sal_uChar* nOutGlyphID, sal_Int32* nOutGlyphSetID);
+ sal_Bool AddCharID (sal_Unicode nChar,
+ sal_uChar* nOutGlyphID,
+ sal_Int32* nOutGlyphSetID);
+ sal_Bool GetGlyphID (sal_uInt32 nGlyph, sal_Unicode nUnicode,
sal_uChar* nOutGlyphID, sal_Int32* nOutGlyphSetID);
- sal_Bool AddGlyphID (sal_Unicode nChar,
- sal_uChar* nOutGlyphID, sal_Int32* nOutGlyphSetID);
- sal_uChar GetAnsiMapping (sal_Unicode nUnicodeChar);
- sal_uChar GetSymbolMapping (sal_Unicode nUnicodeChar);
-
- void ImplDrawText (PrinterGfx &rGfx, const Point& rPoint,
- const sal_Unicode* pStr, sal_Int16 nLen);
- void ImplDrawText (PrinterGfx &rGfx, const Point& rPoint,
- const sal_Unicode* pStr, sal_Int16 nLen,
- const sal_Int32* pDeltaArray);
-
- public:
-
- GlyphSet ();
- GlyphSet (sal_Int32 nFontID, sal_Bool bVertical);
- ~GlyphSet ();
-
- sal_Int32 GetFontID ();
- fonttype::type GetFontType ();
- static rtl::OString
- GetReencodedFontName (rtl_TextEncoding nEnc,
- const rtl::OString &rFontName);
- static rtl::OString
- GetGlyphSetEncodingName (rtl_TextEncoding nEnc,
- const rtl::OString &rFontName);
- sal_Bool IsVertical ();
-
- sal_Bool SetFont (sal_Int32 nFontID, sal_Bool bVertical);
-
- void DrawText (PrinterGfx &rGfx, const Point& rPoint,
- const sal_Unicode* pStr, sal_Int16 nLen,
- const sal_Int32* pDeltaArray = NULL);
- sal_Bool PSUploadEncoding(osl::File* pOutFile, PrinterGfx &rGfx);
- sal_Bool PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42 );
+ sal_Bool LookupGlyphID (sal_uInt32 nGlyph,
+ sal_uChar* nOutGlyphID, sal_Int32* nOutGlyphSetID);
+ sal_Bool AddGlyphID (sal_uInt32 nGlyph, sal_Unicode nUnicode,
+ sal_uChar* nOutGlyphID,
+ sal_Int32* nOutGlyphSetID);
+ sal_uChar GetAnsiMapping (sal_Unicode nUnicodeChar);
+ sal_uChar GetSymbolMapping (sal_Unicode nUnicodeChar);
+
+ void ImplDrawText (PrinterGfx &rGfx, const Point& rPoint,
+ const sal_Unicode* pStr, sal_Int16 nLen);
+ void ImplDrawText (PrinterGfx &rGfx, const Point& rPoint,
+ const sal_Unicode* pStr, sal_Int16 nLen,
+ const sal_Int32* pDeltaArray);
+
+public:
+
+ GlyphSet ();
+ GlyphSet (sal_Int32 nFontID, sal_Bool bVertical);
+ ~GlyphSet ();
+
+ sal_Int32 GetFontID ();
+ fonttype::type GetFontType ();
+ static rtl::OString
+ GetReencodedFontName (rtl_TextEncoding nEnc,
+ const rtl::OString &rFontName);
+ static rtl::OString
+ GetGlyphSetEncodingName (rtl_TextEncoding nEnc,
+ const rtl::OString &rFontName);
+ sal_Bool IsVertical ();
+
+ sal_Bool SetFont (sal_Int32 nFontID, sal_Bool bVertical);
+
+ void DrawText (PrinterGfx &rGfx, const Point& rPoint,
+ const sal_Unicode* pStr, sal_Int16 nLen,
+ const sal_Int32* pDeltaArray = NULL);
+ void DrawGlyphs (PrinterGfx& rGfx,
+ const Point& rPoint,
+ const sal_uInt32* pGlyphIds,
+ const sal_Unicode* pUnicodes,
+ sal_Int16 nLen,
+ const sal_Int32* pDeltaArray );
+ sal_Bool PSUploadEncoding(osl::File* pOutFile, PrinterGfx &rGfx);
+ sal_Bool PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42 );
};
diff --git a/psprint/source/printergfx/text_gfx.cxx b/psprint/source/printergfx/text_gfx.cxx
index 86a974eb65ca..3982a30b25b4 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.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: hdu $ $Date: 2001-12-21 16:27:15 $
+ * last change: $Author: pl $ $Date: 2002-02-19 16:28:53 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -223,6 +223,69 @@ PrinterGfx::SetFallbackFont ( sal_Int32 nFontID )
return 0;
}
+void PrinterGfx::DrawGlyphs(
+ const Point& rPoint,
+ sal_uInt32* pGlyphIds,
+ sal_Unicode* pUnicodes,
+ sal_Int16 nLen,
+ sal_Int32* pDeltaArray
+ )
+{
+ if( nLen <= 0 )
+ return;
+
+ if ( !mrFontMgr.isFontDownloadingAllowed( mnFontID ) )
+ {
+ LicenceWarning(rPoint, pUnicodes, nLen, pDeltaArray);
+ return;
+ }
+
+ if( mrFontMgr.getFontType( mnFontID ) != fonttype::TrueType )
+ {
+ DrawText( rPoint, pUnicodes, nLen, pDeltaArray );
+ return;
+ }
+ // move and rotate the user coordinate system
+ // avoid the gsave/grestore for the simple cases since it allows
+ // reuse of the current font if it hasn't changed
+ sal_Int32 nCurrentTextAngle = mnTextAngle;
+ Point aPoint( rPoint );
+
+ if (nCurrentTextAngle != 0)
+ {
+ PSGSave ();
+ PSTranslate (rPoint);
+ PSRotate (nCurrentTextAngle);
+ mnTextAngle = 0;
+ aPoint = Point( 0, 0 );
+ }
+
+ // draw the string
+ // 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).DrawGlyphs (*this, aPoint, pGlyphIds, pUnicodes, nLen, pDeltaArray);
+ break;
+ }
+
+ // not found ? create a new one
+ if (aIter == maPS3Font.end())
+ {
+ maPS3Font.push_back (GlyphSet(mnFontID, mbTextVertical));
+ maPS3Font.back().DrawGlyphs (*this, aPoint, pGlyphIds, pUnicodes, nLen, pDeltaArray);
+ }
+
+ // restore the user coordinate system
+ if (nCurrentTextAngle != 0)
+ {
+ PSGRestore ();
+ mnTextAngle = nCurrentTextAngle;
+ }
+}
+
void
PrinterGfx::DrawText (
const Point& rPoint,