mirror of https://github.com/buggins/dlangui.git
fonts and X11 fixes:
This commit is contained in:
parent
477e825f8f
commit
1a54009bf0
|
@ -176,6 +176,7 @@
|
||||||
<VersionIds>
|
<VersionIds>
|
||||||
<String>USE_X11</String>
|
<String>USE_X11</String>
|
||||||
<String>USE_FREETYPE</String>
|
<String>USE_FREETYPE</String>
|
||||||
|
<String>EmbedStandardResources</String>
|
||||||
</VersionIds>
|
</VersionIds>
|
||||||
</VersionIds>
|
</VersionIds>
|
||||||
<ObjectsDirectory>obj/DebugX11</ObjectsDirectory>
|
<ObjectsDirectory>obj/DebugX11</ObjectsDirectory>
|
||||||
|
|
|
@ -488,12 +488,32 @@ class FreeTypeFontManager : FontManager {
|
||||||
return null;
|
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) {
|
private FontFileItem findBestMatch(int weight, bool italic, FontFamily family, string face) {
|
||||||
FontFileItem best = null;
|
FontFileItem best = null;
|
||||||
int bestScore = 0;
|
int bestScore = 0;
|
||||||
string[] faces = face ? split(face, ",") : null;
|
string[] faces = face ? split(face, ",") : null;
|
||||||
foreach(int index, FontFileItem item; _fontFiles) {
|
foreach(int index, FontFileItem item; _fontFiles) {
|
||||||
int score = 0;
|
int score = 0;
|
||||||
|
int bestFaceMatch = 0;
|
||||||
if (faces && face.length) {
|
if (faces && face.length) {
|
||||||
for (int i = 0; i < faces.length; i++) {
|
for (int i = 0; i < faces.length; i++) {
|
||||||
string f = faces[i].strip;
|
string f = faces[i].strip;
|
||||||
|
@ -501,8 +521,12 @@ class FreeTypeFontManager : FontManager {
|
||||||
score += 3000 - i;
|
score += 3000 - i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
int match = faceMatch(f, item.def.face);
|
||||||
|
if (match > bestFaceMatch)
|
||||||
|
bestFaceMatch = match;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
score += bestFaceMatch;
|
||||||
if (family == item.def.family)
|
if (family == item.def.family)
|
||||||
score += 1000; // family match
|
score += 1000; // family match
|
||||||
if (italic == item.def.italic)
|
if (italic == item.def.italic)
|
||||||
|
@ -561,6 +585,7 @@ class FreeTypeFontManager : FontManager {
|
||||||
FontFileItem f = findBestMatch(weight, italic, family, face);
|
FontFileItem f = findBestMatch(weight, italic, family, face);
|
||||||
if (f is null)
|
if (f is null)
|
||||||
return _nullFontRef;
|
return _nullFontRef;
|
||||||
|
//Log.d("getFont requesteed: ", face, " found: ", f.def.face);
|
||||||
return f.get(size);
|
return f.get(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -243,12 +243,6 @@ class X11Window : DWindow {
|
||||||
if (width > 0 && height > 0)
|
if (width > 0 && height > 0)
|
||||||
onResize(width, height);
|
onResize(width, height);
|
||||||
Log.d(format("processExpose(%d, %d)", 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();
|
drawUsingBitmap();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue