LibreOffice Module vcl (master)  1
impglyphitem.hxx
Go to the documentation of this file.
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 #ifndef INCLUDED_VCL_IMPGLYPHITEM_HXX
21 #define INCLUDED_VCL_IMPGLYPHITEM_HXX
22 
23 #include <o3tl/typed_flags_set.hxx>
24 #include <tools/gen.hxx>
25 #include <vcl/dllapi.h>
26 #include <vcl/glyphitem.hxx>
27 #include <vcl/outdev.hxx>
28 #include <vector>
29 
30 #include "fontinstance.hxx"
31 
33 {
34  NONE = 0,
35  IS_IN_CLUSTER = 0x01,
36  IS_RTL_GLYPH = 0x02,
37  IS_DIACRITIC = 0x04,
38  IS_VERTICAL = 0x08,
39  IS_SPACING = 0x10,
40  ALLOW_KASHIDA = 0x20,
41  IS_DROPPED = 0x40,
42  IS_CLUSTER_START = 0x80
43 };
44 namespace o3tl
45 {
46 template <> struct typed_flags<GlyphItemFlags> : is_typed_flags<GlyphItemFlags, 0xff>
47 {
48 };
49 };
50 
52 {
53  sal_Int32 m_nOrigWidth; // original glyph width
54  sal_Int32 m_nCharPos; // index in string
55  sal_Int32 m_nXOffset;
57  sal_Int8 m_nCharCount; // number of characters making up this glyph
59 
60 public:
61  Point m_aLinearPos; // absolute position of non rotated string
62  sal_Int32 m_nNewWidth; // width after adjustments
63 
64  GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, const Point& rLinearPos,
65  GlyphItemFlags nFlags, int nOrigWidth, int nXOffset)
66  : m_nOrigWidth(nOrigWidth)
67  , m_nCharPos(nCharPos)
68  , m_nXOffset(nXOffset)
69  , m_aGlyphId(aGlyphId)
70  , m_nCharCount(nCharCount)
71  , m_nFlags(nFlags)
72  , m_aLinearPos(rLinearPos)
73  , m_nNewWidth(nOrigWidth)
74  {
75  }
76 
77  bool IsInCluster() const { return bool(m_nFlags & GlyphItemFlags::IS_IN_CLUSTER); }
78  bool IsRTLGlyph() const { return bool(m_nFlags & GlyphItemFlags::IS_RTL_GLYPH); }
79  bool IsDiacritic() const { return bool(m_nFlags & GlyphItemFlags::IS_DIACRITIC); }
80  bool IsVertical() const { return bool(m_nFlags & GlyphItemFlags::IS_VERTICAL); }
81  bool IsSpacing() const { return bool(m_nFlags & GlyphItemFlags::IS_SPACING); }
82  bool AllowKashida() const { return bool(m_nFlags & GlyphItemFlags::ALLOW_KASHIDA); }
83  bool IsDropped() const { return bool(m_nFlags & GlyphItemFlags::IS_DROPPED); }
84  bool IsClusterStart() const { return bool(m_nFlags & GlyphItemFlags::IS_CLUSTER_START); }
85 
86  inline bool GetGlyphBoundRect(const LogicalFontInstance*, tools::Rectangle&) const;
87  inline bool GetGlyphOutline(const LogicalFontInstance*, basegfx::B2DPolyPolygon&) const;
88  inline void dropGlyph();
89 
90  sal_GlyphId glyphId() const { return m_aGlyphId; }
91  int charCount() const { return m_nCharCount; }
92  int origWidth() const { return m_nOrigWidth; }
93  int charPos() const { return m_nCharPos; }
94  int xOffset() const { return m_nXOffset; }
95 };
96 
98  tools::Rectangle& rRect) const
99 {
100  return pFontInstance->GetGlyphBoundRect(m_aGlyphId, rRect, IsVertical());
101 }
102 
104  basegfx::B2DPolyPolygon& rPoly) const
105 {
106  return pFontInstance->GetGlyphOutline(m_aGlyphId, rPoly, IsVertical());
107 }
108 
110 {
111  m_nCharPos = -1;
113 }
114 
115 class SalLayoutGlyphsImpl : public std::vector<GlyphItem>
116 {
117  friend class GenericSalLayout;
118 
119 public:
120  SalLayoutGlyphsImpl* clone() const;
122  bool IsValid() const;
123 
124 private:
127 
129  : m_rFontInstance(&rFontInstance)
130  {
131  }
132 };
133 
134 #endif // INCLUDED_VCL_IMPGLYPHITEM_HXX
135 
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle &, bool) const
bool AllowKashida() const
Point m_aLinearPos
bool IsDiacritic() const
signed char sal_Int8
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
bool GetGlyphOutline(const LogicalFontInstance *, basegfx::B2DPolyPolygon &) const
bool IsSpacing() const
bool GetGlyphBoundRect(const LogicalFontInstance *, tools::Rectangle &) const
bool IsValid() const
sal_uInt16 sal_GlyphId
Definition: glyphitem.hxx:29
SalLayoutFlags mnFlags
GlyphItemFlags
void dropGlyph()
sal_GlyphId glyphId() const
GlyphItemFlags m_nFlags
bool IsVertical() const
sal_Int8 m_nCharCount
bool IsInCluster() const
sal_Int32 m_nOrigWidth
bool IsDropped() const
sal_Int32 m_nNewWidth
SalLayoutGlyphsImpl(LogicalFontInstance &rFontInstance)
bool IsRTLGlyph() const
sal_Int32 m_nCharPos
rtl::Reference< LogicalFontInstance > m_rFontInstance
const rtl::Reference< LogicalFontInstance > & GetFont() const
int charCount() const
int charPos() const
int origWidth() const
unsigned char sal_uInt8
bool IsClusterStart() const
sal_GlyphId m_aGlyphId
virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon &, bool) const =0
GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, const Point &rLinearPos, GlyphItemFlags nFlags, int nOrigWidth, int nXOffset)
int xOffset() const
sal_Int32 m_nXOffset
SalLayoutGlyphsImpl * clone() const
SalLayoutFlags