Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
b4ec6f6c
Commit
b4ec6f6c
authored
Jul 17, 2013
by
Didier Clerc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed text item font problem on resize
parent
bc5a17e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
11 deletions
+24
-11
UBGraphicsTextItemDelegate.cpp
src/domain/UBGraphicsTextItemDelegate.cpp
+24
-11
No files found.
src/domain/UBGraphicsTextItemDelegate.cpp
View file @
b4ec6f6c
...
...
@@ -354,14 +354,19 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode cha
if
(
0
==
anchorPos
-
cursorPos
)
{
// If nothing is selected, then we select all the text
cursor
.
setPosition
(
0
,
QTextCursor
::
MoveAnchor
);
cursor
.
setPosition
(
cursor
.
document
()
->
characterCount
()
-
1
,
QTextCursor
::
KeepAnchor
);
}
// Now we got the real start and stop positions
int
startPos
=
qMin
(
cursor
.
anchor
(),
cursor
.
position
());
int
endPos
=
qMax
(
cursor
.
anchor
(),
cursor
.
position
());
qDebug
()
<<
"start: "
<<
startPos
<<
", stop: "
<<
endPos
;
QFont
curFont
;
QFont
nextCharFont
;
bool
bEndofTheSameBlock
;
int
iBlockLen
;
int
iPointSize
;
...
...
@@ -375,35 +380,43 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode cha
bEndofTheSameBlock
=
false
;
iBlockLen
=
0
;
// Here we get the point size of the first character
cursor
.
setPosition
(
iCursorPos
+
1
,
QTextCursor
::
KeepAnchor
);
iPointSize
=
cursor
.
charFormat
().
font
().
pointSize
();
curFont
=
cursor
.
charFormat
().
font
();
iPointSize
=
curFont
.
pointSize
();
// Then we position the end cursor to the start cursor position
cursor
.
setPosition
(
iCursorPos
,
QTextCursor
::
KeepAnchor
);
curFont
=
cursor
.
charFormat
().
font
();
do
{
iBlockLen
++
;
// Get the next character font size
cursor
.
setPosition
(
iCursorPos
+
iBlockLen
+
1
,
QTextCursor
::
KeepAnchor
);
iNextPointSize
=
cursor
.
charFormat
().
font
().
pointSize
();
nextCharFont
=
cursor
.
charFormat
().
font
();
iNextPointSize
=
nextCharFont
.
pointSize
();
cursor
.
setPosition
(
iCursorPos
+
iBlockLen
,
QTextCursor
::
KeepAnchor
);
if
((
iPointSize
!=
iNextPointSize
)
||
(
iCursorPos
+
iBlockLen
>=
endPos
))
if
((
iPointSize
!=
iNextPointSize
)
||
(
iCursorPos
+
iBlockLen
>=
endPos
)
||
(
0
!=
curFont
.
family
().
compare
(
nextCharFont
.
family
()))){
bEndofTheSameBlock
=
true
;
break
;
}
iBlockLen
++
;
}
while
(
!
bEndofTheSameBlock
);
//setting new parameners
QFont
tmpFont
=
curFont
;
int
iNewPointSize
=
(
changeSize
==
changeMode
)
?
(
iPointSize
+
factor
)
:
(
iPointSize
*
factor
);
curFont
.
setPointSize
(
(
iNewPointSize
>
0
)
?
iNewPointSize
:
1
);
textFormat
.
setFont
(
curFont
);
cursor
.
mergeCharFormat
(
textFormat
);
tmpFont
.
setPointSize
(
(
iNewPointSize
>
0
)
?
iNewPointSize
:
1
);
textFormat
.
setFont
(
tmpFont
);
cursor
.
setPosition
(
iCursorPos
+
iBlockLen
,
QTextCursor
::
KeepAnchor
);
cursor
.
setCharFormat
(
textFormat
);
iCursorPos
+=
iBlockLen
;
cursor
.
setPosition
(
iCursorPos
,
QTextCursor
::
MoveAnchor
);
curFont
=
nextCharFont
;
}
delegated
()
->
setFont
(
curFont
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment