Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PoroCYon
Bonzomatic
Commits
f773ae33
Commit
f773ae33
authored
Feb 08, 2018
by
PoroCYon
Committed by
Gargaj
Feb 08, 2018
Browse files
slightly fix font selection on Linux (#50)
parent
62b85d9e
Changes
3
Show whitespace changes
Inline
Side-by-side
README.md
View file @
f773ae33
...
...
@@ -14,7 +14,7 @@ The tool was originally conceived and implemented after the Revision 2014 demosc
-
F2: toggle texture preview
-
F5 or Ctrl-R: recompile shader
-
F11 or Ctrl/Cmd-f: hide shader overlay
-
Alt-F4: exbobolate your planet
-
Alt-F4
or Shift+Escape
: exbobolate your planet
## Configuration
Create a
```config.json```
with e.g. the following contents: (all fields are optional)
...
...
src/main.cpp
View file @
f773ae33
...
...
@@ -143,19 +143,27 @@ int main(int argc, char *argv[])
editorOptions
.
sFontPath
=
"/Library/Fonts/Courier New.ttf"
;
#else
// Linux case
const
std
::
string
fontPaths
[
2
]
=
{
// TODO: use fonts.conf(5) or X resources or something like that
const
char
*
fontPaths
[]
=
{
"/usr/share/fonts/TTF/DejaVuSansMono.ttf"
,
"/usr/share/fonts/TTF/FreeMono.ttf"
,
"/usr/share/fonts/TTF/LiberationMono-Regular.ttf"
,
"/usr/share/fonts/TTF/VeraMono.ttf"
,
"/usr/share/fonts/corefonts/cour.ttf"
,
"/usr/share/fonts/truetype/msttcorefonts/cour.ttf"
"/usr/share/fonts/truetype/msttcorefonts/cour.ttf"
,
NULL
};
editorOptions
.
sFontPath
=
""
;
int
step
=
0
;
while
(
step
<
2
&&
editorOptions
.
sFontPath
.
size
()
==
0
)
{
const
std
::
string
&
current
=
fontPaths
[
step
++
];
if
(
access
(
current
.
c_str
(),
R_OK
)
!=
-
1
)
{
editorOptions
.
sFontPath
=
current
;
for
(
int
i
=
0
;
fontPaths
[
i
];
++
i
)
{
if
(
access
(
fontPaths
[
i
],
R_OK
)
!=
-
1
)
{
editorOptions
.
sFontPath
=
fontPaths
[
i
];
break
;
}
}
// aiee - no font found, but don't report yet, it might still get changed
// though config.json
#endif
editorOptions
.
nOpacity
=
0xC0
;
editorOptions
.
bUseSpacesForTabs
=
true
;
...
...
@@ -199,7 +207,24 @@ int main(int argc, char *argv[])
if
(
options
.
get
<
jsonxx
::
Object
>
(
"font"
).
has
<
jsonxx
::
Number
>
(
"size"
))
editorOptions
.
nFontSize
=
options
.
get
<
jsonxx
::
Object
>
(
"font"
).
get
<
jsonxx
::
Number
>
(
"size"
);
if
(
options
.
get
<
jsonxx
::
Object
>
(
"font"
).
has
<
jsonxx
::
String
>
(
"file"
))
editorOptions
.
sFontPath
=
options
.
get
<
jsonxx
::
Object
>
(
"font"
).
get
<
jsonxx
::
String
>
(
"file"
);
{
std
::
string
fontpath
=
options
.
get
<
jsonxx
::
Object
>
(
"font"
).
get
<
jsonxx
::
String
>
(
"file"
);
// TODO: port this to other platforms
#if !defined(_WIN32) && !defined(__APPLE__)
if
(
access
(
fontpath
.
c_str
(),
R_OK
)
!=
-
1
)
editorOptions
.
sFontPath
=
fontpath
;
else
{
printf
(
"Couldn't open the font file '%s'.
\n
"
,
fontpath
.
c_str
());
return
-
1
;
}
#endif
}
else
if
(
!
editorOptions
.
sFontPath
.
size
())
// coudn't find a default font
{
printf
(
"Couldn't find any of the default fonts. Please specify one in config.json
\n
"
);
return
-
1
;
}
}
if
(
options
.
has
<
jsonxx
::
Object
>
(
"gui"
))
{
...
...
@@ -230,7 +255,7 @@ int main(int argc, char *argv[])
}
Capture
::
LoadSettings
(
options
);
}
if
(
!
Capture
::
Open
(
settings
)
)
if
(
!
Capture
::
Open
(
settings
)
)
{
printf
(
"Initializing capture system failed!
\n
"
);
return
0
;
...
...
@@ -256,6 +281,9 @@ int main(int argc, char *argv[])
printf
(
"Last shader works fine.
\n
"
);
shaderInitSuccessful
=
true
;
}
else
{
printf
(
"Shader error:
\n
%s
\n
"
,
szError
);
}
}
if
(
!
shaderInitSuccessful
)
{
...
...
src/platform_glfw/Renderer.cpp
View file @
f773ae33
#include
<cstdio>
#ifdef _WIN32
#include
<windows.h>
#endif
...
...
@@ -411,7 +414,7 @@ namespace Renderer
void
key_callback
(
GLFWwindow
*
window
,
int
key
,
int
scancode
,
int
action
,
int
mods
)
{
if
(
action
==
GLFW_PRESS
||
action
==
GLFW_REPEAT
)
{
if
((
key
==
GLFW_KEY_F4
)
&&
(
mods
&
GLFW_MOD_ALT
))
{
if
((
key
==
GLFW_KEY_F4
&&
(
mods
&
GLFW_MOD_ALT
))
||
(
key
==
GLFW_KEY_ESCAPE
&&
(
mods
&
GLFW_MOD_SHIFT
)))
{
run
=
false
;
}
int
sciKey
=
0
;
...
...
Write
Preview
Supports
Markdown
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