📄 t1funcs.c
字号:
if (h > 0 && w > 0) { fill(glyphs[i].bits, h, paddedW, area, byte, bit, wordsize ); } Destroy(area); } delmemory(); xfree(pool); if (pFont->info.firstCol > pFont->info.lastCol) { xfree(type1); xfree(pFont); return BadFontName; } if (i != 256 - FIRSTCOL) { for (i--; i >= 0; i--) if (glyphs[i].bits != NULL) xfree(glyphs[i].bits); xfree(type1); xfree(pFont); return rc; } type1->pDefault = NULL; pFont->format = format; pFont->bit = bit; pFont->byte = byte; pFont->glyph = glyph; pFont->scan = scan; pFont->info.firstRow = 0; pFont->info.lastRow = 0; pFont->get_metrics = Type1GetMetrics; pFont->get_glyphs = Type1GetGlyphs; pFont->unload_font = Type1CloseFont; pFont->unload_glyphs = NULL; pFont->refcnt = 0; pFont->maxPrivate = -1; pFont->devPrivates = 0; pFont->fontPrivate = (unsigned char *) type1; if (count) { total_raw_width = (total_raw_width * 10 + count / 2) / count; if (total_width < 0) { /* Predominant direction is R->L */ total_raw_width = -total_raw_width; } vals->width = (int)((double)total_raw_width * vals->pixel_matrix[0] / 1000.0 + (vals->pixel_matrix[0] > 0 ? .5 : -.5)); } T1FillFontInfo(pFont, vals, fileName, entry->name.name, total_raw_width); *ppFont = pFont; return Successful;} static intType1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs) FontPtr pFont; unsigned long count; register unsigned char *chars; FontEncoding charEncoding; unsigned long *glyphCount; /* RETURN */ CharInfoPtr *glyphs; /* RETURN */{ unsigned int firstRow; unsigned int numRows; CharInfoPtr *glyphsBase; register unsigned int c; register CharInfoPtr pci; unsigned int r; CharInfoPtr pDefault; register struct type1font *type1Font; register int firstCol; type1Font = (struct type1font *) pFont->fontPrivate; firstCol = pFont->info.firstCol; pDefault = type1Font->pDefault; glyphsBase = glyphs; switch (charEncoding) {#define EXIST(pci) \ ((pci)->metrics.attributes || \ (pci)->metrics.ascent != -(pci)->metrics.descent || \ (pci)->metrics.leftSideBearing != (pci)->metrics.rightSideBearing) case Linear8Bit: case TwoD8Bit: if (pFont->info.firstRow > 0) break; while (count--) { c = (*chars++); if (c >= firstCol && (pci = &type1Font->glyphs[c-FIRSTCOL]) && EXIST(pci)) *glyphs++ = pci; else if (pDefault) *glyphs++ = pDefault; } break; case Linear16Bit: while (count--) { c = *chars++ << 8; c = (c | *chars++); if (c < 256 && c >= firstCol && (pci = &type1Font->glyphs[c-FIRSTCOL]) && EXIST(pci)) *glyphs++ = pci; else if (pDefault) *glyphs++ = pDefault; } break; case TwoD16Bit: firstRow = pFont->info.firstRow; numRows = pFont->info.lastRow - firstRow + 1; while (count--) { r = (*chars++) - firstRow; c = (*chars++); if (r < numRows && c < 256 && c >= firstCol && (pci = &type1Font->glyphs[(r << 8) + c - FIRSTCOL]) && EXIST(pci)) *glyphs++ = pci; else if (pDefault) *glyphs++ = pDefault; } break; } *glyphCount = glyphs - glyphsBase; return Successful;#undef EXIST} static intType1GetMetrics(pFont, count, chars, charEncoding, glyphCount, glyphs) FontPtr pFont; unsigned long count; register unsigned char *chars; FontEncoding charEncoding; unsigned long *glyphCount; /* RETURN */ xCharInfo **glyphs; /* RETURN */{ static CharInfoRec nonExistantChar; int ret; struct type1font *type1Font; CharInfoPtr oldDefault; type1Font = (struct type1font *) pFont->fontPrivate; oldDefault = type1Font->pDefault; type1Font->pDefault = &nonExistantChar; ret = Type1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, (CharInfoPtr *) glyphs); type1Font->pDefault = oldDefault; return ret;} void Type1CloseFont(pFont) FontPtr pFont;{ register int i; struct type1font *type1; type1 = (struct type1font *) pFont->fontPrivate; for (i=0; i < 256 - FIRSTCOL; i++) if (type1->glyphs[i].bits != NULL) xfree(type1->glyphs[i].bits); xfree(type1); if (pFont->info.props) xfree(pFont->info.props); if (pFont->info.isStringProp) xfree(pFont->info.isStringProp); if (pFont->devPrivates) xfree(pFont->devPrivates); xfree(pFont);} static void fill(dest, h, w, area, byte, bit, wordsize) register char *dest; /* destination bitmap */ int h,w; /* dimensions of 'dest', w padded */ register struct region *area; /* region to write to 'dest' */ int byte,bit; /* flags; LSBFirst or MSBFirst */ int wordsize; /* number of bits per word for LSB/MSB purposes */{ register struct edgelist *edge; /* for looping through edges */ register char *p; /* current scan line in 'dest' */ register int y; /* for looping through scans */ register int wbytes = w / 8; /* number of bytes in width */ register pel *leftP,*rightP; /* pointers to X values, left and right */ int xmin = area->xmin; /* upper left X */ int ymin = area->ymin; /* upper left Y */ for (edge = area->anchor; VALIDEDGE(edge); edge = edge->link->link) { p = dest + (edge->ymin - ymin) * wbytes; leftP = edge->xvalues; rightP = edge->link->xvalues; for (y = edge->ymin; y < edge->ymax; y++) { fillrun(p, *leftP++ - xmin, *rightP++ - xmin, bit); p += wbytes; } }/*Now, as an afterthought, we'll go reorganize if odd byte order requiresit:*/ if (byte == LSBFirst && wordsize != 8) { register int i; switch (wordsize) { case 16: { register unsigned short data,*p; p = (unsigned short *) dest; for (i = h * w /16; --i >= 0;) { data = *p; *p++ = (data << 8) + (data >> 8); } break; } case 64: case 32: { register unsigned long data,*p; p = (unsigned long *) dest; for (i = h * w / 32; --i >= 0;) { data = *p; *p++ = (data << 24) + (data >> 24) + (0xFF00 & (data >> 8)) + (0xFF0000 & (data << 8)); } if (wordsize == 64) { p = (unsigned long *) dest; for (i = h * w / 64; --i >= 0;) { data = *p++; p[-1] = p[0]; *p++ = data; } } break; } default: abort("xiFill: unknown format"); } } } #define ALLONES 0xFF static void fillrun(p, x0, x1, bit) register char *p; /* address of this scan line */ pel x0,x1; /* left and right X */ int bit; /* format: LSBFirst or MSBFirst */{ register int startmask,endmask; /* bits to set in first and last char*/ register int middle; /* number of chars between start and end + 1 */ if (x1 <= x0) return; middle = x1/8 - x0/8; p += x0/8; x0 &= 7; x1 &= 7; if (bit == LSBFirst) { startmask = ALLONES << x0; endmask = ~(ALLONES << x1); } else { startmask = ALLONES >> x0; endmask = ~(ALLONES >> x1); } if (middle == 0) *p++ |= startmask & endmask; else { *p++ |= startmask; while (--middle > 0) *p++ = (char)ALLONES; *p |= endmask; }} #define CAPABILITIES (CAP_MATRIX | CAP_CHARSUBSETTING) static FontRendererRec renderers[] = { { ".pfa", 4, (int (*)()) 0, Type1OpenScalable, (int (*)()) 0, Type1GetInfoScalable, 0, CAPABILITIES }, { ".pfb", 4, (int (*)()) 0, Type1OpenScalable, (int (*)()) 0, Type1GetInfoScalable, 0, CAPABILITIES }}; Type1RegisterFontFileFunctions(){ int i; T1InitStdProps(); for (i=0; i < sizeof(renderers) / sizeof(FontRendererRec); i++) FontFileRegisterRenderer(&renderers[i]);}int Type1ReturnCodeToXReturnCode(rc) int rc;{ switch(rc) { case SCAN_OK: return Successful; case SCAN_FILE_EOF: /* fall through to BadFontFormat */ case SCAN_ERROR: return BadFontFormat; case SCAN_OUT_OF_MEMORY: return AllocError; case SCAN_FILE_OPEN_ERROR: return BadFontName; case SCAN_TRUE: case SCAN_FALSE: case SCAN_END: /* fall through */ default: /* this should not happen */ ErrorF("Type1 return code not convertable to X return code: %d\n", rc); return rc; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -