Ejemplo n.º 1
0
void pangox_layout_set_font_face(PangoLayout *layout, OutputFontFace face)
{
    if (layout != NULL) {
        const PangoFontDescription *old_font;
        PangoFontDescription *new_font;

        if ((old_font = pango_layout_get_font_description(layout)) == NULL) {
            PangoContext *context = pango_layout_get_context(layout);
            new_font = pango_font_description_copy(pango_context_get_font_description(context));
        }
        else {
            new_font = pango_font_description_copy(old_font);
        }
        switch (face) {
            case PS_FONT_SANS: {
                pango_font_description_set_family(new_font, "Sans");
                break;
            }
            case PS_FONT_SERIF: {
                pango_font_description_set_family(new_font, "Serif");
                break;
            }
            default: {
                pango_font_description_set_family(new_font, "Fixed");
                break;
            }
	}
        pango_layout_set_font_description(layout, new_font);
        pango_font_description_free(new_font);
    }
}
static void pf_setFamily(JNIEnv* env, jclass, jlong obj, jstring family) {
    if (!obj) return;
    PangoFontDescription* desc = reinterpret_cast<PangoFontDescription*>(obj);
    if (!family) {
        pango_font_description_set_family(desc, "");
        return;
    }
    const char* cfamily = env->GetStringUTFChars(family, nullptr);
    pango_font_description_set_family(desc, cfamily);
    env->ReleaseStringUTFChars(family, cfamily);
}
Ejemplo n.º 3
0
void wxFontRefData::Init(int pointSize,
                         wxFontFamily family,
                         wxFontStyle style,
                         wxFontWeight weight,
                         bool underlined,
                         const wxString& faceName,
                         wxFontEncoding encoding)
{
    m_family = family == wxFONTFAMILY_DEFAULT ? wxFONTFAMILY_SWISS : family;

    m_underlined = underlined;
    m_encoding = encoding;
    if ( m_encoding == wxFONTENCODING_DEFAULT )
        m_encoding = wxFont::GetDefaultEncoding();

    m_noAA = false;

    // Create native font info
    m_nativeFontInfo.description = pango_font_description_new();

    // And set its values
    if (!faceName.empty())
    {
       pango_font_description_set_family( m_nativeFontInfo.description,
                                           wxGTK_CONV_SYS(faceName) );
    }
    else
    {
        switch (m_family)
        {
            case wxFONTFAMILY_MODERN:
            case wxFONTFAMILY_TELETYPE:
               pango_font_description_set_family( m_nativeFontInfo.description, "monospace" );
               break;
            case wxFONTFAMILY_ROMAN:
               pango_font_description_set_family( m_nativeFontInfo.description, "serif" );
               break;
            case wxFONTFAMILY_SWISS:
               // SWISS = sans serif
            default:
               pango_font_description_set_family( m_nativeFontInfo.description, "sans" );
               break;
        }
    }

    SetStyle( style == wxDEFAULT ? wxFONTSTYLE_NORMAL : style );
    SetPointSize( (pointSize == wxDEFAULT || pointSize == -1)
                    ? wxDEFAULT_FONT_SIZE
                    : pointSize );
    SetWeight( weight == wxDEFAULT ? wxFONTWEIGHT_NORMAL : weight );
}
Ejemplo n.º 4
0
void wxFontRefData::Init(int pointSize,
                         int family,
                         int style,
                         int weight,
                         bool underlined,
                         const wxString& faceName,
                         wxFontEncoding encoding)
{
    m_family = family == wxFONTFAMILY_DEFAULT ? wxFONTFAMILY_SWISS : family;

    m_faceName = faceName;

    // we accept both wxDEFAULT and wxNORMAL here - should we?
    m_style = style == wxDEFAULT ? wxFONTSTYLE_NORMAL : style;
    m_weight = weight == wxDEFAULT ? wxFONTWEIGHT_NORMAL : weight;

    // and here, do we really want to forbid creation of the font of the size
    // 90 (the value of wxDEFAULT)??
    m_pointSize = pointSize == wxDEFAULT || pointSize == -1
                    ? wxDEFAULT_FONT_SIZE
                    : pointSize;

    m_underlined = underlined;
    m_encoding = encoding;

#if wxUSE_UNICODE
    // Create native font info
    m_nativeFontInfo.description = pango_font_description_new();

    // And set its values
    switch (m_family)
    {
        case wxFONTFAMILY_MODERN:
        case wxFONTFAMILY_TELETYPE:
           pango_font_description_set_family( m_nativeFontInfo.description, "monospace" );
           break;
        case wxFONTFAMILY_SWISS:
           pango_font_description_set_family( m_nativeFontInfo.description, "serif" );
           break;
        default:
           pango_font_description_set_family( m_nativeFontInfo.description, "sans" );
           break;
    }
    SetStyle( m_style );
    SetPointSize( m_pointSize );
    SetWeight( m_weight );
#endif
}
Ejemplo n.º 5
0
G_MODULE_EXPORT void 
gw_settingswindow_sync_global_document_font_cb (GSettings *settings, gchar *KEY, gpointer data)
{
    //Declarations
    GwSettingsWindow *window;
    GwSettingsWindowPrivate *priv;
    GwApplication *application;
    LwPreferences *preferences;
    gchar font[50];
    gchar *font2;
    gchar *text;
    PangoFontDescription *desc;

    //Initializations
    window = GW_SETTINGSWINDOW (data);
    g_return_if_fail (window != NULL);
    priv = window->priv;
    application = gw_window_get_application (GW_WINDOW (window));
    preferences = gw_application_get_preferences (application);
    lw_preferences_get_string_by_schema (preferences, font, LW_SCHEMA_GNOME_INTERFACE, LW_KEY_DOCUMENT_FONT_NAME, 50);
    desc = pango_font_description_from_string (font);
    pango_font_description_set_family (desc, "Serif");
    font2 = pango_font_description_to_string (desc);
    if (font2) text = g_strdup_printf (gettext("_Use the System Document Font (%s)"), font2);
    g_free (font2); font2 = NULL;
    pango_font_description_free (desc); desc = NULL;

    if (text != NULL) 
    {
      gtk_button_set_label (GTK_BUTTON (priv->system_font_checkbutton), text);
      g_free (text);
    }
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
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);
	
}
Ejemplo n.º 8
0
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;
}
Ejemplo n.º 9
0
/* {EV_FONT_IMP}.set_face_name */
void F1035_13190 (EIF_REFERENCE Current, EIF_REFERENCE arg1)
{
	GTCX
	EIF_REFERENCE loc1 = (EIF_REFERENCE) 0;
	EIF_POINTER tp1;
	EIF_POINTER tp2;
	EIF_REFERENCE tr1 = NULL;
	RTLD;
	
	RTLI(4);
	RTLR(0,Current);
	RTLR(1,arg1);
	RTLR(2,tr1);
	RTLR(3,loc1);
	
	RTGC;
	tr1 = F920_10294(RTCV(arg1));
	RTAR(Current, tr1);
	*(EIF_REFERENCE *)(Current + _REFACS_2_) = (EIF_REFERENCE) tr1;
	tr1 = RTOSCF(13229,F1035_13229,(Current));
	loc1 = F1049_13651(RTCV(tr1), arg1);
	tp1 = *(EIF_POINTER *)(Current+ _PTROFF_3_2_0_8_0_0_);
	tp2 = *(EIF_POINTER *)(RTCV(loc1)+ _PTROFF_0_1_0_1_0_0_);
	pango_font_description_set_family((PangoFontDescription*) tp1, (char*) tp2);
	F1035_13198(Current);
	RTLE;
}
Ejemplo n.º 10
0
JNIEXPORT void JNICALL
Java_org_gnome_pango_PangoFontDescription_pango_1font_1description_1set_1family
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jstring _family
)
{
	PangoFontDescription* self;
	const char* family;

	// convert parameter self
	self = (PangoFontDescription*) _self;

	// convert parameter family
	family = (const char*) bindings_java_getString(env, _family);
	if (family == NULL) {
		return; // Java Exception already thrown
	}

	// call function
	pango_font_description_set_family(self, family);

	// cleanup parameter self

	// cleanup parameter family
	bindings_java_releaseString(family);
}
/*!
* \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);
	}
}
Ejemplo n.º 12
0
void wxFontRefData::Init(int pointSize,
                         wxFontFamily family,
                         wxFontStyle style,
                         wxFontWeight weight,
                         bool underlined,
                         bool strikethrough,
                         const wxString& faceName,
                         wxFontEncoding WXUNUSED(encoding))
{
    if (family == wxFONTFAMILY_DEFAULT)
        family = wxFONTFAMILY_SWISS;

    m_underlined = underlined;
    m_strikethrough = strikethrough;

    // Create native font info
    m_nativeFontInfo.description = pango_font_description_new();

    // And set its values
    if (!faceName.empty())
    {
        pango_font_description_set_family( m_nativeFontInfo.description,
                                           wxGTK_CONV_SYS(faceName) );
    }
    else
    {
        SetFamily(family);
    }

    SetStyle( style == wxDEFAULT ? wxFONTSTYLE_NORMAL : style );
    SetPointSize( (pointSize == wxDEFAULT || pointSize == -1)
                    ? wxDEFAULT_FONT_SIZE
                    : pointSize );
    SetWeight( weight == wxDEFAULT ? wxFONTWEIGHT_NORMAL : weight );
}
Ejemplo n.º 13
0
/* compose_get_font */
static char const * _compose_get_font(Compose * compose)
{
	char const * p;
	char * q;
	GtkSettings * settings;
	PangoFontDescription * desc;

	if((p = config_get(compose->config, NULL, "messages_font")) != NULL)
		return p;
	settings = gtk_settings_get_default();
	g_object_get(G_OBJECT(settings), "gtk-font-name", &q, NULL);
	if(q != NULL)
	{
		desc = pango_font_description_from_string(q);
		g_free(q);
		pango_font_description_set_family(desc, "monospace");
		q = pango_font_description_to_string(desc);
		config_set(compose->config, NULL, "messages_font", q);
		g_free(q);
		pango_font_description_free(desc);
		if((p = config_get(compose->config, NULL, "messages_font"))
				!= NULL)
			return p;
	}
	return MAILER_MESSAGES_FONT;
}
Ejemplo n.º 14
0
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;
}
Ejemplo n.º 15
0
int main(int argc, char **argv)
{
  GtkWidget *win;
  GtkButton *button;
  PangoFontDescription *pd;

  gtk_init(&argc, &argv);
  win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(win), "Basic Animation");
  g_signal_connect(G_OBJECT(win), "delete-event", gtk_main_quit, NULL);

  label = (GtkLabel *)gtk_label_new(hello);

  // since we shift a whole character per time, it's better to use
  // a monospace font, so that the shifting seems done at the same pace
  pd = pango_font_description_new();
  pango_font_description_set_family(pd, "monospace");
  gtk_widget_modify_font(GTK_WIDGET(label), pd);

  button = (GtkButton *)gtk_button_new();
  gtk_container_add(GTK_CONTAINER(button), GTK_WIDGET(label));

  gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(button));
  g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(change_dir), NULL);

  slen = strlen(hello);

  g_timeout_add(125, scroll_it, NULL);

  gtk_widget_show_all(GTK_WIDGET(win));
  gtk_main();
  return 0;
}
Ejemplo n.º 16
0
Archivo: view.c Proyecto: mrirecon/view
static void add_text(cairo_surface_t* surface, int x, int y, int size, const char* text)
{
	cairo_t* cr = cairo_create(surface);
	cairo_set_source_rgb(cr, 1., 1., 1.);

	PangoLayout* layout = pango_cairo_create_layout(cr);
	pango_layout_set_text(layout, text, -1);
	PangoFontDescription* desc = pango_font_description_new();
	pango_font_description_set_family(desc, "sans");
	pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
	pango_font_description_set_absolute_size(desc, size * PANGO_SCALE);
	pango_layout_set_font_description(layout, desc);
	pango_font_description_free(desc);

	int w = 0;
	int h = 0;
	pango_layout_get_pixel_size(layout, &w, &h);

	cairo_move_to(cr, (x >= 0) ? x : -(x + (double)w),
			  (y >= 0) ? y : -(y + (double)h));

	pango_cairo_show_layout(cr, layout);

	g_object_unref(layout);
	cairo_destroy(cr);
}
Ejemplo n.º 17
0
font_instance *font_factory::FaceFromDescr(char const *family, char const *style)
{
    PangoFontDescription *temp_descr = pango_font_description_from_string(style);
    pango_font_description_set_family(temp_descr,family);
    font_instance *res = Face(temp_descr);
    pango_font_description_free(temp_descr);
    return res;
}
Ejemplo n.º 18
0
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);
}
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 ();
}
Ejemplo n.º 20
0
bool wxNativeFontInfo::SetFaceName(const wxString& facename)
{
    pango_font_description_set_family(description, wxPANGO_CONV(facename));

    // we return true because Pango doesn't tell us if the call failed or not;
    // instead on wxGTK wxFont::SetFaceName() will call wxFontBase::SetFaceName()
    // which does the check
    return true;
}
Ejemplo n.º 21
0
static struct fontmap *
loadfont(char *fontalias, int font_style, int *symbol)
{
  struct fontmap *fcur;
  PangoFontDescription *pfont;
  PangoStyle style;
  PangoWeight weight;

  *symbol = FALSE;

  if (nhash_get_ptr(Gra2cairoConf->fontmap, fontalias, (void *) &fcur)) {
    int i;

    if (nhash_get_int(CompatibleFontHash, fontalias, &i) == 0) {
      if (nhash_get_ptr(Gra2cairoConf->fontmap, CompatibleFont[i].name, (void *) &fcur) == 0) {
	font_style = CompatibleFont[i].style;
	*symbol = CompatibleFont[i].symbol;
      }
    }
    if (fcur == NULL && nhash_get_ptr(Gra2cairoConf->fontmap, DEFAULT_FONT, (void *) &fcur)) {
      return NULL;
    }
  }

  if (fcur->font) {
    pfont = fcur->font;
  } else {
    gchar *ptr;
    pfont = pango_font_description_new();

    ptr = g_strdup_printf("%s%s%s", fcur->fontname, (fcur->alternative) ? "," : "", CHK_STR(fcur->alternative));
    if (ptr) {
      pango_font_description_set_family(pfont, ptr);
      g_free(ptr);
    } else {
      return NULL;
    }
  }

  if (font_style > 0 && (font_style & GRA_FONT_STYLE_ITALIC)) {
    style = PANGO_STYLE_ITALIC;
  } else {
    style = PANGO_STYLE_NORMAL;
  }
  pango_font_description_set_style(pfont, style);

  if (font_style > 0 && (font_style & GRA_FONT_STYLE_BOLD)) {
    weight = PANGO_WEIGHT_BOLD;
  } else {
    weight = PANGO_WEIGHT_NORMAL;
  }
  pango_font_description_set_weight(pfont, weight);

  fcur->font = pfont;

  return fcur;
}
Ejemplo n.º 22
0
void
set_family (GtkWidget *entry, gpointer data)
{
  gchar *family_name = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
  if (!family_name || family_name[0] == '\0')
    return;
  pango_font_description_set_family(font_description, family_name);
  fill_styles_combo (styles_combo);
}
Ejemplo n.º 23
0
Archivo: font.c Proyecto: rennhak/Dia
static void
dia_pfd_set_family(PangoFontDescription* pfd, DiaFontFamily fam) 
{
  switch (fam) {
  case DIA_FONT_SANS :
    pango_font_description_set_family(pfd, "sans");
    break;
  case DIA_FONT_SERIF :
    pango_font_description_set_family(pfd, "serif");
    break;
  case DIA_FONT_MONOSPACE :
    pango_font_description_set_family(pfd, "monospace");
    break;
  default :
    /* Pango does _not_ allow fonts without a name (or at least they are not useful) */
    pango_font_description_set_family(pfd, "sans");
    break;
  }
}
Ejemplo n.º 24
0
void Picture::set_font(const char *family, int height) {
    if (font_description == NULL) {
        font_description = pango_font_description_new( );
    }

    pango_font_description_set_family(font_description, family);
    pango_font_description_set_weight(font_description, PANGO_WEIGHT_BOLD);
    pango_font_description_set_absolute_size(font_description, height * PANGO_SCALE);

}
Ejemplo n.º 25
0
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;
}
    void start()
    {
        cairo_surface_t* cairo_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, m_width, m_height);
        cairo_t* cr = cairo_create(cairo_surface);

        cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0);
        cairo_paint(cr);

        PangoFontDescription *font_description = pango_font_description_new();
        pango_font_description_set_family(font_description, m_font.Family.c_str());
        pango_font_description_set_style(font_description, m_font.Style);
        pango_font_description_set_weight(font_description, m_font.Weight);
        pango_font_description_set_variant(font_description, m_font.Variant);
        pango_font_description_set_size(font_description, m_font.Size * PANGO_SCALE);

        PangoLayout *layout = pango_cairo_create_layout(cr);
        pango_layout_set_font_description(layout, font_description);
        pango_layout_set_text(layout, m_text_file.file_content_p(), -1);

        unsigned char* color = m_font.ColorRGB; // shortcut
        cairo_set_source_rgb(cr, color[0] / 255.0, color[1] / 255.0, color[2] / 255.0);
        cairo_move_to(cr, 0.0, 0.0);
        pango_cairo_show_layout(cr, layout);

        // To texture
        {
            cairo_surface_flush(cairo_surface);
            std::vector<unsigned char> rgba_data;
            rgba_from_cairo_ARGB32(
                cairo_image_surface_get_data(cairo_surface)
                , m_width
                , m_height
                , cairo_image_surface_get_stride(cairo_surface)
                , rgba_data
            );

            glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );
            m_texture.bind();

            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &(rgba_data[0]));

            assert(glGetError() == GL_NO_ERROR);

            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
            assert(glGetError() == GL_NO_ERROR);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
            assert(glGetError() == GL_NO_ERROR);
        }

        g_object_unref(layout);
        pango_font_description_free(font_description);

        cairo_destroy(cr);
        cairo_surface_destroy(cairo_surface);
    }
Ejemplo n.º 27
0
RrFont *RrFontOpen(const RrInstance *inst, const gchar *name, gint size,
                   RrFontWeight weight, RrFontSlant slant)
{
    RrFont *out;
    PangoWeight pweight;
    PangoStyle pstyle;
    PangoAttrList *attrlist;

    out = g_slice_new(RrFont);
    out->inst = inst;
    out->ref = 1;
    out->font_desc = pango_font_description_new();
    out->layout = pango_layout_new(inst->pango);
    out->shortcut_underline = pango_attr_underline_new(PANGO_UNDERLINE_LOW);
    out->shortcut_underline->start_index = 0;
    out->shortcut_underline->end_index = 0;

    attrlist = pango_attr_list_new();
    /* shortcut_underline is owned by the attrlist */
    pango_attr_list_insert(attrlist, out->shortcut_underline);
    /* the attributes are owned by the layout */
    pango_layout_set_attributes(out->layout, attrlist);
    pango_attr_list_unref(attrlist);

    switch (weight) {
    case RR_FONTWEIGHT_LIGHT:     pweight = PANGO_WEIGHT_LIGHT;     break;
    case RR_FONTWEIGHT_NORMAL:    pweight = PANGO_WEIGHT_NORMAL;    break;
    case RR_FONTWEIGHT_SEMIBOLD:  pweight = PANGO_WEIGHT_SEMIBOLD;  break;
    case RR_FONTWEIGHT_BOLD:      pweight = PANGO_WEIGHT_BOLD;      break;
    case RR_FONTWEIGHT_ULTRABOLD: pweight = PANGO_WEIGHT_ULTRABOLD; break;
    default: g_assert_not_reached();
    }

    switch (slant) {
    case RR_FONTSLANT_NORMAL:  pstyle = PANGO_STYLE_NORMAL;    break;
    case RR_FONTSLANT_ITALIC:  pstyle = PANGO_STYLE_ITALIC;    break;
    case RR_FONTSLANT_OBLIQUE: pstyle = PANGO_STYLE_OBLIQUE;   break;
    default: g_assert_not_reached();
    }

    /* setup the font */
    pango_font_description_set_family(out->font_desc, name);
    pango_font_description_set_weight(out->font_desc, pweight);
    pango_font_description_set_style(out->font_desc, pstyle);
    pango_font_description_set_size(out->font_desc, size * PANGO_SCALE);

    /* setup the layout */
    pango_layout_set_font_description(out->layout, out->font_desc);
    pango_layout_set_wrap(out->layout, PANGO_WRAP_WORD_CHAR);

    /* get the ascent and descent */
    measure_font(inst, out);

    return out;
}
Ejemplo n.º 28
0
PangoFontDescription* GetPangoFontDescription(const char* font, int size, int dpi)
{
    PangoFontDescription* desc;
    desc = pango_font_description_new();
    if (dpi)
        pango_font_description_set_size(desc, size * PANGO_SCALE);
    else
        pango_font_description_set_absolute_size(desc, size * PANGO_SCALE);
    pango_font_description_set_family(desc, font);
    return desc;
}
Ejemplo n.º 29
0
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");
  }
}
Ejemplo n.º 30
0
font_instance *font_factory::Face(char const *family, int variant, int style, int weight, int stretch, int /*size*/, int /*spacing*/)
{
    PangoFontDescription *temp_descr = pango_font_description_new();
    pango_font_description_set_family(temp_descr,family);
    pango_font_description_set_weight(temp_descr,(PangoWeight)weight);
    pango_font_description_set_stretch(temp_descr,(PangoStretch)stretch);
    pango_font_description_set_style(temp_descr,(PangoStyle)style);
    pango_font_description_set_variant(temp_descr,(PangoVariant)variant);
    font_instance *res = Face(temp_descr);
    pango_font_description_free(temp_descr);
    return res;
}