Fix Issue 30: Add bold/italic buttons for text elements

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@270 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Jeff Schiller
2009-07-06 14:57:13 +00:00
parent f860d66ace
commit 09b0e8bd4f
5 changed files with 66 additions and 1 deletions

View File

@@ -1360,6 +1360,45 @@ function SvgCanvas(c)
this.setIdPrefix = function(p) {
idprefix = p;
};
this.getBold = function() {
// should only have one element selected
var selected = selectedElements[0];
if (selected != null && selected.tagName == "text" &&
selectedElements[1] == null)
{
return (selected.getAttribute("font-weight") == "bold");
}
return false;
};
this.setBold = function(b) {
var selected = selectedElements[0];
if (selected != null && selected.tagName == "text" &&
selectedElements[1] == null)
{
selected.setAttribute("font-weight", b ? "bold" : "normal");
}
};
this.getItalic = function() {
var selected = selectedElements[0];
if (selected != null && selected.tagName == "text" &&
selectedElements[1] == null)
{
return (selected.getAttribute("font-style") == "italic");
}
return false;
};
this.setItalic = function(i) {
var selected = selectedElements[0];
if (selected != null && selected.tagName == "text" &&
selectedElements[1] == null)
{
selected.setAttribute("font-style", i ? "italic" : "normal");
}
};
this.getFontFamily = function() {
return current_font_family;