2011-05-16 15:15:47 +02:00
|
|
|
/*
|
|
|
|
* Paper.js
|
|
|
|
*
|
|
|
|
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
|
|
|
|
* based on Scriptographer.org and designed to be largely API compatible.
|
|
|
|
* http://paperjs.org/
|
|
|
|
* http://scriptographer.org/
|
|
|
|
*
|
|
|
|
* Distributed under the MIT license. See LICENSE file for details.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
|
|
|
|
* http://lehni.org/ & http://jonathanpuckey.com/
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var CharacterStyle = this.CharacterStyle = PathStyle.extend({
|
2011-05-23 19:28:55 +02:00
|
|
|
/** @lends CharacterStyle# */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CharacterStyle objects don't need to be created directly. Just pass an
|
|
|
|
* object to {@link TextItem#characterStyle}, it will be converted to a
|
|
|
|
* CharacterStyle object internally.
|
|
|
|
*
|
|
|
|
* @constructs CharacterStyle
|
|
|
|
* @param {object} style
|
|
|
|
*
|
|
|
|
* @constructs CharacterStyle
|
|
|
|
*
|
|
|
|
* @class The CharacterStyle object represents the character style of a text
|
|
|
|
* item ({@link TextItem#characterStyle})
|
|
|
|
*
|
2011-05-27 13:54:27 +02:00
|
|
|
* Sample code:
|
|
|
|
* <pre>
|
2011-05-23 19:28:55 +02:00
|
|
|
* var text = new PointText(new Point(50, 50));
|
|
|
|
* text.fillColor = 'black';
|
|
|
|
* text.content = 'Hello world.';
|
|
|
|
* text.characterStyle.fontSize = 50;
|
2011-05-27 13:54:27 +02:00
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* @extends PathStyle
|
2011-05-23 19:28:55 +02:00
|
|
|
*/
|
2011-05-16 15:15:47 +02:00
|
|
|
initialize: function(style) {
|
2011-05-17 13:13:24 +01:00
|
|
|
Base.initialize(this, style, {
|
|
|
|
fontSize: 10,
|
|
|
|
font: 'sans-serif'
|
|
|
|
});
|
2011-05-16 15:15:47 +02:00
|
|
|
this.base(style);
|
|
|
|
},
|
2011-05-17 13:14:04 +01:00
|
|
|
|
2011-05-23 19:28:55 +02:00
|
|
|
/**
|
|
|
|
* The font of the character style.
|
|
|
|
*
|
|
|
|
* @name CharacterStyle#font
|
|
|
|
* @default 'sans-serif'
|
|
|
|
* @type string
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The font size of the character style in points.
|
|
|
|
*
|
|
|
|
* @name CharacterStyle#fontSize
|
|
|
|
* @default 10
|
|
|
|
* @type number
|
|
|
|
*/
|
|
|
|
|
2011-05-16 15:15:47 +02:00
|
|
|
statics: {
|
2011-05-17 13:14:04 +01:00
|
|
|
create: function(item) {
|
2011-05-16 15:15:47 +02:00
|
|
|
var style = new CharacterStyle(CharacterStyle.dont);
|
|
|
|
style._item = item;
|
|
|
|
return style;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|