skrift-x11 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example.rb +28 -40
- data/lib/skrift/x11/glyphs.rb +5 -1
- data/lib/skrift/x11/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92507a6b036b8ab2eb0145017a938019111e2ea17c4e001a693529d2518876f3
|
4
|
+
data.tar.gz: 2da4b5247c4e4b085a4f4591594d09f69f2f35a93c7fe43210b68f7efbfe3798
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bac35a07d623a9f27539ec68d2a2cc4eb2cc906e788660a7cbea25323d55ff30ada7ac1474f92c7caa4b8c92a50a509bf6eaf25550c5e04d6e273a13aebe15f
|
7
|
+
data.tar.gz: c35c1e39c5b5ef7daf70257dc14e0930ac70607e78b6bc8397563964377d8e090b4472162fbbb061c05c584553ae6d0b7e937e7d3ecc156f534b6eed518c41e5
|
data/example.rb
CHANGED
@@ -7,61 +7,49 @@ require 'pp'
|
|
7
7
|
|
8
8
|
Bundler.setup(:default, :development)
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
#$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
11
|
+
#$LOAD_PATH.unshift(File.dirname(__FILE__))
|
12
12
|
|
13
13
|
require 'skrift/x11'
|
14
14
|
|
15
|
-
|
15
|
+
dpy = display = X11::Display.new
|
16
16
|
screen = dpy.screens.first
|
17
|
+
visual = dpy.find_visual(0, 32).visual_id
|
18
|
+
#cmap = dpy.create_colormap(0, screen.root, visual)
|
17
19
|
|
18
|
-
|
19
|
-
#
|
20
|
+
p visual
|
21
|
+
#p cmap
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
cmap = $dpy.create_colormap(0, screen.root, visual)
|
25
|
-
|
26
|
-
wid = display.new_id
|
27
|
-
$dpy.create_window(
|
28
|
-
32,
|
29
|
-
wid, screen.root,
|
30
|
-
0, 0, # x,y
|
23
|
+
wid = dpy.create_window(
|
24
|
+
0, 0, # x,y
|
31
25
|
1000, 600, # w,h
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
X11::Form::CWEventMask
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
cmap # Colormap. Necessary when depth != screen.root_depth
|
45
|
-
]
|
26
|
+
visual: visual,
|
27
|
+
values: {
|
28
|
+
X11::Form::CWBackPixel => 0, # ARGB background
|
29
|
+
X11::Form::CWBorderPixel => 0, # Needed in case window depth != screen.root_depth
|
30
|
+
X11::Form::CWEventMask =>
|
31
|
+
(X11::Form::SubstructureNotifyMask |
|
32
|
+
X11::Form::StructureNotifyMask |
|
33
|
+
X11::Form::ExposureMask |
|
34
|
+
X11::Form::KeyPressMask |
|
35
|
+
X11::Form::ButtonPressMask)#,
|
36
|
+
# X11::Form::CWColorMap => cmap # Needed for same reason as borderpixel
|
37
|
+
}
|
46
38
|
)
|
39
|
+
p wid
|
47
40
|
|
48
41
|
dpy.map_window(wid) # Window won't be visible until this
|
49
42
|
|
50
43
|
# A "picture" object for us to draw in the window with.
|
51
44
|
fmt = dpy.render_find_visual_format(visual)
|
45
|
+
p fmt
|
52
46
|
$pic = dpy.render_create_picture(wid, fmt)
|
53
47
|
|
54
|
-
|
55
|
-
#$fgpic = dpy.render_create_solid_fill(0xffff,0xffff,0,0)
|
56
|
-
|
57
|
-
|
58
|
-
$gc = dpy.create_gc(wid, foreground: 0xffff0000)
|
59
|
-
|
60
|
-
puts "Main loop"
|
48
|
+
gc = dpy.create_gc(wid, foreground: 0xffff0000)
|
61
49
|
|
62
|
-
|
50
|
+
f = Font.load("resources/FiraGO-Regular_extended_with_NotoSansEgyptianHieroglyphs-Regular.ttf")
|
63
51
|
|
64
|
-
$skrift = Skrift::X11::Glyphs.new(
|
52
|
+
$skrift = Skrift::X11::Glyphs.new(dpy, f, x_scale: 40, y_scale: 40)
|
65
53
|
|
66
54
|
def redraw(dpy, wid, gc)
|
67
55
|
dpy.poly_fill_rectangle(wid, gc, [X11::Form::Rectangle.new(20,45, 400, 400)])
|
@@ -74,9 +62,9 @@ end
|
|
74
62
|
loop do
|
75
63
|
pkt = display.next_packet
|
76
64
|
if pkt
|
77
|
-
|
65
|
+
puts pkt.inspect[0..200]
|
78
66
|
#raise "Error" if pkt.is_a?(X11::Form::Error)
|
79
|
-
redraw(display, wid,
|
67
|
+
redraw(display, wid, gc) if pkt.is_a?(X11::Form::Expose)
|
80
68
|
|
81
69
|
if pkt.is_a?(X11::Form::KeyPress)
|
82
70
|
# lookup_keysym(dpy,pkt)
|
data/lib/skrift/x11/glyphs.rb
CHANGED
@@ -20,6 +20,7 @@ module Skrift
|
|
20
20
|
|
21
21
|
@glyphcache = {}
|
22
22
|
@colcache = {}
|
23
|
+
@chcache = {}
|
23
24
|
|
24
25
|
@lm = @sft.lmetrics
|
25
26
|
|
@@ -60,6 +61,7 @@ module Skrift
|
|
60
61
|
|
61
62
|
|
62
63
|
def cache_glyph(gid, baseline)
|
64
|
+
return if gid.nil?
|
63
65
|
mtx = @sft.gmetrics(gid)
|
64
66
|
|
65
67
|
# FIXME: Not sure what to do if mtx.nil? here.
|
@@ -103,7 +105,9 @@ module Skrift
|
|
103
105
|
def map_glyphs(str)
|
104
106
|
# FIXME: Should probably cache by character rather than
|
105
107
|
# glyph
|
106
|
-
str.to_s.each_char.map
|
108
|
+
str.to_s.each_char.map do |ch|
|
109
|
+
@chcache[ch] ||= @sft.lookup(ch.ord).to_i
|
110
|
+
end
|
107
111
|
end
|
108
112
|
|
109
113
|
def cache_glyphs(gl)
|
data/lib/skrift/x11/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skrift-x11
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vidar Hokstad
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: skrift
|