You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
android.text.Layout: actually measure text sizes
This commit is contained in:
@@ -69,7 +69,7 @@ public class GskCanvas extends Canvas {
|
||||
|
||||
@Override
|
||||
public void drawText(String text, float x, float y, Paint paint) {
|
||||
native_drawText(snapshot, text, x, y, paint.skia_paint);
|
||||
native_drawText(snapshot, text, x, y, paint.skia_paint, paint.skia_font);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,6 +102,6 @@ public class GskCanvas extends Canvas {
|
||||
protected native void native_save(long snapshot);
|
||||
protected native void native_restore(long snapshot);
|
||||
protected native void native_drawLine(long snapshot, float startX, float startY, float stopX, float stopY, long paint);
|
||||
protected native void native_drawText(long snapshot, String text, float x, float y, long paint);
|
||||
protected native void native_drawText(long snapshot, String text, float x, float y, long paint, long font);
|
||||
protected native void native_drawRoundRect(long snapshot, float left, float top, float right, float bottom, float rx, float ry, int color, float strokeWidth);
|
||||
}
|
||||
|
||||
@@ -92,13 +92,17 @@ public class Paint {
|
||||
}
|
||||
|
||||
public float measureText(char[] text, int index, int count) { return 10; }
|
||||
public float measureText(String text, int start, int end) { return 10; }
|
||||
public float measureText(String text) {
|
||||
public float measureText(String text, int start, int end) {
|
||||
if (skia_font == 0)
|
||||
skia_font = native_create_font();
|
||||
return native_measure_text(skia_font, text, 0, text.length(), skia_paint);
|
||||
return native_measure_text(skia_font, text, start, end, skia_paint);
|
||||
}
|
||||
public float measureText(String text) {
|
||||
return measureText(text, 0, text.length());
|
||||
}
|
||||
public float measureText(CharSequence text, int start, int end) {
|
||||
return measureText(text.toString(), start, end);
|
||||
}
|
||||
public float measureText(CharSequence text, int start, int end) { return 10; }
|
||||
|
||||
public ColorFilter setColorFilter(ColorFilter colorFilter) {
|
||||
this.colorFilter = colorFilter;
|
||||
|
||||
@@ -32,7 +32,9 @@ public class Layout {
|
||||
|
||||
public int getWidth() {return 10;}
|
||||
|
||||
public int getHeight() {return 10;}
|
||||
public int getHeight() {
|
||||
return (int)(paint.measureText("_") * 3);
|
||||
}
|
||||
|
||||
public void draw(Canvas canvas) {
|
||||
canvas.drawText(text.toString(), 0, 0, paint);
|
||||
@@ -41,7 +43,7 @@ public class Layout {
|
||||
public int getParagraphDirection(int line) {return 0;}
|
||||
|
||||
public static float getDesiredWidth(CharSequence source, int start, int end, TextPaint paint) {
|
||||
return 400;
|
||||
return paint.measureText(source, start, end);
|
||||
}
|
||||
|
||||
public int getLineEnd(int line) {return 100;}
|
||||
|
||||
Reference in New Issue
Block a user