font style support for feature label. r=erilem (closes #3051)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11744 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Frédéric Junod
2011-03-29 09:54:00 +00:00
parent 222162fa98
commit 33d330c0db
6 changed files with 18 additions and 3 deletions

View File

@@ -28,7 +28,8 @@
symbolizer: {
graphic: false,
label: "Label for invisible point",
labelSelect: true
labelSelect: true,
fontStyle: "italic"
},
filter: new OpenLayers.Filter.Comparison({
type: "==",

View File

@@ -387,6 +387,7 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
* fontOpacity - {Number} Opacity (0-1) for the label
* fontFamily - {String} The font family for the label, to be provided like in CSS.
* fontSize - {String} The font size for the label, to be provided like in CSS.
* fontStyle - {String} The font style for the label, to be provided like in CSS.
* fontWeight - {String} The font weight for the label, to be provided like in CSS.
* display - {String} Symbolizers will have no effect if display is set to "none". All other values have no effect.
*/

View File

@@ -333,7 +333,11 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
this.setCanvasStyle("reset");
this.canvas.fillStyle = style.fontColor;
this.canvas.globalAlpha = style.fontOpacity || 1.0;
var fontStyle = style.fontWeight + " " + style.fontSize + " " + style.fontFamily;
var fontStyle = [style.fontStyle ? style.fontStyle : "normal",
"normal", // "font-variant" not supported
style.fontWeight ? style.fontWeight : "normal",
style.fontSize ? style.fontSize : "10px",
style.fontFamily ? style.fontFamily : "sans-serif"].join(" ");
if (this.canvas.fillText) {
// HTML5
var labelAlign =

View File

@@ -712,6 +712,9 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
if (style.fontWeight) {
label.setAttributeNS(null, "font-weight", style.fontWeight);
}
if (style.fontStyle) {
label.setAttributeNS(null, "font-style", style.fontStyle);
}
if(style.labelSelect === true) {
label.setAttributeNS(null, "pointer-events", "visible");
label._featureId = featureId;

View File

@@ -606,6 +606,9 @@ OpenLayers.Renderer.SVG2 = OpenLayers.Class(OpenLayers.Renderer.NG, {
if (style.fontWeight) {
text.setAttributeNS(null, "font-weight", style.fontWeight);
}
if (style.fontStyle) {
text.setAttributeNS(null, "font-style", style.fontStyle);
}
if(style.labelSelect === true) {
text.setAttributeNS(null, "pointer-events", "visible");
text._featureId = featureId;
@@ -790,4 +793,4 @@ OpenLayers.Renderer.SVG2.LABEL_VSHIFT = {
*/
OpenLayers.Renderer.SVG2.preventDefault = function(e) {
e.preventDefault && e.preventDefault();
};
};

View File

@@ -855,6 +855,9 @@ OpenLayers.Renderer.VML = OpenLayers.Class(OpenLayers.Renderer.Elements, {
if (style.fontWeight) {
textbox.style.fontWeight = style.fontWeight;
}
if (style.fontStyle) {
textbox.style.fontStyle = style.fontStyle;
}
if(style.labelSelect === true) {
label._featureId = featureId;
textbox._featureId = featureId;