Browse Source

[android]remove fontconfig dependency

android-fixes
nillerusr 3 years ago
parent
commit
64420781a1
  1. BIN
      lib/android/armeabi-v7a/libfontconfig.a
  2. 74
      vgui2/vgui_surfacelib/linuxfont.cpp
  3. 10
      wscript

BIN
lib/android/armeabi-v7a/libfontconfig.a

Binary file not shown.

74
vgui2/vgui_surfacelib/linuxfont.cpp

@ -92,7 +92,8 @@ void CLinuxFont::CreateFontList() @@ -92,7 +92,8 @@ void CLinuxFont::CreateFontList()
if ( m_FriendlyNameCache.Count() > 0 )
return;
if(!FcInit())
#ifndef ANDROID
if(!FcInit())
return;
FcConfig *config;
FcPattern *pat;
@ -160,8 +161,11 @@ void CLinuxFont::CreateFontList() @@ -160,8 +161,11 @@ void CLinuxFont::CreateFontList()
FcFontSetDestroy(fontset);
FcObjectSetDestroy(os);
FcPatternDestroy(pat);
#endif
}
#ifndef ANDROID
static FcPattern* FontMatch(const char* type, FcType vtype, const void* value,
...)
{
@ -204,6 +208,7 @@ static FcPattern* FontMatch(const char* type, FcType vtype, const void* value, @@ -204,6 +208,7 @@ static FcPattern* FontMatch(const char* type, FcType vtype, const void* value,
return match;
}
#endif
bool CLinuxFont::CreateFromMemory(const char *windowsFontName, void *data, int datasize, int tall, int weight, int blur, int scanlines, int flags)
{
@ -400,6 +405,52 @@ bool CLinuxFont::CreateFromMemory(const char *windowsFontName, void *data, int d @@ -400,6 +405,52 @@ bool CLinuxFont::CreateFromMemory(const char *windowsFontName, void *data, int d
return true;
}
#ifdef ANDROID
char *FindFontAndroid(bool bBold, int italic)
{
const char *fontFileName, *fontFileNamePost = NULL;
fontFileName = "Roboto";
if( bBold )
{
if( italic )
fontFileNamePost = "BoldItalic";
else
fontFileNamePost = "Bold";
}
else if( italic )
fontFileNamePost = "Italic";
else
fontFileName = "Regular";
char dataFile[MAX_PATH];
if( fontFileNamePost )
snprintf( dataFile, sizeof dataFile, "/system/fonts/%s-%s.ttf", fontFileName, fontFileNamePost );
else
snprintf( dataFile, sizeof dataFile, "/system/fonts/%s.ttf", fontFileName );
if( access( dataFile, R_OK ) != 0 )
{
fontFileNamePost = NULL;
fontFileName = "DroidSans";
if( bBold > 500 )
fontFileNamePost = "Bold";
if( fontFileNamePost )
snprintf( dataFile, sizeof dataFile, "/system/fonts/%s-%s.ttf", fontFileName, fontFileNamePost );
else
snprintf( dataFile, sizeof dataFile, "/system/fonts/%s.ttf", fontFileName );
if( access( dataFile, R_OK ) != 0 )
return NULL;
}
return dataFile;
}
#endif
//-----------------------------------------------------------------------------
// Purpose: Given a font name from windows, match it to the filename and return that.
//-----------------------------------------------------------------------------
@ -413,18 +464,24 @@ char *CLinuxFont::GetFontFileName( const char *windowsFontName, int flags ) @@ -413,18 +464,24 @@ char *CLinuxFont::GetFontFileName( const char *windowsFontName, int flags )
else if ( !Q_stricmp( pchFontName, "Arial Black" ) || Q_stristr( pchFontName, "bold" ) )
bBold = true;
const int italic = ( flags & vgui::ISurface::FONTFLAG_ITALIC ) ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
const int nFcWeight = bBold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
const int italic = ( flags & vgui::ISurface::FONTFLAG_ITALIC ) ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
FcPattern *match = FontMatch( FC_FAMILY, FcTypeString, pchFontName,
#ifdef ANDROID
char *filename = FindFontAndroid( bBold, italic );
Msg("Android font: %s", filename);
if( !filename ) return NULL;
return strdup( filename );
#else
const int nFcWeight = bBold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL;
FcPattern *match = FontMatch( FC_FAMILY, FcTypeString, pchFontName,
FC_WEIGHT, FcTypeInteger, nFcWeight,
FC_SLANT, FcTypeInteger, italic,
NULL);
if ( !match )
{
{
AssertMsg1( false, "Unable to find font named %s\n", windowsFontName );
return NULL;
}
return NULL;
}
else
{
char *filenameret = NULL;
@ -440,8 +497,11 @@ char *CLinuxFont::GetFontFileName( const char *windowsFontName, int flags ) @@ -440,8 +497,11 @@ char *CLinuxFont::GetFontFileName( const char *windowsFontName, int flags )
}
FcPatternDestroy( match );
Msg("Android font fc: %s", filenameret);
return filenameret;
}
#endif
}
//-----------------------------------------------------------------------------

10
wscript

@ -86,7 +86,7 @@ projects={ @@ -86,7 +86,7 @@ projects={
'dedicated_main',
'dmxloader',
'engine',
# 'game/server',
'game/server',
'ivp/havana',
'ivp/havana/havok/hk_base',
'ivp/havana/havok/hk_math',
@ -174,7 +174,7 @@ def define_platform(conf): @@ -174,7 +174,7 @@ def define_platform(conf):
'_DLL_EXT=.so'
])
if conf.options.BUILD_TYPE == 'debug':
if conf.options.DEBUG_ENGINE:
conf.env.append_unique('DEFINES', [
'DEBUG', '_DEBUG'
])
@ -192,6 +192,9 @@ def options(opt): @@ -192,6 +192,9 @@ def options(opt):
grp.add_option('-d', '--dedicated', action = 'store_true', dest = 'DEDICATED', default = False,
help = 'build dedicated server [default: %default]')
grp.add_option('-D', '--debug-engine', action = 'store_true', dest = 'DEBUG_ENGINE', default = False,
help = 'build with -DDEBUG [default: %default]')
grp.add_option('--use-sdl', action = 'store', dest = 'SDL', type = 'int', default = True,
help = 'build engine with SDL [default: %default]')
@ -264,7 +267,7 @@ def configure(conf): @@ -264,7 +267,7 @@ def configure(conf):
]
if conf.env.DEST_CPU == 'arm':
flags += ['-mfpu=neon', '-mfloat-abi=hard', '-fsigned-char']
flags += ['-mfpu=neon', '-fsigned-char']
else:
flags += ['-march=pentium4','-mtune=core2','-mfpmath=387']
@ -319,7 +322,6 @@ def configure(conf): @@ -319,7 +322,6 @@ def configure(conf):
else:
conf.check(lib='SDL2', uselib_store='SDL2')
conf.check(lib='freetype2', uselib_store='FT2')
conf.check(lib='fontconfig', uselib_store='FC')
conf.check(lib='openal', uselib_store='OPENAL')
conf.check(lib='jpeg', uselib_store='JPEG')
conf.check(lib='png', uselib_store='PNG')

Loading…
Cancel
Save