html: improve text rendering
This commit is contained in:
parent
e3dccea307
commit
3ab9751128
@ -5,6 +5,7 @@ import org.oscim.backend.canvas.Bitmap;
|
|||||||
import org.oscim.backend.canvas.Paint;
|
import org.oscim.backend.canvas.Paint;
|
||||||
|
|
||||||
import com.google.gwt.canvas.dom.client.Context2d;
|
import com.google.gwt.canvas.dom.client.Context2d;
|
||||||
|
import com.google.gwt.canvas.dom.client.Context2d.LineJoin;
|
||||||
|
|
||||||
public class GwtCanvas implements org.oscim.backend.canvas.Canvas {
|
public class GwtCanvas implements org.oscim.backend.canvas.Canvas {
|
||||||
GwtBitmap bitmap;
|
GwtBitmap bitmap;
|
||||||
@ -28,15 +29,18 @@ public class GwtCanvas implements org.oscim.backend.canvas.Canvas {
|
|||||||
GwtPaint p = (GwtPaint) paint;
|
GwtPaint p = (GwtPaint) paint;
|
||||||
Context2d ctx = bitmap.pixmap.getContext();
|
Context2d ctx = bitmap.pixmap.getContext();
|
||||||
ctx.setFont(p.font);
|
ctx.setFont(p.font);
|
||||||
|
ctx.setLineJoin(LineJoin.ROUND);
|
||||||
|
|
||||||
if (p.stroke){
|
if (p.stroke){
|
||||||
//Log.d("", "stroke " + p.stroke + " " + p.color + " " + p.font + " "+ string);
|
//Log.d("", "stroke " + p.stroke + " " + p.color + " " + p.font + " "+ string);
|
||||||
|
ctx.setLineWidth(p.strokeWidth);
|
||||||
ctx.setStrokeStyle(p.color);
|
ctx.setStrokeStyle(p.color);
|
||||||
ctx.strokeText(string, x, y);
|
//ctx.strokeText(string, p.strokeWidth + x, p.strokeWidth + y);
|
||||||
|
ctx.strokeText(string, x + 1, y + 1);
|
||||||
} else{
|
} else{
|
||||||
//Log.d("", "fill " + p.stroke + " " + p.color + " " + p.font + " "+ string);
|
//Log.d("", "fill " + p.stroke + " " + p.color + " " + p.font + " "+ string);
|
||||||
ctx.setFillStyle(p.color);
|
ctx.setFillStyle(p.color);
|
||||||
ctx.fillText(string, x, y);
|
ctx.fillText(string, x + 1, y + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ public class GwtPaint implements Paint {
|
|||||||
float fontSize;
|
float fontSize;
|
||||||
Align mAlign;
|
Align mAlign;
|
||||||
|
|
||||||
String font = "12px sans-serif";
|
//String font = "12px sans-serif";
|
||||||
|
String font = "13px Helvetica";
|
||||||
|
|
||||||
//private int cap;
|
//private int cap;
|
||||||
|
|
||||||
@ -89,12 +90,12 @@ public class GwtPaint implements Paint {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getFontHeight() {
|
public float getFontHeight() {
|
||||||
return 16;
|
return 14 + strokeWidth * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getFontDescent() {
|
public float getFontDescent() {
|
||||||
return 4;
|
return 4 + strokeWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user