Skip to content

Commit

Permalink
Add font smoothing settings (#943)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImperatorS79 authored Jun 28, 2019
1 parent a1cb1a2 commit bba2f5b
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Engines/Wine/Plugins/Font smoothing/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
include("engines.wine.engine.object");

/**
* Force the Font smoothing
* @param {string} mode ("RGB", "BGR" or "Gray Scale")
* @returns {Wine} Wine object
*/
Wine.prototype.fontSmoothing = function (mode) {
let fontSmoothingType;
let fontSmoothingOrientation;
if (mode === "RGB") {
fontSmoothingType = "2";
fontSmoothingOrientation = "1";
}
else if (mode === "BGR") {
fontSmoothingType = "2";
fontSmoothingOrientation = "0";
}
else if (mode === "Gray Scale"){
fontSmoothingType = "1";
fontSmoothingOrientation = "1";
}
else {
throw tr("Unknown font smoothing mode: \"{0}\"", mode);
}

const regeditFileContent =
"REGEDIT4\n" +
"\n" +
"[HKEY_CURRENT_USER\\Control Panel\\Desktop]\n" +
"\"FontSmoothing\"=\"2\"\n" +
"\"FontSmoothingType\"=dword:0000000" + fontSmoothingType + "\n" +
"\"FontSmoothingGamma\"=dword:00000578\n" +
"\"FontSmoothingOrientation\"=dword:0000000" + fontSmoothingOrientation + "\n";

this.regedit().patch(regeditFileContent);
return this;
};
11 changes: 11 additions & 0 deletions Engines/Wine/Plugins/Font smoothing/script.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"scriptName" : "Font smoothing",
"id" : "engines.wine.plugins.font_smoothing",
"compatibleOperatingSystems" : [
"MACOSX",
"LINUX"
],
"testingOperatingSystems" : [],
"free" : true,
"requiresPatch" : false
}
79 changes: 79 additions & 0 deletions Engines/Wine/Settings/Font smoothing/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
include("engines.wine.engine.object");
include("engines.wine.plugins.regedit");
include("engines.wine.plugins.font_smoothing");

/**
* Setting to set the Fonts Smoothing
*/
var settingImplementation = {
_options: [tr("Default"), tr("RGB"), tr("BGR"), tr("Gray Scale")],

getText: function () {
return tr("Fonts Smoothing");
},
getOptions: function () {
return this._options;
},
getCurrentOption: function (container) {
const fontSmoothing = new Wine()
.prefix(container)
.regedit()
.fetchValue(["HKEY_CURRENT_USER", "Control Panel", "Desktop", "FontSmoothing"]);

const fontSmoothingType = new Wine()
.prefix(container)
.regedit()
.fetchValue(["HKEY_CURRENT_USER", "Control Panel", "Desktop", "FontSmoothingType"]);

const fontSmoothingOrientation = new Wine()
.prefix(container)
.regedit()
.fetchValue(["HKEY_CURRENT_USER", "Control Panel", "Desktop", "FontSmoothingOrientation"]);

let index;

if (fontSmoothing == 1) {
index = 0;
}
else {
if (fontSmoothingType == 2) {
if (fontSmoothingOrientation == 1) {
index = 1;
}
else {
index = 2;
}
}
else if (fontSmoothingType == 1) {
index = 3;
}
}

return this._options[index];
},
setOption: function (container, optionIndex) {
if (0 === optionIndex) {
const regeditFileContent =
"REGEDIT4\n" +
"\n" +
"[HKEY_CURRENT_USER\\Control Panel\\Desktop]\n" +
"\"FontSmoothing\"=\"1\"\n" +
"\"FontSmoothingType\"=dword:00000001\n" +
"\"FontSmoothingGamma\"=dword:00000000\n" +
"\"FontSmoothingOrientation\"=dword:00000001";

new Wine()
.prefix(container)
.regedit()
.patch(regeditFileContent);
}
else {
new Wine()
.prefix(container)
.fontSmoothing(this._options[optionIndex]);
}
}
};

/* exported Setting */
var Setting = Java.extend(org.phoenicis.engines.EngineSetting, settingImplementation);
11 changes: 11 additions & 0 deletions Engines/Wine/Settings/Font smoothing/script.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"scriptName" : "Font smoothing",
"id" : "engines.wine.settings.font_smoothing",
"compatibleOperatingSystems" : [
"MACOSX",
"LINUX"
],
"testingOperatingSystems" : [],
"free" : true,
"requiresPatch" : false
}

0 comments on commit bba2f5b

Please sign in to comment.