diff --git a/common/iconv.h b/common/iconv.h new file mode 100644 index 00000000..3ef7ed7d --- /dev/null +++ b/common/iconv.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#pragma once + +/** + * @file iconv.h + * @brief Character encoding conversion. + */ + +#include +#include + +__BEGIN_DECLS + +/* If we just use void* in the typedef, the compiler exposes that in error messages. */ +struct __iconv_t; + +/** + * The `iconv_t` type that represents an instance of a converter. + */ +typedef struct __iconv_t* iconv_t; + +/** + * [iconv_open(3)](http://man7.org/linux/man-pages/man3/iconv_open.3.html) allocates a new converter + * from `__src_encoding` to `__dst_encoding`. + * + * Returns a new `iconv_t` on success and returns `((iconv_t) -1)` and sets `errno` on failure. + * + * Available since API level 28. + */ + +#if __ANDROID_API__ >= 28 +iconv_t iconv_open(const char* __src_encoding, const char* __dst_encoding) __INTRODUCED_IN(28); + +/** + * [iconv(3)](http://man7.org/linux/man-pages/man3/iconv.3.html) converts characters from one + * encoding to another. + * + * Android supports the `utf8`, `ascii`, `usascii`, `utf16be`, `utf16le`, `utf32be`, `utf32le`, + * and `wchart` encodings. Android also supports the GNU `//IGNORE` and `//TRANSLIT` extensions. + * + * Returns the number of characters converted on success and returns `((size_t) -1)` and + * sets `errno` on failure. + * + * Available since API level 28. + */ +size_t iconv(iconv_t __converter, char** __src_buf, size_t* __src_bytes_left, char** __dst_buf, size_t* __dst_bytes_left) __INTRODUCED_IN(28); + +/** + * [iconv_close(3)](http://man7.org/linux/man-pages/man3/iconv_close.3.html) deallocates a converter + * returned by iconv_open(). + * + * Returns 0 on success and returns -1 and sets `errno` on failure. + * + * Available since API level 28. + */ +int iconv_close(iconv_t __converter) __INTRODUCED_IN(28); +#endif /* __ANDROID_API__ >= 28 */ + + +__END_DECLS diff --git a/engine/host.cpp b/engine/host.cpp index 067f9ee8..57370866 100644 --- a/engine/host.cpp +++ b/engine/host.cpp @@ -3903,7 +3903,7 @@ void Host_PostInit() EngineVGui()->PostInit(); } -#if defined( LINUX ) +#if defined( LINUX ) && !defined ANDROID const char en_US[] = "en_US.UTF-8"; const char *CurrentLocale = setlocale( LC_ALL, NULL ); if ( !CurrentLocale ) diff --git a/launcher/launcher.cpp b/launcher/launcher.cpp index 7c7f663b..217db87c 100644 --- a/launcher/launcher.cpp +++ b/launcher/launcher.cpp @@ -1192,7 +1192,7 @@ extern "C" __declspec(DLL_EXPORT) int LauncherMain( HINSTANCE hInstance, HINSTAN DLL_EXPORT int LauncherMain( int argc, char **argv ) #endif { -#ifdef LINUX +#if defined LINUX && !defined ANDROID // Temporary fix to stop us from crashing in printf/sscanf functions that don't expect // localization to mess with your "." and "," float seperators. Mac OSX also sets LANG // to en_US.UTF-8 before starting up (in info.plist I believe). @@ -1208,12 +1208,12 @@ DLL_EXPORT int LauncherMain( int argc, char **argv ) const char *CurrentLocale = setlocale( LC_ALL, NULL ); if ( Q_stricmp( CurrentLocale, en_US ) ) { - Warning( "WARNING: setlocale('%s') failed, using locale:'%s'. International characters may not work.\n", en_US, CurrentLocale ); + Msg( "WARNING: setlocale('%s') failed, using locale:'%s'. International characters may not work.\n", en_US, CurrentLocale ); } #endif // LINUX -#if defined LINUX && defined USE_SDL && defined TOGLES +#if defined LINUX && defined USE_SDL && defined TOGLES && !defined ANDROID SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1"); #endif diff --git a/lib/android/armeabi-v7a/libandroid_support.a b/lib/android/armeabi-v7a/libandroid_support.a index 30a81d72..c19cd8cc 100644 Binary files a/lib/android/armeabi-v7a/libandroid_support.a and b/lib/android/armeabi-v7a/libandroid_support.a differ diff --git a/vgui2/vgui_surfacelib/linuxfont.cpp b/vgui2/vgui_surfacelib/linuxfont.cpp index f94d7a40..c77065b2 100644 --- a/vgui2/vgui_surfacelib/linuxfont.cpp +++ b/vgui2/vgui_surfacelib/linuxfont.cpp @@ -42,6 +42,8 @@ inline int32_t INT_2FIXED6(int32_t x) { return x << 6; } bool CLinuxFont::ms_bSetFriendlyNameCacheLessFunc = false; CUtlRBTree< CLinuxFont::font_name_entry > CLinuxFont::m_FriendlyNameCache; +#define ANDROID 1 + //----------------------------------------------------------------------------- // Purpose: Constructor //----------------------------------------------------------------------------- @@ -422,9 +424,9 @@ char *FindFontAndroid(bool bBold, int italic) else if( italic ) fontFileNamePost = "Italic"; else - fontFileName = "Regular"; + fontFileNamePost = "Regular"; - char dataFile[MAX_PATH]; + static char dataFile[MAX_PATH]; if( fontFileNamePost ) snprintf( dataFile, sizeof dataFile, "/system/fonts/%s-%s.ttf", fontFileName, fontFileNamePost ); @@ -435,7 +437,7 @@ char *FindFontAndroid(bool bBold, int italic) { fontFileNamePost = NULL; fontFileName = "DroidSans"; - if( bBold > 500 ) + if( bBold ) fontFileNamePost = "Bold"; if( fontFileNamePost ) @@ -468,7 +470,7 @@ char *CLinuxFont::GetFontFileName( const char *windowsFontName, int flags ) #ifdef ANDROID char *filename = FindFontAndroid( bBold, italic ); - Msg("Android font: %s", filename); + Msg("Android font: %s\n", filename); if( !filename ) return NULL; return strdup( filename ); #else