1/* $XTermId: fontutils.h,v 1.150 2024/12/01 19:48:57 tom Exp $ */ 2 3/* 4 * Copyright 1998-2022,2024 by Thomas E. Dickey 5 * 6 * All Rights Reserved 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a 9 * copy of this software and associated documentation files (the 10 * "Software"), to deal in the Software without restriction, including 11 * without limitation the rights to use, copy, modify, merge, publish, 12 * distribute, sublicense, and/or sell copies of the Software, and to 13 * permit persons to whom the Software is furnished to do so, subject to 14 * the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included 17 * in all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 23 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 * 27 * Except as contained in this notice, the name(s) of the above copyright 28 * holders shall not be used in advertising or otherwise to promote the 29 * sale, use or other dealings in this Software without prior written 30 * authorization. 31 */ 32 33#ifndef included_fontutils_h 34#define included_fontutils_h 1 35 36#include <xterm.h> 37/* *INDENT-OFF* */ 38 39extern Bool xtermLoadDefaultFonts (XtermWidget /* xw */); 40extern Bool xtermOpenFont (XtermWidget /* xw */, const char */* name */, XTermFonts * /* result */, XTermFonts * /* current */, Bool /* force */); 41extern XFontStruct * xtermLoadQueryFont(XtermWidget /* xw */, const char * /*name */); 42extern XTermFonts * getDoubleFont (TScreen * /* screen */, int /* which */); 43extern XTermFonts * getItalicFont (TScreen * /* screen */, int /* which */); 44extern XTermFonts * getNormalFont (TScreen * /* screen */, int /* which */); 45extern const VTFontNames * defaultVTFontNames(XtermWidget /* xw */); 46extern const VTFontNames * xtermFontName (const char */* normal */); 47extern const char * whichFontEnum (VTFontEnum /* value */); 48extern const char * whichFontList (XtermWidget /* xw */, const VTFontList * /* value */); 49extern const char * whichFontList2(XtermWidget /* xw */, char ** /* value */); 50extern int lookupRelativeFontSize (XtermWidget /* xw */, int /* old */, int /* relative */); 51extern int xtermGetFont (const char * /* param */); 52extern int xtermLoadFont (XtermWidget /* xw */, const VTFontNames */* fonts */, Bool /* doresize */, int /* fontnum */); 53extern void HandleSetFont PROTO_XT_ACTIONS_ARGS; 54extern Bool SetVTFont (XtermWidget /* xw */, int /* i */, Bool /* doresize */, const VTFontNames */* fonts */); 55extern void allocFontList (XtermWidget /* xw */, const char * /* name */, XtermFontNames * /* target */, VTFontEnum /* which */, const char * /* source */, Bool /* ttf */); 56extern void copyFontList (char *** /* targetp */, char ** /* source */); 57extern void initFontLists (XtermWidget /* xw */); 58extern void freeFontList (char *** /* targetp */); 59extern void freeFontLists (VTFontList * /* lists */); 60extern void xtermCloseFont (XtermWidget /* xw */, XTermFonts * /* fnt */); 61extern void xtermCloseFonts (XtermWidget /* xw */, XTermFonts * /* fnts[fMAX] */); 62extern void xtermComputeFontInfo (XtermWidget /* xw */, VTwin */* win */, XFontStruct */* font */, int /* sbwidth */); 63extern void xtermCopyFontInfo (XTermFonts * /* target */, XTermFonts * /* source */); 64extern void xtermDerivedFont (const char * /* name */); 65extern void xtermFreeFontInfo (XTermFonts * /* target */); 66extern void xtermSetCursorBox (TScreen * /* screen */); 67extern void xtermUpdateFontGCs (XtermWidget /* xw */, MyGetFont /* myfunc */); 68extern void xtermUpdateFontInfo (XtermWidget /* xw */, Bool /* doresize */); 69 70#define getIconicFont(screen) (&((screen)->fnt_icon)) 71 72/* use these when "which" is constant, or known in-limits */ 73#define GetNormalFont(screen, which) (&((screen)->fnts[which])) 74#define GetDoubleFont(screen, which) (&((screen)->double_fonts[which])) 75#if OPT_WIDE_ATTRS 76#define GetItalicFont(screen, which) (&((screen)->ifnts[which])) 77#else 78#define GetItalicFont(screen, which) 0 79#endif 80 81#define FirstItemOf(vector) ((vector) ? (vector)[0] : NULL) 82#define CurrentXftFont(xw) ((xw)->work.fonts.xft.list_n[0]) 83#define DefaultFontN(xw) ((xw)->work.fonts.x11.list_n[0]) 84#define DefaultFontB(xw) ((xw)->work.fonts.x11.list_b[0]) 85#define DefaultFontW(xw) ((xw)->work.fonts.x11.list_w[0]) 86#define DefaultFontWB(xw) ((xw)->work.fonts.x11.list_wb[0]) 87 88#if OPT_DEC_CHRSET 89extern char *xtermSpecialFont (XTermDraw * /* params */); 90#endif 91 92#define FontLacksMetrics(font) \ 93 ((font)->fs != NULL \ 94 && ((font)->fs->per_char == NULL)) 95 96#define FontIsIncomplete(font) \ 97 ((font)->fs != NULL \ 98 && (font)->fs->per_char != NULL \ 99 && !(font)->fs->all_chars_exist) 100 101#if OPT_BOX_CHARS 102 103#define ForceBoxChars(screen,ch) \ 104 (xtermIsDecGraphic(ch) \ 105 && (screen)->force_box_chars) 106 107 /* 108 * Keep track of (some) characters to make the check for missing 109 * characters faster. If the character is known to be missing, 110 * the cache value is '2'. If we have checked the character, the 111 * cached value is '1'. 112 */ 113#if OPT_WIDE_CHARS 114#define CheckedKnownMissing(font, ch) \ 115 (((ch) < MaxUChar) && ((font)->known_missing[(Char)(ch)] > 0)) 116#else 117#define CheckedKnownMissing(font, ch) \ 118 ((font)->known_missing[(Char)(ch)] > 0) 119#endif 120 121#define IsXtermMissingChar(screen, ch, font) \ 122 (CheckedKnownMissing(font, ch) \ 123 ? ( (font)->known_missing[(Char)(ch)] > 1) \ 124 : ( ( ( FontIsIncomplete(font) \ 125 || ( (ch) < MaxUChar && !IsLatin1(ch) ) ) \ 126 && xtermMissingChar(ch, font) ) \ 127 || ForceBoxChars(screen, ch) ) ) 128#else 129#define IsXtermMissingChar(screen, ch, font) False 130#endif 131 132extern void xtermDrawBoxChar (XTermDraw * /* params */, unsigned /* ch */, GC /* gc */, int /* x */, int /* y */, int /* cols */, Bool /* xftords */); 133 134#if OPT_BOX_CHARS || OPT_REPORT_FONTS 135#define XTermFontsRef(fontList, which) \ 136 (((which) != fNorm && \ 137 ((fontList)[(which)].fs == NULL || \ 138 (fontList)[(which)].fs->per_char == NULL) && \ 139 ((fontList)[fNorm].fs != NULL && \ 140 (fontList)[fNorm].fs->per_char != NULL)) \ 141 ? &((fontList)[fNorm]) \ 142 : &((fontList)[(which)])) 143extern Bool xtermMissingChar (unsigned /* ch */, XTermFonts */* font */); 144#endif 145 146#if OPT_LOAD_VTFONTS 147extern void HandleLoadVTFonts PROTO_XT_ACTIONS_ARGS; 148#endif 149 150#if OPT_LOAD_VTFONTS || OPT_WIDE_CHARS 151extern Bool xtermLoadWideFonts (XtermWidget /* w */, Bool /* nullOk */); 152extern void xtermSaveVTFonts (XtermWidget /* xw */); 153#endif 154 155/* checks for internal charset codes */ 156#define xtermIsDecTechnical(ch) ((ch) >= XTERM_PUA && (ch) <= XTERM_PUA + 6) 157#define xtermIsDecGraphic(ch) ((ch) > 0 && (ch) < 32) 158#define xtermIsInternalCs(ch) (xtermIsDecGraphic(ch) || xtermIsDecTechnical(ch)) 159 160#if OPT_RENDERFONT 161extern Boolean maybeXftCache(XtermWidget /* xw */, XftFont * /* font */); 162extern Bool xtermXftMissing (XtermWidget /* xw */, XTermXftFonts * /* fontData */, int /* fontNum */, XftFont * /* font */, unsigned /* wc */); 163extern XTermXftFonts *getMyXftFont (XtermWidget /* xw */, int /* which */, int /* fontnum */); 164extern const char * whichXftFonts(XtermWidget /* xw */, const XTermXftFonts * /* data */); 165extern int findXftGlyph (XtermWidget /* xw */, XTermXftFonts * /* fontData */, unsigned /* wc */); 166extern XftFont *getXftFont (XtermWidget /* xw */, VTFontEnum /* which */, int /* fontnum */); 167extern void closeCachedXft (TScreen * /* screen */, XftFont * /* font */); 168extern void xtermCloseXft (TScreen * /* screen */, XTermXftFonts * /* pub */); 169#if OPT_DEC_CHRSET 170extern void getDoubleXftFont(XTermDraw * /* params */, XTermXftFonts * /* fontData */, unsigned /* chrset */, unsigned /* attr_flags */); 171#endif 172#endif 173 174#if OPT_SHIFT_FONTS 175extern String getFaceName (XtermWidget /* xw */, Bool /* wideName */); 176extern void HandleLargerFont PROTO_XT_ACTIONS_ARGS; 177extern void HandleSmallerFont PROTO_XT_ACTIONS_ARGS; 178extern void setFaceName (XtermWidget /* xw */, const char * /*value */); 179#endif 180 181#if OPT_WIDE_ATTRS 182extern unsigned xtermUpdateItalics (XtermWidget /* xw */, unsigned /* new_attrs */, unsigned /* old_attrs */); 183extern void xtermLoadItalics (XtermWidget /* xw */); 184#endif 185 186#if OPT_WIDE_CHARS 187extern unsigned ucs2dec (TScreen * /* screen */, unsigned /* ch */); 188extern unsigned dec2ucs (TScreen * /* screen */, unsigned /* ch */); 189#endif 190 191/* *INDENT-ON* */ 192 193#endif /* included_fontutils_h */ 194