⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dixfonts.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 4 页
字号:
    if (!fplist) {	*bad = 0;	return BadAlloc;    }    for (i = 0; i < num_fpe_types; i++) {	if (fpe_functions[i].set_path_hook)	    (*fpe_functions[i].set_path_hook) ();    }    for (i = 0; i < npaths; i++) {	len = (unsigned int) (*cp++);	if (len) {	    /* if it's already in our active list, just reset it */	    /*	     * note that this can miss FPE's in limbo -- may be worth catching	     * them, though it'd muck up refcounting	     */	    fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len);	    if (fpe) {		err = (*fpe_functions[fpe->type].reset_fpe) (fpe);		if (err == Successful) {		    UseFPE(fpe);/* since it'll be decref'd later when freed				 * from the old list */		    fplist[valid_paths++] = fpe;		    cp += len;		    continue;		}		/* if error or can't do it, act like it's a new one */	    }	    fpe = (FontPathElementPtr) xalloc(sizeof(FontPathElementRec));	    if (!fpe) {		err = BadAlloc;		goto bail;	    }	    fpe->name = (char *) xalloc(len + 1);	    if (!fpe->name) {		xfree(fpe);		err = BadAlloc;		goto bail;	    }	    fpe->refcount = 1;	    strncpy(fpe->name, (char *) cp, (int) len);	    cp += len;	    fpe->name[len] = '\0';	    fpe->name_length = len;	    fpe->type = DetermineFPEType(fpe->name);	    if (fpe->type == -1) {		xfree(fpe->name);		xfree(fpe);		err = BadValue;		goto bail;	    }	    err = (*fpe_functions[fpe->type].init_fpe) (fpe);	    if (err != Successful) {		xfree(fpe->name);		xfree(fpe);		err = BadValue;		goto bail;	    }	    fplist[valid_paths++] = fpe;	} else {	    err = BadValue;	    goto bail;	}    }    FreeFontPath(font_path_elements, num_fpes, FALSE);    font_path_elements = fplist;    if (patternCache)	EmptyFontPatternCache(patternCache);    num_fpes = valid_paths;    return Success;bail:    *bad = i;    while (--i >= 0)	FreeFPE(fplist[i]);    xfree(fplist);    return err;}/* XXX -- do we need to pass error down to each renderer? */intSetFontPath(client, npaths, paths, error)    ClientPtr   client;    int         npaths;    unsigned char *paths;    int        *error;{    int   err = Success;    if (npaths == 0) {	if (SetDefaultFontPath(defaultFontPath) != Success)	    return BadName;    } else {	err = SetFontPathElements(npaths, paths, error);    }    return err;}/*** TJR - dirty hack - this variable is used in lib/font/fontfile/dirfile.c */int settingDefaultFontPath = 0;intSetDefaultFontPath(path)    char       *path;{    unsigned char *cp,               *pp,               *nump,               *newpath;    int         num = 1,                len,                err,                size = 0,                bad;    /* get enough for string, plus values -- use up commas */    len = strlen(path) + 1;    nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len);    if (!newpath)	return BadAlloc;    pp = (unsigned char *) path;    cp++;    while (*pp) {	if (*pp == ',') {	    *nump = (unsigned char) size;	    nump = cp++;	    pp++;	    num++;	    size = 0;	} else {	    *cp++ = *pp++;	    size++;	}    }    *nump = (unsigned char) size;    settingDefaultFontPath = 1;    err = SetFontPathElements(num, newpath, &bad);    settingDefaultFontPath = 0;    DEALLOCATE_LOCAL(newpath);    return err;}unsigned char *GetFontPath(count, length)    int			*count;    int			*length;{    int			i;    unsigned char       *c;    int			len;    FontPathElementPtr	fpe;    len = 0;    for (i = 0; i < num_fpes; i++) {	fpe = font_path_elements[i];	len += fpe->name_length + 1;    }    font_path_string = (unsigned char *) xrealloc(font_path_string, len);    if (!font_path_string)	return NULL;    c = font_path_string;    *length = 0;    for (i = 0; i < num_fpes; i++) {	fpe = font_path_elements[i];	*c = fpe->name_length;	*length += *c++;	memmove(c, fpe->name, fpe->name_length);	c += fpe->name_length;    }    *count = num_fpes;    return font_path_string;}intLoadGlyphs(client, pfont, nchars, item_size, data)    ClientPtr   client;    FontPtr     pfont;    unsigned    nchars;    int         item_size;    unsigned char *data;{    if (fpe_functions[pfont->fpe->type].load_glyphs)	return (*fpe_functions[pfont->fpe->type].load_glyphs)	    (client, pfont, 0, nchars, item_size, data);    else	return Successful;}voidDeleteClientFontStuff(client)    ClientPtr	client;{    int			i;    FontPathElementPtr	fpe;    for (i = 0; i < num_fpes; i++)    {	fpe = font_path_elements[i];	if (fpe_functions[fpe->type].client_died)	    (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);    }}voidInitFonts (){    patternCache = MakeFontPatternCache();    if (screenInfo.numScreens > screenInfo.numVideoScreens) {	PrinterFontRegisterFpeFunctions();	FontFileCheckRegisterFpeFunctions();	check_fs_register_fpe_functions();    } else {	FontFileRegisterFpeFunctions();	fs_register_fpe_functions();    }}intGetDefaultPointSize (){    return 120;}FontResolutionPtrGetClientResolutions (num)    int        *num;{    if (requestingClient && requestingClient->fontResFunc != NULL &&	!requestingClient->clientGone)    {	return (*requestingClient->fontResFunc)(requestingClient, num);    }    else {	static struct _FontResolution res;	ScreenPtr   pScreen;	pScreen = screenInfo.screens[0];	res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth;	/*	 * XXX - we'll want this as long as bitmap instances are prevalent 	 so that we can match them from scalable fonts	 */	if (res.x_resolution < 88)	    res.x_resolution = 75;	else	    res.x_resolution = 100;	res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight;	if (res.y_resolution < 88)	    res.y_resolution = 75;	else	    res.y_resolution = 100;	res.point_size = 120;	*num = 1;	return &res;    }}/* * returns the type index of the new fpe * * should be called (only once!) by each type of fpe when initialized */int#if NeedFunctionPrototypesRegisterFPEFunctions(    int         (*name_func) (                  char* /* name */                  ),    int         (*init_func) (                  FontPathElementPtr /* fpe */                  ),    int         (*free_func) (                  FontPathElementPtr /* fpe */                  ),    int         (*reset_func) (                  FontPathElementPtr /* fpe */                  ),    int         (*open_func) (                  pointer /* client */,                  FontPathElementPtr /* fpe */,                  int /* flags */,                  char* /* name */,                  int /* namelen */,                  fsBitmapFormat /* format */,                  fsBitmapFormatMask /* fmask */,                  unsigned long /* id (type XID or FSID) */,                  FontPtr* /* pFont */,                  char** /* aliasName */,                  FontPtr /* non_cachable_font */                  ),    int         (*close_func) (                  FontPathElementPtr /* fpe */,                  FontPtr /* pFont */                  ),    int         (*list_func) (                  pointer /* client */,                  FontPathElementPtr /* fpe */,                  char* /* pat */,                  int /* len */,                  int /* max */,                  FontNamesPtr /* names */                  ),    int         (*start_lfwi_func) (                  pointer /* client */,                  FontPathElementPtr /* fpe */,                  char* /* pat */,                  int /* patlen */,                  int /* maxnames */,                  pointer* /* privatep */                  ),    int         (*next_lfwi_func) (                  pointer /* client */,                  FontPathElementPtr /* fpe */,                  char** /* name */,                  int* /* namelen */,                  FontInfoPtr* /* info */,                  int* /* numFonts */,                  pointer /* private */                  ),    int         (*wakeup_func) (                  FontPathElementPtr /* fpe */,                  unsigned long* /* LastSelectMask */                  ),    int         (*client_died) (                  pointer /* client */,                  FontPathElementPtr /* fpe */                  ),    int         (*load_glyphs) (                  pointer /* client */,                  FontPtr /* pfont */,                  Bool /* range_flag */,                  unsigned int /* nchars */,                  int /* item_size */,                  unsigned char* /* data */                  ),    int         (*start_list_alias_func) (                  pointer /* client */,                  FontPathElementPtr /* fpe */,                  char* /* pat */,                  int /* len */,                  int /* max */,                  pointer* /* privatep */                  ),    int         (*next_list_alias_func) (                  pointer /* client */,                  FontPathElementPtr /* fpe */,                  char** /* namep */,                  int* /* namelenp */,                  char** /* resolvedp */,                  int* /* resolvedlenp */,                  pointer /* private */                  ),    void        (*set_path_func) (                  void                  ))#elseRegisterFPEFunctions(name_func, init_func, free_func, reset_func,	   open_func, close_func, list_func, start_lfwi_func, next_lfwi_func,		     wakeup_func, client_died, load_glyphs,		     start_list_alias_func, next_list_alias_func,		     set_path_func)    Bool        (*name_func) ();    int         (*init_func) ();    int         (*free_func) ();    int         (*reset_func) ();    int         (*open_func) ();    int         (*close_func) ();    int         (*list_func) ();    int         (*start_lfwi_func) ();    int         (*next_lfwi_func) ();    int         (*wakeup_func) ();    int		(*client_died) ();    int		(*load_glyphs) ();    int		(*start_list_alias_func) ();    int		(*next_list_alias_func) ();    void	(*set_path_func) ();#endif{    FPEFunctions *new;    /* grow the list */    new = (FPEFunctions *) xrealloc(fpe_functions,				 (num_fpe_types + 1) * sizeof(FPEFunctions));    if (!new)	return -1;    fpe_functions = new;    fpe_functions[num_fpe_types].name_check = name_func;    fpe_functions[num_fpe_types].open_font = open_func;    fpe_functions[num_fpe_types].close_font = close_func;    fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func;    fpe_functions[num_fpe_types].list_fonts = list_func;    fpe_functions[num_fpe_types].start_list_fonts_with_info =	start_lfwi_func;    fpe_functions[num_fpe_types].list_next_font_with_info =	next_lfwi_func;    fpe_functions[num_fpe_types].init_fpe = init_func;    fpe_functions[num_fpe_types].free_fpe = free_func;    fpe_functions[num_fpe_types].reset_fpe = reset_func;    fpe_functions[num_fpe_types].client_died = client_died;    fpe_functions[num_fpe_types].load_glyphs = load_glyphs;    fpe_functions[num_fpe_types].start_list_fonts_and_aliases =	start_list_alias_func;    fpe_functions[num_fpe_types].list_next_font_or_alias =	next_list_alias_func;    fpe_functions[num_fpe_types].set_path_hook = set_path_func;    return num_fpe_types++;}voidFreeFonts(){    if (patternCache) {	FreeFontPatternCache(patternCache);	patternCache = 0;    }    FreeFontPath(font_path_elements, num_fpes, TRUE);    font_path_elements = 0;    num_fpes = 0;    xfree(fpe_functions);    num_fpe_types = 0;    fpe_functions = (FPEFunctions *) 0;}/* convenience functions for FS interface */FontPtrfind_old_font(id)    XID         id;{    return (FontPtr) SecurityLookupIDByType(NullClient, id, RT_NONE,					    SecurityUnknownAccess);}FontGetNewFontClientID(){    return FakeClientID(0);}intStoreFontClientFont(pfont, id)    FontPtr     pfont;    Font        id;{    return AddResource(id, RT_NONE, (pointer) pfont);}voidDeleteFontClientID(id)    Font        id;{    FreeResource(id, RT_NONE);}intclient_auth_generation(client)    ClientPtr client;{    return 0;}static int  fs_handlers_installed = 0;static unsigned int last_server_gen;intinit_fs_handlers(fpe, block_handler)    FontPathElementPtr fpe;    BlockHandlerProcPtr block_handler;{    /* if server has reset, make sure the b&w handlers are reinstalled */    if (last_server_gen < serverGeneration) {	last_server_gen = serverGeneration;	fs_handlers_installed = 0;    }    if (fs_handlers_installed == 0) {#ifdef DEBUG	fprintf(stderr, "adding FS b & w handlers\n");#endif	if (!RegisterBlockAndWakeupHandlers(block_handler,					    FontWakeup, (pointer) 0))	    return AllocError;	fs_handlers_installed++;    }    QueueFontWakeup(fpe);    return Successful;}voidremove_fs_handlers(fpe, block_handler, all)    FontPathElementPtr fpe;    BlockHandlerProcPtr block_handler;    Bool        all;{    if (all) {	/* remove the handlers if no one else is using them */	if (--fs_handlers_installed == 0) {#ifdef DEBUG	    fprintf(stderr, "removing FS b & w handlers\n");#endif	    RemoveBlockAndWakeupHandlers(block_handler, FontWakeup,					 (pointer) 0);	}    }    RemoveFontWakeup(fpe);}#ifdef DEBUG#define GLWIDTHBYTESPADDED(bits,nbytes) \	((nbytes) == 1 ? (((bits)+7)>>3)        /* pad to 1 byte */ \	:(nbytes) == 2 ? ((((bits)+15)>>3)&~1)  /* pad to 2 bytes */ \	:(nbytes) == 4 ? ((((bits)+31)>>3)&~3)  /* pad to 4 bytes */ \	:(nbytes) == 8 ? ((((bits)+63)>>3)&~7)  /* pad to 8 bytes */ \	: 0)#define GLYPH_SIZE(ch, nbytes)          \	GLWIDTHBYTESPADDED((ch)->metrics.rightSideBearing - \			(ch)->metrics.leftSideBearing, (nbytes))dump_char_ascii(cip)    CharInfoPtr cip;{    int         r,                l;    int         bpr;    int         byte;    static unsigned maskTab[] = {	(1 << 7), (1 << 6), (1 << 5), (1 << 4),	(1 << 3), (1 << 2), (1 << 1), (1 << 0),    };    bpr = GLYPH_SIZE(cip, 4);    for (r = 0; r < (cip->metrics.ascent + cip->metrics.descent); r++) {	pointer     row = (pointer) cip->bits + r * bpr;	byte = 0;	for (l = 0; l <= (cip->metrics.rightSideBearing -			  cip->metrics.leftSideBearing); l++) {	    if (maskTab[l & 7] & row[l >> 3])		putchar('X');	    else		putchar('.');	}	putchar('\n');    }}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -