X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/bf02e82ebf5cdbe3eee6b64f6a12b2a55d26fc58..9a30e26b7801d63e4ccfe8d36169299c09b89dff:/winstore.c diff --git a/winstore.c b/winstore.c index 3199c1cd..a69d58d0 100644 --- a/winstore.c +++ b/winstore.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "putty.h" #include "storage.h" @@ -150,6 +151,67 @@ int read_setting_i(void *handle, const char *key, int defvalue) return val; } +int read_setting_fontspec(void *handle, const char *name, FontSpec *result) +{ + char *settingname; + FontSpec ret; + + if (!read_setting_s(handle, name, ret.name, sizeof(ret.name))) + return 0; + settingname = dupcat(name, "IsBold", NULL); + ret.isbold = read_setting_i(handle, settingname, -1); + sfree(settingname); + if (ret.isbold == -1) return 0; + settingname = dupcat(name, "CharSet", NULL); + ret.charset = read_setting_i(handle, settingname, -1); + sfree(settingname); + if (ret.charset == -1) return 0; + settingname = dupcat(name, "Height", NULL); + ret.height = read_setting_i(handle, settingname, INT_MIN); + sfree(settingname); + if (ret.height == INT_MIN) return 0; + if (ret.height < 0) { + int oldh, newh; + HDC hdc = GetDC(NULL); + int logpix = GetDeviceCaps(hdc, LOGPIXELSY); + ReleaseDC(NULL, hdc); + + oldh = -ret.height; + newh = MulDiv(oldh, 72, logpix) + 1; + if (MulDiv(newh, logpix, 72) > oldh) + newh--; + ret.height = newh; + } + *result = ret; + return 1; +} + +void write_setting_fontspec(void *handle, const char *name, FontSpec font) +{ + char *settingname; + + write_setting_s(handle, name, font.name); + settingname = dupcat(name, "IsBold", NULL); + write_setting_i(handle, settingname, font.isbold); + sfree(settingname); + settingname = dupcat(name, "CharSet", NULL); + write_setting_i(handle, settingname, font.charset); + sfree(settingname); + settingname = dupcat(name, "Height", NULL); + write_setting_i(handle, settingname, font.height); + sfree(settingname); +} + +int read_setting_filename(void *handle, const char *name, Filename *result) +{ + return !!read_setting_s(handle, name, result->path, sizeof(result->path)); +} + +void write_setting_filename(void *handle, const char *name, Filename result) +{ + write_setting_s(handle, name, result.path); +} + void close_settings_r(void *handle) { RegCloseKey((HKEY) handle);