Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
fx_bidi.h
Go to the documentation of this file.
1// Copyright 2014 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef CORE_FXCRT_FX_BIDI_H_
8#define CORE_FXCRT_FX_BIDI_H_
9
10#include <stdint.h>
11
12#include <vector>
13
14#include "core/fxcrt/widestring.h"
15
16// Processes characters and group them into segments based on text direction.
18 public:
20 struct Segment {
21 int32_t start; // Start position.
22 int32_t count; // Character count.
23 Direction direction; // Segment direction.
24 };
25
27
28 // Append a character and classify it as left, left-weak, right, or neutral.
29 // Returns true if the character has a different direction than the
30 // existing direction to indicate there is a segment to process.
31 bool AppendChar(wchar_t wch);
32
33 // Call this after the last character has been appended. AppendChar()
34 // must not be called after this.
35 // Returns true if there is still a segment to process.
36 bool EndChar();
37
38 // Call after a change in direction is indicated by the above to get
39 // information about the segment to process.
40 const Segment& GetSegmentInfo() const { return m_LastSegment; }
41
42 private:
43 void StartNewSegment(CFX_BidiChar::Direction direction);
44
45 Segment m_CurrentSegment;
46 Segment m_LastSegment;
47};
48
50 public:
52
53 explicit CFX_BidiString(const WideString& str);
55
56 // Overall direction is always LEFT or RIGHT, never NEUTRAL.
58
59 // Force the overall direction to be R2L regardless of what was detected.
61
62 const_iterator begin() const { return m_Order.begin(); }
63 const_iterator end() const { return m_Order.end(); }
64
65 private:
66 const WideString& m_Str;
67 std::vector<CFX_BidiChar::Segment> m_Order;
69};
70
71#endif // CORE_FXCRT_FX_BIDI_H_
const Segment & GetSegmentInfo() const
Definition fx_bidi.h:40
bool AppendChar(wchar_t wch)
Definition fx_bidi.cpp:18
bool EndChar()
Definition fx_bidi.cpp:50
const_iterator begin() const
Definition fx_bidi.h:62
void SetOverallDirectionRight()
Definition fx_bidi.cpp:93
const_iterator end() const
Definition fx_bidi.h:63
CFX_BidiString(const WideString &str)
Definition fx_bidi.cpp:62
CFX_BidiChar::Direction OverallDirection() const
Definition fx_bidi.cpp:87
bool Contains(const CFX_PointF &point) const
CFX_FloatRect(const CFX_FloatRect &that)=default
constexpr CFX_FloatRect(float l, float b, float r, float t)
float Width() const
bool IsEmpty() const
void Intersect(const CFX_FloatRect &other_rect)
CFX_FloatRect & operator=(const CFX_FloatRect &that)=default
float Height() const
void Translate(float e, float f)
void Union(const CFX_FloatRect &other_rect)
CFX_Matrix & operator=(const CFX_Matrix &other)=default
CFX_FloatRect TransformRect(const CFX_FloatRect &rect) const
float TransformDistance(float distance) const
CFX_Matrix operator*(const CFX_Matrix &right) const
CFX_PointF Transform(const CFX_PointF &point) const
CFX_Matrix GetInverse() const
float TransformXDistance(float dx) const
uint16_t CIDFromCharCode(uint32_t charcode) const
int16_t GetVertWidth(uint16_t cid) const
RetainPtr< const CPDF_Dictionary > GetParam() const
virtual FX_RECT GetCharBBox(uint32_t charcode)=0
virtual int GetCharWidthF(uint32_t charcode)=0
static constexpr uint32_t kInvalidCharCode
Definition cpdf_font.h:63
virtual WideString UnicodeFromCharCode(uint32_t charcode) const
void AppendChar(ByteString *str, uint32_t charcode) const
int GetStringWidth(ByteStringView pString)
const CPDF_Form * form() const
const CFX_Matrix & form_matrix() const
virtual bool IsText() const
const CFX_FloatRect & GetRect() const
virtual CPDF_FormObject * AsForm()
virtual CPDF_TextObject * AsText()
const CPDF_TextState & text_state() const
virtual bool IsForm() const
float GetPageHeight() const override
Definition cpdf_page.cpp:59
float GetPageWidth() const override
Definition cpdf_page.cpp:55
CFX_Matrix GetDisplayMatrix(const FX_RECT &rect, int iRotate) const override
RetainPtr< CPDF_Font > GetFont() const
CFX_Matrix GetTextMatrix() const
float GetCharWidth(uint32_t charcode) const
float GetFontSize() const
CharInfo(const CharInfo &)
int CharIndexFromTextIndex(int text_index) const
bool GetRect(int rectIndex, CFX_FloatRect *pRect) const
int CountChars() const
WideString GetTextByRect(const CFX_FloatRect &rect) const
const CharInfo & GetCharInfo(size_t index) const
CFX_FloatRect GetCharLooseBounds(size_t index) const
CPDF_TextPage(const CPDF_Page *pPage, bool rtl)
WideString GetTextByObject(const CPDF_TextObject *pTextObj) const
int GetIndexAtPos(const CFX_PointF &point, const CFX_SizeF &tolerance) const
float GetCharFontSize(size_t index) const
int CountRects(int start, int nCount)
int TextIndexFromCharIndex(int char_index) const
std::vector< CFX_FloatRect > GetRectArray(int start, int count) const
WideString GetPageText(int start, int count) const
WideString & operator+=(wchar_t ch)
CharType operator[](const size_t index) const
Definition widestring.h:146
bool IsEmpty() const
Definition widestring.h:118
CharType Back() const
Definition widestring.h:152
bool FXSYS_iswalnum(wchar_t c)
#define FXSYS_IsFloatZero(f)
Definition fx_system.h:35
wchar_t GetMirrorChar(wchar_t wch)
#define CHECK(cvref)
Direction direction
Definition fx_bidi.h:23
int32_t bottom
bool Valid() const
int32_t right
int Width() const
int32_t top
int32_t left
constexpr FX_RECT(int l, int t, int r, int b)
const uint16_t kUnicodeDataNormalizationMap2[1724]
const uint16_t kUnicodeDataNormalization[65536]
const uint16_t kUnicodeDataNormalizationMap4[488]
const uint16_t kUnicodeDataNormalizationMap1[5376]
const uint16_t kUnicodeDataNormalizationMap3[1164]