From b9b9ace9a8d2d1c0beda1dc0a2ebc6be9b47c305 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 10 Jun 2007 18:00:00 +0200 Subject: =?UTF-8?q?Version=201.5.3=20-=20Fixed=20some=20spelling=20errors?= =?UTF-8?q?=20in=20'newplugin'=20(thanks=20to=20Ville=20Skytt=C3=A4).=20-?= =?UTF-8?q?=20Fixed=20a=20busy=20loop=20in=20fast=20forward=20if=20the=20n?= =?UTF-8?q?ext=20video=20data=20file=20is=20missing=20=20=20(thanks=20to?= =?UTF-8?q?=20Reinhard=20Nissl).=20-=20Fixed=20handling=20frequencies=20in?= =?UTF-8?q?=20NitFilter::Process()=20(thanks=20to=20Anssi=20Hannula).=20-?= =?UTF-8?q?=20Fixed=20a=20race=20condition=20with=20signal=20handlers=20at?= =?UTF-8?q?=20program=20exit=20(thanks=20to=20Udo=20=20=20Richter).=20-=20?= =?UTF-8?q?Non-primary=20devices=20in=20Transfer=20mode=20are=20now=20also?= =?UTF-8?q?=20used=20for=20recording=20(thanks=20=20=20to=20Anssi=20Hannul?= =?UTF-8?q?a).=20-=20Fixed=20handling=20ChannelUp/Down=20keys=20if=20there?= =?UTF-8?q?=20is=20currently=20a=20replay=20running=20=20=20(thanks=20to?= =?UTF-8?q?=20Marco=20Schl=C3=BC=C3=9Fler).=20-=20The=20new=20SVDRP=20comm?= =?UTF-8?q?and=20REMO=20can=20be=20used=20to=20turn=20VDR's=20remote=20con?= =?UTF-8?q?trol=20off=20and=20=20=20on=20in=20case=20other=20programs=20ne?= =?UTF-8?q?ed=20to=20be=20controlled=20(based=20on=20patches=20from=20Krzy?= =?UTF-8?q?sztof=20=20=20Parma=20and=20Helmut=20Auer).=20-=20Increased=20t?= =?UTF-8?q?he=20maximum=20number=20of=20CA=20system=20ids=20to=20cope=20wi?= =?UTF-8?q?th=20the=20AlphaCrypt=20=20=20CAM's=20version=203.11=20firmware?= =?UTF-8?q?.=20-=20Fixed=20getting=20the=20code=20setting=20from=20the=20l?= =?UTF-8?q?ocale=20(thanks=20to=20Matthias=20Schwarzott).=20-=20Implemente?= =?UTF-8?q?d=20support=20for=20Freetype=20fonts=20(based=20on=20a=20patch?= =?UTF-8?q?=20from=20Alexander=20Riedel).=20=20=20The=20font=20names=20and?= =?UTF-8?q?=20sizes=20can=20be=20adjusted=20in=20the=20"Setup/OSD"=20menu.?= =?UTF-8?q?=20=20=20Note=20that=20VDR=20now=20requires=20freetype=20fonts?= =?UTF-8?q?=20to=20be=20installed=20in=20=20=20/usr/share/fonts/truetype.?= =?UTF-8?q?=20-=20If=20the=20OSD=20device=20in=20use=20has=20at=20least=20?= =?UTF-8?q?8bpp=20bitmap=20depth=20and=20this=20is=20also=20=20=20used=20b?= =?UTF-8?q?y=20the=20current=20skin,=20Freetype=20fonts=20are=20displayed?= =?UTF-8?q?=20"anti-aliased".=20=20=20The=20new=20setup=20parameter=20"OSD?= =?UTF-8?q?/Anti-alias"=20can=20be=20used=20to=20turn=20this=20off.=20-=20?= =?UTF-8?q?The=20new=20function=20cOsd::SetAntiAliasGranularity()=20can=20?= =?UTF-8?q?be=20used=20to=20help=20the=20OSD=20=20=20in=20managing=20the?= =?UTF-8?q?=20available=20color=20palette=20entries=20when=20doing=20anti-?= =?UTF-8?q?aliasing.=20=20=20Skins=20that=20use=208bpp=20bitmaps=20can=20c?= =?UTF-8?q?all=20this=20function=20with=20the=20maximum=20number=20=20=20o?= =?UTF-8?q?f=20colors=20used,=20and=20the=20maximum=20number=20of=20color?= =?UTF-8?q?=20combinations.=20The=20OSD=20will=20=20=20then=20evenly=20spl?= =?UTF-8?q?it=20the=20available=20palette=20entries=20between=20the=20vari?= =?UTF-8?q?ous=20colors=20=20=20combinations,=20so=20that=20fonts=20can=20?= =?UTF-8?q?be=20"anti-aliased".=20By=20default=20a=20total=20of=20=20=2010?= =?UTF-8?q?=20colors=20and=2010=20combinations=20is=20assumed.=20-=20The?= =?UTF-8?q?=20pixel=20fonts=20have=20been=20completely=20removed=20from=20?= =?UTF-8?q?the=20VDR=20source.=20-=20VDR=20is=20now=20"UTF-8=20aware".=20I?= =?UTF-8?q?t=20handles=20strings=20according=20to=20the=20character=20=20?= =?UTF-8?q?=20encoding=20used=20on=20the=20user's=20system.=20All=20intern?= =?UTF-8?q?ationalization=20strings=20and=20=20=20incoming=20SI=20data=20a?= =?UTF-8?q?re=20converted=20to=20the=20system=20encoding.=20-=20Plugins=20?= =?UTF-8?q?that=20handle=20strings=20need=20to=20be=20aware=20that=20on=20?= =?UTF-8?q?systems=20with=20UTF-8=20=20=20encoding=20a=20"character=20symb?= =?UTF-8?q?ol"=20may=20consist=20of=20more=20than=20a=20single=20byte=20in?= =?UTF-8?q?=20=20=20memory.=20The=20functions=20and=20macros=20named=20Utf?= =?UTF-8?q?8...()=20can=20be=20used=20to=20handle=20=20=20strings=20withou?= =?UTF-8?q?t=20needing=20to=20care=20about=20the=20underlying=20character?= =?UTF-8?q?=20encoding=20=20=20(see=20tools.h=20for=20details).=20-=20Even?= =?UTF-8?q?=20though=20the=20weekdays=20of=20repeating=20timers=20are=20pr?= =?UTF-8?q?esented=20to=20the=20user=20as=20UTF-8=20=20=20characters=20in?= =?UTF-8?q?=20the=20OSD,=20the=20timers.conf=20file=20and=20the=20SVDRP=20?= =?UTF-8?q?timer=20commands=20still=20=20=20use=20single=20byte=20characte?= =?UTF-8?q?rs=20("MTWTFSS")=20to=20make=20sure=20this=20information=20is?= =?UTF-8?q?=20handled=20=20=20correctly=20between=20systems=20with=20diffe?= =?UTF-8?q?rent=20character=20encodings.=20-=20Added=20a=20missing=20i18n?= =?UTF-8?q?=20string=20for=20"CAM"=20in=20the=20Turkish=20OSD=20texts.=20-?= =?UTF-8?q?=20Improved=20editing=20strings=20that=20are=20too=20long=20to?= =?UTF-8?q?=20fit=20into=20the=20editable=20area.=20-=20Changes=20to=20the?= =?UTF-8?q?=20OSD=20settings=20in=20the=20"Setup/OSD"=20menu=20now=20immed?= =?UTF-8?q?iately=20take=20effect=20=20=20when=20the=20"Ok"=20key=20is=20p?= =?UTF-8?q?ressed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- genfontfile.c | 381 ---------------------------------------------------------- 1 file changed, 381 deletions(-) delete mode 100644 genfontfile.c (limited to 'genfontfile.c') diff --git a/genfontfile.c b/genfontfile.c deleted file mode 100644 index 9dc6bce..0000000 --- a/genfontfile.c +++ /dev/null @@ -1,381 +0,0 @@ -/* Copyright (c) Mark J. Kilgard, 1997. */ - -/* This program is freely distributable without licensing fees and is - provided without guarantee or warrantee expressed or implied. This - program is -not- in the public domain. */ - -/* X compile line: cc -o gentexfont gentexfont.c -lX11 */ - -/* 2000-10-01: Stripped down the original code to get a simple bitmap C-code generator */ -/* for use with the VDR project (see http://www.cadsoft.de/vdr) */ -/* Renamed the file 'genfontfile.c' since it no longer generates 'tex' data */ -/* Klaus Schmidinger (kls@cadsoft.de) */ - -#include -#include -#include -#include -#include -#include -#include - -typedef struct { - unsigned short c; /* Potentially support 16-bit glyphs. */ - unsigned char width; - unsigned char height; - signed char xoffset; - signed char yoffset; - signed char advance; - char dummy; /* Space holder for alignment reasons. */ - short x; - short y; -} TexGlyphInfo; - -typedef struct { - short width; - short height; - short xoffset; - short yoffset; - short advance; - unsigned char *bitmap; -} PerGlyphInfo, *PerGlyphInfoPtr; - -typedef struct { - int min_char; - int max_char; - int max_ascent; - int max_descent; - PerGlyphInfo glyph[1]; -} FontInfo, *FontInfoPtr; - -Display *dpy; -FontInfoPtr fontinfo; - -/* #define REPORT_GLYPHS */ -#ifdef REPORT_GLYPHS -#define DEBUG_GLYPH4(msg,a,b,c,d) printf(msg,a,b,c,d) -#define DEBUG_GLYPH(msg) printf(msg) -#else -#define DEBUG_GLYPH4(msg,a,b,c,d) { /* nothing */ } -#define DEBUG_GLYPH(msg) { /* nothing */ } -#endif - -#define MAX_GLYPHS_PER_GRAB 512 /* this is big enough for 2^9 glyph - character sets */ - -FontInfoPtr -SuckGlyphsFromServer(Display * dpy, Font font) -{ - Pixmap offscreen; - XFontStruct *fontinfo; - XImage *image; - GC xgc; - XGCValues values; - int numchars; - int width, height, pixwidth; - int i, j; - XCharStruct *charinfo; - XChar2b character; - unsigned char *bitmapData; - int x, y; - int spanLength; - int charWidth, charHeight, maxSpanLength; - int grabList[MAX_GLYPHS_PER_GRAB]; - int glyphsPerGrab = MAX_GLYPHS_PER_GRAB; - int numToGrab, thisglyph; - FontInfoPtr myfontinfo; - - fontinfo = XQueryFont(dpy, font); - if (!fontinfo) - return NULL; - - numchars = fontinfo->max_char_or_byte2 - fontinfo->min_char_or_byte2 + 1; - if (numchars < 1) - return NULL; - - myfontinfo = (FontInfoPtr) malloc(sizeof(FontInfo) + (numchars - 1) * sizeof(PerGlyphInfo)); - if (!myfontinfo) - return NULL; - - myfontinfo->min_char = fontinfo->min_char_or_byte2; - myfontinfo->max_char = fontinfo->max_char_or_byte2; - myfontinfo->max_ascent = fontinfo->max_bounds.ascent; - myfontinfo->max_descent = fontinfo->max_bounds.descent; - - width = fontinfo->max_bounds.rbearing - fontinfo->min_bounds.lbearing; - height = fontinfo->max_bounds.ascent + fontinfo->max_bounds.descent; - - maxSpanLength = (width + 7) / 8; - /* Be careful determining the width of the pixmap; the X protocol allows - pixmaps of width 2^16-1 (unsigned short size) but drawing coordinates - max out at 2^15-1 (signed short size). If the width is too large, we - need to limit the glyphs per grab. */ - if ((glyphsPerGrab * 8 * maxSpanLength) >= (1 << 15)) { - glyphsPerGrab = (1 << 15) / (8 * maxSpanLength); - } - pixwidth = glyphsPerGrab * 8 * maxSpanLength; - offscreen = XCreatePixmap(dpy, RootWindow(dpy, DefaultScreen(dpy)), - pixwidth, height, 1); - - values.font = font; - values.background = 0; - values.foreground = 0; - xgc = XCreateGC(dpy, offscreen, GCFont | GCBackground | GCForeground, &values); - - XFillRectangle(dpy, offscreen, xgc, 0, 0, 8 * maxSpanLength * glyphsPerGrab, height); - XSetForeground(dpy, xgc, 1); - - numToGrab = 0; - if (fontinfo->per_char == NULL) { - charinfo = &(fontinfo->min_bounds); - charWidth = charinfo->rbearing - charinfo->lbearing; - charHeight = charinfo->ascent + charinfo->descent; - spanLength = (charWidth + 7) / 8; - } - for (i = 0; i < numchars; i++) { - if (fontinfo->per_char != NULL) { - charinfo = &(fontinfo->per_char[i]); - charWidth = charinfo->rbearing - charinfo->lbearing; - charHeight = charinfo->ascent + charinfo->descent; - if (charWidth == 0 || charHeight == 0) { - /* Still must move raster pos even if empty character */ - myfontinfo->glyph[i].width = 0; - myfontinfo->glyph[i].height = 0; - myfontinfo->glyph[i].xoffset = 0; - myfontinfo->glyph[i].yoffset = 0; - myfontinfo->glyph[i].advance = charinfo->width; - myfontinfo->glyph[i].bitmap = NULL; - goto PossiblyDoGrab; - } - } - grabList[numToGrab] = i; - - /* XXX is this right for large fonts? */ - character.byte2 = (i + fontinfo->min_char_or_byte2) & 255; - character.byte1 = (i + fontinfo->min_char_or_byte2) >> 8; - - /* XXX we could use XDrawImageString16 which would also paint the backing - - rectangle but X server bugs in some scalable font rasterizers makes it - - more effective to do XFillRectangles to clear the pixmap and - XDrawImage16 for the text. */ - XDrawString16(dpy, offscreen, xgc, - -charinfo->lbearing + 8 * maxSpanLength * numToGrab, - charinfo->ascent, &character, 1); - - numToGrab++; - - PossiblyDoGrab: - - if (numToGrab >= glyphsPerGrab || i == numchars - 1) { - image = XGetImage(dpy, offscreen, - 0, 0, pixwidth, height, 1, XYPixmap); - for (j = 0; j < numToGrab; j++) { - thisglyph = grabList[j]; - if (fontinfo->per_char != NULL) { - charinfo = &(fontinfo->per_char[thisglyph]); - charWidth = charinfo->rbearing - charinfo->lbearing; - charHeight = charinfo->ascent + charinfo->descent; - spanLength = (charWidth + 7) / 8; - } - bitmapData = (unsigned char *)calloc(height * spanLength, sizeof(char)); - if (!bitmapData) - goto FreeFontAndReturn; - DEBUG_GLYPH4("index %d, glyph %d (%d by %d)\n", - j, thisglyph + fontinfo->min_char_or_byte2, charWidth, charHeight); - for (y = 0; y < charHeight; y++) { - for (x = 0; x < charWidth; x++) { - /* XXX The algorithm used to suck across the font ensures that - each glyph begins on a byte boundary. In theory this would - make it convienent to copy the glyph into a byte oriented - bitmap. We actually use the XGetPixel function to extract - each pixel from the image which is not that efficient. We - could either do tighter packing in the pixmap or more - efficient extraction from the image. Oh well. */ - if (XGetPixel(image, j * maxSpanLength * 8 + x, charHeight - 1 - y)) { - DEBUG_GLYPH("x"); - bitmapData[y * spanLength + x / 8] |= (1 << (x & 7)); - } else { - DEBUG_GLYPH(" "); - } - } - DEBUG_GLYPH("\n"); - } - myfontinfo->glyph[thisglyph].width = charWidth; - myfontinfo->glyph[thisglyph].height = charHeight; - myfontinfo->glyph[thisglyph].xoffset = charinfo->lbearing; - myfontinfo->glyph[thisglyph].yoffset = -charinfo->descent; - myfontinfo->glyph[thisglyph].advance = charinfo->width; - myfontinfo->glyph[thisglyph].bitmap = bitmapData; - } - XDestroyImage(image); - numToGrab = 0; - /* do we need to clear the offscreen pixmap to get more? */ - if (i < numchars - 1) { - XSetForeground(dpy, xgc, 0); - XFillRectangle(dpy, offscreen, xgc, 0, 0, 8 * maxSpanLength * glyphsPerGrab, height); - XSetForeground(dpy, xgc, 1); - } - } - } - XFreeGC(dpy, xgc); - XFreePixmap(dpy, offscreen); - return myfontinfo; - -FreeFontAndReturn: - XDestroyImage(image); - XFreeGC(dpy, xgc); - XFreePixmap(dpy, offscreen); - for (j = i - 1; j >= 0; j--) { - if (myfontinfo->glyph[j].bitmap) - free(myfontinfo->glyph[j].bitmap); - } - free(myfontinfo); - return NULL; -} - -void -printGlyph(FontInfoPtr font, int c) -{ - PerGlyphInfoPtr glyph; - unsigned char *bitmapData; - int width, height, spanLength, charWidth; - int x, y, l; - char buf[1000], *b; - - if (c < font->min_char || c > font->max_char) { - fprintf(stderr, "out of range glyph\n"); - exit(1); - } - glyph = &font->glyph[c - font->min_char]; - bitmapData = glyph->bitmap; - width = glyph->width; - spanLength = (width + 7) / 8; - height = glyph->height; - charWidth = glyph->xoffset + width; - if (charWidth < glyph->advance) - charWidth = glyph->advance; - - printf(" { // %d\n", c); - printf(" %d, %d,\n", charWidth, font->max_ascent + font->max_descent); - for (y = 0; y < font->max_ascent - glyph->yoffset - height; y++) { - printf(" 0x%08X, // ", 0); - for (x = 0; x < charWidth; x++) - putchar('.'); - putchar('\n'); - } - for (y = height; y-- > 0;) { - l = 0; - b = buf; - for (x = 0; x < glyph->xoffset; x++) - *b++ = '.'; - if (bitmapData) { - for (x = 0; x < width; x++) { - l <<= 1; - if (bitmapData[y * spanLength + x / 8] & (1 << (x & 7))) { - *b++ = '*'; - l |= 1; - } - else - *b++ = '.'; - } - for (x = 0; x < glyph->advance - width - glyph->xoffset; x++) { - *b++ = '.'; - l <<= 1; - } - } - *b = 0; - printf(" 0x%08X, // %s\n", l, buf); - } - for (y = 0; y < font->max_descent + glyph->yoffset; y++) { - printf(" 0x%08X, // ", 0); - for (x = 0; x < glyph->xoffset + width || x < glyph->advance; x++) - putchar('.'); - putchar('\n'); - } - printf(" },\n"); -} - -void -getMetric(FontInfoPtr font, int c, TexGlyphInfo * tgi) -{ - PerGlyphInfoPtr glyph; - unsigned char *bitmapData; - - tgi->c = c; - if (c < font->min_char || c > font->max_char) { - tgi->width = 0; - tgi->height = 0; - tgi->xoffset = 0; - tgi->yoffset = 0; - tgi->dummy = 0; - tgi->advance = 0; - return; - } - glyph = &font->glyph[c - font->min_char]; - bitmapData = glyph->bitmap; - if (bitmapData) { - tgi->width = glyph->width; - tgi->height = glyph->height; - tgi->xoffset = glyph->xoffset; - tgi->yoffset = glyph->yoffset; - } else { - tgi->width = 0; - tgi->height = 0; - tgi->xoffset = 0; - tgi->yoffset = 0; - } - tgi->dummy = 0; - tgi->advance = glyph->advance; -} - -int -main(int argc, char *argv[]) -{ - int c; - TexGlyphInfo tgi; - int usageError = 0; - char *varname, *fontname; - XFontStruct *xfont; - int i; - - if (argc == 3) { - varname = argv[1]; - fontname = argv[2]; - } - else - usageError = 1; - - if (usageError) { - fprintf(stderr, "\n"); - fprintf(stderr, "usage: genfontfile variable_name X_font_name\n"); - fprintf(stderr, "\n"); - exit(1); - } - - dpy = XOpenDisplay(NULL); - if (!dpy) { - fprintf(stderr, "could not open display\n"); - exit(1); - } - /* find an OpenGL-capable RGB visual with depth buffer */ - xfont = XLoadQueryFont(dpy, fontname); - if (!xfont) { - fprintf(stderr, "could not get load X font: %s\n", fontname); - exit(1); - } - fontinfo = SuckGlyphsFromServer(dpy, xfont->fid); - if (!fontinfo) { - fprintf(stderr, "could not get font glyphs\n"); - exit(1); - } - - printf("static const %s[][%d] = {\n", varname, fontinfo->max_ascent + fontinfo->max_descent + 2); - for (c = 32; c < 256; c++) { - getMetric(fontinfo, c, &tgi); - printGlyph(fontinfo, c); - } - printf(" };\n"); - return 0; -} -- cgit v1.2.3