aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent/Font.c
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2011-10-10 17:58:31 +0200
committerReinhard Tartler <siretart@tauware.de>2011-10-10 17:58:31 +0200
commit1c25e92b9ea5811d8ab9c2bfdc0dcb2e4d21bd0a (patch)
tree56b1d4196538a8abb7747e8455b59aa778d6b948 /nx-X11/programs/Xserver/hw/nxagent/Font.c
parent266b5554943baffafbf1d574f567283cc9792278 (diff)
downloadnx-libs-1c25e92b9ea5811d8ab9c2bfdc0dcb2e4d21bd0a.tar.gz
nx-libs-1c25e92b9ea5811d8ab9c2bfdc0dcb2e4d21bd0a.tar.bz2
nx-libs-1c25e92b9ea5811d8ab9c2bfdc0dcb2e4d21bd0a.zip
Imported nxagent-3.2.0-10.tar.gznxagent/3.2.0-10
Summary: Imported nxagent-3.2.0-10.tar.gz Keywords: Imported nxagent-3.2.0-10.tar.gz into Git repository
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Font.c')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Font.c155
1 files changed, 149 insertions, 6 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c
index ff968bcc5..e552f826b 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Font.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c
@@ -101,6 +101,8 @@ static XFontStruct *nxagentLoadQueryFont(register Display *dpy , char *fontName
int nxagentFreeFont(XFontStruct *fs);
static Bool nxagentGetFontServerPath(char * fontServerPath);
+static char * nxagentMakeScalableFontName(const char *fontName, int scalableResolution);
+
RESTYPE RT_NX_FONT;
#ifdef NXAGENT_RECONNECT_FONT_DEBUG
@@ -419,13 +421,59 @@ Bool nxagentFontFind(const char *name, int *pos)
Bool nxagentFontLookUp(const char *name)
{
int i;
- if (name)
- if (!strlen(name))
- return 0;
- if (nxagentFontFind(name, &i))
- return (nxagentRemoteFontList.list[i]->status > 0);
- else
+ int result;
+
+ char *scalable;
+
+ if (name != NULL && strlen(name) == 0)
+ {
+ return 0;
+ }
+
+ result = nxagentFontFind(name, &i);
+
+ scalable = NULL;
+
+ /*
+ * Let's try with the scalable font description.
+ */
+
+ if (result == 0)
+ {
+ scalable = nxagentMakeScalableFontName(name, 0);
+
+ if (scalable != NULL)
+ {
+ result = nxagentFontFind(scalable, &i);
+
+ free(scalable);
+ }
+ }
+
+ /*
+ * Let's try again after replacing zero to xdpi and ydpi in the pattern.
+ */
+
+ if (result == 0)
+ {
+ scalable = nxagentMakeScalableFontName(name, 1);
+
+ if (scalable != NULL)
+ {
+ result = nxagentFontFind(scalable, &i);
+
+ free(scalable);
+ }
+ }
+
+ if (result == 0)
+ {
return 0;
+ }
+ else
+ {
+ return (nxagentRemoteFontList.list[i]->status > 0);
+ }
}
Bool nxagentRealizeFont(ScreenPtr pScreen, FontPtr pFont)
@@ -768,6 +816,11 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
fprintf(stderr, "nxagentLoadBestQueryFont: Weight '%d' of more accurate font '%s' .\n", weight, substFontBuf);
#endif
}
+
+ for (j = 0; j < numSearchFields; j++)
+ {
+ free (searchFields[j]);
+ }
}
}
@@ -783,6 +836,11 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
free (substFontBuf);
+ for (j = 0; j < numFontFields; j++)
+ {
+ free (fontNameFields[j]);
+ }
+
return fontStruct;
}
@@ -1688,3 +1746,88 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep)
return i;
}
+char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution)
+{
+ char *scalableFontName;
+ const char *s;
+ int len;
+ int field;
+
+ len = strlen(fontName) + 1;
+
+ scalableFontName = malloc(len);
+
+ if (scalableFontName == NULL)
+ {
+ #ifdef PANIC
+ fprintf(stderr, "nxagentMakeScalableFontName: PANIC! malloc() failed.\n");
+ #endif
+
+ return NULL;
+ }
+
+ scalableFontName[0] = 0;
+
+ if (*fontName != '-')
+ {
+ goto MakeScalableFontNameError;
+ }
+
+ s = fontName;
+
+ field = 0;
+
+ while (s != NULL)
+ {
+ s = strchr(s + 1, '-');
+
+ if (s != NULL)
+ {
+ if (field == 6 || field == 7 || field == 11)
+ {
+ /*
+ * PIXEL_SIZE || POINT_SIZE || AVERAGE_WIDTH
+ */
+
+ strcat(scalableFontName, "-0");
+ }
+ else if (scalableResolution == 1 && (field == 8 || field == 9))
+ {
+ /*
+ * RESOLUTION_X || RESOLUTION_Y
+ */
+
+ strcat(scalableFontName, "-0");
+ }
+ else
+ {
+ strncat(scalableFontName, fontName, s - fontName);
+ }
+
+ fontName = s;
+ }
+ else
+ {
+ strcat(scalableFontName, fontName);
+ }
+
+ field++;
+ }
+
+ if (field != 14)
+ {
+ goto MakeScalableFontNameError;
+ }
+
+ return scalableFontName;
+
+MakeScalableFontNameError:
+
+ free(scalableFontName);
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentMakeScalableFontName: Invalid font name.\n");
+ #endif
+
+ return NULL;
+}