📄 fsconvert.c
字号:
fsRange *expected_ranges;{ register FSFontPtr fsfont; register FSFontDataRec *fsd; register int i; fsfont = (FSFontPtr) pfont->fontPrivate; fsd = (FSFontDataRec *) pfont->fpePrivate; if (fsfont->encoding) { fsRange full_range[1]; if (!num_expected_ranges) { full_range[0].min_char_low = pfont->info.firstCol; full_range[0].min_char_high = pfont->info.firstRow; full_range[0].max_char_low = pfont->info.lastCol; full_range[0].max_char_high = pfont->info.lastRow; num_expected_ranges = 1; expected_ranges = full_range; } for (i = 0; i < num_expected_ranges; i++) { int row, col; for (row = expected_ranges[i].min_char_high; row <= expected_ranges[i].max_char_high; row++) { register CharInfoPtr encoding = fsfont->encoding + ((row - pfont->info.firstRow) * (pfont->info.lastCol - pfont->info.firstCol + 1) + expected_ranges[i].min_char_low - pfont->info.firstCol); for (col = expected_ranges[i].min_char_low; col <= expected_ranges[i].max_char_low; encoding++, col++) { if (encoding->bits == &_fs_glyph_requested) encoding->bits = &_fs_glyph_undefined; } } } }}/* * figures out what extents to request * this is where lots of extra * smarts wants to live *//* ARGSUSED */int_fs_check_extents(pfont, flags, nranges, range, blockrec) FontPtr pfont; Mask flags; int nranges; fsRange *range; FSBlockDataPtr blockrec;{/* XXX -- either fill in the requested info if we have it somewhere * and return AccessDone, or else return Successful */ return Successful;}/* * figures out what glyphs to request * this is where lots of extra * smarts wants to live *//* ARGSUSED */int_fs_check_bitmaps(pfont, format, flags, nranges, range, blockrec) FontPtr pfont; fsBitmapFormat format; Mask flags; int nranges; fsRange *range; FSBlockDataPtr blockrec;{/* XXX -- either fill in the requested info if we have it somewhere * and return AccessDone, or else return Successful */ return Successful;}int_fs_get_glyphs(pFont, count, chars, charEncoding, glyphCount, glyphs) FontPtr pFont; unsigned long count; register unsigned char *chars; FontEncoding charEncoding; unsigned long *glyphCount; /* RETURN */ CharInfoPtr *glyphs; /* RETURN */{ FSFontPtr fsdata; unsigned int firstCol; register unsigned int numCols; unsigned int firstRow; unsigned int numRows; CharInfoPtr *glyphsBase; register unsigned int c; register CharInfoPtr pci; unsigned int r; CharInfoPtr encoding; CharInfoPtr pDefault; FSFontDataPtr fsd = (FSFontDataPtr) pFont->fpePrivate; int itemSize; int err = Successful; fsdata = (FSFontPtr) pFont->fontPrivate; encoding = fsdata->encoding; pDefault = fsdata->pDefault; firstCol = pFont->info.firstCol; numCols = pFont->info.lastCol - firstCol + 1; glyphsBase = glyphs; if (charEncoding == Linear8Bit || charEncoding == TwoD8Bit) itemSize = 1; else itemSize = 2; /* In this age of glyph caching, any glyphs gotten through this procedure should already be loaded. If they are not, we are dealing with someone (perhaps a ddx driver optimizing a font) that doesn't understand the finer points of glyph caching. The CHECK_ENCODING macro checks for this condition... if found, it calls fs_load_all_glyphs(), which corrects it. Since the caller of this code will not know how to handle a return value of Suspended, the fs_load_all_glyphs() procedure will block and freeze the server until the load operation is done. Moral: the glyphCachingMode flag really must indicate the capabilities of the ddx drivers. */#define CHECK_ENCODING(cnum) \ ( pci = encoding + (cnum), \ fsd->glyphs_to_get ? \ ( pci->bits == &_fs_glyph_undefined || pci->bits == &_fs_glyph_requested ? \ ((err = fs_load_all_glyphs(pFont)), pci) : \ pci ) : \ pci ) switch (charEncoding) { case Linear8Bit: case TwoD8Bit: if (pFont->info.firstRow > 0) break; if (pFont->info.allExist && pDefault) { while (err == Successful && count--) { c = (*chars++) - firstCol; if (c < numCols) *glyphs++ = CHECK_ENCODING(c); else *glyphs++ = pDefault; } } else { while (err == Successful && count--) { c = (*chars++) - firstCol; if (c < numCols && CHECK_ENCODING(c)->bits) *glyphs++ = pci; else if (pDefault) *glyphs++ = pDefault; } } break; case Linear16Bit: if (pFont->info.allExist && pDefault) { while (err == Successful && count--) { c = *chars++ << 8; c = (c | *chars++) - firstCol; if (c < numCols) *glyphs++ = CHECK_ENCODING(c); else *glyphs++ = pDefault; } } else { while (err == Successful && count--) { c = *chars++ << 8; c = (c | *chars++) - firstCol; if (c < numCols && CHECK_ENCODING(c)->bits) *glyphs++ = pci; else if (pDefault) *glyphs++ = pDefault; } } break; case TwoD16Bit: firstRow = pFont->info.firstRow; numRows = pFont->info.lastRow - firstRow + 1; while (err == Successful && count--) { r = (*chars++) - firstRow; c = (*chars++) - firstCol; if (r < numRows && c < numCols && CHECK_ENCODING(r * numCols + c)->bits) *glyphs++ = pci; else if (pDefault) *glyphs++ = pDefault; } break; } *glyphCount = glyphs - glyphsBase; return err;}static int_fs_get_metrics(pFont, count, chars, charEncoding, glyphCount, glyphs) FontPtr pFont; unsigned long count; register unsigned char *chars; FontEncoding charEncoding; unsigned long *glyphCount; /* RETURN */ xCharInfo **glyphs; /* RETURN */{ FSFontPtr fsdata; unsigned int firstCol; register unsigned int numCols; unsigned int firstRow; unsigned int numRows; xCharInfo **glyphsBase; register unsigned int c; unsigned int r; CharInfoPtr encoding; CharInfoPtr pDefault; FSFontDataPtr fsd = (FSFontDataPtr) pFont->fpePrivate; int itemSize; int err = Successful; fsdata = (FSFontPtr) pFont->fontPrivate; encoding = fsdata->inkMetrics; pDefault = fsdata->pDefault; firstCol = pFont->info.firstCol; numCols = pFont->info.lastCol - firstCol + 1; glyphsBase = glyphs; /* XXX - this should be much smarter */ /* make sure the glyphs are there */ if (charEncoding == Linear8Bit || charEncoding == TwoD8Bit) itemSize = 1; else itemSize = 2; switch (charEncoding) { case Linear8Bit: case TwoD8Bit: if (pFont->info.firstRow > 0) break; if (pFont->info.allExist && pDefault) { while (count--) { c = (*chars++) - firstCol; if (c < numCols) *glyphs++ = (xCharInfo *)&encoding[c]; else *glyphs++ = (xCharInfo *)pDefault; } } else { while (count--) { c = (*chars++) - firstCol; if (c < numCols) *glyphs++ = (xCharInfo *)(encoding + c); else if (pDefault) *glyphs++ = (xCharInfo *)pDefault; } } break; case Linear16Bit: if (pFont->info.allExist && pDefault) { while (count--) { c = *chars++ << 8; c = (c | *chars++) - firstCol; if (c < numCols) *glyphs++ = (xCharInfo *)(encoding + c); else *glyphs++ = (xCharInfo *)pDefault; } } else { while (count--) { c = *chars++ << 8; c = (c | *chars++) - firstCol; if (c < numCols) *glyphs++ = (xCharInfo *)(encoding + c); else if (pDefault) *glyphs++ = (xCharInfo *)pDefault; } } break; case TwoD16Bit: firstRow = pFont->info.firstRow; numRows = pFont->info.lastRow - firstRow + 1; while (count--) { r = (*chars++) - firstRow; c = (*chars++) - firstCol; if (r < numRows && c < numCols) *glyphs++ = (xCharInfo *)(encoding + (r * numCols + c)); else if (pDefault) *glyphs++ = (xCharInfo *)pDefault; } break; } *glyphCount = glyphs - glyphsBase; return Successful;}void_fs_unload_font(pfont) FontPtr pfont;{ FSFontPtr fsdata = (FSFontPtr) pfont->fontPrivate; if (fsdata->encoding) { register int i; register CharInfoPtr encoding = fsdata->encoding; FontInfoPtr pfi = &pfont->info; for (i = (pfi->lastCol - pfi->firstCol + 1) * (pfi->lastRow - pfi->firstRow + 1); i > 0; encoding++, i--) { if (encoding->bits && encoding->bits != &_fs_glyph_undefined && encoding->bits != &_fs_glyph_requested && encoding->bits != &_fs_glyph_zero_length) xfree(encoding->bits); } } xfree(fsdata->encoding); xfree(fsdata); pfont->fontPrivate = 0;}void_fs_init_font(pfont) FontPtr pfont;{ /* set font function pointers */ pfont->get_glyphs = _fs_get_glyphs; pfont->get_metrics = _fs_get_metrics; pfont->unload_font = _fs_unload_font; pfont->unload_glyphs = (void (*)())0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -