Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
openjazz
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
openjazz
Commits
a27afa6d
Commit
a27afa6d
authored
Nov 02, 2009
by
anotherguest
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrong spacing in font for Scenes. Add functions to get font height and text width of a string.
parent
afbc33f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
font.cpp
src/io/gfx/font.cpp
+30
-3
font.h
src/io/gfx/font.h
+2
-1
No files found.
src/io/gfx/font.cpp
View file @
a27afa6d
...
@@ -340,6 +340,10 @@ int Font::showString (char * s, int x, int y) {
...
@@ -340,6 +340,10 @@ int Font::showString (char * s, int x, int y) {
// Determine the character's position on the screen
// Determine the character's position on the screen
src
.
w
=
w
[(
int
)(
map
[(
int
)(
s
[
count
])])];
src
.
w
=
w
[(
int
)(
map
[(
int
)(
s
[
count
])])];
if
(
s
[
count
]
==
32
)
{
src
.
w
=
src
.
w
/
2
;
}
dst
.
y
=
yOffset
;
dst
.
y
=
yOffset
;
dst
.
x
=
xOffset
;
dst
.
x
=
xOffset
;
...
@@ -349,9 +353,8 @@ int Font::showString (char * s, int x, int y) {
...
@@ -349,9 +353,8 @@ int Font::showString (char * s, int x, int y) {
// Draw the character to the screen
// Draw the character to the screen
SDL_BlitSurface
(
surface
,
&
src
,
screen
,
&
dst
);
SDL_BlitSurface
(
surface
,
&
src
,
screen
,
&
dst
);
xOffset
+=
w
[(
int
)(
map
[(
int
)(
s
[
count
])])];
xOffset
+=
src
.
w
-
1
;
}
}
}
}
...
@@ -463,3 +466,27 @@ void Font::restorePalette () {
...
@@ -463,3 +466,27 @@ void Font::restorePalette () {
}
}
int
Font
::
calcStringWidth
(
char
*
s
)
{
int
count
;
int
stringwidth
=
0
;
// Go through each character of the string
for
(
count
=
0
;
s
[
count
];
count
++
)
{
if
(
s
[
count
]
==
'\n'
)
{
}
else
{
int
width
=
w
[(
int
)(
map
[(
int
)(
s
[
count
])])];
if
(
s
[
count
]
==
32
)
{
width
=
width
/
2
;
}
stringwidth
+=
(
width
-
1
);
}
}
return
stringwidth
;
}
src/io/gfx/font.h
View file @
a27afa6d
...
@@ -51,7 +51,8 @@ class Font {
...
@@ -51,7 +51,8 @@ class Font {
void
mapPalette
(
int
start
,
int
length
,
int
newStart
,
void
mapPalette
(
int
start
,
int
length
,
int
newStart
,
int
newLength
);
int
newLength
);
void
restorePalette
();
void
restorePalette
();
int
fontHeight
()
{
return
h
;
}
int
calcStringWidth
(
char
*
s
);
};
};
// Variables
// Variables
...
...
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