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
: sal_uInt8
42 IS_CLUSTER_START
= 0x80
46 template <> struct typed_flags
<GlyphItemFlags
> : is_typed_flags
<GlyphItemFlags
, 0xff>
51 class VCL_DLLPUBLIC GlyphItem
53 sal_Int32 m_nOrigWidth
; // original glyph width
54 sal_Int32 m_nCharPos
; // index in string
56 sal_GlyphId m_aGlyphId
;
57 sal_Int8 m_nCharCount
; // number of characters making up this glyph
58 GlyphItemFlags m_nFlags
;
61 Point m_aLinearPos
; // absolute position of non rotated string
62 sal_Int32 m_nNewWidth
; // width after adjustments
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
)
72 , m_aLinearPos(rLinearPos
)
73 , m_nNewWidth(nOrigWidth
)
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
); }
86 inline bool GetGlyphBoundRect(const LogicalFontInstance
*, tools::Rectangle
&) const;
87 inline bool GetGlyphOutline(const LogicalFontInstance
*, basegfx::B2DPolyPolygon
&) const;
88 inline void dropGlyph();
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
; }
97 VCL_DLLPUBLIC
bool GlyphItem::GetGlyphBoundRect(const LogicalFontInstance
* pFontInstance
,
98 tools::Rectangle
& rRect
) const
100 return pFontInstance
->GetGlyphBoundRect(m_aGlyphId
, rRect
, IsVertical());
103 VCL_DLLPUBLIC
bool GlyphItem::GetGlyphOutline(const LogicalFontInstance
* pFontInstance
,
104 basegfx::B2DPolyPolygon
& rPoly
) const
106 return pFontInstance
->GetGlyphOutline(m_aGlyphId
, rPoly
, IsVertical());
109 void GlyphItem::dropGlyph()
112 m_nFlags
|= GlyphItemFlags::IS_DROPPED
;
115 class SalLayoutGlyphsImpl
: public std::vector
<GlyphItem
>
118 SalLayoutGlyphsImpl(LogicalFontInstance
& rFontInstance
)
119 : m_rFontInstance(&rFontInstance
)
122 SalLayoutGlyphsImpl
* clone() const;
123 const rtl::Reference
<LogicalFontInstance
>& GetFont() const { return m_rFontInstance
; }
124 bool IsValid() const;
125 void SetFlags(SalLayoutFlags flags
) { mnFlags
= flags
; }
126 SalLayoutFlags
GetFlags() const { return mnFlags
; }
129 rtl::Reference
<LogicalFontInstance
> m_rFontInstance
;
130 SalLayoutFlags mnFlags
= SalLayoutFlags::NONE
;
133 #endif // INCLUDED_VCL_IMPGLYPHITEM_HXX
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */