From feaed21e5448fb9cf4cce38c7ffebb97e6ab3e6c Mon Sep 17 00:00:00 2001 From: Dmitry Karasik Date: Tue, 12 Nov 2024 13:18:57 +0100 Subject: [PATCH] don't override explicit --xxx-font from commandline by gtk fonts --- Prima/Classes.pm | 2 +- include/apricot.h | 2 +- include/unix/guts.h | 7 +++++++ unix/font.c | 5 +++++ unix/gtk.c | 18 +++++++++++------- unix/resource.c | 2 +- 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Prima/Classes.pm b/Prima/Classes.pm index df77edbf6..6060545cc 100644 --- a/Prima/Classes.pm +++ b/Prima/Classes.pm @@ -431,7 +431,7 @@ sub _debug $r .= sprintf " dir=%g", $f->{direction} if $f->{direction} != 0.0; $r .= sprintf " %s", $f->{encoding}; return $r if $noprint; - print STDERR "$f\n"; + print STDERR "$r\n"; } package Prima::Matrix; diff --git a/include/apricot.h b/include/apricot.h index 45fa0ec45..0301f5a7e 100644 --- a/include/apricot.h +++ b/include/apricot.h @@ -6,7 +6,7 @@ #define POLLUTE_NAME_SPACE 1 #endif -#define PRIMA_CORE_VERSION 2024072501 +#define PRIMA_CORE_VERSION 2024111201 #define PRIMA_VERSION_BOOTCHECK \ if(apc_get_core_version()!=PRIMA_CORE_VERSION) \ diff --git a/include/unix/guts.h b/include/unix/guts.h index d5e2a2968..7c2653c9a 100644 --- a/include/unix/guts.h +++ b/include/unix/guts.h @@ -829,6 +829,13 @@ typedef struct _UnixGuts unsigned long int rotated_font_cache_size; int try_fc_monospace_emulation_by_name; int force_fc_monospace_emulation; + +#define SKIP_GTK_FONT_DEFAULT 1 +#define SKIP_GTK_FONT_MSG 2 +#define SKIP_GTK_FONT_MENU 4 +#define SKIP_GTK_FONT_CAPTION 8 +#define SKIP_GTK_FONT_WIDGET 16 + int skip_gtk_font; } UnixGuts; extern UnixGuts guts; diff --git a/unix/font.c b/unix/font.c index f8bfe90cd..3bcab2194 100644 --- a/unix/font.c +++ b/unix/font.c @@ -67,6 +67,7 @@ prima_font_init_x11( char * error_buf) prima_corefont_pp2font( do_default_font, &guts. default_font); free( do_default_font); do_default_font = NULL; + guts.skip_gtk_font |= SKIP_GTK_FONT_DEFAULT; } else if ( !apc_fetch_resource( "Prima", "", "Font", "font", NULL_HANDLE, frFont, &guts. default_font)) { prima_fill_default_font( &guts. default_font); @@ -91,6 +92,7 @@ prima_font_init_x11( char * error_buf) prima_corefont_pp2font( do_menu_font, &guts. default_menu_font); free( do_menu_font); do_menu_font = NULL; + guts.skip_gtk_font |= SKIP_GTK_FONT_MENU; } else if ( !apc_fetch_resource( "Prima", "", "Font", "menu_font", NULL_HANDLE, frFont, &guts. default_menu_font)) { memcpy( &guts. default_menu_font, &guts. default_font, sizeof( Font)); @@ -102,6 +104,7 @@ prima_font_init_x11( char * error_buf) prima_corefont_pp2font( do_widget_font, &guts. default_widget_font); free( do_widget_font); do_widget_font = NULL; + guts.skip_gtk_font |= SKIP_GTK_FONT_WIDGET; } else if ( !apc_fetch_resource( "Prima", "", "Font", "widget_font", NULL_HANDLE, frFont, &guts. default_widget_font)) { memcpy( &guts. default_widget_font, &guts. default_font, sizeof( Font)); @@ -113,6 +116,7 @@ prima_font_init_x11( char * error_buf) prima_corefont_pp2font( do_msg_font, &guts. default_msg_font); free( do_msg_font); do_msg_font = NULL; + guts.skip_gtk_font |= SKIP_GTK_FONT_MSG; } else if ( !apc_fetch_resource( "Prima", "", "Font", "message_font", NULL_HANDLE, frFont, &guts. default_msg_font)) { memcpy( &guts. default_msg_font, &guts. default_font, sizeof( Font)); @@ -124,6 +128,7 @@ prima_font_init_x11( char * error_buf) prima_corefont_pp2font( do_caption_font, &guts. default_caption_font); free( do_caption_font); do_caption_font = NULL; + guts.skip_gtk_font |= SKIP_GTK_FONT_CAPTION; } else if ( !apc_fetch_resource( "Prima", "", "Font", "caption_font", NULL_HANDLE, frFont, &guts. default_caption_font)) { memcpy( &guts. default_caption_font, &guts. default_font, sizeof( Font)); diff --git a/unix/gtk.c b/unix/gtk.c index b684bd09d..e0ad44ba5 100644 --- a/unix/gtk.c +++ b/unix/gtk.c @@ -445,7 +445,7 @@ prima_gtk_init(void) f-> undef. width = f-> undef. height = f-> undef. pitch = f-> undef. vector = 1; apc_font_pick( f, NULL ); #define DEBUG_FONT(font) f->height,f->width,f->size,f->name,f->encoding - Fdebug("gtk-font (%s): %d.[w=%d,s=%d].%s.%s", s->name, DEBUG_FONT(f)); + Fdebug("gtk-font (%s): %d.[w=%d,s=%g].%s.%s", s->name, DEBUG_FONT(f)); #undef DEBUG_FONT } } @@ -479,12 +479,16 @@ prima_gtk_init(void) #define DEBUG_FONT font.height,font.width,font.size,font.name,font.encoding Fdebug("gtk-font (%s): %d.[w=%d,s=%g].%s.%s", g_value_peek_pointer(&value), DEBUG_FONT); #undef DEBUG_FONT - guts.default_msg_font = - guts.default_menu_font = - guts.default_widget_font = - guts.default_caption_font = - guts.default_font = font; - + if ( !( guts.skip_gtk_font & SKIP_GTK_FONT_DEFAULT)) + guts.default_font = font; + if ( !( guts.skip_gtk_font & SKIP_GTK_FONT_MSG)) + guts.default_msg_font = font; + if ( !( guts.skip_gtk_font & SKIP_GTK_FONT_WIDGET)) + guts.default_widget_font = font; + if ( !( guts.skip_gtk_font & SKIP_GTK_FONT_CAPTION)) + guts.default_caption_font = font; + if ( !( guts.skip_gtk_font & SKIP_GTK_FONT_MENU)) + guts.default_menu_font = font; pango_font_description_free(pfd); } diff --git a/unix/resource.c b/unix/resource.c index a2e183326..558861b4d 100644 --- a/unix/resource.c +++ b/unix/resource.c @@ -171,7 +171,7 @@ apc_fetch_resource( const char *className, const char *name, case frFont: prima_corefont_pp2font( s, ( Font *) result); #define DEBUG_FONT(font) font.height,font.width,font.size,font.name,font.encoding - Xdebug("font: %d.[w=%d,s=%d].%s.%s", DEBUG_FONT((*(( Font *) result)))); + Xdebug("font: %d.[w=%d,s=%g].%s.%s", DEBUG_FONT((*(( Font *) result)))); break; case frUnix_int: *((int*)result) = atoi( s);