Exemplo n.º 1
0
static void okAction(Widget widget, xfselControlBlkType *ctrlBlk,
                 XmPushButtonCallbackStruct *call_data)
{
    char    *fontPattern;
    char    **fontName;
    int i;

    fontPattern = XmTextGetString(ctrlBlk->fontNameField);
    fontName    = XListFonts(XtDisplay(ctrlBlk->form), fontPattern, 1, &i);
    XtFree(fontPattern);
    
    if (i != 1)
    {
        DialogF (DF_ERR, ctrlBlk->okButton, 1, "Font Specification",
                "Invalid Font Specification", "OK");
        XFreeFontNames(fontName);
    }
    else
    {
        XtFree(ctrlBlk->fontName);
        ctrlBlk->fontName = XtMalloc(strlen(fontName[0]) + 1);
        strcpy(ctrlBlk->fontName, fontName[0]);

        XtFree(ctrlBlk->sel1);
        XtFree(ctrlBlk->sel2);
        XtFree(ctrlBlk->sel3);
    
        XFreeFontNames(fontName);
        XFreeFontNames(ctrlBlk->fontData);

        ctrlBlk->exitFlag = TRUE;
    }
}
Exemplo n.º 2
0
static void startupFont(xfselControlBlkType *ctrlBlk, const char *font)
{
    int         i;
    char        **fontName;
    char        part[TEMP_BUF_SIZE];
    XmString    str;

    fontName = XListFonts(XtDisplay(ctrlBlk->form), font, 1, &i);

    if (i == 0)
    {           /*  invalid font passed in at startup */
        XFreeFontNames(fontName);
        return;
    }

    ctrlBlk->fontName = XtMalloc(strlen(fontName[0]) + 1);
    strcpy(ctrlBlk->fontName, fontName[0]);

    getFontPart(fontName[0], part);
    XFreeFontNames(fontName);
    str = XmStringCreate(part, XmSTRING_DEFAULT_CHARSET);
    XmListSetBottomItem(ctrlBlk->fontList, str);
    XmListSelectItem(ctrlBlk->fontList, str, TRUE);
    XmListSelectItem(ctrlBlk->fontList, str, TRUE);
    XmStringFree(str);

    dispSample(ctrlBlk);
    XmTextSetString(ctrlBlk->fontNameField, ctrlBlk->fontName);
}
Exemplo n.º 3
0
/*ARGSUSED*/
    static void
ok_callback(Widget w,
	SharedFontSelData *data,
	XmPushButtonCallbackStruct *call_data)
{
    char    *pattern;
    char    **name;
    int	    i;

    pattern = XmTextGetString(data->name);
    name    = XListFonts(XtDisplay(data->dialog), pattern, 1, &i);
    XtFree(pattern);

    if (i != 1)
    {
	do_dialog(VIM_ERROR,
		(char_u *)_("Error"),
		(char_u *)_("Invalid font specification"),
		(char_u *)_("&Dismiss"), 1, NULL);
	XFreeFontNames(name);
    }
    else
    {
	if (data->font_name)
	    XtFree(data->font_name);
	data->font_name = XtNewString(name[0]);

	if (data->sel[ENCODING])
	{
	    XtFree(data->sel[ENCODING]);
	    data->sel[ENCODING] = NULL;
	}
	if (data->sel[NAME])
	{
	    XtFree(data->sel[NAME]);
	    data->sel[NAME] = NULL;
	}
	if (data->sel[STYLE])
	{
	    XtFree(data->sel[STYLE]);
	    data->sel[STYLE] = NULL;
	}
	if (data->sel[SIZE])
	{
	    XtFree(data->sel[SIZE]);
	    data->sel[SIZE] = NULL;
	}

	XFreeFontNames(name);

	data->num = 0;
	XFreeFontNames(data->names);
	data->names = NULL;
	data->exit = True;
    }
}
Exemplo n.º 4
0
bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding,
                                          bool fixedWidthOnly)
{
#if wxUSE_NANOX
    return false;
#else
    int nFonts;
    char **fonts;

    if ( fixedWidthOnly )
    {
        bool cont = true;
        fonts = CreateFontList(wxT('m'), encoding, &nFonts);
        if ( fonts )
        {
            cont = ProcessFamiliesFromFontList(this, fonts, nFonts);

            XFreeFontNames(fonts);
        }

        if ( !cont )
        {
            return true;
        }

        fonts = CreateFontList(wxT('c'), encoding, &nFonts);
        if ( !fonts )
        {
            return true;
        }
    }
    else
    {
        fonts = CreateFontList(wxT('*'), encoding, &nFonts);

        if ( !fonts )
        {
            // it's ok if there are no fonts in given encoding - but it's not
            // ok if there are no fonts at all
            wxASSERT_MSG(encoding != wxFONTENCODING_SYSTEM,
                         wxT("No fonts at all on this system?"));

            return false;
        }
    }

    (void)ProcessFamiliesFromFontList(this, fonts, nFonts);

    XFreeFontNames(fonts);
    return true;
#endif
    // wxUSE_NANOX
}
Exemplo n.º 5
0
int
drawText(Display *d, int screen, Window *w, GC *gc, const char *str) {
    XFontStruct *font;
    XColor textColor;
    char **list;
    int textWidth, textHeight, textX, textY, returnNo;

    list = XListFonts(d, "-*-*-bold-r-normal--*-*-100-100-c-*-*", 200, &returnNo);
    if (returnNo) {
        srand(time(NULL));
        static int fontIndex = rand() % returnNo;
        font = XLoadQueryFont(d, *(list + fontIndex));
        XFreeFontNames(list);
    }

    if (!font)
        return -1;

    XParseColor(d, DefaultColormap(d, screen), text, &textColor);
    XAllocColor(d, DefaultColormap(d, screen), &textColor);
    XSetForeground(d, *gc, textColor.pixel);
    XSetBackground(d, *gc, WhitePixel(d, screen));
    XSetFont(d, *gc, font->fid);

    textWidth = XTextWidth(font, str, strlen(str));
    textHeight = font->ascent + font->descent;
    textX = (windowWidth - textWidth) / 2;
    textY = ((windowHeight - rectHeight) / 2 - textHeight) / 2 + textHeight / 2;

    XDrawImageString(d, *w, *gc, textX, textY, str, strlen(str));
    return 0;
}
Exemplo n.º 6
0
/*
 * main.c
 *
 */
int main (int argc, char *argv[])
{
    int nFonts;
    char **szaFontNames;
    int i;

    /* --- Initialize GTK.  Needed for the GDK_DISPLAY call --- */
    gtk_init (&argc, &argv);

    /* --- Get the font names --- */
    szaFontNames = XListFonts (GDK_DISPLAY (), "*", MAX_FONTS, &nFonts);

    /* --- Check number retrieved --- */
    if (nFonts == MAX_FONTS) {

        /* --- They got a lot of fonts on their system. --- */
        printf ("Many fonts on your system.  Not displaying all.");
    }

    /* --- Display all the fonts --- */
    for (i = 0; i < nFonts; i++) {

        /* --- Get the name --- */
        printf ("%s\n", szaFontNames[i]);
    }

    XFreeFontNames (szaFontNames);

    return (0);
}
Exemplo n.º 7
0
static PyObject *
tkwin_ListFonts(TkWinObject *self, PyObject *args)
{
    char *pattern;
    char **fontnames;
    int count;
    PyObject *list;

    if (!PyArg_ParseTuple(args, "s", &pattern))
	return NULL;

    fontnames = XListFonts(Tk_Display(self->tkwin), pattern, 10000, &count);
    if (fontnames == NULL)
	count = 0;
    list = PyList_New(count);
    if (list != NULL)
    {
	int i;
	for (i = 0; i < count; i++)
	{
	    PyObject *item = PyString_FromString(fontnames[i]);
	    if (item == NULL)
	    {
		Py_DECREF(list);
		list = NULL;
		break;
	    }
	    PyList_SetItem(list, i, item);
	}
    }
    if (fontnames != NULL)
	XFreeFontNames(fontnames);
    return list;
}
Exemplo n.º 8
0
static void motFontDlgInitFamilyList(Ihandle* ih)
{
  int i, j = 1, count = 0;
  char prev[1024]="", family[1024];
  Ihandle* list1 = IupGetDialogChild(ih, "LIST1");            /* this will reduce the initial number */
  char**font_list_str = XListFonts(iupmot_display, "-*-*-medium-r-*-*-0-0-*-*-*-*-*-*", 32767, &count);
  char*backup_list[32767];

  if (!font_list_str)
    return;

  memcpy(backup_list, font_list_str, count*sizeof(char*));
  qsort(font_list_str, count, sizeof(char*), motFontDlgCompareStr);

  for (i=0; i<count; i++)
  {
    motFontGetFamily(font_list_str[i], family);

    if (!iupStrEqual(family, prev))  /* avoid duplicates */
    {
      IupStoreAttributeId(list1, "", j, family);
      strcpy(prev, family);
      j++;
    }
  }
  IupSetAttributeId(list1, "", j, NULL);

  memcpy(font_list_str, backup_list, count*sizeof(char*));
  XFreeFontNames(font_list_str);
}
Exemplo n.º 9
0
/*ARGSUSED*/
    static void
cancel_callback(Widget w,
	SharedFontSelData *data,
	XmListCallbackStruct *call_data)
{
    if (data->sel[ENCODING])
    {
	XtFree(data->sel[ENCODING]);
	data->sel[ENCODING] = NULL;
    }
    if (data->sel[NAME])
    {
	XtFree(data->sel[NAME]);
	data->sel[NAME] = NULL;
    }
    if (data->sel[STYLE])
    {
	XtFree(data->sel[STYLE]);
	data->sel[STYLE] = NULL;
    }
    if (data->sel[SIZE])
    {
	XtFree(data->sel[SIZE]);
	data->sel[SIZE] = NULL;
    }

    if (data->font_name)
	XtFree(data->font_name);
    data->font_name = NULL;

    data->num = 0;
    XFreeFontNames(data->names);
    data->names = NULL;
    data->exit = True;
}
Exemplo n.º 10
0
void MCOldFontnode::buildtable()
{
	if (table != NULL || MCnoui)
		return;
	int nnames;
	char **allnames = XListFonts(MCdpy, "-*-iso8859-1", MAXUINT2, &nnames);
	int i;
	for (i = 0 ; i < nnames ; i++)
	{
		char *sptr = allnames[i];
		sptr++;
		if (MCU_strtok(sptr, "-") == NULL)
			continue;
		if ((sptr = MCU_strtok(NULL, "-")) == NULL)
			continue;
		MCOldFonttablenode *fnptr = findtablenode(sptr);
		if (fnptr == NULL)
		{
			fnptr = new MCOldFonttablenode;
			fnptr->name = strclone(sptr);
			fnptr->next = table;
			table = fnptr;
		}
		fnptr->addfont();
	}
	XFreeFontNames(allnames);
}
Exemplo n.º 11
0
Bool
XftCoreAddFonts (XftFontSet *set, Display *dpy, Bool ignore_scalable)
{
    char	**xlfds;
    int		num;
    int		i;
    XftPattern	*font;
    Bool	ret;

    xlfds = XListFonts (dpy,
			"-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
			10000, &num);
    if (!xlfds)
	return False;
    ret = True;
    for (i = 0; ret && i < num; i++)
    {
	font = XftXlfdParse (xlfds[i], ignore_scalable, True);
	if (font)
	{
	    if (!XftFontSetAdd (set, font))
	    {
		XftPatternDestroy (font);
		ret = False;
	    }
	}
    }
    XFreeFontNames (xlfds);
    return ret;
}
Exemplo n.º 12
0
static void
Realize(Widget aw, XtValueMask * value_mask, XSetWindowAttributes * attributes)
{
	XltFontChooserWidget	fc = (XltFontChooserWidget) aw;
	char			*f = XtMalloc(256), **list;
	int			i, j, nfonts;

#define	superclass	(&xmMessageBoxClassRec)
  (*superclass->core_class.realize) (aw, value_mask, attributes);
#undef	superclass

	if (! FC_ShowDemo(fc))
		return;

/* Show the right font initially */
	f[0] = '\0';
	for (j=0; j<14; j++) {
		strcat(f, "-");
		strcat(f, FC_Setting(fc)[j]);
	}

	if (FC_FontName(fc))
		XtFree(FC_FontName(fc));
	FC_FontName(fc) = f;

/* How many fonts ? */
	list = XListFonts(XtDisplay(fc), f, 4096, &nfonts);
	for (i=0; i<nfonts; i++)
		EnableMenu(aw, list[i]);
	XFreeFontNames(list);

	if (FC_DemoWidget(fc)) {
		XmFontList      fl;
		XmFontListEntry fle;
		XFontSet        fs;
		char            m1[2][80], **missing = (char **)&m1[0][0];
		char            m2[80], *def = &m2[0];
		int             nmissing = 0;

		fs = XCreateFontSet(XtDisplay(fc), f, &missing, &nmissing, &def);

		if (fs != NULL) {
                	fle = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
			         XmFONT_IS_FONTSET, (XtPointer)fs);
                	fl = XmFontListAppendEntry(NULL, fle);

			XtVaSetValues(FC_DemoWidget(fc), XmNfontList, fl, NULL);

			XmFontListEntryFree(&fle);
			XmFontListFree(fl);
#if 0
			/* Freeing the font set produces nice little core dumps */
			XFreeFontSet(XtDisplay(fc), fs);	/* FIX ME leak ?? */
#endif
        	}

	}

	ShowCount(aw, nfonts);
}
Exemplo n.º 13
0
// Returns true if the font exists, false otherwise
static bool fontExists(const QString &fontName)
{
    int count;
    char **fontNames = XListFonts(QX11Info::display(), (char*)fontName.toLatin1().constData(), 32768, &count);
    if (fontNames) XFreeFontNames(fontNames);

    return count != 0;
}
Exemplo n.º 14
0
static void
tmp_free(void)
{
  char **tmp = tmp_fonts;
  if (tmp) {
    tmp_fonts = 0;
    XFreeFontNames(tmp);
  }
}
Exemplo n.º 15
0
// Returns TRUE if the font exists, FALSE otherwise
static bool fontExists( const QString &fontName )
{
    int count;
    char **fontNames = XListFonts( QPaintDevice::x11AppDisplay(),
				   (char*)fontName.latin1(), 32768, &count );
    if ( fontNames ) XFreeFontNames( fontNames );

    return count != 0;
}
Exemplo n.º 16
0
static void ListFontNames(Display* dpy)
{
    char **cp, **cp0;
    int i, count;
    cp = cp0 = XListFonts (dpy, "*", 256, &count);
    printf("%d fonts found\n", count);
    for(i = 0; i < count; i ++, cp++)
        printf("%s\n", *cp);
    if(count) XFreeFontNames(cp0);
}
Exemplo n.º 17
0
static
void get_list(char *pattern)
{
    int           available = nnames+1,
                  i;
    char        **fonts;
    XFontStruct  *info;

    /* Get list of fonts matching pattern */
    for (;;) {
        if (open_instead_of_list) {
            info = XLoadQueryFont (dpy, pattern);

            if (info) {
                fonts = &pattern;
                available = 1;
                XUnloadFont (dpy, info->fid);
            } else {
                fonts = NULL;
            }
            break;
        }
            
        if (long_list == L_MEDIUM)
            fonts = XListFontsWithInfo(dpy, pattern, nnames, &available, &info);
        else
            fonts = XListFonts(dpy, pattern, nnames, &available);
        if (fonts == NULL || available < nnames)
            break;
        if (long_list == L_MEDIUM)
            XFreeFontInfo(fonts, info, available);
        else
            XFreeFontNames(fonts);
        nnames = available * 2;
    }

    if (fonts == NULL) {
        fprintf(stderr, "%s: pattern \"%s\" unmatched\n",
                program_name, pattern);
        return;
    }

    font_list = (FontList *)Realloc((char *)font_list,
            (font_cnt + available) * sizeof(FontList));
    for (i=0; i<available; i++) {
        font_list[font_cnt].name = fonts[i];
        if (long_list == L_MEDIUM)
            font_list[font_cnt].info = info + i;
        else
            font_list[font_cnt].info = NULL;
        
        font_cnt++;
    }
}
Exemplo n.º 18
0
/*
  Removes wildcards from an XLFD.

  Returns \a xlfd with all wildcards removed if a match for \a xlfd is
  found, otherwise it returns \a xlfd.
*/
static QByteArray qt_fixXLFD(const QByteArray &xlfd)
{
    QByteArray ret = xlfd;
    int count = 0;
    char **fontNames =
        XListFonts(QX11Info::display(), xlfd, 32768, &count);
    if (count > 0)
        ret = fontNames[0];
    XFreeFontNames(fontNames);
    return ret ;
}
Exemplo n.º 19
0
/*
  Removes wildcards from an XLFD.

  Returns \a xlfd with all wildcards removed if a match for \a xlfd is
  found, otherwise it returns \a xlfd.
*/
static QCString qt_fixXLFD( const QCString &xlfd )
{
    QCString ret = xlfd;
    int count = 0;
    char **fontNames =
	XListFonts( QPaintDevice::x11AppDisplay(), xlfd, 32768, &count );
    if ( count > 0 )
	ret = fontNames[0];
    XFreeFontNames( fontNames );
    return ret ;
}
Exemplo n.º 20
0
void KFontChooser::getFontList( QStrList &list, const char *pattern )
{
	int num;
	char **xFonts = XListFonts( qt_xdisplay(), pattern, 2000, &num );

	for ( int i = 0; i < num; i++ )
	{
		addFont( list, xFonts[i] );
	}

	XFreeFontNames( xFonts );
}
Exemplo n.º 21
0
Arquivo: xdemo.c Projeto: cuzz/xrdp
int drawFont(int count, char *msg)
{
    int  x1;
    int  y1;
    int  i;
    int  index;

#ifdef CHANGE_FONT_SIZE
    int  w;
    int  h;
    int  actual_count;
    char **font_list;
#endif

    if (count <= 0) {
        return 0; // nothing to do
    }

    srandom(time(NULL));
    XClearArea(g_disp, g_win, 0, 0, g_winWidth, g_winHeight, 0);

#ifdef CHANGE_FONT_SIZE
    font_list = XListFonts(g_disp, "−*−courier−*−*−*−*−0−0−*−*−*−0−*−*", 2000, &actual_count);
    if (!font_list) {
        printf("actual_count=%d\n", actual_count);
        for (i = 0; i < actual_count; i++)
        {
            printf("%s\n", font_list[i]);
        }
        XFreeFontNames(font_list);
    }
    else {
        printf("XListFonts() reted NULL\n");
    }
#endif

    srandom(time(NULL));

    for (i = 0, index = 0; i < count; i++)
    {
        x1 = random() % g_winWidth;
        y1 = random() % g_winHeight;
        XSetForeground(g_disp, g_gc, g_colors[index++].pixel);
        if (index == MAX_COLORS) {
            index = 0;
        }
        XDrawString(g_disp, g_win, g_gc, x1, y1, msg, strlen(msg));
        XFlush(g_disp);
        usleep(g_delay_dur);
    }
    return 0; // nothing to do
}
Exemplo n.º 22
0
static void cancelAction(Widget widget, xfselControlBlkType *ctrlBlk,
                 XmListCallbackStruct *call_data)
{
    XtFree(ctrlBlk->sel1);
    XtFree(ctrlBlk->sel2);
    XtFree(ctrlBlk->sel3);
    XtFree(ctrlBlk->fontName);

    ctrlBlk->fontName = NULL;
    XFreeFontNames(ctrlBlk->fontData);

    ctrlBlk->exitFlag = TRUE;
}
Exemplo n.º 23
0
static Lisp_Object __gtk_list_fonts_internal (const char *pattern)
{
  char **names;
  int count = 0;
  Lisp_Object result = Qnil;

  names = XListFonts (GDK_DISPLAY (), pattern, MAX_FONT_COUNT, &count);
  while (count--)
    result = Fcons (build_ext_string (names [count], Qbinary), result);
  if (names)
    XFreeFontNames (names);

  return result;
}
Exemplo n.º 24
0
static int
valid_font_name_p (Display *dpy, char *name)
{
  /* Maybe this should be implemented by callign XLoadFont and trapping
     the error.  That would be a lot of work, and wasteful as hell, but
     might be more correct.
   */
  int nnames = 0;
  char **names = 0;
  if (! name)
    return 0;
  names = XListFonts (dpy, name, 1, &nnames);
  if (names)
    XFreeFontNames (names);
  return (nnames != 0);
}
Exemplo n.º 25
0
DviFontSizeList *
InstallFontSizes (DviWidget dw, const char *x_name, Boolean *scalablep)
{
	char	fontNameString[2048];
	char	**fonts;
	int	i, count;
	int	size;
	DviFontSizeList	*sizes, *new_size;
	XFontName	fontName;
	unsigned int	fontNameAttributes;

	*scalablep = FALSE;
	if (!XParseFontName ((XFontNameString)x_name, &fontName,
			     &fontNameAttributes))
		return 0;
	fontNameAttributes &= ~(FontNamePixelSize|FontNamePointSize
				|FontNameAverageWidth);
	fontNameAttributes |= FontNameResolutionX;
	fontNameAttributes |= FontNameResolutionY;
	fontName.ResolutionX = dw->dvi.display_resolution;
	fontName.ResolutionY = dw->dvi.display_resolution;
	XFormatFontName (&fontName, fontNameAttributes, fontNameString);
	fonts = XListFonts (XtDisplay (dw), fontNameString, 10000000, &count);
	sizes = 0;
	for (i = 0; i < count; i++) {
		size = ConvertFontNameToSize (fonts[i]);
		if (size == 0) {
			DisposeFontSizes (dw, sizes);
			sizes = 0;
			*scalablep = TRUE;
			break;
		}
		if (size != -1) {
			new_size = (DviFontSizeList *) XtMalloc (sizeof *new_size);
			new_size->next = sizes;
			new_size->size = size;
			new_size->x_name = savestr (fonts[i]);
			new_size->doesnt_exist = 0;
			new_size->font = 0;
			sizes = new_size;
		}
	}
	XFreeFontNames (fonts);
	return sizes;
}
Exemplo n.º 26
0
void
JXFontManager::GetXFontNames
	(
	const JRegex&		regex,
	JPtrArray<JString>*	fontNames,
	JSortXFontNamesFn	compare
	)
	const
{
	fontNames->CleanOut();
	fontNames->SetCompareFunction(
					compare != NULL ? compare : JCompareStringsCaseInsensitive);
	fontNames->SetSortOrder(JOrderedSetT::kSortAscending);

#ifdef _J_USE_XFT
#else
	int nameCount;
	char** nameList = XListFonts(*itsDisplay, "*", INT_MAX, &nameCount);
	if (nameList == NULL)
		{
		return;
		}

	for (int i=0; i<nameCount; i++)
		{
		if (regex.Match(nameList[i]) && strcmp(nameList[i], "nil") != 0)
			{
			JString name = nameList[i];
			JBoolean isDuplicate;
			const JIndex index =
				fontNames->GetInsertionSortIndex(&name, &isDuplicate);
			if (!isDuplicate)
				{
				JString* n = new JString(name);
				assert( n != NULL );
				fontNames->InsertAtIndex(index, n);
				}
			}
		}

	XFreeFontNames(nameList);
#endif
}
Exemplo n.º 27
0
XFontStruct *
find_best_font(
	Display         *dpy,
	char		**name)
{
	char **list;
	int cnt;
	XFontStruct *s;

	list = XListFonts(dpy, *name, 1, &cnt);
	if (cnt && list) {
		free(*name);
		*name = strdup(list[0]);
		s = XLoadQueryFont(dpy, *name);
		XFreeFontNames(list);
		return s;
	}
	return NULL;
}
Exemplo n.º 28
0
/* find a font spec that matches font spec FONT and also matches
   (the registry of) CHARSET. */
static Lisp_Object
gtk_find_charset_font (Lisp_Object device, Lisp_Object font, Lisp_Object charset)
{
  char **names;
  int count = 0;
  Lisp_Object result = Qnil;
  const char *patternext;
  int i;

  TO_EXTERNAL_FORMAT (LISP_STRING, font, C_STRING_ALLOCA, patternext, Qbinary);

  names = XListFonts (GDK_DISPLAY (),
		      patternext, MAX_FONT_COUNT, &count);
  /* ### This code seems awfully bogus -- mrb */
  for (i = 0; i < count; i ++)
    {
      const Bufbyte *intname;
      Bytecount intlen;

      TO_INTERNAL_FORMAT (C_STRING, names[i], ALLOCA, (intname, intlen),
			  Qctext);
      if (gtk_font_spec_matches_charset (XDEVICE (device), charset,
					 intname, Qnil, 0, -1))
	{
	  result = make_string ((char *) intname, intlen);
	  break;
	}
    }

  if (names)
    XFreeFontNames (names);

  /* Check for a short font name. */
  if (NILP (result)
      && gtk_font_spec_matches_charset (XDEVICE (device), charset, 0,
					font, 0, -1))
    return font;

  return result;
}
Exemplo n.º 29
0
static void motFontDlgInitSizeList(Ihandle* ih, const char* fontface, int size)
{
  int i, j = 1, selected=-1, count = 0, sz, prev_sz = -1;
  char pattern[1024];
  Ihandle* list3 = IupGetDialogChild(ih, "LIST3");
  int size_list[32767];
  char**font_list_str;

  sprintf(pattern,"-*-%s-medium-r-*-*-*-*-*-*-*-*-*-*", fontface);
  font_list_str = XListFonts(iupmot_display, pattern, 32767, &count);
  if (!font_list_str)
    return;

  for (i=0; i<count; i++)
    size_list[i] = motGetFontSize(font_list_str[i]);

  qsort(size_list, count, sizeof(int), motFontDlgCompareSize);

  for (i=0; i<count; i++)
  {
    sz = size_list[i];
    if (sz && sz != prev_sz)  /* avoid duplicates, and zero */
    {
      if (sz == size)
        selected = j;
      IupSetfAttributeId(list3, "", j, "%d", sz);
      prev_sz = sz;
      j++;
    }
  }
  IupSetAttributeId(list3, "", j, NULL);

  if (selected != -1)
  {
    IupSetfAttribute(list3, "VALUE", "%d", selected);
    IupSetfAttribute(list3, "TOPITEM", "%d", selected);
  }

  XFreeFontNames(font_list_str);
}
Exemplo n.º 30
0
Lisp_Object
__get_gtk_font_truename (GdkFont *gdk_font, int expandp)
{
  Display *dpy = GDK_FONT_XDISPLAY (gdk_font);
  GSList *names = ((GdkFontPrivate *) gdk_font)->names;
  Lisp_Object font_name = Qnil;

  while (names)
    {
      if (names->data)
	{
	  if (valid_font_name_p (dpy, names->data))
	    {
	      if (!expandp)
		{
		  /* They want the wildcarded version */
		  font_name = build_string (names->data);
		}
	      else
		{
		  /* Need to expand out */
		  int nnames = 0;
		  char **x_font_names = 0;

		  x_font_names = XListFonts (dpy, names->data, 1, &nnames);
		  if (x_font_names)
		    {
		      font_name = build_string (x_font_names[0]);
		      XFreeFontNames (x_font_names);
		    }
		}
	      break;
	    }
	}
      names = names->next;
    }
  return (font_name);
}