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
8b460274
Commit
8b460274
authored
Sep 28, 2019
by
Tomas Heran
Committed by
Gargaj
Oct 07, 2019
Browse files
Use fontconfig on Linux to find appropriate default font.
parent
2278d99c
Changes
3
Hide whitespace changes
Inline
Side-by-side
.travis.yml
View file @
8b460274
...
...
@@ -17,11 +17,11 @@ before_install:
-
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32 40976EAF437D05B5;
sudo apt-get update;
sudo apt-get install -q -y xorg-dev;
sudo apt-get install -q -y xorg-dev
libfontconfig1-dev
;
fi
script
:
-
cmake . && cmake --build .
notifications
:
email
:
false
\ No newline at end of file
email
:
false
CMakeLists.txt
View file @
8b460274
...
...
@@ -443,7 +443,7 @@ if (APPLE)
mark_as_advanced
(
COCOA_FRAMEWORK OPENGL_FRAMEWORK CARBON_FRAMEWORK COREAUDIO_FRAMEWORK AVFOUNDATION_FRAMEWORK
)
set
(
PLATFORM_LIBS
${
COCOA_FRAMEWORK
}
${
OPENGL_FRAMEWORK
}
${
CARBON_FRAMEWORK
}
${
COREAUDIO_FRAMEWORK
}
${
AVFOUNDATION_FRAMEWORK
}
)
elseif
(
UNIX
)
set
(
PLATFORM_LIBS GL
)
set
(
PLATFORM_LIBS GL
fontconfig
)
elseif
(
WIN32
)
if
(
${
BONZOMATIC_WINDOWS_FLAVOR
}
MATCHES
"DX11"
)
set
(
PLATFORM_LIBS d3d11 d3dcompiler dxguid DXGI winmm shlwapi
)
...
...
src/platform_x11/Misc.cpp
View file @
8b460274
...
...
@@ -4,7 +4,11 @@
#include
<string.h>
#include
"../Misc.h"
#include
<stdlib.h>
#include
<unistd.h>
#include
<limits.h>
#include
<fontconfig/fontconfig.h>
void
Misc
::
PlatformStartup
()
{
...
...
@@ -16,17 +20,17 @@ void Misc::PlatformShutdown()
void
Misc
::
InitKeymaps
()
{
return
;
return
;
}
void
Misc
::
GetKeymapName
(
char
*
sz
)
{
strncpy
(
sz
,
"<native>"
,
7
);
strncpy
(
sz
,
"<native>"
,
7
);
}
bool
Misc
::
ExecuteCommand
(
const
char
*
cmd
,
const
char
*
param
)
{
return
false
;
return
false
;
}
bool
Misc
::
FileExists
(
const
char
*
path
)
...
...
@@ -36,28 +40,54 @@ bool Misc::FileExists(const char * path)
const
char
*
Misc
::
GetDefaultFontPath
()
{
// Linux case
// TODO: use fonts.conf(5) or X resources or something like that
const
char
*
fontPaths
[]
=
static
char
ret
[
PATH_MAX
]
=
{
0
};
FcPattern
*
pat
;
FcFontSet
*
fs
;
FcObjectSet
*
os
;
FcChar8
*
file
=
NULL
;
FcConfig
*
config
;
FcBool
result
;
int
i
;
const
char
*
familyNames
[]
=
{
"/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/truetype/dejavu/DejaVuSansMono.ttf"
,
"/usr/share/fonts/truetype/freefont/FreeMono.ttf"
,
"/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf"
,
"/usr/share/fonts/truetype/msttcorefonts/cour.ttf"
,
"/usr/share/fonts/truetype/ubuntu-font-family/UbuntuMono-R.ttf"
,
"/usr/share/fonts/corefonts/cour.ttf"
,
"DejaVu Sans Mono"
,
"FreeMono"
,
"Liberation Mono"
,
"Bitstream Vera Sans Mono"
,
"Ubuntu Mono"
,
NULL
};
for
(
int
i
=
0
;
fontPaths
[
i
];
++
i
)
{
if
(
FileExists
(
fontPaths
[
i
]))
{
return
fontPaths
[
i
];
result
=
FcInit
();
config
=
FcConfigGetCurrent
();
FcConfigSetRescanInterval
(
config
,
0
);
pat
=
FcPatternCreate
();
os
=
FcObjectSetBuild
(
FC_FAMILY
,
FC_FILE
,
(
char
*
)
0
);
FcPatternAddInteger
(
pat
,
FC_SPACING
,
FC_MONO
);
FcPatternAddInteger
(
pat
,
FC_WEIGHT
,
FC_WEIGHT_REGULAR
);
FcPatternAddInteger
(
pat
,
FC_SLANT
,
FC_SLANT_ROMAN
);
fs
=
FcFontList
(
config
,
pat
,
os
);
for
(
i
=
0
;
fs
&&
i
<
fs
->
nfont
;
i
++
)
{
FcChar8
*
family
;
FcPattern
*
font
=
fs
->
fonts
[
i
];
if
(
FcPatternGetString
(
font
,
FC_FAMILY
,
0
,
&
family
)
==
FcResultMatch
)
{
for
(
int
i
=
0
;
familyNames
[
i
]
!=
NULL
;
i
++
)
{
if
(
strcmp
((
const
char
*
)
family
,
familyNames
[
i
])
==
0
)
{
if
(
FcPatternGetString
(
font
,
FC_FILE
,
0
,
&
file
)
==
FcResultMatch
)
{
strcpy
(
ret
,
(
const
char
*
)
file
);
goto
out
;
}
}
}
}
}
return
NULL
;
out:
FcFontSetDestroy
(
fs
);
FcObjectSetDestroy
(
os
);
FcPatternDestroy
(
pat
);
return
ret
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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