Merge pull request #1111 from tschaub/font-weight

Add fontWeight property to TextSymbolizer.
This commit is contained in:
Tim Schaub
2013-10-09 13:20:47 -07:00
7 changed files with 112 additions and 1 deletions

View File

@@ -269,6 +269,7 @@ describe('ol.style.Style', function() {
color: '#ffffff',
fontFamily: 'Arial',
fontSize: 11,
fontWeight: 'normal',
text: 'Test',
opacity: 0.5,
zIndex: 0

View File

@@ -9,6 +9,7 @@ describe('ol.style.TextLiteral', function() {
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
fontWeight: 'normal',
text: 'Test',
opacity: 0.5,
zIndex: 0
@@ -22,6 +23,7 @@ describe('ol.style.TextLiteral', function() {
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
fontWeight: 'normal',
text: 'Test',
opacity: 0.5,
strokeColor: '#ff0000',
@@ -38,6 +40,7 @@ describe('ol.style.TextLiteral', function() {
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
fontWeight: 'normal',
text: 'Test',
opacity: 0.5,
strokeColor: '#ff0000',
@@ -57,6 +60,7 @@ describe('ol.style.TextLiteral', function() {
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
fontWeight: 'normal',
text: 'Test',
opacity: 0.5,
zIndex: 0
@@ -65,6 +69,7 @@ describe('ol.style.TextLiteral', function() {
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
fontWeight: 'normal',
text: 'Test',
opacity: 0.5,
zIndex: 0
@@ -73,6 +78,7 @@ describe('ol.style.TextLiteral', function() {
color: '#0000ff',
fontFamily: 'Arial',
fontSize: 11,
fontWeight: 'normal',
text: 'Test',
opacity: 0.5,
zIndex: 0
@@ -81,6 +87,7 @@ describe('ol.style.TextLiteral', function() {
color: '#ff0000',
fontFamily: 'Dingbats',
fontSize: 11,
fontWeight: 'normal',
text: 'Test',
opacity: 0.5,
zIndex: 0
@@ -89,6 +96,16 @@ describe('ol.style.TextLiteral', function() {
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 12,
fontWeight: 'normal',
text: 'Test',
opacity: 0.5,
zIndex: 0
});
var differentFontWeight = new ol.style.TextLiteral({
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
fontWeight: 'bold',
text: 'Test',
opacity: 0.5,
zIndex: 0
@@ -97,6 +114,7 @@ describe('ol.style.TextLiteral', function() {
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
fontWeight: 'normal',
text: 'Test',
opacity: 0.6,
zIndex: 0
@@ -105,6 +123,7 @@ describe('ol.style.TextLiteral', function() {
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
fontWeight: 'normal',
text: 'Text is not compared for equality',
opacity: 0.5,
zIndex: 0
@@ -113,6 +132,7 @@ describe('ol.style.TextLiteral', function() {
color: '#ff0000',
fontFamily: 'Arial',
fontSize: 11,
fontWeight: 'normal',
text: 'Test',
opacity: 0.5,
zIndex: 3
@@ -121,6 +141,7 @@ describe('ol.style.TextLiteral', function() {
expect(literal.equals(differentColor)).to.be(false);
expect(literal.equals(differentFontFamily)).to.be(false);
expect(literal.equals(differentFontSize)).to.be(false);
expect(literal.equals(differentFontWeight)).to.be(false);
expect(literal.equals(differentOpacity)).to.be(false);
expect(literal.equals(equalLiteral2)).to.be(true);
expect(literal.equals(differentZIndex)).to.be(false);

View File

@@ -109,6 +109,7 @@ describe('ol.style.Text', function() {
expect(literal.color).to.be('#000');
expect(literal.fontFamily).to.be('sans-serif');
expect(literal.fontSize).to.be(10);
expect(literal.fontWeight).to.be('normal');
expect(literal.text).to.be('Test');
expect(literal.opacity).to.be(1);
});
@@ -216,6 +217,20 @@ describe('ol.style.Text', function() {
});
describe('#getFontWeight()', function() {
it('returns the font size', function() {
var symbolizer = new ol.style.Text({
fontWeight: 'bold'
});
var fontWeight = symbolizer.getFontWeight();
expect(fontWeight).to.be.a(ol.expr.Literal);
expect(fontWeight.getValue()).to.be('bold');
});
});
describe('#getOpacity()', function() {
it('returns the opacity', function() {
@@ -314,6 +329,33 @@ describe('ol.style.Text', function() {
});
describe('#setFontWeight()', function() {
it('sets the font size', function() {
var symbolizer = new ol.style.Text({
fontWeight: 'bold'
});
symbolizer.setFontWeight(new ol.expr.Literal('900'));
var fontWeight = symbolizer.getFontWeight();
expect(fontWeight).to.be.a(ol.expr.Literal);
expect(fontWeight.getValue()).to.be('900');
});
it('throws when not provided an expression', function() {
var symbolizer = new ol.style.Text({
fontWeight: 'lighter'
});
expect(function() {
symbolizer.setFontWeight('bolder');
}).throwException(function(err) {
expect(err).to.be.a(goog.asserts.AssertionError);
});
});
});
describe('#setOpacity()', function() {
it('sets the opacity', function() {