File: PangoCairo.lua

package info (click to toggle)
lua-lgi 0.9.2-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,388 kB
  • sloc: ansic: 5,082; makefile: 169; sh: 31
file content (43 lines) | stat: -rw-r--r-- 1,538 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
------------------------------------------------------------------------------
--
--  LGI PangoCairo override module.
--
--  Copyright (c) 2012 Pavel Holejsovsky
--  Licensed under the MIT license:
--  http://www.opensource.org/licenses/mit-license.php
--
------------------------------------------------------------------------------

local pairs = pairs
local lgi = require 'lgi'
local PangoCairo = lgi.PangoCairo
local cairo = lgi.cairo
local Pango = lgi.Pango

-- Make assorted PangoCairo global methods taking cairo.Context as first
-- argument methods of the cairo.Context (where they logically belong).
for _, name in pairs {
   'update_context', 'update_layout',
   'show_glyph_string', 'show_glyph_item', 'show_layout_line', 'show_layout',
   'show_error_underline',
   'glyph_string_path', 'layout_line_path', 'layout_path',
   'error_underline_path',
} do
   cairo.Context._method[name] = PangoCairo[name]
end
Pango.Layout.create = PangoCairo.create_layout

-- Extend Pango.Context with additional methods and attributes coming from
-- PangoCairo package.
Pango.Context.create = PangoCairo.context_create
for _, name in pairs {
   'get_font_options', 'set_font_options', 'get_resolution', 'set_resolution',
   'set_shape_renderer' } do
   Pango.Context[name] = PangoCairo['context_' .. name]
end
for _, name in pairs { 'font_options', 'resolution', 'shape_renderer' } do
   Pango.Context._attribute[name] = {
      get = Pango.Context['get_' .. name] or Pango.Context[name],
      set = Pango.Context['set_' .. name],
   }
end