Ticket #13377: fontconfig-20190126a.patch

File fontconfig-20190126a.patch, 6.2 KB (added by mspieth, 8 years ago)
  • android/android-package-source/src/org/qtproject/qt5/android/bindings/QtActivity.java

    diff --git a/android/android-package-source/src/org/qtproject/qt5/android/bindings/QtActivity.java b/android/android-package-source/src/org/qtproject/qt5/android/bindings/QtActivity.java
    index a0cd407e..a1572256 100644
    a b import android.app.Dialog;  
    4141import android.app.Fragment;
    4242import android.content.Context;
    4343import android.content.Intent;
     44import android.content.res.AssetManager;
    4445import android.content.res.Configuration;
    4546import android.content.res.Resources.Theme;
    4647import android.graphics.Bitmap;
    import android.graphics.Canvas;  
    4849import android.os.Build;
    4950import android.os.Bundle;
    5051import android.util.AttributeSet;
     52import android.util.Log;
    5153import android.view.ActionMode;
    5254import android.view.ActionMode.Callback;
    5355import android.view.ContextMenu;
    import android.view.MotionEvent;  
    5961import android.view.View;
    6062import android.view.WindowManager.LayoutParams;
    6163import android.view.accessibility.AccessibilityEvent;
     64import org.qtproject.qt5.android.bindings.MD5;
     65import java.io.FileOutputStream;
     66import java.io.IOException;
     67import java.io.InputStream;
     68import java.io.OutputStream;
     69import java.io.File;
    6270
    6371
    6472public class QtActivity extends Activity
    public class QtActivity extends Activity  
    294302        }
    295303        */
    296304        View decorView = getWindow().getDecorView();
    297         int uiOptions = 
     305        int uiOptions =
    298306            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
    299307            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
    300308            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
    public class QtActivity extends Activity  
    335343    @Override
    336344    public void onCreate(Bundle savedInstanceState)
    337345    {
     346        copyFontConfig();
     347
    338348        super.onCreate(savedInstanceState);
    339349        onCreateHook(savedInstanceState);
    340350        hideSystemUI();
    public class QtActivity extends Activity  
    11161126            }
    11171127        } );
    11181128    }
     1129
     1130    private static String TAG1 = "mfeCP";
     1131    private void copyFontConfig() {
     1132        Log.e(TAG1, "copyFontConfig");
     1133        String toPath = "/data/data/" + getPackageName();  // The application path
     1134        Log.e(TAG1, "basepath " + toPath);
     1135        AssetManager assetManager = getAssets();
     1136        copyAssetIfDifferent(assetManager, "mythtv/fonts.conf", toPath + "/files/fonts.conf");
     1137        copyAssetFolder(assetManager, "mythtv/fonts", toPath + "/files/fonts");
     1138    }
     1139
     1140    private static boolean copyAssetFolder(AssetManager assetManager,
     1141            String fromAssetPath, String toPath) {
     1142        try {
     1143            String[] files = assetManager.list(fromAssetPath);
     1144            new File(toPath).mkdirs();
     1145            boolean res = true;
     1146            for (String file : files) {
     1147                Log.e(TAG1, "do file " + file);
     1148                if (file.contains("."))
     1149                    res &= copyAssetIfDifferent(assetManager,
     1150                            fromAssetPath + "/" + file,
     1151                            toPath + "/" + file);
     1152                else
     1153                    res &= copyAssetFolder(assetManager,
     1154                            fromAssetPath + "/" + file,
     1155                            toPath + "/" + file);
     1156            }
     1157            return res;
     1158        } catch (Exception e) {
     1159            Log.e(TAG1, "Exception in copyAssetFolder", e);
     1160            e.printStackTrace();
     1161            return false;
     1162        }
     1163    }
     1164
     1165    private static boolean copyAssetIfDifferent(AssetManager assetManager, String fromAssetPath, String toFilePath) {
     1166        boolean same = false;
     1167        try {
     1168            Log.e(TAG1, "caif " + fromAssetPath + " " + toFilePath);
     1169            InputStream assetStream = assetManager.open(fromAssetPath);
     1170            same = MD5.compareMD5(assetStream, new File(toFilePath));
     1171        } catch (IOException e) {
     1172            Log.e(TAG1, "Exception in copyAssetIfDifferent", e);
     1173        }
     1174        if (!same) {
     1175            return copyAsset(assetManager, fromAssetPath, toFilePath);
     1176        }
     1177        return true;
     1178    }
     1179
     1180    private static boolean copyAsset(AssetManager assetManager,
     1181            String fromAssetPath, String toPath) {
     1182        InputStream in = null;
     1183        OutputStream out = null;
     1184        try {
     1185            Log.e(TAG1, "ca " + fromAssetPath + " " + toPath);
     1186            in = assetManager.open(fromAssetPath);
     1187            new File(toPath).createNewFile();
     1188            out = new FileOutputStream(toPath);
     1189            copyFile(in, out);
     1190            in.close();
     1191            in = null;
     1192            out.flush();
     1193            out.close();
     1194            out = null;
     1195            return true;
     1196        } catch(Exception e) {
     1197            Log.e(TAG1, "Exception in copyAsset", e);
     1198            e.printStackTrace();
     1199            return false;
     1200        }
     1201    }
     1202
     1203    private static void copyFile(InputStream in, OutputStream out) throws IOException {
     1204        byte[] buffer = new byte[1024];
     1205        int read;
     1206        while((read = in.read(buffer)) != -1){
     1207            out.write(buffer, 0, read);
     1208        }
     1209    }
     1210
    11191211}
  • android/makelibs.sh

    diff --git a/android/makelibs.sh b/android/makelibs.sh
    index d006679b..21e6bb34 100755
    a b fi  
    12221222#fi
    12231223#./autogen.sh &&
    12241224PKG_CONFIG_PATH=$PKG_CONFIG_LIBDIR/pkgconfig \
    1225 CFLAGS="-isysroot $SYSROOT $CPUOPT $ANDROID_API_DEF" \
    1226 CXXFLAGS="-isysroot $SYSROOT $CPUOPT $ANDROID_API_DEF" \
    1227 LDFLAGS="-L$INSTALLROOT/lib -Wl,-rpath-link=$SYSROOT/usr/lib -Wl,-rpath-link=$INSTALLROOT/lib" \
     1225CFLAGS="-isysroot $SYSROOT $CPUOPT $ANDROID_API_DEF -DFONTCONFIG_FILE=\\\"~/fonts.conf\\\"" \
     1226CXXFLAGS="-isysroot $SYSROOT $CPUOPT $ANDROID_API_DEF -DFONTCONFIG_FILE=\\\"~/fonts.conf\\\"" \
     1227LDFLAGS="-L$INSTALLROOT/lib -Wl,-rpath-link=$SYSROOT/usr/lib -Wl,-rpath-link=$INSTALLROOT/lib -llog" \
    12281228RANLIB=${CROSSPATH2}ranlib \
    12291229OBJDUMP=${CROSSPATH2}objdump \
    12301230AR=${CROSSPATH2}ar \
    CPP="$CROSSPATH/$MY_ANDROID_NDK_TOOLS_PREFIX-cpp" \  
    12491249PATH=$OPATH
    12501250unset OPATH
    12511251popd
     1252
     1253# install our fonts.conf
     1254mkdir -p $INSTALLROOT/assets/mythtv
     1255cp $INSTALLROOT/../android-package-source/fonts.conf $INSTALLROOT/assets/mythtv
     1256
    12521257return $ERR
    12531258}
    12541259