fonts and X11 fixes:

This commit is contained in:
Vadim Lopatin 2015-12-01 13:29:36 +03:00
parent 477e825f8f
commit 1a54009bf0
3 changed files with 26 additions and 6 deletions

View File

@ -176,6 +176,7 @@
<VersionIds>
<String>USE_X11</String>
<String>USE_FREETYPE</String>
<String>EmbedStandardResources</String>
</VersionIds>
</VersionIds>
<ObjectsDirectory>obj/DebugX11</ObjectsDirectory>

View File

@ -488,12 +488,32 @@ class FreeTypeFontManager : FontManager {
return null;
}
private static int faceMatch(string requested, string existing) {
if (!requested.icmp("Arial")) {
if (!existing.icmp("DejaVu Sans")) {
return 200;
}
}
if (!requested.icmp("Times New Roman")) {
if (!existing.icmp("DejaVu Serif")) {
return 200;
}
}
if (!requested.icmp("Courier New")) {
if (!existing.icmp("DejaVu Sans Mono")) {
return 200;
}
}
return 0;
}
private FontFileItem findBestMatch(int weight, bool italic, FontFamily family, string face) {
FontFileItem best = null;
int bestScore = 0;
string[] faces = face ? split(face, ",") : null;
foreach(int index, FontFileItem item; _fontFiles) {
int score = 0;
int bestFaceMatch = 0;
if (faces && face.length) {
for (int i = 0; i < faces.length; i++) {
string f = faces[i].strip;
@ -501,8 +521,12 @@ class FreeTypeFontManager : FontManager {
score += 3000 - i;
break;
}
int match = faceMatch(f, item.def.face);
if (match > bestFaceMatch)
bestFaceMatch = match;
}
}
score += bestFaceMatch;
if (family == item.def.family)
score += 1000; // family match
if (italic == item.def.italic)
@ -561,6 +585,7 @@ class FreeTypeFontManager : FontManager {
FontFileItem f = findBestMatch(weight, italic, family, face);
if (f is null)
return _nullFontRef;
//Log.d("getFont requesteed: ", face, " found: ", f.def.face);
return f.get(size);
}

View File

@ -243,12 +243,6 @@ class X11Window : DWindow {
if (width > 0 && height > 0)
onResize(width, height);
Log.d(format("processExpose(%d, %d)", width, height));
// ulong black, white;
// black = BlackPixel(x11display, x11screen); /* get color black */
// white = WhitePixel(x11display, x11screen); /* get color white */
// XSetBackground(x11display, _gc, white);
// XClearWindow(x11display, _win);
drawUsingBitmap();