xref: /core/vcl/inc/win/winlayout.hxx (revision b06e7814d2edbc369b7c441941c3392df1266423)
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 <sal/config.h>
23 
24 #include <rtl/ustring.hxx>
25 
26 #include <sallayout.hxx>
27 #include <svsys.h>
28 #include <win/salgdi.h>
29 #include <o3tl/sorted_vector.hxx>
30 
31 // win32 specific logical font instance
32 class WinFontInstance : public LogicalFontInstance
33 {
34     friend rtl::Reference<LogicalFontInstance> WinFontFace::CreateFontInstance(const vcl::font::FontSelectPattern&) const;
35 
36 public:
37     ~WinFontInstance() override;
38 
39     float getHScale() const;
40 
41     void SetGraphics(WinSalGraphics*);
GetGraphics() const42     WinSalGraphics* GetGraphics() const { return m_pGraphics; }
43 
GetHFONT() const44     HFONT GetHFONT() const { return m_hFont; }
GetVerticalHFONT() const45     HFONT GetVerticalHFONT() const { return m_hVerticalFont; }
46 
47     // Return true if the font is for vertical writing.
IsCJKVerticalFont() const48     bool IsCJKVerticalFont() const { return m_hVerticalFont != nullptr; }
GetTmDescent() const49     sal_Int32 GetTmDescent() const { return m_nTmDescent; }
50 
GetFontFace() const51     const WinFontFace * GetFontFace() const { return static_cast<const WinFontFace *>(LogicalFontInstance::GetFontFace()); }
GetFontFace()52     WinFontFace * GetFontFace() { return static_cast<WinFontFace *>(LogicalFontInstance::GetFontFace()); }
53 
54     bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override;
55 
56     IDWriteFontFace* GetDWFontFace() const;
57 
58 private:
59     explicit WinFontInstance(const WinFontFace&, const vcl::font::FontSelectPattern&);
60 
61     virtual void ImplInitHbFont(hb_font_t*) override;
62 
63     WinSalGraphics *m_pGraphics;
64     HFONT m_hFont;
65     HFONT m_hVerticalFont = nullptr;
66     sal_Int32 m_nTmDescent;
67     mutable sal::systools::COMReference<IDWriteFontFace> mxDWFontFace;
68 };
69 
70 class TextOutRenderer
71 {
72 protected:
73     explicit TextOutRenderer() = default;
74     TextOutRenderer(const TextOutRenderer &) = delete;
75     TextOutRenderer & operator = (const TextOutRenderer &) = delete;
76 
77 public:
78     static TextOutRenderer & get(bool bUseDWrite, bool bRenderingModeNatural, bool bAntiAlias);
79 
80     virtual ~TextOutRenderer() = default;
81 
82     virtual bool operator ()(GenericSalLayout const &rLayout,
83         SalGraphics &rGraphics,
84         HDC hDC) = 0;
85 };
86 
87 class ExTextOutRenderer : public TextOutRenderer
88 {
89     ExTextOutRenderer(const ExTextOutRenderer &) = delete;
90     ExTextOutRenderer & operator = (const ExTextOutRenderer &) = delete;
91 
92 public:
93     explicit ExTextOutRenderer() = default;
94 
95     bool operator ()(GenericSalLayout const &rLayout,
96         SalGraphics &rGraphics,
97         HDC hDC) override;
98 };
99 
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
101