annotate nodejs/font.cc @ 1447:b916bb0dc7ca

Add setFrameRate
author wycc
date Mon, 11 Apr 2011 20:25:44 +0800
parents 586e50f82c1f
children
rev   line source
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 576
diff changeset
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*-
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 576
diff changeset
2 // vim: sw=4:ts=8:sts=4
575
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3 #include <v8.h>
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4 #include "mbfly_njs.h"
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6 extern "C" {
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
7 #include <mb.h>
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
8 }
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
9
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10 #ifndef ASSERT
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
11 #define ASSERT(x)
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
12 #endif
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
13
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
14 using namespace v8;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
15
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
16 static Persistent<FunctionTemplate> xnjsmb_font_face_temp;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
17
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18 /*! \brief Query a font face.
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19 *
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
20 * This function should be a method of rt object.
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
21 *
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
22 * \param family is family of font face.
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 * \param slant is slant type of font face.
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
24 * \param weight is weight of font face.
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
25 */
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
26 static Handle<Value>
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
27 xnjsmb_font_face_query(const Arguments &args) {
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
28 HandleScope scope;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
29 int argc = args.Length();
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
30 Handle<Object> self = args.This();
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
31 char *face;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
32 int slant, weight;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
33 redraw_man_t *rdman;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
34 mb_font_face_t *font_face;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
35 Handle<Function> func_obj;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
36 Handle<Object> face_obj;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
37
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
38 if(argc != 3)
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
39 THROW("Invalid number of arguments (!= 3)");
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
40 if(!args[0]->IsString() || !args[1]->IsInt32() || !args[2]->IsInt32())
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
41 THROW("Invalid argument type");
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
42
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
43 String::Utf8Value face_utf8(args[0]);
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
44 face = *face_utf8;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
45 slant = args[1]->ToInt32()->Value();
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
46 weight = args[2]->ToInt32()->Value();
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
47
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
48 rdman = xnjsmb_rt_rdman(self);
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
49 font_face = mb_font_face_query(rdman, face, slant, weight);
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
50 if(font_face == NULL)
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
51 return Null();
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
52
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
53 func_obj = xnjsmb_font_face_temp->GetFunction();
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
54 face_obj = func_obj->NewInstance();
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
55 WRAP(face_obj, font_face);
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
56
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
57 return face_obj;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
58 }
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
59
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
60 static void
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
61 xnjsmb_font_face_init_temp(void) {
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
62 Handle<FunctionTemplate> temp;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
63 Handle<ObjectTemplate> inst_temp;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
64
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
65 temp = FunctionTemplate::New();
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
66 temp->SetClassName(String::New("font_face"));
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 576
diff changeset
67
575
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
68 inst_temp = temp->InstanceTemplate();
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
69 inst_temp->SetInternalFieldCount(1);
822
586e50f82c1f Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents: 576
diff changeset
70
575
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
71 xnjsmb_font_face_temp = Persistent<FunctionTemplate>::New(temp);
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
72 }
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
73
576
5a68e2bcea17 Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 575
diff changeset
74 /*! \brief Add properties to the template of runtime objects.
5a68e2bcea17 Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 575
diff changeset
75 */
575
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
76 void
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
77 xnjsmb_font_init_mb_rt_temp(Handle<FunctionTemplate> mb_rt_temp) {
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
78 HandleScope scope;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
79 static int init_flag = 0;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
80 Handle<ObjectTemplate> rt_proto_temp;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
81 Handle<FunctionTemplate> query_func_temp;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
82
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
83 if(!init_flag) {
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
84 xnjsmb_font_face_init_temp();
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
85 init_flag = 1;
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
86 }
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
87
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
88 rt_proto_temp = mb_rt_temp->PrototypeTemplate();
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
89 query_func_temp = FunctionTemplate::New(xnjsmb_font_face_query);
576
5a68e2bcea17 Set font styles for stext in Javascript
Thinker K.F. Li <thinker@branda.to>
parents: 575
diff changeset
90 SET(rt_proto_temp, "font_face_query", query_func_temp);
575
97159102f886 Function of query font face in Javascript
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
91 }