Nikolay Sivov : riched20: Convert from twips to points when tomUsePoints is used.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri May 29 05:29:48 CDT 2015
Module: wine
Branch: master
Commit: eecb757248c0383464a0338271054f9b0d28cf7f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=eecb757248c0383464a0338271054f9b0d28cf7f
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed May 27 23:52:05 2015 +0300
riched20: Convert from twips to points when tomUsePoints is used.
---
dlls/riched20/richole.c | 11 ++++++++---
dlls/riched20/tests/richole.c | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 63926e2..008c124 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -416,6 +416,11 @@ static inline void init_textfont_prop_value(enum textfont_prop_id propid, textfo
}
}
+static inline FLOAT twips_to_points(LONG value)
+{
+ return value * 72.0 / 1440;
+}
+
static HRESULT get_textfont_prop_for_pos(const IRichEditOleImpl *reole, int pos, enum textfont_prop_id propid,
textfont_prop_val *value)
{
@@ -459,7 +464,7 @@ static HRESULT get_textfont_prop_for_pos(const IRichEditOleImpl *reole, int pos,
value->l = fmt.dwEffects & CFE_AUTOCOLOR ? GetSysColor(COLOR_WINDOWTEXT) : fmt.crTextColor;
break;
case FONT_KERNING:
- value->f = fmt.wKerning;
+ value->f = twips_to_points(fmt.wKerning);
break;
case FONT_LANGID:
value->l = fmt.lcid;
@@ -471,10 +476,10 @@ static HRESULT get_textfont_prop_for_pos(const IRichEditOleImpl *reole, int pos,
return E_OUTOFMEMORY;
break;
case FONT_POSITION:
- value->f = fmt.yOffset;
+ value->f = twips_to_points(fmt.yOffset);
break;
case FONT_SIZE:
- value->f = fmt.yHeight;
+ value->f = twips_to_points(fmt.yHeight);
break;
case FONT_SPACING:
value->f = fmt.sSpacing;
diff --git a/dlls/riched20/tests/richole.c b/dlls/riched20/tests/richole.c
index 3e41ede..327b3ac 100644
--- a/dlls/riched20/tests/richole.c
+++ b/dlls/riched20/tests/richole.c
@@ -2111,11 +2111,17 @@ static void test_textfont_undefined(ITextFont *font)
ok(value == tomUndefined, "got %d\n", value);
}
+static inline FLOAT twips_to_points(LONG value)
+{
+ return value * 72.0 / 1440;
+}
+
static void test_ITextFont(void)
{
static const WCHAR arialW[] = {'A','r','i','a','l',0};
static const CHAR test_text1[] = "TestSomeText";
ITextFont *font, *font2, *font3;
+ FLOAT size, position, kerning;
IRichEditOle *reOle = NULL;
ITextDocument *doc = NULL;
ITextRange *range = NULL;
@@ -2138,6 +2144,38 @@ static void test_ITextFont(void)
hr = ITextFont_GetName(font, NULL);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
+ /* default font size unit is point */
+ size = 0.0;
+ hr = ITextFont_GetSize(font, &size);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ /* set to some non-zero values */
+ hr = ITextFont_SetPosition(font, 20.0);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = ITextFont_SetKerning(font, 10.0);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ position = 0.0;
+ hr = ITextFont_GetPosition(font, &position);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ kerning = 0.0;
+ hr = ITextFont_GetKerning(font, &kerning);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ memset(&cf, 0, sizeof(cf));
+ cf.cbSize = sizeof(cf);
+ cf.dwMask = CFM_SIZE|CFM_OFFSET|CFM_KERNING;
+
+ /* CHARFORMAT members are in twips */
+ SendMessageA(hwnd, EM_SETSEL, 0, 10);
+ ret = SendMessageA(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
+ ok(ret, "got %d\n", ret);
+ ok(size == twips_to_points(cf.yHeight), "got yHeight %d, size %.2f\n", cf.yHeight, size);
+ ok(position == twips_to_points(cf.yOffset), "got yOffset %d, position %.2f\n", cf.yOffset, position);
+ ok(kerning == twips_to_points(cf.wKerning), "got wKerning %d, kerning %.2f\n", cf.wKerning, kerning);
+
/* default font name */
str = NULL;
hr = ITextFont_GetName(font, &str);
More information about the wine-cvs
mailing list