Provide the ability of drawing text using GWTCanvas.The jars are compatible with GWT 1.5.3, 1.6.x and 1.7.x
Add the following into your gwt.xml project file:
Do not forget to add the following jars in the build path:
gwt-incubator_1-5_Dec_28.jar for GWT 1.5.3 (available at http://code.google.com/p/google-web-toolkit-incubator/) or gwt-incubator-march-02-2009.jar for GWT 1.6.x/1.7.x swtbfont-0.1.jar swtbcanvasfont-0.2.jar
The supplied font called Simplex has been created from the font of the same name you can find at URL: http://local.wasp.uwa.edu.au/~pbourke/dataformats/hershey/ We shall thank the creator and contributors to have released these fonts in the public domain.
Example:
package com.swtb.fontexample.client;
import com.google.gwt.core.client.EntryPoint;
/**
* Entry point classes define onModuleLoad().
*/
public class SWTBFontExample implements EntryPoint {
Simplex simplex = new Simplex();
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
SWTBCanvasText canvas = new SWTBCanvasText(800, 600);
rootPanel.add(canvas);
canvas.setFont(simplex);
canvas.saveContext();
canvas.beginPath();
canvas.textTo("Hello world!", 20.0, 350.0, 0.0, 2.0);
canvas.stroke();
canvas.restoreContext();
canvas.saveContext();
canvas.setLineWidth(2.0);
canvas.beginPath();
canvas.textTo("This should be in bold", 20.0, 60.0, 0.0, 1.0);
canvas.stroke();
canvas.restoreContext();
canvas.saveContext();
canvas.setItalic(true);
canvas.beginPath();
canvas.textTo("This should be in italic", 20.0, 100.0, 0.0, 1.0);
canvas.stroke();
canvas.restoreContext();
canvas.saveContext();
canvas.setItalic(true);
canvas.setLineWidth(2.0);
canvas.beginPath();
canvas.textTo("This should be in bold and italic", 20, 140, 0.0, 1.0);
canvas.stroke();
canvas.restoreContext();
canvas.saveContext();
canvas.beginPath();
canvas.moveTo(20, 180);
canvas.textTo("This should be normal", 20, 180, 0.0, 1.0);
canvas.stroke();
canvas.restoreContext();
canvas.saveContext();
canvas.setItalic(true);
canvas.setLineWidth(1.25);
canvas.beginPath();
canvas.textTo("Diagonal going up", 50, 580, Math.toRadians(30), 0.75);
canvas.stroke();
canvas.restoreContext();
canvas.saveContext();
canvas.setItalic(true);
canvas.setLineWidth(1.25);
canvas.beginPath();
canvas.textTo("Diagonal going down", 50, 220, Math.toRadians(-30), 0.75);
canvas.stroke();
canvas.restoreContext();
}
}The above code will produce the following image:
NOTE:
Version 0.1 of the Font Editor is available in the project swtbfonteditor.
----
For further information see the Javadoc included into swtbcanvasfont-0.2.jar
30 Day Summary May 11 2013 — Jun 10 2013
|
12 Month Summary Jun 10 2012 — Jun 10 2013
|
Copyright
©
2013
Black Duck Software, Inc.
and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a
Creative Commons Attribution 3.0 Unported License
. Ohloh
®
and the Ohloh logo are trademarks of
Black Duck Software, Inc.
in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.