void testText(WMScreen * scr) { WMWindow *win; WMText *text; WMFont *font; void *tb; FILE *file = fopen("wm.html", "rb"); windowCount++; win = WMCreateWindow(scr, "testText"); WMResizeWidget(win, 500, 300); WMSetWindowCloseAction(win, closeAction, NULL); text = WMCreateText(win); WMResizeWidget(text, 480, 280); WMMoveWidget(text, 10, 10); WMSetTextHasVerticalScroller(text, True); WMSetTextEditable(text, False); WMSetTextIgnoresNewline(text, False); #define FNAME "Verdana,sans serif:pixelsize=12" #define MSG \ "Window Maker is the GNU window manager for the " \ "X Window System. It was designed to emulate the " \ "look and feel of part of the NEXTSTEP(tm) GUI. It's " \ "supposed to be relatively fast and small, feature " \ "rich, easy to configure and easy to use, with a simple " \ "and elegant appearance borrowed from NEXTSTEP(tm)." font = WMCreateFont(scr, FNAME ":autohint=false"); WMSetTextDefaultFont(text, font); WMReleaseFont(font); if (0 && file) { char buf[1024]; WMFreezeText(text); while (fgets(buf, 1023, file)) WMAppendTextStream(text, buf); fclose(file); WMThawText(text); } else { WMAppendTextStream(text, "First paragraph has autohinting turned off, " "while the second has it turned on:"); WMAppendTextStream(text, "\n\n\n"); WMAppendTextStream(text, MSG); WMAppendTextStream(text, "\n\n\n"); font = WMCreateFont(scr, FNAME ":autohint=true"); tb = WMCreateTextBlockWithText(text, MSG, font, WMBlackColor(scr), 0, strlen(MSG)); WMAppendTextBlock(text, tb); WMReleaseFont(font); } WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
WMFont* WMBoldSystemFontOfSize(WMScreen *scrPtr, int size) { WMFont *font; char *fontSpec; fontSpec = makeFontOfSize(WINGsConfiguration.boldSystemFont, size, "sans"); font = WMCreateFont(scrPtr, fontSpec); if (!font) { wwarning(_("could not load font %s."), fontSpec); } wfree(fontSpec); return font; }
WMFont* WMCopyFontWithStyle(WMScreen *scrPtr, WMFont *font, WMFontStyle style) { FcPattern *pattern; WMFont *copy; char *name; if (!font) return NULL; pattern = FcNameParse(WMGetFontName(font)); switch (style) { case WFSNormal: FcPatternDel(pattern, "weight"); FcPatternDel(pattern, "slant"); FcPatternAddString(pattern, "weight", "regular"); FcPatternAddString(pattern, "weight", "medium"); FcPatternAddString(pattern, "slant", "roman"); break; case WFSBold: FcPatternDel(pattern, "weight"); FcPatternAddString(pattern, "weight", "bold"); break; case WFSEmphasized: FcPatternDel(pattern, "slant"); FcPatternAddString(pattern, "slant", "italic"); FcPatternAddString(pattern, "slant", "oblique"); break; case WFSBoldEmphasized: FcPatternDel(pattern, "weight"); FcPatternDel(pattern, "slant"); FcPatternAddString(pattern, "weight", "bold"); FcPatternAddString(pattern, "slant", "italic"); FcPatternAddString(pattern, "slant", "oblique"); break; } name = FcNameUnparse(pattern); copy = WMCreateFont(scrPtr, name); FcPatternDestroy(pattern); wfree(name); return copy; }