Skip to content

Commit

Permalink
don't override explicit --xxx-font from commandline by gtk fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
dk committed Nov 12, 2024
1 parent e01035e commit feaed21
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Prima/Classes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion include/apricot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
7 changes: 7 additions & 0 deletions include/unix/guts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions unix/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand Down
18 changes: 11 additions & 7 deletions unix/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion unix/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit feaed21

Please sign in to comment.