aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-11-04 10:58:42 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-04 10:58:42 -0800
commit36c9c11ed97d6c6f49bfdad53537a459b9e4b41d (patch)
tree3ecf5fff8e0323ae5f838347bb74fe0f6bc5e904
parent4b86bacb0428b07cba01fd46452d5c46e6f21af0 (diff)
add more typeface methods to lua
BUG=skia: NOTRY=True TBR= Review URL: https://codereview.chromium.org/697053004
-rw-r--r--resources/slides.lua6
-rw-r--r--src/utils/SkLua.cpp20
2 files changed, 23 insertions, 3 deletions
diff --git a/resources/slides.lua b/resources/slides.lua
index cf1a1a6229..df9fc47bd6 100644
--- a/resources/slides.lua
+++ b/resources/slides.lua
@@ -110,7 +110,7 @@ function drawSlide(canvas, slide, master_template)
local blob, newBottom = Sk.newTextBlob(node.text, bounds, paint)
draw_bullet(canvas, x + x_offset, y - fm.ascent, paint, node.indent)
canvas:drawTextBlob(blob, 0, 0, paint)
- y = newBottom + paint:getTextSize() * .5
+ y = newBottom + paint:getTextSize() * .5 + extra_dy
if gShowBounds then
bounds.bottom = newBottom
@@ -141,8 +141,8 @@ function SkiaPoint_make_template()
margin_y = 25,
}
slide[1] = make_tmpl(make_paint("Arial", 1, 35, { a=1, r=1, g=1, b=1 }), 18)
- slide[2] = make_tmpl(make_paint("Arial", 0, 25, { a=1, r=1, g=1, b=1 }), 0)
- slide[3] = make_tmpl(make_paint("Arial", 0, 20, { a=1, r=.9, g=.9, b=.9 }), 0)
+ slide[2] = make_tmpl(make_paint("Arial", 0, 25, { a=1, r=1, g=1, b=1 }), 10)
+ slide[3] = make_tmpl(make_paint("Arial", 0, 20, { a=1, r=.9, g=.9, b=.9 }), 5)
return {
title = title,
diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp
index 7491086a85..967233d21b 100644
--- a/src/utils/SkLua.cpp
+++ b/src/utils/SkLua.cpp
@@ -806,6 +806,11 @@ static int lpaint_isLCDRenderText(lua_State* L) {
return 1;
}
+static int lpaint_setLCDRenderText(lua_State* L) {
+ get_obj<SkPaint>(L, 1)->setLCDRenderText(lua2bool(L, 2));
+ return 1;
+}
+
static int lpaint_isEmbeddedBitmapText(lua_State* L) {
lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isEmbeddedBitmapText());
return 1;
@@ -1075,6 +1080,7 @@ static const struct luaL_Reg gSkPaint_Methods[] = {
{ "setSubpixelText", lpaint_setSubpixelText },
{ "isDevKernText", lpaint_isDevKernText },
{ "isLCDRenderText", lpaint_isLCDRenderText },
+ { "setLCDRenderText", lpaint_setLCDRenderText },
{ "isEmbeddedBitmapText", lpaint_isEmbeddedBitmapText },
{ "isAutohinted", lpaint_isAutohinted },
{ "isVerticalText", lpaint_isVerticalText },
@@ -1731,12 +1737,26 @@ static const struct luaL_Reg gSkTextBlob_Methods[] = {
///////////////////////////////////////////////////////////////////////////////
+static int ltypeface_getFamilyName(lua_State* L) {
+ SkString str;
+ get_ref<SkTypeface>(L, 1)->getFamilyName(&str);
+ lua_pushstring(L, str.c_str());
+ return 1;
+}
+
+static int ltypeface_getStyle(lua_State* L) {
+ lua_pushnumber(L, (double)get_ref<SkTypeface>(L, 1)->style());
+ return 1;
+}
+
static int ltypeface_gc(lua_State* L) {
SkSafeUnref(get_ref<SkTypeface>(L, 1));
return 0;
}
static const struct luaL_Reg gSkTypeface_Methods[] = {
+ { "getFamilyName", ltypeface_getFamilyName },
+ { "getStyle", ltypeface_getStyle },
{ "__gc", ltypeface_gc },
{ NULL, NULL }
};