textext.c
来自「Nxlib,一个模拟xlib的程序。使用microwindows的库来运行需要x」· C语言 代码 · 共 69 行
C
69 行
#include <stdio.h>#include <string.h>#include "nxlib.h"static int_nxTextWidth(XFontStruct * font, void *string, int count, int flag){ int w, h, b; GR_GC_ID local = GrNewGC(); GrSetGCFont(local, font->fid); GrGetGCTextSize(local, (void *) string, count, flag, &w, &h, &b); GrDestroyGC(local); return (w);}intXTextWidth(XFontStruct * font, _Xconst char *string, int count){ return _nxTextWidth(font, (void *) string, count, GR_TFASCII);}intXTextWidth16(XFontStruct * font, _Xconst XChar2b * string, int count){ return _nxTextWidth(font, (void *) string, count, GR_TFXCHAR2B);}static int_nxTextExtents(XFontStruct * font, void *string, int count, int *dir, int *ascent, int *descent, XCharStruct * overall, int flag){ int w, h, b; GR_GC_ID local = GrNewGC(); GrSetGCFont(local, font->fid); GrGetGCTextSize(local, (void *) string, count, flag, &w, &h, &b); GrDestroyGC(local); *ascent = b; *descent = h - b; *dir = FontLeftToRight; overall->lbearing = 0; /* Figure this out */ overall->rbearing = w; /* Figure this out */ overall->width = w; overall->ascent = b; overall->descent = *descent; overall->attributes = 0; /* FIXME? */ return 1;}intXTextExtents(XFontStruct * font, _Xconst char *string, int count, int *dir, int *ascent, int *descent, XCharStruct * overall){ return _nxTextExtents(font, (void *) string, count, dir, ascent, descent, overall, GR_TFASCII);}intXTextExtents16(XFontStruct * font, _Xconst XChar2b * string, int count, int *dir, int *ascent, int *descent, XCharStruct * overall){ return _nxTextExtents(font, (void *) string, count, dir, ascent, descent, overall, GR_TFXCHAR2B);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?