1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_IMPGLYPHITEM_HXX
21 #define INCLUDED_VCL_IMPGLYPHITEM_HXX
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>
30 #include "fontinstance.hxx"
32 enum class GlyphItemFlags
35 IS_IN_CLUSTER
= 0x001,
40 ALLOW_KASHIDA
= 0x020,
42 IS_CLUSTER_START
= 0x080
46 template <> struct typed_flags
<GlyphItemFlags
> : is_typed_flags
<GlyphItemFlags
, 0xff>
51 class VCL_DLLPUBLIC GlyphItem
53 sal_GlyphId m_aGlyphId
;
54 int m_nCharCount
; // number of characters making up this glyph
55 int m_nOrigWidth
; // original glyph width
56 LogicalFontInstance
* m_pFontInstance
;
57 int m_nCharPos
; // index in string
58 GlyphItemFlags m_nFlags
;
62 int m_nNewWidth
; // width after adjustments
63 Point m_aLinearPos
; // absolute position of non rotated string
65 GlyphItem(int nCharPos
, int nCharCount
, sal_GlyphId aGlyphId
, const Point
& rLinearPos
,
66 GlyphItemFlags nFlags
, int nOrigWidth
, int nXOffset
,
67 LogicalFontInstance
* pFontInstance
)
68 : m_aGlyphId(aGlyphId
)
69 , m_nCharCount(nCharCount
)
70 , m_nOrigWidth(nOrigWidth
)
71 , m_pFontInstance(pFontInstance
)
72 , m_nCharPos(nCharPos
)
74 , m_nXOffset(nXOffset
)
75 , m_nNewWidth(nOrigWidth
)
76 , m_aLinearPos(rLinearPos
)
78 assert(m_pFontInstance
);
81 bool IsInCluster() const { return bool(m_nFlags
& GlyphItemFlags::IS_IN_CLUSTER
); }
82 bool IsRTLGlyph() const { return bool(m_nFlags
& GlyphItemFlags::IS_RTL_GLYPH
); }
83 bool IsDiacritic() const { return bool(m_nFlags
& GlyphItemFlags::IS_DIACRITIC
); }
84 bool IsVertical() const { return bool(m_nFlags
& GlyphItemFlags::IS_VERTICAL
); }
85 bool IsSpacing() const { return bool(m_nFlags
& GlyphItemFlags::IS_SPACING
); }
86 bool AllowKashida() const { return bool(m_nFlags
& GlyphItemFlags::ALLOW_KASHIDA
); }
87 bool IsDropped() const { return bool(m_nFlags
& GlyphItemFlags::IS_DROPPED
); }
88 bool IsClusterStart() const { return bool(m_nFlags
& GlyphItemFlags::IS_CLUSTER_START
); }
90 inline bool GetGlyphBoundRect(tools::Rectangle
&) const;
91 inline bool GetGlyphOutline(basegfx::B2DPolyPolygon
&) const;
92 inline void dropGlyph();
94 sal_GlyphId
glyphId() const { return m_aGlyphId
; }
95 int charCount() const { return m_nCharCount
; }
96 int origWidth() const { return m_nOrigWidth
; }
97 int charPos() const { return m_nCharPos
; }
98 int xOffset() const { return m_nXOffset
; }
101 VCL_DLLPUBLIC
bool GlyphItem::GetGlyphBoundRect(tools::Rectangle
& rRect
) const
103 return m_pFontInstance
->GetGlyphBoundRect(m_aGlyphId
, rRect
, IsVertical());
106 VCL_DLLPUBLIC
bool GlyphItem::GetGlyphOutline(basegfx::B2DPolyPolygon
& rPoly
) const
108 return m_pFontInstance
->GetGlyphOutline(m_aGlyphId
, rPoly
, IsVertical());
111 void GlyphItem::dropGlyph()
114 m_nFlags
|= GlyphItemFlags::IS_DROPPED
;
117 class SalLayoutGlyphsImpl
: public std::vector
<GlyphItem
>
119 friend class GenericSalLayout
;
122 ~SalLayoutGlyphsImpl();
123 SalLayoutGlyphsImpl
* clone(SalLayoutGlyphs
& rGlyphs
) const;
124 LogicalFontInstance
& GetFont() const { return *m_rFontInstance
; }
125 bool IsValid() const;
129 mutable rtl::Reference
<LogicalFontInstance
> m_rFontInstance
;
130 SalLayoutFlags mnFlags
= SalLayoutFlags::NONE
;
132 SalLayoutGlyphsImpl(SalLayoutGlyphs
& rGlyphs
, LogicalFontInstance
& rFontInstance
)
133 : m_rFontInstance(&rFontInstance
)
135 rGlyphs
.m_pImpl
= this;
139 #endif // INCLUDED_VCL_IMPGLYPHITEM_HXX
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */