renamed from libt4k_common and updated sources [release 0.1.1-2mamba;Sun Nov 27 2022]

This commit is contained in:
Silvan Calarco 2024-01-05 18:20:27 +01:00
parent 01ca2fcd83
commit 704b52cecf
7 changed files with 218 additions and 0 deletions

View File

@ -1,2 +1,4 @@
# t4kcommon
A library of code shared between tuxmath and tuxtype.

View File

@ -0,0 +1,32 @@
Description: fix loading each frame from SVG sprites
rsvg_handle_get_desc returns null so next sscanf segfaults. Use instead iterating
up from zero for id frame%d
Author: cdonoghu@gmail.com
Origin: other
Forwarded: no
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/src/t4k_loaders.c
+++ b/src/t4k_loaders.c
@@ -213,14 +213,13 @@
new_sprite = malloc(sizeof(sprite));
new_sprite->default_img = render_svg_from_handle(file_handle, width, height, "#default");
- /* get number of frames from description */
- sscanf(rsvg_handle_get_desc(file_handle), "%d", &new_sprite->num_frames);
- DEBUGMSG(debug_loaders, "load_svg_sprite(): loading %d frames\n", new_sprite->num_frames);
-
- for(i = 0; i < new_sprite->num_frames; i++)
- {
- sprintf(lay_name, "#frame%d", i);
- new_sprite->frame[i] = render_svg_from_handle(file_handle, width, height, lay_name);
+ /* get number of frames directly. End when #frame<num> doesn't exist */
+ new_sprite->num_frames = 0;
+ while(1) {
+ sprintf(lay_name, "#frame%d", new_sprite->num_frames);
+ if ( ! (rsvg_handle_has_sub(file_handle, lay_name)) ) break;
+ new_sprite->frame[new_sprite->num_frames] = render_svg_from_handle(file_handle, width, height, lay_name);
+ new_sprite->num_frames++;
}
g_object_unref(file_handle);

View File

@ -0,0 +1,20 @@
diff --git a/src/t4k_loaders.c b/src/t4k_loaders.c
index 7248e35..61fe63f 100644
--- a/src/t4k_loaders.c
+++ b/src/t4k_loaders.c
@@ -1028,12 +1028,9 @@ static int do_png_save(FILE * fi, const char *const fname, SDL_Surface * surf)
{
png_init_io(png_ptr, fi);
- info_ptr->width = surf->w;
- info_ptr->height = surf->h;
- info_ptr->bit_depth = 8;
- info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
- info_ptr->interlace_type = 1;
- info_ptr->valid = 0; /* will be updated by various png_set_FOO() functions */
+ png_set_IHDR(png_ptr, info_ptr, surf->w, surf->h, 8,
+ PNG_COLOR_TYPE_RGB_ALPHA, 1,
+ PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr,
PNG_sRGB_INTENT_PERCEPTUAL);

View File

@ -0,0 +1,13 @@
diff --git a/src/t4k_menu.c b/src/t4k_menu.c
index b1ed842..96f4f35 100644
--- a/src/t4k_menu.c
+++ b/src/t4k_menu.c
@@ -151,7 +151,7 @@ SDL_Surface** render_buttons(MenuNode* menu, bool selected);
char* find_title_length(MenuNode* menu, int* length);
char* find_longest_text(MenuNode* menu, int* length);
int find_longest_menu_page(MenuNode* menu);
-void set_font_size();
+void set_font_size(bool uniform);
void prerender_menu(MenuNode* menu);
int min(int a, int b);
int max(int a, int b);

View File

@ -0,0 +1,28 @@
diff --git a/src/t4k_sdl.c b/src/t4k_sdl.c
index bba1a53..99653f9 100644
--- a/src/t4k_sdl.c
+++ b/src/t4k_sdl.c
@@ -1441,17 +1441,18 @@ SDL_Surface* T4K_BlackOutline(const char* t, int size, SDL_Color* c)
dstrect.x = 1;
dstrect.y = 1;
- SDL_BlitSurface(white_letters, NULL, bg, &dstrect);
- SDL_FreeSurface(white_letters);
+ /*SDL_BlitSurface(white_letters, NULL, bg, &dstrect);
+ SDL_FreeSurface(white_letters);*/
/* --- Convert to the screen format for quicker blits --- */
- SDL_SetColorKey(bg, SDL_SRCCOLORKEY|SDL_RLEACCEL, color_key);
- out = SDL_DisplayFormatAlpha(bg);
+ /*SDL_SetColorKey(bg, SDL_SRCCOLORKEY|SDL_RLEACCEL, color_key);
+ out = SDL_DisplayFormatAlpha(bg);*/
SDL_FreeSurface(bg);
DEBUGMSG(debug_sdl, "\nLeaving T4K_BlackOutline(): \n");
- return out;
+ /*return out;*/
+ return white_letters;
}

View File

@ -0,0 +1,13 @@
diff --git a/src/t4k_common.h b/src/t4k_common.h
index d4676e7..27e635c 100644
--- a/src/t4k_common.h
+++ b/src/t4k_common.h
@@ -239,7 +239,7 @@ MFStrategy;
#define MAX_LINES 128 //!< Maximum lines to wrap.
#define MAX_LINEWIDTH 256 //!< Maximum characters of each line.
-char wrapped_lines[MAX_LINES][MAX_LINEWIDTH]; //!< Global buffer for wrapped lines.
+extern char wrapped_lines[MAX_LINES][MAX_LINEWIDTH]; //!< Global buffer for wrapped lines.
//TODO separate headers for different areas a la SDL?

110
t4kcommon.spec Normal file
View File

@ -0,0 +1,110 @@
Name: t4kcommon
Version: 0.1.1
Release: 2mamba
Summary: A library of code shared between tuxmath and tuxtype
Group: System/Libraries
Vendor: openmamba
Distribution: openmamba
Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
URL: https://github.com/tux4kids/t4kcommon
Source: https://github.com/tux4kids/t4kcommon.git/upstream%2f%{version}/t4kcommon-%{version}.tar.bz2
Patch0: t4kcommon-0.1.1-libpng15.patch
Patch1: t4kcommon-0.1.1-menu_font_size.patch
Patch2: t4kcommon-0.1.1-missing_texts.patch
Patch3: t4kcommon-0.1.1-wrapped_lines.patch
Patch4: t4kcommon-0.1.1-debian_bugfix.patch
License: GPL
## AUTOBUILDREQ-BEGIN
BuildRequires: glibc-devel
BuildRequires: libSDL-devel
BuildRequires: libSDL_Pango-devel
BuildRequires: libSDL_image-devel
BuildRequires: libSDL_mixer-devel
BuildRequires: libSDL_net-devel
BuildRequires: libcairo-devel
BuildRequires: libdirectfb-devel
BuildRequires: libgdk-pixbuf-devel
BuildRequires: libglib-devel
BuildRequires: libharfbuzz-devel
BuildRequires: libpango-devel
BuildRequires: libpng-devel
BuildRequires: librsvg-devel
BuildRequires: libts-devel
BuildRequires: libxml2-devel
BuildRequires: libz-devel
## AUTOBUILDREQ-END
Requires: lib%{name} = %{?epoch:%epoch:}%{version}-%{release}
%description
A library of code shared between tuxmath and tuxtype.
%package -n lib%{name}
Group: System/Libraries
Summary: A library of code shared between tuxmath and tuxtype
Provides: libt4k_common
Obsoletes: libt4k_common < 0.1.1-2mamba
Requires: %{name} = %{?epoch:%epoch:}%{version}-%{release}
%description -n lib%{name}
A library of code shared between tuxmath and tuxtype.
%package -n lib%{name}-devel
Group: Development/Libraries
Summary: Static libraries and headers for %{name}
Requires: lib%{name} = %{?epoch:%epoch:}%{version}-%{release}
Provides: libt4k_common-devel
Obsoletes: libt4k_common-devel < 0.1.1-2mamba
%description -n lib%{name}-devel
A library of code shared between tuxmath and tuxtype.
This package contains static libraries and header files needed for development.
%debug_package
%prep
%setup -q
%patch0 -p1 -b .libpng15
%patch1 -p1 -b .menu_font_size
%patch2 -p1 -b .missing_texts
%patch3 -p1 -b .wrapped_lines
%patch4 -p1 -b .debian_bugfix
%build
%configure
%make
%install
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%makeinstall
%clean
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%post -n lib%{name} -p /sbin/ldconfig
%postun -n lib%{name} -p /sbin/ldconfig
%files
%defattr(-,root,root)
%dir %{_datadir}/t4k_common
%{_datadir}/t4k_common/images/menu/*
%files -n lib%{name}
%defattr(-,root,root)
%{_libdir}/libt4k_common.so.*
%doc COPYING
%files -n lib%{name}-devel
%defattr(-,root,root)
%{_includedir}/t4k_*.h
%{_libdir}/libt4k_common.a
%{_libdir}/libt4k_common.so
%{_libdir}/pkgconfig/t4k_common.pc
%doc README
%changelog
* Sun Nov 27 2022 Silvan Calarco <silvan.calarco@mambasoft.it> 0.1.1-2mamba
- renamed from libt4k_common and updated sources
* Tue Jul 26 2011 Silvan Calarco <silvan.calarco@mambasoft.it> 0.1.1-1mamba
- package created by autospec