/* callback to react to key press events */ static gboolean key_press_cb(VteTerminal* vte, GdkEventKey* event) { if ((event->state & (TINYTERM_MODIFIER)) == (TINYTERM_MODIFIER)) { switch (gdk_keyval_to_upper(event->keyval)) { case TINYTERM_KEY_FONTSIZE_INCREASE: { const PangoFontDescription *font = vte_terminal_get_font(vte); pango_font_description_set_size(font, (pango_font_description_get_size(font) / PANGO_SCALE + 1) * PANGO_SCALE); vte_terminal_set_font(vte, font); return TRUE; } case TINYTERM_KEY_FONTSIZE_DECREASE: { const PangoFontDescription *font = vte_terminal_get_font(vte); const gint size = pango_font_description_get_size(font) / PANGO_SCALE - 1; if (size > 0) { pango_font_description_set_size(font, size * PANGO_SCALE); vte_terminal_set_font(vte, font); } return TRUE; } } } return FALSE; }
static void dump_font_sizes (PangoContext *context, FILE *f, guint flags) { PangoFont *font; PangoFontDescription *pfd; int nf; real height; fprintf (f, "height/cm"); for (nf = 0; test_families[nf] != NULL; ++nf) fprintf (f, "\t%s", test_families[nf]); fprintf (f, "\n"); for (height = 0.1; height <= 10.0; height += 0.1) { fprintf (f, "%g", height); for (nf = 0; test_families[nf] != NULL; ++nf) { pfd = pango_font_description_new (); pango_font_description_set_family (pfd, test_families[nf]); //pango_font_description_set_size (pfd, height * pixels_per_cm * PANGO_SCALE); if (flags & DUMP_ABSOLUTE) pango_font_description_set_absolute_size (pfd, height * pixels_per_cm * PANGO_SCALE); else pango_font_description_set_size (pfd, height * pixels_per_cm * PANGO_SCALE); font = pango_context_load_font (context, pfd); if (font) { PangoFontMetrics *metrics = pango_font_get_metrics (font, NULL); /* now make a font-size where the font/line-height matches the given pixel size */ real total = ((double)pango_font_metrics_get_ascent (metrics) + pango_font_metrics_get_descent (metrics)) / PANGO_SCALE; real factor = height*pixels_per_cm/total; real line_height; if (flags & DUMP_ABSOLUTE) pango_font_description_set_absolute_size (pfd, factor * height * pixels_per_cm * PANGO_SCALE); else pango_font_description_set_size (pfd, factor * height * pixels_per_cm * PANGO_SCALE); pango_font_metrics_unref (metrics); g_object_unref (font); font = pango_context_load_font (context, pfd); metrics = pango_font_get_metrics (font, NULL); line_height = ((double)pango_font_metrics_get_ascent (metrics) + pango_font_metrics_get_descent (metrics)) / PANGO_SCALE; fprintf (f, "\t%.3g", flags & DUMP_FACTORS ? factor : line_height); g_object_unref (font); } pango_font_description_free (pfd); } fprintf (f, "\n"); } }
void clock_init_fonts() { if (!time1_font_desc) { time1_font_desc = pango_font_description_from_string(get_default_font()); pango_font_description_set_weight(time1_font_desc, PANGO_WEIGHT_BOLD); pango_font_description_set_size(time1_font_desc, pango_font_description_get_size(time1_font_desc)); } if (!time2_font_desc) { time2_font_desc = pango_font_description_from_string(get_default_font()); pango_font_description_set_size(time2_font_desc, pango_font_description_get_size(time2_font_desc) - PANGO_SCALE); } }
static void gimp_scale_combo_box_style_set (GtkWidget *widget, GtkStyle *prev_style) { GtkWidget *entry; GtkRcStyle *rc_style; gint font_size; gdouble scale; GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); gtk_widget_style_get (widget, "label-scale", &scale, NULL); entry = gtk_bin_get_child (GTK_BIN (widget)); rc_style = gtk_widget_get_modifier_style (GTK_WIDGET (entry)); if (! rc_style->font_desc) { PangoContext *context; PangoFontDescription *font_desc; context = gtk_widget_get_pango_context (widget); font_desc = pango_context_get_font_description (context); rc_style->font_desc = pango_font_description_copy (font_desc); } font_size = pango_font_description_get_size (rc_style->font_desc); pango_font_description_set_size (rc_style->font_desc, scale * font_size); gtk_widget_modify_style (GTK_WIDGET (entry), rc_style); }
/* {EV_FONT_IMP}.set_height_in_points */ void F1035_13194 (EIF_REFERENCE Current, EIF_INTEGER_32 arg1) { GTCX EIF_POINTER tp1; EIF_REFERENCE tr1 = NULL; EIF_INTEGER_32 ti4_1; EIF_INTEGER_32 ti4_2; RTLD; RTLI(2); RTLR(0,Current); RTLR(1,tr1); RTGC; *(EIF_INTEGER_32 *)(Current+ _LNGOFF_3_2_0_2_) = (EIF_INTEGER_32) arg1; tr1 = RTOSCF(13229,F1035_13229,(Current)); ti4_1 = F791_8091(RTCV(tr1), arg1); *(EIF_INTEGER_32 *)(Current+ _LNGOFF_3_2_0_3_) = (EIF_INTEGER_32) ti4_1; tp1 = *(EIF_POINTER *)(Current+ _PTROFF_3_2_0_8_0_0_); ti4_1 = *(EIF_INTEGER_32 *)(Current+ _LNGOFF_3_2_0_2_); ti4_2 = (EIF_INTEGER_32) PANGO_SCALE; pango_font_description_set_size((PangoFontDescription*) tp1, (gint) (EIF_INTEGER_32) (ti4_1 * ti4_2)); F1035_13198(Current); RTLE; }
void SetUpStatusBarStuff (GtkWidget* aWindow) { _String fName = baseDirectory & "GTKResources/striped.xpm"; statusBarLayout = pango_layout_new (screenPContext); statusBarFontDesc = pango_font_description_new (); stripedFill = gdk_pixmap_create_from_xpm (GDK_DRAWABLE(aWindow->window), NULL, NULL, fName.sData); stripedFillGC = gdk_gc_new (GDK_DRAWABLE(aWindow->window)); if (stripedFill) { gdk_gc_set_fill (stripedFillGC,GDK_TILED); gdk_gc_set_tile (stripedFillGC,stripedFill); } else { printf ("Failed to load a status bar .xpm from %s\n", fName.sData); } gdk_gc_set_line_attributes (stripedFillGC, 1, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER); GdkColor saveFG = {0,0,0,0}; gdk_gc_set_foreground (stripedFillGC, &saveFG); pango_font_description_set_family (statusBarFontDesc, statusBarFont.face.sData); pango_font_description_set_style (statusBarFontDesc, (statusBarFont.style & HY_FONT_ITALIC) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); pango_font_description_set_weight (statusBarFontDesc, (statusBarFont.style & HY_FONT_BOLD) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL); pango_font_description_set_size (statusBarFontDesc, statusBarFont.size*PANGO_SCALE); pango_layout_set_font_description (statusBarLayout, statusBarFontDesc ); // ref ? pango_layout_set_width (statusBarLayout, -1); redButtonIcon = (GdkPixbuf*)ProcureIconResource(4000); yellowButtonIcon = (GdkPixbuf*)ProcureIconResource(4001); greenButtonIcon = (GdkPixbuf*)ProcureIconResource(4002); orangeButtonIcon = (GdkPixbuf*)ProcureIconResource(4003); }
static void gst_time_overlay_class_init (GstTimeOverlayClass * klass) { GstTextOverlayClass *gsttextoverlay_class; PangoContext *context; PangoFontDescription *font_description; gsttextoverlay_class = (GstTextOverlayClass *) klass; gsttextoverlay_class->get_text = gst_time_overlay_get_text; g_mutex_lock (GST_TEXT_OVERLAY_CLASS (klass)->pango_lock); context = GST_TEXT_OVERLAY_CLASS (klass)->pango_context; pango_context_set_language (context, pango_language_from_string ("en_US")); pango_context_set_base_dir (context, PANGO_DIRECTION_LTR); font_description = pango_font_description_new (); pango_font_description_set_family_static (font_description, "Monospace"); pango_font_description_set_style (font_description, PANGO_STYLE_NORMAL); pango_font_description_set_variant (font_description, PANGO_VARIANT_NORMAL); pango_font_description_set_weight (font_description, PANGO_WEIGHT_NORMAL); pango_font_description_set_stretch (font_description, PANGO_STRETCH_NORMAL); pango_font_description_set_size (font_description, 18 * PANGO_SCALE); pango_context_set_font_description (context, font_description); pango_font_description_free (font_description); g_mutex_unlock (GST_TEXT_OVERLAY_CLASS (klass)->pango_lock); }
/* Get the current font as a PangoFontDescription. Must be freed with pango_font_description_free. */ PangoFontDescription * get_font_description(void) { PangoFontDescription *font = get_font_family(); pango_font_description_set_size(font, get_font_size(font)); return font; }
static void adjust_font_size(GtkWidget *widget, gpointer data, gint howmuch) { VteTerminal *terminal; PangoFontDescription *desired; gint newsize; gint columns, rows, owidth, oheight; /* Read the screen dimensions in cells. */ terminal = VTE_TERMINAL(widget); columns = terminal->column_count; rows = terminal->row_count; /* Take into account padding and border overhead. */ gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight); owidth -= terminal->char_width * terminal->column_count; oheight -= terminal->char_height * terminal->row_count; /* Calculate the new font size. */ desired = pango_font_description_copy(vte_terminal_get_font(terminal)); newsize = pango_font_description_get_size(desired) / PANGO_SCALE; newsize += howmuch; pango_font_description_set_size(desired, CLAMP(newsize, 4, 144) * PANGO_SCALE); /* Change the font, then resize the window so that we have the same * number of rows and columns. */ vte_terminal_set_font(terminal, desired); gtk_window_resize(GTK_WINDOW(data), columns * terminal->char_width + owidth, rows * terminal->char_height + oheight); pango_font_description_free(desired); }
static void apply_subtitle_style_to_layout (GtkStyleContext *context, PangoLayout *layout, GtkStateFlags flags) { PangoFontDescription *desc; PangoAttrList *layout_attr; PangoAttribute *attr_alpha; gtk_style_context_save (context); gtk_style_context_set_state (context, flags); gtk_style_context_get (context, gtk_style_context_get_state (context), "font", &desc, NULL); gtk_style_context_restore (context); /* Set the font size */ pango_font_description_set_size (desc, pango_font_description_get_size (desc) * SUBTITLE_SIZE_PERCENTAGE); pango_layout_set_font_description (layout, desc); pango_font_description_free (desc); /* Set the font alpha */ layout_attr = pango_attr_list_new (); attr_alpha = pango_attr_foreground_alpha_new (SUBTITLE_DIM_PERCENTAGE * 65535); pango_attr_list_insert (layout_attr, attr_alpha); pango_layout_set_attributes (layout, layout_attr); pango_attr_list_unref (layout_attr); }
static int _pango_xft_Load(TextState * ts, const char *name) { FontCtxPangoXft *fdc; PangoFontDescription *font; PangoFontMask flags; if (!_pango_ctx) _pango_ctx = pango_xft_get_context(disp, Dpy.screen); if (!_pango_ctx) return -1; font = pango_font_description_from_string(name); if (!font) return -1; flags = pango_font_description_get_set_fields(font); if ((flags & PANGO_FONT_MASK_FAMILY) == 0) pango_font_description_set_family(font, "sans"); if ((flags & PANGO_FONT_MASK_SIZE) == 0) pango_font_description_set_size(font, 10 * PANGO_SCALE); fdc = EMALLOC(FontCtxPangoXft, 1); if (!fdc) return -1; fdc->font = font; ts->fdc = fdc; ts->need_utf8 = 1; ts->type = FONT_TYPE_PANGO_XFT; ts->ops = &FontOps_pango; return 0; }
/*! \brief draw_valtext() draws the dynamic values for the traces on the left hand side of the logviewer. This is optimized so that if the value becomes temporarily static, it won't keep blindly updating the screen and wasting CPU time. \param force_draw when true to write the values to screen for all controls no matter if hte previous value is the same or not. */ G_MODULE_EXPORT void draw_valtext(gboolean force_draw) { gint last_index = 0; gfloat val = 0.0; gfloat last_val = 0.0; gint val_x = 0; gint val_y = 0; gint info_ctr = 0; gint h = 0; gint i = 0; GArray *array = NULL; Viewable_Value *v_value = NULL; PangoLayout *layout; GdkPixmap *pixmap = lv_data->pixmap; GtkAllocation allocation; gtk_widget_get_allocation(lv_data->darea,&allocation); h = allocation.height; if (!lv_data->font_desc) { lv_data->font_desc = pango_font_description_from_string("courier"); pango_font_description_set_size(lv_data->font_desc,(10)*PANGO_SCALE); } val_x = 7; for (i=0;i<lv_data->active_traces;i++) { v_value = (Viewable_Value *)g_list_nth_data(lv_data->tlist,i); info_ctr = (lv_data->spread * (i+1))- (lv_data->spread/2); val_y = info_ctr + 1; last_index = v_value->last_index; array = DATA_GET(v_value->object,v_value->data_source); val = g_array_index(array,gfloat,last_index); if (array->len > 1) last_val = g_array_index(array,gfloat,last_index-1); /* IF this value matches the last one, don't bother * updating the text as there's no point... */ if ((val == last_val) && (!force_draw) && (!v_value->force_update)) continue; v_value->force_update = FALSE; gdk_draw_rectangle(pixmap, gtk_widget_get_style(lv_data->darea)->black_gc, TRUE, v_value->ink_rect->x+val_x, v_value->ink_rect->y+val_y, lv_data->info_width-1-v_value->ink_rect->x-val_x, v_value->ink_rect->height); layout = gtk_widget_create_pango_layout(lv_data->darea,g_strdup_printf("%1$.*2$f",val,v_value->precision)); pango_layout_set_font_description(layout,lv_data->font_desc); pango_layout_get_pixel_extents(layout,v_value->ink_rect,v_value->log_rect); gdk_draw_layout(pixmap,v_value->font_gc,val_x,val_y,layout); } }
/*! * \todo ROB parse more attributes like font-color, background-color */ void AP_UnixToolbar_StyleCombo::getPangoAttrs (PD_Style *pStyle, PangoFontDescription *desc) { UT_return_if_fail (pStyle); UT_LocaleTransactor t (LC_NUMERIC, "C"); const gchar *value = NULL; if (pStyle->getPropertyExpand ("font-family", value)) { pango_font_description_set_family (desc, value); } if (pStyle->getPropertyExpand ("font-size", value)) { pango_font_description_set_size (desc, (gint)(UT_convertToDimension (value, DIM_PT) * PANGO_SCALE)); } if (pStyle->getPropertyExpand ("font-style", value)) { PangoStyle style = PANGO_STYLE_NORMAL; if (!strcmp (value, "italic")) style = PANGO_STYLE_ITALIC; pango_font_description_set_style (desc, style); } if (pStyle->getPropertyExpand ("font-weight", value)) { PangoWeight weight = PANGO_WEIGHT_NORMAL; if (!strcmp (value, "bold")) weight = PANGO_WEIGHT_BOLD; pango_font_description_set_weight (desc, weight); } }
static bool pango_load (Lisp_Font *f) { PangoLanguage *language; PangoFontDescription *fontdesc; PangoFont *font; PangoFontMetrics *metrics; if (pango_context) { language = pango_context_get_language (pango_context); } else { char *langname, *p; #ifdef HAVE_PANGO_XFT pango_context = pango_xft_get_context (dpy, screen_num); #endif langname = g_strdup (setlocale (LC_CTYPE, NULL)); p = strchr (langname, '.'); if (p) *p = 0; p = strchr (langname, '@'); if (p) *p = 0; language = pango_language_from_string (langname); pango_context_set_language (pango_context, language); g_free (langname); } fontdesc = pango_font_description_from_string (rep_STR (f->name)); if (!pango_font_description_get_family (fontdesc)) pango_font_description_set_family (fontdesc, "Sans"); if (pango_font_description_get_size (fontdesc) <= 0) pango_font_description_set_size (fontdesc, 12 * PANGO_SCALE); pango_context_set_font_description (pango_context, fontdesc); font = pango_context_load_font (pango_context, fontdesc); if (!font) { pango_font_description_free(fontdesc); return FALSE; } metrics = pango_font_get_metrics (font, language); f->ascent = metrics->ascent / PANGO_SCALE; f->descent = metrics->descent / PANGO_SCALE; pango_font_metrics_unref (metrics); f->font = fontdesc; /* We save the font description, not the font itself! That's because it seems we can't recover it perfectly later, and the layout routines want a description */ return TRUE; }
// Narysowanie zawartosci calego okna (z legenda, opisami osi i charakterystykami) void t_display_przerysuj(T_Display *w) { int szer, wys ; double units_per_pixel_x ; //double units_per_pixel_y ; szer = w->canvas->allocation.width ; wys = w->canvas->allocation.height ; units_per_pixel_x = (double)w->time_range / ((double)szer) ; //PangoLayout *etykieta = gtk_widget_create_pango_layout (w->canvas, ""); PangoContext *pc = gtk_widget_get_pango_context (w->canvas) ; PangoFontDescription* pfd = pango_context_get_font_description (pc) ; //printf ("czcionka %d\n", pango_font_description_get_size(pfd)) ; pango_font_description_set_size (pfd, w->font_size * PANGO_SCALE) ; //pango_layout_context_changed(etykieta) ; t_display_draw_legend(w) ; t_display_calculate_borders(w) ; t_display_rysuj_siatke_czas(w) ; t_display_rysuj_siatke_temp(w) ; t_display_draw_plots(w) ; } ;
static void begin_print_text (GtkPrintOperation * op, GtkPrintContext * cnt, gpointer data) { gchar *buf; gint i = 0; gdouble ph; /* load file */ g_file_get_contents (options.common_data.uri, &buf, NULL, NULL); text = g_strsplit (buf, "\n", 0); g_free (buf); while (text[i] != NULL) i++; ph = gtk_print_context_get_height (cnt); if (options.print_data.headers) ph -= HEADER_HEIGHT + HEADER_GAP; nlines = ph / FONTSIZE; npages = i / nlines + 1; gtk_print_operation_set_n_pages (op, npages); /* set font */ if (options.common_data.font) fdesc = pango_font_description_from_string (options.common_data.font); else { fdesc = pango_font_description_from_string (FONTNAME); pango_font_description_set_size (fdesc, FONTSIZE * PANGO_SCALE); } }
void fill_cmbo(GtkWidget *cmbo) { FILE *f; int i = 0; PangoFontDescription *pfd; GtkWidget *entry1; char buffer[1024]={0}; char buffer1[1024]={0}; char buffer2[1024]={0}; GtkCellRenderer *renderer = NULL; renderer = gtk_cell_renderer_text_new();//gtk_cell_renderer_combo_new(); g_object_set (G_OBJECT(renderer), "font", "Simsun 16","foreground", "RED",NULL ); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "text", 0,NULL); f=fopen("res/data.txt","rb"); if(f) { strncpy(g_context[g_context_item].id,"0000000000000000",17); strncpy(g_context[g_context_item].name,"全部",60); gtk_combo_box_text_append_text((GtkComboBoxText *)combo,g_context[g_context_item++].name); while(fgets(buffer,1024,f)) { if(strlen(buffer) > 0 && (buffer[strlen(buffer) - 1] == '\n' || buffer[strlen(buffer) - 1] == '\r')) { buffer[strlen(buffer) - 1] = 0; } if(strlen(buffer) > 0 && (buffer[strlen(buffer) - 1] == '\n' || buffer[strlen(buffer) - 1] == '\r')) { buffer[strlen(buffer) - 1] = 0; } i = sscanf(buffer,"%s %s",buffer1,buffer2); if(i==2) { if(strlen(buffer1)==16) { strncpy(g_context[g_context_item].id,buffer1,16); g_print("====>>[%s]\n",g_context[g_context_item].id); strncpy(g_context[g_context_item].name,buffer2,60); gtk_combo_box_text_append_text((GtkComboBoxText *)combo, g_convert(g_context[g_context_item].name,-1,"UTF-8", "GBK", NULL, NULL, NULL)); g_context_item++; if(g_context_item >= 30) { break; } } } } fclose(f); } entry1 = gtk_bin_get_child((GtkBin *)combo); gtk_editable_set_editable((GtkEditable *)entry1,FALSE); gtk_entry_set_text((GtkEntry *)entry1,g_convert(g_context[0].name,-1,"UTF-8", "GBK", NULL, NULL, NULL)); pfd = pango_font_description_from_string("Simsun"); pango_font_description_set_size (pfd, 20 * PANGO_SCALE); gtk_widget_modify_font(GTK_WIDGET(entry1),pfd); pango_font_description_free(pfd); }
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkTextAreaPeer_gtkWidgetModifyFont (JNIEnv *env, jobject obj, jstring name, jint style, jint size) { const char *font_name; void *ptr; GtkWidget *text; PangoFontDescription *font_desc; gdk_threads_enter(); ptr = NSA_GET_PTR (env, obj); text = gtk_bin_get_child (GTK_BIN (ptr)); font_name = (*env)->GetStringUTFChars (env, name, NULL); font_desc = pango_font_description_from_string (font_name); pango_font_description_set_size (font_desc, size * cp_gtk_dpi_conversion_factor); if (style & AWT_STYLE_BOLD) pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD); if (style & AWT_STYLE_ITALIC) pango_font_description_set_style (font_desc, PANGO_STYLE_OBLIQUE); gtk_widget_modify_font (GTK_WIDGET (text), font_desc); pango_font_description_free (font_desc); (*env)->ReleaseStringUTFChars (env, name, font_name); gdk_threads_leave(); }
/** * gwy_graph_label_new: * * Creates a new graph label. * * Returns: A new graph label widget as a #GtkWidget. **/ GtkWidget* gwy_graph_label_new() { GwyGraphLabel *label; PangoFontDescription *description; PangoContext *context; gint size; gwy_debug(""); label = g_object_new(GWY_TYPE_GRAPH_LABEL, NULL); context = gtk_widget_get_pango_context(GTK_WIDGET(label)); description = pango_context_get_font_description(context); /* Make major font a bit smaller */ label->font_desc = pango_font_description_copy(description); size = pango_font_description_get_size(label->font_desc); size = MAX(1, size*10/11); pango_font_description_set_size(label->font_desc, size); gtk_widget_set_events(GTK_WIDGET(label), 0); return GTK_WIDGET(label); }
static void font_size_action_ativated (GSimpleAction *action, GVariant *parameter, gpointer userdata) { VteTerminal *vtterm = window_get_term_widget (GTK_WINDOW (userdata)); const gint modifier = g_variant_get_int32 (parameter); const PangoFontDescription *fontd = vte_terminal_get_font (vtterm); gint old_size = pango_font_description_get_size (fontd); if (default_font_size == 0) default_font_size = old_size; PangoFontDescription *new_fontd; gint new_size; switch (modifier) { case 0: old_size = default_font_size; /* fall-through */ case 1: case -1: new_size = old_size + modifier * PANGO_SCALE; new_fontd = pango_font_description_copy_static (fontd); pango_font_description_set_size (new_fontd, new_size); vte_terminal_set_font (vtterm, new_fontd); break; default: g_printerr ("%s: invalid modifier '%i'", __func__, modifier); return; } pango_font_description_free (new_fontd); }
static void gst_time_overlay_init (GstTimeOverlay * overlay, GstTimeOverlayClass * klass) { PangoFontDescription *font_description; GstTextOverlay *textoverlay; PangoContext *context; textoverlay = GST_TEXT_OVERLAY (overlay); context = GST_TEXT_OVERLAY_CLASS (klass)->pango_context; pango_context_set_language (context, pango_language_from_string ("en_US")); pango_context_set_base_dir (context, PANGO_DIRECTION_LTR); font_description = pango_font_description_new (); pango_font_description_set_family_static (font_description, "Monospace"); pango_font_description_set_style (font_description, PANGO_STYLE_NORMAL); pango_font_description_set_variant (font_description, PANGO_VARIANT_NORMAL); pango_font_description_set_weight (font_description, PANGO_WEIGHT_NORMAL); pango_font_description_set_stretch (font_description, PANGO_STRETCH_NORMAL); pango_font_description_set_size (font_description, 18 * PANGO_SCALE); pango_context_set_font_description (context, font_description); pango_font_description_free (font_description); textoverlay->valign = GST_TEXT_OVERLAY_VALIGN_TOP; textoverlay->halign = GST_TEXT_OVERLAY_HALIGN_LEFT; }
static PangoFontDescription * get_pango_font_description_from_info (gchar *font_family, gchar *font_weight, gint font_size) { PangoFontDescription *description = NULL; PangoWeight pw = PANGO_WEIGHT_NORMAL; g_assert(font_family); g_assert(font_weight); g_assert(font_size > 0); description = pango_font_description_new(); pango_font_description_set_family(description, font_family); if (!g_strcmp0(font_weight, "bold")) { pw = PANGO_WEIGHT_BOLD; } else { pw = PANGO_WEIGHT_NORMAL; } pango_font_description_set_weight(description, pw); pango_font_description_set_size(description, font_size * PANGO_SCALE); return description; }
/* ****************************** ADDING ROWS DYNAMICALLY FUNCTION ****************************** */ void init_table(){ /* setting spacings for columns and rows */ gtk_table_set_col_spacings(GTK_TABLE(table), 10); gtk_table_set_row_spacings(GTK_TABLE(table), 0); /* Creating table headers */ GtkWidget * id_header = gtk_label_new ("Thread ID"); GtkWidget * progress_header = gtk_label_new ("Progress"); GtkWidget * status_header = gtk_label_new ("Status"); GtkWidget * result_header = gtk_label_new ("Result"); PangoFontDescription *df; df = pango_font_description_from_string("Monospace"); pango_font_description_set_size(df, 20 * PANGO_SCALE); gtk_widget_modify_font(id_header, df); gtk_widget_modify_font(progress_header, df); gtk_widget_modify_font(status_header, df); gtk_widget_modify_font(result_header, df); gtk_table_attach(GTK_TABLE(table), id_header, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 10, 10); gtk_table_attach(GTK_TABLE(table), progress_header, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 10); gtk_table_attach(GTK_TABLE(table), status_header, 2, 3, 0, 1, GTK_FILL, GTK_FILL, 0, 10); gtk_table_attach(GTK_TABLE(table), result_header, 3, 4, 0, 1, GTK_FILL, GTK_FILL, 0, 10); }
GdkPixbuf * pixbuf_render_text(GtkWidget *da, const char *str, int point_size, int r, int g, int b, int *w, int *h) { int width; int height; PangoLayout *layout = gtk_widget_create_pango_layout(da, NULL); PangoFontDescription *desc = pango_font_description_new(); pango_font_description_set_size(desc, point_size * PANGO_SCALE); pango_layout_set_font_description(layout, desc); pango_font_description_free(desc); pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); pango_layout_set_text(layout, str, -1); pango_layout_get_pixel_size(layout, &width, &height); GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); pixbuf_set_rect_fill(pixbuf, 0, 0, width, height, 0, 0, 0, 0); pixbuf_draw_layout(pixbuf, layout, da, 0, 0, r, g, b, 255); //gdk_draw_layout(da->window, da->style->fg_gc[GTK_STATE_NORMAL], 0, 0, layout); g_object_unref(G_OBJECT(layout)); *w = width; *h = height; return pixbuf; }
JNIEXPORT void JNICALL Java_org_gnome_pango_PangoFontDescription_pango_1font_1description_1set_1size ( JNIEnv* env, jclass cls, jlong _self, jint _size ) { PangoFontDescription* self; gint size; // convert parameter self self = (PangoFontDescription*) _self; // convert parameter size size = (gint) _size; // call function pango_font_description_set_size(self, size); // cleanup parameter self // cleanup parameter size }
void HYFont2PangoFontDesc (const _HYFont& f, PangoFontDescription* theFont) { pango_font_description_set_family (theFont, f.face.sData); pango_font_description_set_style (theFont, (f.style & HY_FONT_ITALIC) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); pango_font_description_set_weight (theFont, (f.style & HY_FONT_BOLD) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL); pango_font_description_set_size (theFont, f.size*PANGO_SCALE); //pango_font_description_set_absolute_size (theFont, f.size*PANGO_SCALE); }
void set_result_label_font() { PangoFontDescription *font_desc = pango_font_description_from_string("Ubuntu"); pango_font_description_set_size(font_desc, 100*PANGO_SCALE); gtk_widget_modify_font(result_label, font_desc); gtk_label_set_text(GTK_LABEL(result_label), ""); }
void TextView::updatePangoFont(PangoLayout* layout, Text* t) { PangoFontDescription* desc = pango_font_description_from_string(t->getFont().getName().c_str()); //pango_font_description_set_absolute_size(desc, t->getFont().getSize() * PANGO_SCALE); pango_font_description_set_size(desc, t->getFont().getSize() * PANGO_SCALE); pango_layout_set_font_description(layout, desc); pango_font_description_free(desc); }
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkClasspathFontPeer_setFont (JNIEnv *env, jobject self, jstring family_name_str, jint style_int, jint size) { struct peerfont *pfont = NULL; PangoFontMap *map = NULL; char const *family_name = NULL; gdk_threads_enter (); enum java_awt_font_style style = (enum java_awt_font_style) style_int; g_assert (self != NULL); pfont = (struct peerfont *)NSA_GET_FONT_PTR (env, self); g_assert (pfont != NULL); if (pfont->ctx != NULL) g_object_unref (pfont->ctx); if (pfont->font != NULL) g_object_unref (pfont->font); if (pfont->desc != NULL) pango_font_description_free (pfont->desc); pfont->desc = pango_font_description_new (); g_assert (pfont->desc != NULL); family_name = (*env)->GetStringUTFChars(env, family_name_str, 0); g_assert (family_name != NULL); pango_font_description_set_family (pfont->desc, family_name); (*env)->ReleaseStringUTFChars(env, family_name_str, family_name); pango_font_description_set_size (pfont->desc, size * PANGO_SCALE); if (style & java_awt_font_BOLD) pango_font_description_set_weight (pfont->desc, PANGO_WEIGHT_BOLD); if (style & java_awt_font_ITALIC) pango_font_description_set_style (pfont->desc, PANGO_STYLE_ITALIC); /* FIXME: these are possibly wrong, and should in any case probably be cached between calls. */ map = pango_ft2_font_map_for_display (); g_assert (map != NULL); if (pfont->ctx == NULL) pfont->ctx = pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP (map)); g_assert (pfont->ctx != NULL); if (pfont->font != NULL) g_object_unref (pfont->font); pfont->font = pango_font_map_load_font (map, pfont->ctx, pfont->desc); g_assert (pfont->font != NULL); gdk_threads_leave (); }
G_MODULE_EXPORT gboolean display_init() { gdk_color_parse("lightgray", &inst_color_lightgray_); gdk_color_parse("black", &inst_color_black_); font_sans12_desc = pango_font_description_new(); pango_font_description_set_family(font_sans12_desc, "Sans"); pango_font_description_set_size(font_sans12_desc, 12 * PANGO_SCALE); font_sans8_desc = pango_font_description_new(); pango_font_description_set_family(font_sans8_desc, "Sans"); pango_font_description_set_size(font_sans8_desc, 8 * PANGO_SCALE); GdkScreen* const screen = gdk_screen_get_default(); const gint monitor_num = gdk_screen_get_primary_monitor(screen); gdk_screen_get_monitor_geometry(screen, monitor_num, &screen_rect); return TRUE; }