Mercurial > dwindows
comparison gtk3/dw.c @ 1001:4ef0e878fe06
Added support for Dynamic Windows style font names for GTK3.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 08 May 2011 06:18:41 +0000 |
parents | f019c5e8511f |
children | 751522e9f3ac |
comparison
equal
deleted
inserted
replaced
1000:99907f19a703 | 1001:4ef0e878fe06 |
---|---|
18 # include <sys/mman.h> | 18 # include <sys/mman.h> |
19 #endif | 19 #endif |
20 #include <stdarg.h> | 20 #include <stdarg.h> |
21 #include <stdio.h> | 21 #include <stdio.h> |
22 #include <unistd.h> | 22 #include <unistd.h> |
23 #include <ctype.h> | |
23 #include <errno.h> | 24 #include <errno.h> |
24 #include <sys/time.h> | 25 #include <sys/time.h> |
25 #include <dirent.h> | 26 #include <dirent.h> |
26 #include <sys/stat.h> | 27 #include <sys/stat.h> |
27 #include <signal.h> | 28 #include <signal.h> |
2507 */ | 2508 */ |
2508 int dw_window_set_font(HWND handle, char *fontname) | 2509 int dw_window_set_font(HWND handle, char *fontname) |
2509 { | 2510 { |
2510 PangoFontDescription *pfont; | 2511 PangoFontDescription *pfont; |
2511 GtkWidget *handle2 = handle; | 2512 GtkWidget *handle2 = handle; |
2512 char *font; | 2513 char *font = strdup(fontname); |
2514 char *name = strchr(font, '.'); | |
2513 int _locked_by_me = FALSE; | 2515 int _locked_by_me = FALSE; |
2514 gpointer data; | 2516 gpointer data; |
2515 | 2517 |
2516 DW_MUTEX_LOCK; | 2518 DW_MUTEX_LOCK; |
2517 if(GTK_IS_SCROLLED_WINDOW(handle)) | 2519 if(GTK_IS_SCROLLED_WINDOW(handle)) |
2518 { | 2520 { |
2519 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); | 2521 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); |
2520 if(tmp) | 2522 if(tmp) |
2521 handle2 = tmp; | 2523 handle2 = tmp; |
2522 } | 2524 } |
2523 font = strdup(fontname); | 2525 |
2526 /* Detect Dynamic Windows style font name... | |
2527 * Format: ##.Fontname | |
2528 * and convert to a Pango name | |
2529 */ | |
2530 if(name && isdigit(*font)) | |
2531 { | |
2532 int size = atoi(font); | |
2533 *name = 0; | |
2534 name++; | |
2535 sprintf(font, "%s %d", name, size); | |
2536 } | |
2524 | 2537 |
2525 /* Free old font name if one is allocated */ | 2538 /* Free old font name if one is allocated */ |
2526 data = g_object_get_data(G_OBJECT(handle2), "_dw_fontname"); | 2539 data = g_object_get_data(G_OBJECT(handle2), "_dw_fontname"); |
2527 if(data) | 2540 if(data) |
2528 free(data); | 2541 free(data); |