Ticket #798: sdl_font_patches

File sdl_font_patches, 4.0 KB (added by richardh, 5 years ago)
Line 
1diff -r -u rakudo/parrot/config/gen/call_list/misc.in sdl_things/parrot/config/gen/call_list/misc.in
2--- rakudo/parrot/config/gen/call_list/misc.in  2009-06-28 13:42:41.000000000 +0400
3+++ sdl_things/parrot/config/gen/call_list/misc.in      2009-06-28 13:53:27.000000000 +0400
4@@ -227,6 +227,8 @@
5 v    pip
6 p    pti
7 i    ppp
8+# added by RNH for the RenderXXX_XXXX text routines
9+p    ptii
10 
11 # Used by SDL::Font
12 p    ti
13diff -r -u rakudo/parrot/CREDITS sdl_things/parrot/CREDITS
14--- rakudo/parrot/CREDITS       2009-06-28 13:42:45.000000000 +0400
15+++ sdl_things/parrot/CREDITS   2009-06-28 14:15:10.000000000 +0400
16@@ -780,6 +780,11 @@
17 E: rurban@cpan.org
18 D: cygwin, 64-bit pbc compat, float converters, bignum.pmc
19 
20+N: Richard Hainsworth
21+U: finanalyst
22+E: richard@rusrating.ru
23+D: bugfix SDL Font
24+
25 N: Richard Tibbetts
26 D: Divide by zero exceptions in some PMCs
27 
28diff -r -u rakudo/parrot/runtime/parrot/library/SDL/Font.pir sdl_things/parrot/runtime/parrot/library/SDL/Font.pir
29--- rakudo/parrot/runtime/parrot/library/SDL/Font.pir   2009-06-28 13:41:59.000000000 +0400
30+++ sdl_things/parrot/runtime/parrot/library/SDL/Font.pir       2009-06-28 13:47:05.000000000 +0400
31@@ -136,14 +136,29 @@
32     font_surface = new 'SDL::Surface'
33     font_surface.'init'( 'height' => 0, 'width' => 0 )
34 
35-    .local pmc RenderText_Solid
36-    get_hll_global RenderText_Solid, ['SDL::NCI::TTF'], 'RenderText_Solid'
37+# RNH use RenderUTF8 in preference to RenderText by default
38+    .local pmc RenderUTF8_Solid
39+    get_hll_global RenderUTF8_Solid, ['SDL::NCI::TTF'], 'RenderUTF8_Solid'
40+
41+    .local int color
42+# RNH font routine takes color in the order rgb rather than bgr used by surface.pir hence cannot rely on color.get_integer
43+    .local int component
44+    .local pmc colors
45+    colors = color_pmc.'color'()
46+
47+    component = colors['b']
48+    component <<= 16
49+    color = component
50+
51+    component = colors['g']
52+    component <<= 8
53+    color += component
54 
55-    .local pmc color
56-    color = color_pmc.'color'()
57+    component = colors['r']
58+    color += component
59 
60     .local pmc font_surface_struct
61-    font_surface_struct = RenderText_Solid( font, text, color )
62+    font_surface_struct = RenderUTF8_Solid( font, text, color )
63     font_surface.'wrap_surface'( font_surface_struct )
64 
65     .return( font_surface )
66diff -r -u rakudo/parrot/runtime/parrot/library/SDL.pir sdl_things/parrot/runtime/parrot/library/SDL.pir
67--- rakudo/parrot/runtime/parrot/library/SDL.pir        2009-06-28 13:42:01.000000000 +0400
68+++ sdl_things/parrot/runtime/parrot/library/SDL.pir    2009-06-28 13:52:01.000000000 +0400
69@@ -219,6 +219,7 @@
70     loadlib ttf_lib, 'libSDL_ttf'
71     if ttf_lib goto initialize
72     loadlib ttf_lib, 'cygSDL_ttf-2-0-0'
73+# RNH this is not trapping a non-existent libSDL_ttf library
74     unless ttf_lib goto error
75 
76   initialize:
77@@ -243,15 +244,21 @@
78   success:
79     dlfunc nci_sub, ttf_lib, 'TTF_OpenFont', 'pti'
80     set_hll_global ['SDL::NCI::TTF'], 'OpenFont', nci_sub
81-
82-    dlfunc nci_sub, ttf_lib, 'TTF_RenderText_Solid', 'pptp'
83+#RNH changes: all text routines expect an integer, not a pmc, for color parameter
84+    dlfunc nci_sub, ttf_lib, 'TTF_RenderText_Solid', 'ppti'
85     set_hll_global ['SDL::NCI::TTF'], 'RenderText_Solid', nci_sub
86-    dlfunc nci_sub, ttf_lib, 'TTF_RenderUTF8_Solid', 'pptp'
87+    dlfunc nci_sub, ttf_lib, 'TTF_RenderUTF8_Solid', 'ppti'
88     set_hll_global ['SDL::NCI::TTF'], 'RenderUTF8_Solid', nci_sub
89 
90     # this one could be wrong
91-    dlfunc nci_sub, ttf_lib, 'TTF_RenderUNICODE_Solid', 'pptp'
92+    dlfunc nci_sub, ttf_lib, 'TTF_RenderUNICODE_Solid', 'ppti'
93     set_hll_global ['SDL::NCI::TTF'], 'RenderUNICODE_Solid', nci_sub
94+# RNH Additions. Add UTF8_Shaded and FontLine skip
95+    dlfunc nci_sub, ttf_lib, 'TTF_RenderUTF8_Shaded', 'pptii'
96+    set_hll_global ['SDL::NCI::TTF'], 'RenderUTF8_Shaded', nci_sub
97+    dlfunc nci_sub, ttf_lib, 'TTF_FontLineSkip', 'ip'
98+    set_hll_global ['SDL::NCI::TTF'], 'FontLineSkip', nci_sub
99+#end additions
100 
101     dlfunc nci_sub, ttf_lib, 'TTF_SizeText', 'ipt33'
102     set_hll_global ['SDL::NCI::TTF'], 'SizeText', nci_sub