strokeText.js is an unobtrusive javascript library working in all the major browsers - Mozilla Firefox 1.5+, Opera 9+, Safari and IE6+. The library provides cross API text stroking capability for Canvas and VML. The (built in) sans-serif font is also adapted for SVG to ensure an identical representation.
strokeText.js is not a standalone application. It act's as an expansion to support core text stroke capability and has to be accessed via API, which is different for Canvas and VML.
The library is based on cvi_text_lib.js and was original made for the CVI-Projects but because of the universal nature of this library (every software project using canvas, vml or svg can benefit from it) it seems to be fair to release it as strokeText.js to the open source community.
strokeText.js: Font Attributes
Images used are copyrighted and released under a ShareAlike CC license. Licensees may distribute derivative works only under a license identical to the license that governs the original work.
strokeText.js: Font Characters (UTF-8|ISO-8859-1)
strokeText.js: Font Sizes (28|24|20|16|12|11|10|9|8|7 px)
Images used are copyrighted and released under a ShareAlike CC license. Licensees may distribute derivative works only under a license identical to the license that governs the original work.
strokeText.js: Font Weight (50%|100%|200%)
strokeText.js: Font Width (50%|100%|200%)
strokeText.js: Font Spacing (200%|100%|50%)
Images used are copyrighted and released under a ShareAlike CC license. Licensees may distribute derivative works only under a license identical to the license that governs the original work.
strokeText.js: Multiple Master (through different weight/width/space)
strokeText.js: Special Effects (through multiple strokes)
Images used are copyrighted and released under a ShareAlike CC license. Licensees may distribute derivative works only under a license identical to the license that governs the original work.
Init Function:
BOOLEAN = check_textRenderContext(context)
webKit (Safari) patch function:
set_textRenderContext(context)
Main Function:
context.strokeText(text, x, y, fontsize, fontweight, fontwidth, charspace, fonttype)
fontsize == baseline == textheight / 32 * 25
Helper Function:
draw_boundingBox(context, x, y, baseline, textheight, textwidth)
Utility Functions:
STRING = get_widthText(string, textwidth, fontsize, fontwidth, charspace, fonttype)
FLOAT = get_textWidth(string, fontsize, fontwidth, charspace, fonttype)
FLOAT = get_textHeight(fontsize)
FLOAT = get_baseLine(fontsize)
Init Function:
BOOLEAN = check_strokeTextCapability()
Main Function:
STRING = get_strokeText(text, x, y, fontsize, fontweight, fontwidth, charspace, fonttype, color, opacity, rotation, id)
fontsize == baseline == textheight / 32 * 25
Helper Function:
STRING = get_boundingBox(x, y, baseline, textheight, textwidth, linewidth, color, opacity, rotation, id)
Utility Functions:
STRING = get_widthText(string, textwidth, fontsize, fontwidth, charspace, fonttype)
FLOAT = get_textWidth(string, fontsize, fontwidth, charspace, fonttype)
FLOAT = get_textHeight(fontsize)
FLOAT = get_baseLine(fontsize)
Canvas:
var context = canvas.getContext('2d');
set_textRenderContext(context);
if(check_textRenderContext(context)) {
...
context.strokeText(text, x, y, fontsize);
...
}
VML:
if(check_strokeTextCapability()) {
...
var txtobj = get_strokeText(text, x, y, fontsize);
document.getElementById("element").innerHTML += txtobj;
...
}
strokeText.js: Showcase (WYSIWYG application)
strokeText.zip: Download (javascript library)
cvi-sans-serif-font.svg Download (svg stroke font)
Images used are copyrighted and released under a ShareAlike CC license. Licensees may distribute derivative works only under a license identical to the license that governs the original work.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License or GNU Lesser General Public License or GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the Licenses, or (at your option) any later versions.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GPL, LGPL and AGPL for more details.
You should have received copies of all three licenses along with this program. If not, get them here: GPL | LGPL | AGPL
For many companies and products, Open Source licenses are not an option. For these situations and for companies using the CVI Developer Scripts in commercial applications we offer the Netzgestade Closed Distribution License. It is a non-copyleft license which gives companies complete freedom when integrating the CVI Developer Scripts in their products and web sites.