diff --git a/OsmAnd-java/src/main/java/net/osmand/NativeLibrary.java b/OsmAnd-java/src/main/java/net/osmand/NativeLibrary.java index 8893c01286..25e1a21969 100644 --- a/OsmAnd-java/src/main/java/net/osmand/NativeLibrary.java +++ b/OsmAnd-java/src/main/java/net/osmand/NativeLibrary.java @@ -354,6 +354,7 @@ public class NativeLibrary { FileInputStream fis = new FileInputStream(f); Algorithms.streamCopy(fis, ous); fis.close(); + System.out.println("FONT " + name); initFontType(ous.toByteArray(), name.substring(0, name.length() - 4), name.toLowerCase().contains("bold"), name.toLowerCase().contains("italic")); } catch (IOException e) { diff --git a/OsmAnd-java/src/main/java/net/osmand/Reshaper.java b/OsmAnd-java/src/main/java/net/osmand/Reshaper.java index c6af6ada3a..8a55a6f77f 100644 --- a/OsmAnd-java/src/main/java/net/osmand/Reshaper.java +++ b/OsmAnd-java/src/main/java/net/osmand/Reshaper.java @@ -20,14 +20,18 @@ public class Reshaper { return ""; } } + public static String reshape(String s) { try { - ArabicShaping as = new ArabicShaping(ArabicShaping.LETTERS_SHAPE |ArabicShaping.LENGTH_GROW_SHRINK); + ArabicShaping as = new ArabicShaping(ArabicShaping.LETTERS_SHAPE | + ArabicShaping.LENGTH_GROW_SHRINK); + //printSplit("B", s); try { s = as.shape(s); } catch (ArabicShapingException e) { LOG.error(e.getMessage(), e); } + //printSplit("A", s); Bidi line = new Bidi(s.length(), s.length()); line.setPara(s, Bidi.LEVEL_DEFAULT_LTR, null); // line.setPara(s, Bidi.LEVEL_DEFAULT_LTR, null); @@ -96,33 +100,27 @@ public class Reshaper { return ch; } public static void main(String[] args) { -// char[] c = new char[] {'א', 'ד','ם', ' ', '1', '2'} ; -// String reshape = "אדם"; -// char[] c = new char[] {'א', 'ד','ם'} ; -// String reshape = reshape(new String(c)); -// for (int i = 0; i < reshape.length(); i++) { -// System.out.println(reshape.charAt(i)); -// } test2(); test3(); test4(); test5(); } - private static void test3() { + public static void test3() { String s = "מרכז מסחרי/השלום (40050)"; String reshape = reshape(s); String expected = "(40050) םולשה/ירחסמ זכרמ"; check(s, reshape, expected); } - private static void test5() { + public static void test5() { String s = "מרכז מסחרי/השלום (מרז)"; String reshape = reshape(s); String expected = "(זרמ) םולשה/ירחסמ זכרמ"; check(s, reshape, expected); } - private static void check(String source, String reshape, String expected) { + + public static void check(String source, String reshape, String expected) { printSplit("Source ", source); printSplit("Expected", expected); printSplit("Reshaped", reshape); @@ -131,19 +129,28 @@ public class Reshaper { throw new IllegalArgumentException(String.format("Bug: expected '%s', reshaped '%s'", expected, reshape)); } } - private static void printSplit(String p, String source) { + + static void printSplit(String p, String source) { + printSplit(p, source, true); + printSplit(p, source, false); + } + static void printSplit(String p, String source, boolean f) { System.out.print(p); System.out.print(": \u2066"); - for(int i = 0; i < source.length(); i++) { - System.out.print(source.charAt(i)); - System.out.print(" \u200e"); + for (int i = 0; i < source.length(); i++) { + if (f) { + System.out.print(source.charAt(i)); + System.out.print(" \u200e"); + } else { + System.out.print(String.format("%04x ", (int) source.charAt(i))); + } } // System.out.println(Arrays.toString(source.toCharArray())); System.out.println(); System.out.flush(); } - private static void test2() { + public static void test2() { String s = "گچ پژ نمکی باللغة العربي"; String reshape = reshape(s); String expected1 = "ﻲﺑﺮﻌﻟﺍ ﺔﻐﻠﻟﺎﺑ ﯽﮑﻤﻧ ﮋﭘ ﭻﮔ"; @@ -151,7 +158,7 @@ public class Reshaper { check(s, reshape, expected1); } - private static void test4() { + public static void test4() { String s = "Abc (123)"; check(s, reshape(s), s); } diff --git a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java index 78966e4b5d..f57a4f1c3d 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/BinaryRoutePlanner.java @@ -810,14 +810,12 @@ public class BinaryRoutePlanner { printRoad(">?", visitedSegments.get(calculateRoutePointId(next, next.isPositive())), next.isPositive()); } - if (distFromStart < next.distanceFromStart) { - if (ctx.config.heuristicCoefficient <= 1) { - System.err.println("! Alert distance from start " + distFromStart + " < " - + next.distanceFromStart + " id=" + next.road.id); - } - } if (distFromStart < visIt.distanceFromStart && next.getParentRoute() == null) { toAdd = true; + if (ctx.config.heuristicCoefficient <= 1) { + System.err.println("! Alert distance from start " + distFromStart + " < " + + visIt.distanceFromStart + " id=" + next.road.id); + } } else { toAdd = false; } diff --git a/OsmAnd-java/src/test/java/net/osmand/ReShaperTest.java b/OsmAnd-java/src/test/java/net/osmand/ReShaperTest.java new file mode 100644 index 0000000000..c915789762 --- /dev/null +++ b/OsmAnd-java/src/test/java/net/osmand/ReShaperTest.java @@ -0,0 +1,56 @@ +package net.osmand; + +import java.text.Normalizer; + +import org.junit.Test; + +import com.ibm.icu.text.ArabicShaping; +import com.ibm.icu.text.ArabicShapingException; +import com.ibm.icu.text.Bidi; + +import net.osmand.Reshaper; + +public class ReShaperTest { + + + // + +// Source : ⁦ه ‎ە ‎ی ‎ب ‎ە ‎ +// Expected: ⁦ه ‎ە ‎ی ‎ب ‎ە ‎ +// Reshaped: ⁦ە ‎ﺐ ‎ﯾ ‎ە ‎ﻩ + @Test + public void testArabName() throws ArabicShapingException { + // https://www.compart.com/en/unicode/U+FCD8 +// String source = "\uFEEB\u06d5"; +// System.out.println(new ArabicShaping(0).shape(s)); +// System.out.println("\uFEEB\u06d5"); + String source = "هەیبە"; + String expected = "ەﺐﯾەﻩ"; + String res = Reshaper.reshape(source); + Reshaper.check(source, res, expected); + } + + + @Test + public void test2() throws ArabicShapingException { + Reshaper.test2(); + } + + @Test + public void test3() throws ArabicShapingException { + Reshaper.test3(); + } + + @Test + public void test4() throws ArabicShapingException { + Reshaper.test4(); + } + + @Test + public void test5() throws ArabicShapingException { + Reshaper.test5(); + } + + + +}