2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2007 Apple Computer, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
27 #include "PlatformString.h"
32 class RenderSVGResource;
36 TextRun(const UChar* c, int len, bool allowTabs = false, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false,
37 bool applyRunRounding = true, bool applyWordRounding = true)
43 , m_horizontalGlyphStretch(1)
45 , m_allowTabs(allowTabs)
47 , m_directionalOverride(directionalOverride)
48 , m_applyRunRounding(applyRunRounding)
49 , m_applyWordRounding(applyWordRounding)
50 , m_disableSpacing(false)
52 , m_referencingRenderObject(0)
53 , m_activePaintingResource(0)
58 TextRun(const String& s, bool allowTabs = false, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false,
59 bool applyRunRounding = true, bool applyWordRounding = true)
60 : m_characters(s.characters())
65 , m_horizontalGlyphStretch(1)
67 , m_allowTabs(allowTabs)
69 , m_directionalOverride(directionalOverride)
70 , m_applyRunRounding(applyRunRounding)
71 , m_applyWordRounding(applyWordRounding)
72 , m_disableSpacing(false)
74 , m_referencingRenderObject(0)
75 , m_activePaintingResource(0)
80 UChar operator[](int i) const { return m_characters[i]; }
81 const UChar* data(int i) const { return &m_characters[i]; }
83 const UChar* characters() const { return m_characters; }
84 int length() const { return m_len; }
86 void setText(const UChar* c, int len) { m_characters = c; m_len = len; }
89 float horizontalGlyphStretch() const { return m_horizontalGlyphStretch; }
90 void setHorizontalGlyphStretch(float scale) { m_horizontalGlyphStretch = scale; }
93 bool allowTabs() const { return m_allowTabs; }
94 int xPos() const { return m_xpos; }
95 int padding() const { return m_padding; }
96 bool rtl() const { return m_rtl; }
97 bool ltr() const { return !m_rtl; }
98 bool directionalOverride() const { return m_directionalOverride; }
99 bool applyRunRounding() const { return m_applyRunRounding; }
100 bool applyWordRounding() const { return m_applyWordRounding; }
101 bool spacingDisabled() const { return m_disableSpacing; }
103 void disableSpacing() { m_disableSpacing = true; }
104 void disableRoundingHacks() { m_applyRunRounding = m_applyWordRounding = false; }
105 void setRTL(bool b) { m_rtl = b; }
106 void setDirectionalOverride(bool override) { m_directionalOverride = override; }
108 #if ENABLE(SVG_FONTS)
109 RenderObject* referencingRenderObject() const { return m_referencingRenderObject; }
110 void setReferencingRenderObject(RenderObject* object) { m_referencingRenderObject = object; }
112 RenderSVGResource* activePaintingResource() const { return m_activePaintingResource; }
113 void setActivePaintingResource(RenderSVGResource* object) { m_activePaintingResource = object; }
117 const UChar* m_characters;
120 // m_xpos is the x position relative to the left start of the text line, not relative to the left
121 // start of the containing block. In the case of right alignment or center alignment, left start of
122 // the text line is not the same as left start of the containing block.
126 float m_horizontalGlyphStretch;
130 bool m_directionalOverride;
131 bool m_applyRunRounding;
132 bool m_applyWordRounding;
133 bool m_disableSpacing;
135 #if ENABLE(SVG_FONTS)
136 RenderObject* m_referencingRenderObject;
137 RenderSVGResource* m_activePaintingResource;