void draw_init_font (drawctx_t *ctx, GtkStyle *new_font_style) { if (!ctx->pango_ready || (new_font_style && ctx->font_style != new_font_style)) { if (ctx->pangoctx) { g_object_unref (ctx->pangoctx); ctx->pangoctx = NULL; } if (ctx->pangolayout) { g_object_unref (ctx->pangolayout); ctx->pangolayout = NULL; } ctx->font_style = new_font_style ? new_font_style : gtk_widget_get_default_style (); ctx->pangoctx = gdk_pango_context_get (); ctx->pangolayout = pango_layout_new (ctx->pangoctx); pango_layout_set_ellipsize (ctx->pangolayout, PANGO_ELLIPSIZE_END); PangoFontDescription *desc = ctx->font_style->font_desc; ctx->font_weight = pango_font_description_get_weight (desc); pango_layout_set_font_description (ctx->pangolayout, desc); ctx->pango_ready = 1; } else if (new_font_style) { PangoFontDescription *desc = ctx->font_style->font_desc; pango_layout_set_font_description (ctx->pangolayout, desc); } }
int sg_text_width(const char *txt, PangoFontDescription *font) { int wid = 0; PangoLayout *layout = NULL; PangoContext *ctx; if (txt == NULL) return(0); if (snd_strlen(txt) == 0) return(0); if (!(g_utf8_validate(txt, -1, NULL))) { #if MUS_DEBUGGING fprintf(stderr,"text width: invalid UTF-8: %s\n", txt); abort(); #endif return(0); } ctx = gdk_pango_context_get(); layout = pango_layout_new(ctx); if (layout) { pango_layout_set_font_description(layout, font); pango_layout_set_text(layout, txt, -1); pango_layout_get_pixel_size(layout, &wid, NULL); g_object_unref(G_OBJECT(layout)); } g_object_unref(ctx); return(wid); }
PangoContext * dia_font_get_context() { if (pango_context == NULL) { /* Maybe this one with pangocairo dia_font_push_context (pango_cairo_font_map_create_context (pango_cairo_font_map_get_default())); * but it gives: (lt-dia:30476): Pango-CRITICAL **: pango_renderer_draw_layout: assertion `PANGO_IS_RENDERER (renderer)' failed */ #ifdef HAVE_FREETYPE /* This is suggested by new Pango (1.2.4+), but doesn't get us the * right resolution:( dia_font_push_context(pango_ft2_font_map_create_context(pango_ft2_font_map_new())); */ /* with 96x96 it gives consistent - too big - sizes with the cairo renderer, it was 75x75 with 0.96.x dia_font_push_context(pango_ft2_get_context(96,96)); */ dia_font_push_context(pango_ft2_get_context(75,75)); #else if (gdk_display_get_default ()) dia_font_push_context(gdk_pango_context_get()); else { # ifdef GDK_WINDOWING_WIN32 dia_font_push_context(pango_win32_get_context ()); # else g_warning ("dia_font_get_context() : not font context w/o display. Crashing soon."); # endif } #endif } return pango_context; }
void ZDrawSongInfo(IDirectFB *dfb, IDirectFBSurface *dfbsurface, const gchar *title, const gchar *artist, gint w, gint h, DFBColor *color, DFBColor *strokeColor, double strokeWidth, const PangoFontDescription *desc) { cairo_t *cr = NULL; cairo_surface_t *surface = NULL; cairo_surface_t *cairosurface = NULL; PangoLayout *layout = NULL; if(!dfb || !dfbsurface) return; /* prepare layout */ layout = pango_layout_new(gdk_pango_context_get()); pango_layout_set_single_paragraph_mode (layout, TRUE); pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); pango_layout_set_width(layout, w* PANGO_SCALE); pango_layout_set_font_description(layout, desc); surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); cr = cairo_create(surface); /* Draw title */ if(title) { pango_layout_set_text(layout, title, -1); cairo_move_to(cr, 0, 0); pango_cairo_layout_path(cr, layout); ZCairoSetDFBColor(cr, strokeColor); cairo_set_line_width(cr, strokeWidth); cairo_stroke_preserve(cr); ZCairoSetDFBColor(cr, color); cairo_fill(cr); } /* Draw artist */ if(artist) { pango_layout_set_text(layout, artist, -1); cairo_move_to(cr, 0, h/2); pango_cairo_layout_path(cr, layout); ZCairoSetDFBColor(cr, strokeColor); cairo_set_line_width(cr, strokeWidth); cairo_stroke_preserve(cr); ZCairoSetDFBColor(cr, color); cairo_fill(cr); } g_object_unref(layout); cairo_destroy(cr); /* Draw cairo_surface to dfbsurface */ /* create surface */ cairosurface = cairo_directfb_surface_create(dfb, dfbsurface); cr = cairo_create(cairosurface); cairo_set_source_surface(cr, surface, 0, 0); cairo_paint(cr); cairo_destroy(cr); cairo_surface_destroy(surface); cairo_surface_destroy(cairosurface); }
int main (int argc, char**argv) { PangoContext* context; PangoLayout * layout; Testcase * testcase; gboolean passed = TRUE; /* prepare */ gtk_init (&argc, &argv); testcase = testcase_new (); context = gdk_pango_context_get (); layout = pango_layout_new (context); pango_layout_set_text (layout, "Foo Bar Baz", -1); /* exercise */ g_signal_connect (testcase, "exercise-gdk", G_CALLBACK (test_gdk_cb), layout); g_signal_connect (testcase, "exercise-cairo", G_CALLBACK (test_cairo_cb), layout); testcase_exercise (testcase); /* verify */ passed = testcase_get_passed (testcase); /* cleanup */ g_object_unref (testcase); g_object_unref (layout); g_object_unref (context); return passed ? 0 : 1; }
static int ol_scroll_window_get_font_height (OlScrollWindow *scroll) { ol_assert_ret (OL_IS_SCROLL_WINDOW (scroll), 0); OlScrollWindowPrivate *priv = OL_SCROLL_WINDOW_GET_PRIVATE (scroll); PangoContext *pango_context = gdk_pango_context_get (); PangoLayout *pango_layout = pango_layout_new (pango_context); PangoFontDescription *font_desc = pango_font_description_from_string (priv->font_name); pango_layout_set_font_description (pango_layout, font_desc); PangoFontMetrics *metrics = pango_context_get_metrics (pango_context, pango_layout_get_font_description (pango_layout), /* font desc */ NULL); /* languague */ int height = 0; int ascent, descent; ascent = pango_font_metrics_get_ascent (metrics); descent = pango_font_metrics_get_descent (metrics); pango_font_metrics_unref (metrics); height += PANGO_PIXELS (ascent + descent); pango_font_description_free (font_desc); g_object_unref (pango_layout); g_object_unref (pango_context); return height; }
void draw_init_font (drawctx_t *ctx, int type, int reset) { if (reset || !ctx->pango_ready) { if (ctx->pangoctx) { g_object_unref (ctx->pangoctx); ctx->pangoctx = NULL; } if (ctx->pangolayout) { g_object_unref (ctx->pangolayout); ctx->pangolayout = NULL; } if (ctx->font_style) { g_object_unref (ctx->font_style); ctx->font_style = NULL; } ctx->font_style = gtk_style_new (); if (ctx->font_style->font_desc) { pango_font_description_free (ctx->font_style->font_desc); ctx->font_style->font_desc = get_new_font_description_from_type (type); } ctx->pangoctx = gdk_pango_context_get (); ctx->pangolayout = pango_layout_new (ctx->pangoctx); pango_layout_set_ellipsize (ctx->pangolayout, PANGO_ELLIPSIZE_END); PangoFontDescription *desc = ctx->font_style->font_desc; ctx->font_weight = pango_font_description_get_weight (desc); pango_layout_set_font_description (ctx->pangolayout, desc); ctx->pango_ready = 1; } else if (ctx->pango_ready) { PangoFontDescription *desc = ctx->font_style->font_desc; pango_layout_set_font_description (ctx->pangolayout, desc); } }
gboolean time_line_internal_draw_layer_name(TimeLinePrivate *priv, gint layer_number) { // Local variables const GdkColor colour_black = {0, 0, 0, 0 }; static GdkColormap *colourmap = NULL; // Colourmap used for drawing static GdkGC *display_buffer_gc = NULL; static PangoContext *font_context = NULL; static PangoFontDescription *font_description = NULL; static PangoLayout *font_layout = NULL; layer *layer_data; GList *layer_pointer; // Points to the layers in the selected slide GString *message = NULL; message = g_string_new(NULL); // Initialisation if (NULL == colourmap) { colourmap = gdk_colormap_get_system(); gdk_drawable_set_colormap(GDK_DRAWABLE(priv->display_buffer_bot_left), GDK_COLORMAP(colourmap)); } if (NULL == font_context) { font_context = gdk_pango_context_get(); } if (NULL == font_layout) { font_layout = pango_layout_new(font_context); } if (NULL == display_buffer_gc) { display_buffer_gc = gdk_gc_new(GDK_DRAWABLE(priv->display_buffer_bot_left)); } if (NULL == font_description) { font_description = pango_font_description_from_string("Sans , 15px"); pango_layout_set_font_description(font_layout, font_description); } // Retrieve the layer name string layer_pointer = get_current_slide_layers_pointer(); layer_pointer = g_list_first(layer_pointer); layer_data = g_list_nth_data(layer_pointer, layer_number); // g_string_printf(message, "%d %s ",layer_number,layer_data->name->str); pango_layout_set_text(font_layout, layer_data->name->str, -1); // Set a clip mask // clip_region.x = 0; // clip_region.y = (layer_number <= 0)?0:(layer_number * priv->row_height); // clip_region.width = priv->left_border_width - 1; // clip_region.height = priv->row_height * 2; // gdk_gc_set_clip_rectangle(GDK_GC(display_buffer_gc), &clip_region); // Draw the text string gdk_gc_set_rgb_fg_color(GDK_GC(display_buffer_gc), &colour_black); gdk_draw_layout(GDK_DRAWABLE(priv->display_buffer_bot_left), GDK_GC(display_buffer_gc), 5, (layer_number * priv->row_height)+1,font_layout); return TRUE; }
static VALUE gdkpango_s_context_get(int argc, VALUE *argv, VALUE self) { VALUE screen, ret; rb_scan_args(argc, argv, "01", &screen); if (NIL_P(screen)){ ret = GOBJ2RVAL(gdk_pango_context_get()); } else { #if GTK_CHECK_VERSION(2,2,0) ret = GOBJ2RVAL(gdk_pango_context_get_for_screen(GDK_SCREEN(RVAL2GOBJ(screen)))); #else rb_warn("Gdk::Pango.context_get: Not supported arguments in GTK+-2.0.x."); ret = GOBJ2RVAL(gdk_pango_context_get()); #endif } return ret; }
cdCtxCanvas *cdgdkCreateCanvas(cdCanvas* canvas, GdkDrawable* wnd, GdkScreen* scr, GdkVisual* vis) { cdCtxCanvas *ctxcanvas = (cdCtxCanvas *)malloc(sizeof(cdCtxCanvas)); memset(ctxcanvas, 0, sizeof(cdCtxCanvas)); ctxcanvas->scr = scr; ctxcanvas->vis = vis; ctxcanvas->wnd = wnd; ctxcanvas->gc = gdk_gc_new(wnd); if (!ctxcanvas->gc) { free(canvas); return NULL; } ctxcanvas->fontcontext = gdk_pango_context_get(); #if PANGO_VERSION_CHECK(1,16,0) pango_context_set_language(ctxcanvas->fontcontext, pango_language_get_default()); #endif ctxcanvas->canvas = canvas; canvas->ctxcanvas = ctxcanvas; gdk_drawable_get_size(wnd, &ctxcanvas->canvas->w, &ctxcanvas->canvas->h); ctxcanvas->depth = gdk_drawable_get_depth(wnd); canvas->bpp = ctxcanvas->depth; canvas->xres = ((double)gdk_screen_get_width(scr) / (double)gdk_screen_get_width_mm(scr)); canvas->yres = ((double)gdk_screen_get_height(scr) / (double)gdk_screen_get_height_mm(scr)); canvas->w_mm = ((double)canvas->w) / canvas->xres; canvas->h_mm = ((double)canvas->h) / canvas->yres; canvas->invert_yaxis = 1; if (canvas->bpp <= 8) { ctxcanvas->colormap = gdk_gc_get_colormap(ctxcanvas->gc); if (!ctxcanvas->colormap) { ctxcanvas->colormap = gdk_colormap_get_system(); gdk_gc_set_colormap(ctxcanvas->gc, ctxcanvas->colormap); } ctxcanvas->num_colors = ctxcanvas->colormap->size; } cdRegisterAttribute(canvas, &gc_attrib); cdRegisterAttribute(canvas, &rotate_attrib); cdRegisterAttribute(canvas, &pangoversion_attrib); cdRegisterAttribute(canvas, &imgdither_attrib); cdRegisterAttribute(canvas, &interp_attrib); return ctxcanvas; }
static inline void nsfont_pango_check(void) { if (nsfont_pango_context == NULL) { LOG("Creating nsfont_pango_context."); nsfont_pango_context = gdk_pango_context_get(); } if (nsfont_pango_layout == NULL) { LOG("Creating nsfont_pango_layout."); nsfont_pango_layout = pango_layout_new(nsfont_pango_context); } }
void ZCairoDrawLyric(cairo_t *cr, gboolean isUpLine, gint space, gint w, gint h, DFBColor *bgColor, const gchar *text, gint fullWidth, DFBColor *color1, DFBColor *strokeColor1, double strokeWidth1, DFBColor *color2, DFBColor *strokeColor2, double strokeWidth2, const PangoFontDescription *desc) { PangoLayout *layout = NULL; gint x, y; /* Prepare layout */ layout = pango_layout_new(gdk_pango_context_get()); pango_layout_set_single_paragraph_mode (layout, TRUE); pango_layout_set_alignment(layout, isUpLine ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT); pango_layout_set_font_description(layout, desc); pango_layout_set_text(layout, text, -1); /* Clear background */ cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); cairo_paint(cr); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); /* Draw background */ if(bgColor) { ZCairoSetDFBColor(cr, bgColor); cairo_paint(cr); } /* Draw original text */ x = isUpLine ? space : w - fullWidth - space; y = 0; cairo_move_to(cr, x, y); pango_cairo_layout_path(cr, layout); ZCairoSetDFBColor(cr, strokeColor1); cairo_set_line_width(cr, strokeWidth1); cairo_stroke_preserve(cr); ZCairoSetDFBColor(cr, color1); cairo_fill(cr); /* Draw effect text */ y = h/2; cairo_move_to(cr, x, y); pango_cairo_layout_path(cr, layout); ZCairoSetDFBColor(cr, strokeColor2); cairo_set_line_width(cr, strokeWidth2); cairo_stroke_preserve(cr); ZCairoSetDFBColor(cr, color2); cairo_fill(cr); g_object_unref(layout); }
void wxMemoryDC::Init() { m_ok = false; m_cmap = gtk_widget_get_default_colormap(); m_context = gdk_pango_context_get(); // Note: The Sun customised version of Pango shipping with Solaris 10 // crashes if the language is left NULL (see bug 1374114) pango_context_set_language( m_context, gtk_get_default_language() ); m_layout = pango_layout_new( m_context ); m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) ); }
/** * Find where to split a string to make it fit a width. * * \param[in] fstyle style for this text * \param[in] string UTF-8 string to measure * \param[in] length length of string, in bytes * \param[in] x width available * \param[out] char_offset updated to offset in string of actual_x, [1..length] * \param[out] actual_x updated to x coordinate of character closest to x * \return NSERROR_OK or appropriate error code on faliure * * On exit, char_offset indicates first character after split point. * * \note char_offset of 0 must never be returned. * * Returns: * char_offset giving split point closest to x, where actual_x <= x * else * char_offset giving split point closest to x, where actual_x > x * * Returning char_offset == length means no split possible */ static nserror nsfont_split(const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x) { int index = length; PangoFontDescription *desc; PangoContext *context; PangoLayout *layout; PangoLayoutLine *line; context = gdk_pango_context_get(); layout = pango_layout_new(context); desc = nsfont_style_to_description(fstyle); pango_layout_set_font_description(layout, desc); pango_font_description_free(desc); pango_layout_set_text(layout, string, length); /* Limit width of layout to the available width */ pango_layout_set_width(layout, x * PANGO_SCALE); /* Request word wrapping */ pango_layout_set_wrap(layout, PANGO_WRAP_WORD); /* Prevent pango treating linebreak characters as line breaks */ pango_layout_set_single_paragraph_mode(layout, TRUE); /* Obtain the second line of the layout (if there is one) */ line = pango_layout_get_line(layout, 1); if (line != NULL) { /* Pango split the text. The line's start_index indicates the * start of the character after the line break. */ index = line->start_index; } g_object_unref(layout); g_object_unref(context); *char_offset = index; /* Obtain the pixel offset of the split character */ nsfont_width(fstyle, string, index, actual_x); return NSERROR_OK; }
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkTextLayout_initState (JNIEnv *env, jobject self) { struct textlayout *tl; gdk_threads_enter (); g_assert(self != NULL); tl = g_malloc0 (sizeof (struct textlayout)); g_assert(tl != NULL); tl->pango_layout = pango_layout_new(gdk_pango_context_get()); g_assert(tl->pango_layout != NULL); NSA_SET_TEXT_LAYOUT_PTR (env, self, tl); gdk_threads_leave (); }
void rotate_text(GdkDrawable *wn, GdkGC *gc, PangoFontDescription *font, const char *text, int angle, gint x0, gint y0) { #if HAVE_PANGO_MATRIX_ROTATE PangoLayout *layout; PangoContext *context; PangoMatrix matrix = PANGO_MATRIX_INIT; context = gdk_pango_context_get(); layout = pango_layout_new(context); pango_matrix_rotate(&matrix, angle); pango_context_set_matrix(context, &matrix); pango_layout_set_font_description(layout, font); pango_layout_set_text(layout, text, -1); gdk_draw_layout(wn, gc, x0, y0, layout); g_object_unref(layout); g_object_unref(context); #endif }
static int sg_font_width(PangoFontDescription *font) { /* returns size in pixels */ int wid = 0; double dpi = 96.0; /* see below */ PangoContext *ctx; PangoFontMetrics *m; #if HAVE_GTK_LINK_BUTTON_NEW dpi = gdk_screen_get_resolution(gdk_display_get_default_screen(gdk_display_get_default())); /* pixels/inch */ #endif ctx = gdk_pango_context_get(); m = pango_context_get_metrics(ctx, font, gtk_get_default_language()); /* returns size in pango-scaled points (1024/72 inch) */ wid = (int)((dpi / 72.0) * PANGO_PIXELS(pango_font_metrics_get_approximate_char_width(m))); pango_font_metrics_unref(m); g_object_unref(ctx); return(wid); }
static void drawWindow(InstanceData* instanceData, GdkDrawable* gdkWindow) { NPWindow window = instanceData->window; int x = window.x; int y = window.y; int width = window.width; int height = window.height; NPP npp = instanceData->npp; if (!npp) return; const char* uaString = sBrowserFuncs->uagent(npp); if (!uaString) return; GdkGC* gdkContext = gdk_gc_new(gdkWindow); // draw a grey background for the plugin frame GdkColor grey; grey.red = grey.blue = grey.green = 32767; gdk_gc_set_rgb_fg_color(gdkContext, &grey); gdk_draw_rectangle(gdkWindow, gdkContext, TRUE, x, y, width, height); // draw a 3-pixel-thick black frame around the plugin GdkColor black; black.red = black.green = black.blue = 0; gdk_gc_set_rgb_fg_color(gdkContext, &black); gdk_gc_set_line_attributes(gdkContext, 3, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER); gdk_draw_rectangle(gdkWindow, gdkContext, FALSE, x + 1, y + 1, width - 3, height - 3); // paint the UA string PangoContext* pangoContext = gdk_pango_context_get(); PangoLayout* pangoTextLayout = pango_layout_new(pangoContext); pango_layout_set_width(pangoTextLayout, (width - 10) * PANGO_SCALE); pango_layout_set_text(pangoTextLayout, uaString, -1); gdk_draw_layout(gdkWindow, gdkContext, x + 5, y + 5, pangoTextLayout); g_object_unref(pangoTextLayout); g_object_unref(gdkContext); }
// -------------------------------------------------------------- // - Font services ---------------------------------------------- // -------------------------------------------------------------- // "width" feature for font is not portable: has been replaced by // horizontal scaling of device context. const VGFont* GSystemGtk::CreateVGFont( const char * faceName, int size, int properties ) const { PangoFontDescription *pangoFontDescr = pango_font_description_new(); pango_font_description_set_family( pangoFontDescr, faceName ); int myWeight = PANGO_WEIGHT_NORMAL; PangoStyle myStyle = PANGO_STYLE_NORMAL; if (properties) { if (properties & VGFont::kFontBold) myWeight = PANGO_WEIGHT_BOLD; if (properties & VGFont::kFontItalic) myStyle = PANGO_STYLE_ITALIC; } pango_font_description_set_style( pangoFontDescr, myStyle ); // pango_font_description_set_size( pangoFontDescr, height * PANGO_SCALE / 10 ); pango_font_description_set_size( pangoFontDescr, size * PANGO_SCALE / 10 ); // + underline ?? // printf( "ok... where is the font ? %s italic=%d\n", faceName, italic ); //XXX: GetThe font into the pangocontext PangoContext* pangoContext = gdk_pango_context_get(); PangoLanguage* pangoLanguage = pango_language_from_string( "en-us" ); PangoFontset *fontset = pango_context_load_fontset( pangoContext, pangoFontDescr, pangoLanguage ); GFontGtk * outFont = 0; if( fontset ) outFont = new GFontGtk( pangoFontDescr, faceName, size, properties, 0 ); else g_object_unref( G_OBJECT( pangoFontDescr) ); return outFont; }
OlOsdRenderContext * ol_osd_render_context_new () { OlOsdRenderContext *context = g_new (OlOsdRenderContext, 1); context->font_name = g_strdup (DEFAULT_FONT_NAME); int i; for (i = 0; i < OL_LINEAR_COLOR_COUNT; i++) { context->linear_colors[i] = ol_color_black; } context->linear_pos[0] = 0.0; context->linear_pos[1] = 0.5; context->linear_pos[2] = 1.0; context->pango_context = gdk_pango_context_get (); context->pango_layout = pango_layout_new (context->pango_context); context->text = NULL; context->blur_radius = 0.0; ol_osd_render_update_font (context); ol_osd_render_set_outline_width (context, DEFAULT_OUTLINE_WIDTH); return context; }
void wxScreenDCImpl::Init() { m_ok = false; m_cmap = gdk_colormap_get_system(); m_gdkwindow = gdk_get_default_root_window(); m_context = gdk_pango_context_get(); // Note: The Sun customised version of Pango shipping with Solaris 10 // crashes if the language is left NULL (see bug 1374114) pango_context_set_language( m_context, gtk_get_default_language() ); m_layout = pango_layout_new( m_context ); // m_fontdesc = pango_font_description_copy( widget->style->font_desc ); m_isScreenDC = true; SetUpDC(); gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS ); gdk_gc_set_subwindow( m_brushGC, GDK_INCLUDE_INFERIORS ); gdk_gc_set_subwindow( m_textGC, GDK_INCLUDE_INFERIORS ); gdk_gc_set_subwindow( m_bgGC, GDK_INCLUDE_INFERIORS ); }
static int sg_font_height(PangoFontDescription *font) { /* returns size in pixels */ double dpi = 96.0; /* a plausible guess */ int hgt = 0; PangoContext *ctx; PangoFontMetrics *m; #if HAVE_GTK_LINK_BUTTON_NEW /* gtk 2.1: gdk_display_get_default, gdk_display_get_default_screen */ /* gtk 2.9: gdk_screen_get_resolution */ dpi = gdk_screen_get_resolution(gdk_display_get_default_screen(gdk_display_get_default())); #endif ctx = gdk_pango_context_get(); m = pango_context_get_metrics(ctx, font, gtk_get_default_language()); hgt = (int)((dpi / 72.0) * PANGO_PIXELS(pango_font_metrics_get_ascent(m))); pango_font_metrics_unref(m); g_object_unref(ctx); return(hgt); }
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont (JNIEnv *env, jobject self, jstring family_name_str, jint style_int, jint size, jboolean useGraphics2D) { struct peerfont *pfont = NULL; char const *family_name = NULL; enum java_awt_font_style style; PangoFT2FontMap *ft2_map; gdk_threads_enter (); 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); 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); if (useGraphics2D) { pango_font_description_set_size (pfont->desc, size * PANGO_SCALE); if (pfont->ctx == NULL) { ft2_map = PANGO_FT2_FONT_MAP(pango_ft2_font_map_for_display ()); pfont->ctx = pango_ft2_font_map_create_context (ft2_map); } } else { /* GDK uses a slightly different DPI setting. */ pango_font_description_set_size (pfont->desc, size * dpi_conversion_factor); if (pfont->ctx == NULL) pfont->ctx = gdk_pango_context_get(); } g_assert (pfont->ctx != NULL); if (pfont->font != NULL) { g_object_unref (pfont->font); pfont->font = NULL; } pango_context_set_font_description (pfont->ctx, pfont->desc); pango_context_set_language (pfont->ctx, gtk_get_default_language()); pfont->font = pango_context_load_font (pfont->ctx, pfont->desc); g_assert (pfont->font != NULL); if (pfont->layout == NULL) pfont->layout = pango_layout_new (pfont->ctx); g_assert (pfont->layout != NULL); gdk_threads_leave (); }
void init() { extern gint buffer_area_width; extern gint buffer_area_height; extern gint dir_width; extern gint dir_height; /* Initialize ALL variables, should be first functional called from main. These are still needed in case default file is missing or incomplete. */ /* Pango text bullshit */ layout = pango_layout_new(gdk_pango_context_get()); font_desc = pango_font_description_from_string("sans"); pango_font_description_set_size(font_desc,(8)*PANGO_SCALE); data_handle = -1; /* initialize to empty handle */ data_source = PULSEAUDIO; scope_zoom = 1.0; /* normal zoom, (none) */ refresh_rate = 34; /* 34 frames per sec */ left_amplitude = 32768.0; /* Scaler for something */ right_amplitude = 32768.0; /* Scaler for something */ fft_signal_source = LEFT_PLUS_RIGHT;/* signal input source for fft */ landflip = FALSE; /* Flip 3D axis over */ spikeflip = FALSE; /* Flip 3D axis over */ axis_type = LOG; /* Logarithmic display for 3D land and EQ modes */ window_func = HAMMING; /* Hamming window (see misc.c) */ win_width = FULL; /* use full window function, not cramped version */ nsamp = 2048; /* number of samples per FFT/scope */ bands = 128; /* to start with, should be configurable */ mode = LAND_3D; /* default mode. (3D FFT) */ sub_mode_3D = FILL_3D; /* default 3D mode */ scope_sub_mode = LINE_SCOPE;/* default Scope mode */ show_graticule = 1; /* show scope graticule*/ lag = 360; /* Lag (how many milliseconds behind) */ decimation_factor=1; seg_height = 2; /* height per segment in 2d spectrum analyzer */ seg_space = 1; /* space between segments in 2d analyzer */ stabilized = TRUE; /* Scope stabilizer routine */ bar_decay = FALSE; /* bar_decay and peak_decay are tied together */ peak_decay = TRUE; /* bar_decay and peak_decay are tied together */ bar_decay_speed = 7; /* decay_speed ONLY works with bar_decay "on" (1) */ peak_decay_speed = 1; /* decay_speed ONLY works with peak_decay "on" (1) */ peak_hold_time = 10; /* hold_time ONLY works with peak_decay "on" (1) */ xdet_scroll = 2; /* detailed scroll in pixels */ zdet_scroll = 2; /* detailed scroll in pixels */ xdet_start= 0.00; /* The 3d DETAILED fft's amount of horizontal */ ydet_start = 0.00; /* detailed y axis start position (percent) */ xdet_end = 0.95; /* The 3d DETAILED fft's amount of horizontal */ ydet_end = 0.23; /* detailed y axis start position (percent) */ x3d_start = 0.00; /* The 3d X start point of axis (percentage) */ y3d_start = 0.00; /* The 3d Y start point of axis (percentage) */ x3d_end = 0.95; /* 3D fft X end point of axis (percentage) */ y3d_end = 0.13; /* 3D fft Y end point of axis (percentage) */ x3d_scroll = 3; /* 3D scroll in pixels x axis */ z3d_scroll = 6; /* 3D scroll in pixels z axis */ border = 8; /* border around most displays */ x_offset = 0; /* 3D X axis offset for centering */ y_offset = 0; /* 3D X axis offset for centering */ landtilt = TRUE; /* Flag */ outlined = TRUE; /* Outlined 3D Landform style */ spiketilt = TRUE; /* Flag */ recalc_scale = TRUE; /* its NOT fixed YET. (done dynamically) */ recalc_markers = TRUE; /* its NOT fixed YET. (done dynamically) */ show_leader = TRUE; /* show leading edge on 3d landscape fft */ multiplier = 26.0; /* Level multiplier, fft amplitude adj */ noise_floor = -80; /* FFT noise floor position. (NEEDS WORK!!!) */ /* WON'T max out when you resize */ dir_win_present = TRUE; /* Direction control window */ grad_win_present = FALSE; /* Color picker window */ height = 480; /* Self explanitory */ width = 640; /* Self explanitory */ buffer_area_height = 100; /* Self explanitory */ buffer_area_width = 400; /* Self explanitory */ dir_width = 100; /* Self explanitory */ dir_height = 100; /* Self explanitory */ main_x_origin = 40; /* window locations on screen */ main_y_origin = 40; /* window locations on screen */ dir_x_origin = width + 0; dir_y_origin = 0; grad_x_origin = width + 0; grad_y_origin = dir_y_origin + dir_height; tape_scroll = 2; horiz_spec_start = 80; /* 60 from right edge of screen */ vert_spec_start = 135; /* 120 from BOTTOM of the screen, unconventional */ scope_sync_source = SYNC_LEFT; paused = FALSE; /* display running */ low_freq = 0; /* Low frequency cutoff in hi-res displays */ high_freq = 22050; /* Low frequency cutoff in hi-res displays */ clear_display = FALSE; /* Flag for markers */ /* Color presets (default colormap) */ // printf("eXtace version is %i.%i.%i\n",_MAJOR_,_MINOR_,_MICRO_); }
weed_plant_t *weed_setup(weed_bootstrap_f weed_boot) { weed_plant_t *plugin_info=weed_plugin_info_init(weed_boot,num_versions,api_versions); if (plugin_info!=NULL) { weed_plant_t *in_params[P_END+1],*gui; weed_plant_t *filter_class; PangoContext *ctx; const char *modes[]= {"Spiral text","Spinning letters","Letter starfield","Word coalesce",NULL}; char *rfx_strings[]= {"special|fileread|0|"}; char *deftextfile; int palette_list[2]; weed_plant_t *in_chantmpls[2]; weed_plant_t *out_chantmpls[2]; int flags,error; if (is_big_endian()) palette_list[0]=WEED_PALETTE_ARGB32; else palette_list[0]=WEED_PALETTE_BGRA32; palette_list[1]=WEED_PALETTE_END; in_chantmpls[0]=weed_channel_template_init("in channel 0",0,palette_list); in_chantmpls[1]=NULL; out_chantmpls[0]=weed_channel_template_init("out channel 0",WEED_CHANNEL_CAN_DO_INPLACE,palette_list); out_chantmpls[1]=NULL; init_unal(); // this section contains code // for configure fonts available num_fonts_available = 0; fonts_available = NULL; ctx = gdk_pango_context_get(); if (ctx) { PangoFontMap *pfm = pango_context_get_font_map(ctx); if (pfm) { int num = 0; PangoFontFamily **pff = NULL; pango_font_map_list_families(pfm, &pff, &num); if (num > 0) { // we should reserve num+1 for a final NULL pointer fonts_available = (char **)weed_malloc((num+1)*sizeof(char *)); if (fonts_available) { register int i; num_fonts_available = num; for (i = 0; i < num; ++i) { fonts_available[i] = strdup(pango_font_family_get_name(pff[i])); } // don't forget this thing fonts_available[num] = NULL; } } g_free(pff); } g_object_unref(ctx); } deftextfile=g_build_filename(g_get_home_dir(), "livestext.txt", NULL); in_params[P_TEXT]=weed_text_init("textfile","_Text file",deftextfile); gui=weed_parameter_template_get_gui(in_params[P_TEXT]); weed_set_int_value(gui,"maxchars",80); // for display only - fileread will override this flags=0; if (weed_plant_has_leaf(in_params[P_TEXT],"flags")) flags=weed_get_int_value(in_params[P_TEXT],"flags",&error); flags|=WEED_PARAMETER_REINIT_ON_VALUE_CHANGE; weed_set_int_value(in_params[P_TEXT],"flags",flags); in_params[P_MODE]=weed_string_list_init("mode","Effect _mode",0,modes); flags=0; if (weed_plant_has_leaf(in_params[P_MODE],"flags")) flags=weed_get_int_value(in_params[P_MODE],"flags",&error); flags|=WEED_PARAMETER_REINIT_ON_VALUE_CHANGE; weed_set_int_value(in_params[P_MODE],"flags",flags); in_params[P_END]=NULL; g_free(deftextfile); filter_class=weed_filter_class_init("puretext","Salsaman & Aleksej Penkov",1,0,&puretext_init,&puretext_process,NULL, in_chantmpls,out_chantmpls,in_params,NULL); gui=weed_filter_class_get_gui(filter_class); weed_set_string_value(gui,"layout_scheme","RFX"); weed_set_string_value(gui,"rfx_delim","|"); weed_set_string_array(gui,"rfx_strings",1,rfx_strings); weed_plugin_info_add_filter_class(plugin_info,filter_class); weed_set_int_value(plugin_info,"version",package_version); } return plugin_info; }
static void render_logo (void) { ClutterActor *image; ClutterActor *text, *text_shadow; ClutterActor *desc, *desc_shadow; ClutterColor actor_color = {0xff,0xff,0xff,0xff}; ClutterColor shadow_color = {0x00, 0x00, 0x00, 0x88}; ClutterActor *text_group; static gint width, height; gint size; gfloat stage_w, stage_h; PangoFontDescription *pfd; PangoLayout *layout; PangoContext *context; gchar *nibbles = _("Nibbles"); /* Translators: This string will be included in the intro screen, so don't make sure it fits! */ gchar *description = _("A worm game for MATE."); logo = clutter_group_new (); text_group = clutter_group_new (); if (!logo_pixmap) gnibbles_load_logo (properties->tilesize); image = gtk_clutter_texture_new_from_pixbuf (logo_pixmap); stage_w = board->width * properties->tilesize; stage_h = board->height * properties->tilesize; clutter_actor_set_size (CLUTTER_ACTOR (image), stage_w, stage_h); clutter_actor_set_position (CLUTTER_ACTOR (image), 0, 0); clutter_actor_show (image); text = clutter_text_new (); clutter_text_set_color (CLUTTER_TEXT (text), &actor_color); context = gdk_pango_context_get (); layout = clutter_text_get_layout (CLUTTER_TEXT (text)); pfd = pango_context_get_font_description (context); size = pango_font_description_get_size (pfd); pango_font_description_set_size (pfd, (size * stage_w) / 100); pango_font_description_set_family (pfd, "Sans"); pango_font_description_set_weight(pfd, PANGO_WEIGHT_BOLD); pango_layout_set_font_description (layout, pfd); pango_layout_set_text (layout, nibbles, -1); pango_layout_get_pixel_size (layout, &width, &height); text_shadow = clutter_text_new (); clutter_text_set_color (CLUTTER_TEXT (text_shadow), &shadow_color); layout = clutter_text_get_layout (CLUTTER_TEXT (text_shadow)); pango_layout_set_font_description (layout, pfd); pango_layout_set_text (layout, nibbles, -1); clutter_actor_set_position (CLUTTER_ACTOR (text), (stage_w - width) * 0.5 , stage_h * .72); clutter_actor_set_position (CLUTTER_ACTOR (text_shadow), (stage_w - width) * 0.5 + 5, stage_h * .72 + 5); desc = clutter_text_new (); layout = clutter_text_get_layout (CLUTTER_TEXT (desc)); clutter_text_set_color (CLUTTER_TEXT (desc), &actor_color); pango_font_description_set_size (pfd, (size * stage_w) / 400); pango_layout_set_font_description (layout, pfd); pango_layout_set_text (layout, description, -1); pango_layout_get_pixel_size(layout, &width, &height); desc_shadow = clutter_text_new (); layout = clutter_text_get_layout (CLUTTER_TEXT (desc_shadow)); clutter_text_set_color (CLUTTER_TEXT (desc_shadow), &shadow_color); pango_font_description_set_size (pfd, (size * stage_w) / 400); pango_layout_set_font_description (layout, pfd); pango_layout_set_text (layout, description, -1); clutter_actor_set_position (CLUTTER_ACTOR (desc), (stage_w - width) * 0.5, stage_h* .93); clutter_actor_set_position (CLUTTER_ACTOR (desc_shadow), (stage_w - width) * 0.5 + 3, stage_h * .93 + 3); clutter_container_add (CLUTTER_CONTAINER (text_group), CLUTTER_ACTOR (text_shadow), CLUTTER_ACTOR (text), CLUTTER_ACTOR (desc_shadow), CLUTTER_ACTOR (desc), NULL); clutter_container_add (CLUTTER_CONTAINER (logo), CLUTTER_ACTOR (image), CLUTTER_ACTOR (text_group), NULL); clutter_actor_set_opacity (CLUTTER_ACTOR (text_group), 0); clutter_actor_set_scale (CLUTTER_ACTOR (text_group), 0.0, 0.0); clutter_actor_animate (text_group, CLUTTER_EASE_OUT_CIRC, 800, "opacity", 0xff, "scale-x", 1.0, "scale-y", 1.0, "fixed::scale-center-y", stage_w / 2, "fixed::scale-center-x", stage_h / 2, NULL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (logo)); }
void iupdrvFontInit(void) { gtk_fonts = iupArrayCreate(50, sizeof(IgtkFont)); gtk_fonts_context = gdk_pango_context_get(); pango_context_set_language(gtk_fonts_context, gtk_get_default_language()); }
int mozilla_decoders_init(void) { static PRBool initialized = PR_FALSE; if (initialized) return 0; PangoContext* context = gdk_pango_context_get (); PangoFontMap* fontmap = pango_context_get_font_map (context); g_object_unref (context); if (!PANGO_IS_FC_FONT_MAP (fontmap)) return -1; encoder_hash = g_hash_table_new(g_str_hash, g_str_equal); cmap_hash = g_hash_table_new(g_str_hash, g_str_equal); wide_hash = g_hash_table_new(g_str_hash, g_str_equal); PRBool dumb = PR_FALSE; nsCOMPtr<nsIPersistentProperties> props; nsCOMPtr<nsISimpleEnumerator> encodeEnum; NS_LoadPersistentPropertiesFromURISpec(getter_AddRefs(props), NS_LITERAL_CSTRING("resource://gre/res/fonts/pangoFontEncoding.properties")); if (!props) goto loser; // Enumerate the properties in this file and figure out all of the // fonts for which we have custom encodings. props->Enumerate(getter_AddRefs(encodeEnum)); if (!encodeEnum) goto loser; while (encodeEnum->HasMoreElements(&dumb), dumb) { nsCOMPtr<nsIPropertyElement> prop; encodeEnum->GetNext(getter_AddRefs(prop)); if (!prop) goto loser; nsCAutoString name; prop->GetKey(name); nsAutoString value; prop->GetValue(value); if (!StringBeginsWith(name, NS_LITERAL_CSTRING("encoding."))) { printf("string doesn't begin with encoding?\n"); continue; } name = Substring(name, 9); if (StringEndsWith(name, NS_LITERAL_CSTRING(".ttf"))) { name = Substring(name, 0, name.Length() - 4); // Strip off a .wide if it's there. if (StringEndsWith(value, NS_LITERAL_STRING(".wide"))) { g_hash_table_insert(wide_hash, g_strdup(name.get()), g_strdup("wide")); value = Substring(value, 0, name.Length() - 5); } g_hash_table_insert(encoder_hash, g_strdup(name.get()), g_strdup(NS_ConvertUTF16toUTF8(value).get())); } else if (StringEndsWith(name, NS_LITERAL_CSTRING(".ftcmap"))) { name = Substring(name, 0, name.Length() - 7); g_hash_table_insert(cmap_hash, g_strdup(name.get()), g_strdup(NS_ConvertUTF16toUTF8(value).get())); } else { printf("unknown suffix used for mapping\n"); } } pango_fc_font_map_add_decoder_find_func(PANGO_FC_FONT_MAP(fontmap), mozilla_find_decoder, NULL, NULL); initialized = PR_TRUE; #ifdef DEBUG_CUSTOM_ENCODER printf("*** encoders\n"); g_hash_table_foreach(encoder_hash, (GHFunc)dump_hash, NULL); printf("*** cmaps\n"); g_hash_table_foreach(cmap_hash, (GHFunc)dump_hash, NULL); #endif return 0; loser: return -1; }
static void table_show_player_box(int player, int write_to_screen) { int x, y, w, h; const char *name = player_names[player]; const char *message = player_messages[player]; int string_y; int max_width = 0; static PangoLayout *layout = NULL; PangoRectangle rect; GdkGC *gc = table_style->fg_gc[GTK_WIDGET_STATE(table)]; static int max_height = 0; assert(table_ready); if (!layout) { /* This variable is static so we only allocate it once. */ layout = pango_layout_new(gdk_pango_context_get()); } pango_layout_set_font_description(layout, table_style->font_desc); get_text_box_pos(player, &x, &y); x++; y++; /* Clear the text box */ gdk_draw_rectangle(table_buf, table_style->bg_gc[GTK_WIDGET_STATE(table)], TRUE, x, y, TEXT_BOX_WIDTH - 1, TEXT_BOX_WIDTH - 1); x += XWIDTH; y += XWIDTH; w = h = TEXT_WIDTH; string_y = y; /* The y values we're going to draw at. */ /* Draw the name. */ if (name) { assert(strchr(name, '\n') == NULL); pango_layout_set_text(layout, name, -1); pango_layout_get_pixel_extents(layout, NULL, &rect); max_width = MAX(max_width, rect.width); max_height = MAX(max_height, rect.height); gdk_draw_layout(table_buf, gc, x + (w - rect.width) / 2, string_y, layout); string_y += max_height + 5; } /* Draw player message. */ if (message) { char *my_message = ggz_strdup(message); char *next = my_message; /* This is so ugly!! Is there no better way?? */ do { char *next_after_this = strchr(next, '\n'); if (next_after_this) { *next_after_this = '\0'; next_after_this++; } string_y += 3; pango_layout_set_text(layout, next, -1); pango_layout_get_pixel_extents(layout, NULL, &rect); max_height = MAX(max_height, rect.height); max_width = MAX(max_width, rect.width); gdk_draw_layout(table_buf, gc, x + 3, string_y, layout); string_y += rect.height; next = next_after_this; } while (next && *next); ggz_free(my_message); } /* FIXME: we shouldn't call table_setup() from *within* the drawing code */ if (set_min_text_width(string_y - y) || set_min_text_width(max_width)) { table_setup(); } if (write_to_screen) table_show_table(x, y, TEXT_BOX_WIDTH - 1, TEXT_BOX_WIDTH - 1); }