1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #pragma once
21 
22 #include <osl/file.hxx>
23 
24 #include <rtl/string.hxx>
25 #include <vcl/glyphitem.hxx>
26 
27 #include <string_view>
28 #include <vector>
29 #include <unordered_map>
30 
31 class Point;
32 
33 namespace psp {
34 
35 class PrinterGfx;
36 class PrintFontManager;
37 
38 class GlyphSet
39 {
40 private:
41 
42     sal_Int32           mnFontID;
43     bool                mbVertical;
44     OString             maBaseName;
45 
46     typedef std::unordered_map< sal_GlyphId, sal_uInt8 > glyph_map_t;
47     std::vector< glyph_map_t > maGlyphList;
48 
49     OString     GetGlyphSetName (sal_Int32 nGlyphSetID);
50 
51     void        GetGlyphID (sal_GlyphId nGlyphId,
52                                 unsigned char* nOutGlyphID, sal_Int32* nOutGlyphSetID);
53     bool        LookupGlyphID (sal_GlyphId nGlyphId,
54                                    unsigned char* nOutGlyphID, sal_Int32* nOutGlyphSetID);
55     void        AddGlyphID (sal_GlyphId nGlyphId,
56                                 unsigned char* nOutGlyphID,
57                                 sal_Int32* nOutGlyphSetID);
58     static void     AddNotdef (glyph_map_t &rGlyphMap);
59 
60 public:
61 
62     GlyphSet (sal_Int32 nFontID, bool bVertical);
63     /* FIXME delete the glyphlist in ~GlyphSet ??? */
64 
GetFontID() const65     sal_Int32       GetFontID () const { return mnFontID;}
66     static OString
67     GetReencodedFontName (rtl_TextEncoding nEnc,
68                           std::string_view rFontName);
69 
IsVertical() const70     bool            IsVertical () const { return mbVertical;}
71 
72     void            DrawGlyph (PrinterGfx& rGfx,
73                                const Point& rPoint,
74                                const sal_GlyphId nGlyphId);
75     void        PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42, std::vector< OString >& rSuppliedFonts );
76 };
77 
78 } /* namespace psp */
79 
80 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
81