1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _PSPRINT_GLYPHSET_HXX_
25 #define _PSPRINT_GLYPHSET_HXX_
26 
27 #include "vcl/fontmanager.hxx"
28 
29 #include "osl/file.hxx"
30 
31 #include "rtl/string.hxx"
32 
33 #include "tools/gen.hxx"
34 
35 #include <list>
36 #include <hash_map>
37 
38 namespace psp {
39 
40 class PrinterGfx;
41 class PrintFontManager;
42 
43 class GlyphSet
44 {
45 private:
46 
47     sal_Int32 	 	    mnFontID;
48     sal_Bool		    mbVertical;
49     rtl::OString 	    maBaseName;
50     fonttype::type      meBaseType;
51     rtl_TextEncoding    mnBaseEncoding;
52     bool				mbUseFontEncoding;
53 
54     typedef std::hash_map< sal_Unicode, sal_uInt8 > char_map_t;
55     typedef std::list< char_map_t > char_list_t;
56     typedef std::hash_map< sal_GlyphId, sal_uInt8 > glyph_map_t;
57     typedef std::list< glyph_map_t > glyph_list_t;
58 
59     char_list_t		maCharList;
60     glyph_list_t  	maGlyphList;
61 
62     rtl::OString 	GetGlyphSetName (sal_Int32 nGlyphSetID);
63     rtl::OString 	GetCharSetName (sal_Int32 nGlyphSetID);
64     sal_Int32       GetGlyphSetEncoding (sal_Int32 nGlyphSetID);
65     rtl::OString    GetGlyphSetEncodingName (sal_Int32 nGlyphSetID);
66 
67     rtl::OString    GetReencodedFontName (sal_Int32 nGlyphSetID);
68     void            PSDefineReencodedFont (osl::File* pOutFile,
69                                            sal_Int32 nGlyphSetID);
70 
71     sal_Bool		GetCharID (sal_Unicode nChar,
72 								sal_uChar* nOutGlyphID, sal_Int32* nOutGlyphSetID);
73     sal_Bool		LookupCharID (sal_Unicode nChar,
74                                    sal_uChar* nOutGlyphID, sal_Int32* nOutGlyphSetID);
75     sal_Bool		AddCharID (sal_Unicode nChar,
76                                 sal_uChar* nOutGlyphID,
77                                 sal_Int32* nOutGlyphSetID);
78     sal_Bool		GetGlyphID( sal_GlyphId nGlyphId, sal_Unicode nUnicode,
79 								sal_uChar* nOutGlyphID, sal_Int32* nOutGlyphSetID);
80     sal_Bool		LookupGlyphID( sal_GlyphId nGlyphId,
81                                    sal_uChar* nOutGlyphID, sal_Int32* nOutGlyphSetID);
82     sal_Bool		AddGlyphID (sal_GlyphId nGlyphId, sal_Unicode nUnicode,
83                                 sal_uChar* nOutGlyphID,
84                                 sal_Int32* nOutGlyphSetID);
85     void            AddNotdef (char_map_t &rCharMap);
86     void            AddNotdef (glyph_map_t &rGlyphMap);
87     sal_uChar       GetAnsiMapping (sal_Unicode nUnicodeChar);
88     sal_uChar       GetSymbolMapping (sal_Unicode nUnicodeChar);
89 
90     void			ImplDrawText (PrinterGfx &rGfx, const Point& rPoint,
91                                   const sal_Unicode* pStr, sal_Int16 nLen);
92     void			ImplDrawText (PrinterGfx &rGfx, const Point& rPoint,
93                                   const sal_Unicode* pStr, sal_Int16 nLen,
94                                   const sal_Int32* pDeltaArray);
95 
96 public:
97 
98     GlyphSet ();
99     GlyphSet (sal_Int32 nFontID, sal_Bool bVertical);
100     ~GlyphSet ();
101 
102     sal_Int32		GetFontID ();
103     fonttype::type  GetFontType ();
104     static rtl::OString
105     GetReencodedFontName (rtl_TextEncoding nEnc,
106                           const rtl::OString &rFontName);
107     static rtl::OString
108     GetGlyphSetEncodingName (rtl_TextEncoding nEnc,
109                              const rtl::OString &rFontName);
110     sal_Bool		IsVertical ();
111 
112     sal_Bool		SetFont (sal_Int32 nFontID, sal_Bool bVertical);
113 
114     void			DrawText (PrinterGfx &rGfx, const Point& rPoint,
115                               const sal_Unicode* pStr, sal_Int16 nLen,
116                               const sal_Int32* pDeltaArray = NULL);
117     void			DrawGlyphs (PrinterGfx& rGfx,
118                                 const Point& rPoint,
119                                 const sal_GlyphId* pGlyphIds,
120                                 const sal_Unicode* pUnicodes,
121                                 sal_Int16 nLen,
122                                 const sal_Int32* pDeltaArray );
123     sal_Bool        PSUploadEncoding(osl::File* pOutFile, PrinterGfx &rGfx);
124     sal_Bool		PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42, std::list< rtl::OString >& rSuppliedFonts );
125 };
126 
127 
128 } /* namespace psp */
129 
130 #endif
131 
132