paper.js/src/text/CharacterStyle.js

75 lines
1.7 KiB
JavaScript
Raw Normal View History

/*
* 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
*/
initialize: function(style) {
Base.initialize(this, style, {
fontSize: 10,
font: 'sans-serif'
});
this.base(style);
},
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
*/
statics: {
create: function(item) {
var style = new CharacterStyle(CharacterStyle.dont);
style._item = item;
return style;
}
}
});