Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
24550f3f
Commit
24550f3f
authored
Dec 05, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tilda handling for STROKE_FONT class.
parent
6be27ae2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
18 deletions
+24
-18
stroke_font.cpp
common/gal/stroke_font.cpp
+22
-15
stroke_font.h
include/gal/stroke_font.h
+2
-3
No files found.
common/gal/stroke_font.cpp
View file @
24550f3f
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
*
*
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
* Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors.
* Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors.
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
*
* Stroke font class
* Stroke font class
*
*
...
@@ -47,11 +49,6 @@ STROKE_FONT::STROKE_FONT( GAL* aGal ) :
...
@@ -47,11 +49,6 @@ STROKE_FONT::STROKE_FONT( GAL* aGal ) :
}
}
STROKE_FONT
::~
STROKE_FONT
()
{
}
bool
STROKE_FONT
::
LoadNewStrokeFont
(
const
char
*
const
aNewStrokeFont
[],
int
aNewStrokeFontSize
)
bool
STROKE_FONT
::
LoadNewStrokeFont
(
const
char
*
const
aNewStrokeFont
[],
int
aNewStrokeFontSize
)
{
{
m_glyphs
.
clear
();
m_glyphs
.
clear
();
...
@@ -190,7 +187,7 @@ void STROKE_FONT::Draw( wxString aText, const VECTOR2D& aPosition, double aRotat
...
@@ -190,7 +187,7 @@ void STROKE_FONT::Draw( wxString aText, const VECTOR2D& aPosition, double aRotat
// Split multiline strings into separate ones and draw them line by line
// Split multiline strings into separate ones and draw them line by line
int
begin
=
0
;
int
begin
=
0
;
int
newlinePos
=
aText
.
f
ind
(
'\n'
);
int
newlinePos
=
aText
.
F
ind
(
'\n'
);
while
(
newlinePos
!=
wxNOT_FOUND
)
while
(
newlinePos
!=
wxNOT_FOUND
)
{
{
...
@@ -203,7 +200,8 @@ void STROKE_FONT::Draw( wxString aText, const VECTOR2D& aPosition, double aRotat
...
@@ -203,7 +200,8 @@ void STROKE_FONT::Draw( wxString aText, const VECTOR2D& aPosition, double aRotat
}
}
// Draw the last (or the only one) line
// Draw the last (or the only one) line
drawSingleLineText
(
aText
.
Mid
(
begin
)
);
if
(
!
aText
.
IsEmpty
()
)
drawSingleLineText
(
aText
.
Mid
(
begin
)
);
m_gal
->
Restore
();
m_gal
->
Restore
();
}
}
...
@@ -243,7 +241,6 @@ void STROKE_FONT::drawSingleLineText( const wxString& aText )
...
@@ -243,7 +241,6 @@ void STROKE_FONT::drawSingleLineText( const wxString& aText )
break
;
break
;
}
}
if
(
m_mirrored
)
if
(
m_mirrored
)
{
{
// In case of mirrored text invert the X scale of points and their X direction
// In case of mirrored text invert the X scale of points and their X direction
...
@@ -256,13 +253,18 @@ void STROKE_FONT::drawSingleLineText( const wxString& aText )
...
@@ -256,13 +253,18 @@ void STROKE_FONT::drawSingleLineText( const wxString& aText )
xOffset
=
0.0
;
xOffset
=
0.0
;
}
}
for
(
wxString
::
const_iterator
chIt
=
aText
.
begin
();
chIt
!=
aText
.
end
();
chIt
++
)
for
(
wxString
::
const_iterator
chIt
=
aText
.
begin
();
chIt
!=
aText
.
end
();
++
chIt
)
{
{
// Toggle overbar
// Toggle overbar
if
(
*
chIt
==
'~'
)
if
(
*
chIt
==
'~'
)
{
{
m_overbar
=
!
m_overbar
;
if
(
++
chIt
==
aText
.
end
()
)
continue
;
break
;
if
(
*
chIt
!=
'~'
)
// It was a single tilda, it toggles overbar
m_overbar
=
!
m_overbar
;
// If it is a double tilda, just process the second one
}
}
unsigned
dd
=
*
chIt
-
' '
;
unsigned
dd
=
*
chIt
-
' '
;
...
@@ -282,12 +284,12 @@ void STROKE_FONT::drawSingleLineText( const wxString& aText )
...
@@ -282,12 +284,12 @@ void STROKE_FONT::drawSingleLineText( const wxString& aText )
}
}
for
(
GLYPH
::
iterator
pointListIt
=
glyph
.
begin
();
pointListIt
!=
glyph
.
end
();
for
(
GLYPH
::
iterator
pointListIt
=
glyph
.
begin
();
pointListIt
!=
glyph
.
end
();
pointListIt
++
)
++
pointListIt
)
{
{
std
::
deque
<
VECTOR2D
>
pointListScaled
;
std
::
deque
<
VECTOR2D
>
pointListScaled
;
for
(
std
::
deque
<
VECTOR2D
>::
iterator
pointIt
=
pointListIt
->
begin
();
for
(
std
::
deque
<
VECTOR2D
>::
iterator
pointIt
=
pointListIt
->
begin
();
pointIt
!=
pointListIt
->
end
();
pointIt
++
)
pointIt
!=
pointListIt
->
end
();
++
pointIt
)
{
{
VECTOR2D
pointPos
(
pointIt
->
x
*
glyphSize
.
x
+
xOffset
,
pointIt
->
y
*
glyphSize
.
y
);
VECTOR2D
pointPos
(
pointIt
->
x
*
glyphSize
.
x
+
xOffset
,
pointIt
->
y
*
glyphSize
.
y
);
...
@@ -315,13 +317,18 @@ VECTOR2D STROKE_FONT::computeTextSize( const wxString& aText ) const
...
@@ -315,13 +317,18 @@ VECTOR2D STROKE_FONT::computeTextSize( const wxString& aText ) const
{
{
VECTOR2D
result
=
VECTOR2D
(
0.0
,
m_glyphSize
.
y
);
VECTOR2D
result
=
VECTOR2D
(
0.0
,
m_glyphSize
.
y
);
for
(
wxString
::
const_iterator
chIt
=
aText
.
begin
();
chIt
!=
aText
.
end
();
chIt
++
)
for
(
wxString
::
const_iterator
chIt
=
aText
.
begin
();
chIt
!=
aText
.
end
();
++
chIt
)
{
{
wxASSERT_MSG
(
*
chIt
!=
'\n'
,
wxASSERT_MSG
(
*
chIt
!=
'\n'
,
wxT
(
"This function is intended to work with single line strings"
)
);
wxT
(
"This function is intended to work with single line strings"
)
);
// If it is double tilda, then it is displayed as a single tilda
// If it is single tilda, then it is toggling overbar, so we need to skip it
if
(
*
chIt
==
'~'
)
if
(
*
chIt
==
'~'
)
continue
;
{
if
(
++
chIt
==
aText
.
end
()
)
break
;
}
// Index in the bounding boxes table
// Index in the bounding boxes table
unsigned
dd
=
*
chIt
-
' '
;
unsigned
dd
=
*
chIt
-
' '
;
...
...
include/gal/stroke_font.h
View file @
24550f3f
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
*
*
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
* Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors.
* Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors.
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
*
* Stroke font class
* Stroke font class
*
*
...
@@ -52,9 +54,6 @@ public:
...
@@ -52,9 +54,6 @@ public:
/// Constructor
/// Constructor
STROKE_FONT
(
GAL
*
aGal
);
STROKE_FONT
(
GAL
*
aGal
);
/// Destructor
~
STROKE_FONT
();
/**
/**
* @brief Load the new stroke font.
* @brief Load the new stroke font.
*
*
...
...
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