Skip to content

Commit

Permalink
1.17
Browse files Browse the repository at this point in the history
updated
  • Loading branch information
silight-jp committed Oct 23, 2016
1 parent bc08503 commit 3d5df35
Show file tree
Hide file tree
Showing 12 changed files with 239 additions and 25 deletions.
Binary file modified bin/Release/EasyHK32.dll
Binary file not shown.
Binary file modified bin/Release/EasyHK64.dll
Binary file not shown.
Binary file modified ini/win7/UserParams.ini
Binary file not shown.
Binary file modified ini/win8.1 or later/UserParams.ini
Binary file not shown.
2 changes: 2 additions & 0 deletions readmeEN.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ How to use
Good Luck!

Version History
2016/10/11 1.17 Bug fix for High DPI.
Add ForceNoHinting for Windows Vista or later.
2016/10/08 1.16 Bug fix.
2016/10/07 1.15 Bug fix and speed up.
2016/10/05 1.14 Bug fix for High DPI.
Expand Down
Binary file modified readmeJP.txt
Binary file not shown.
8 changes: 4 additions & 4 deletions resource32.rc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,16,0,0
PRODUCTVERSION 1,16,0,0
FILEVERSION 1,17,0,0
PRODUCTVERSION 1,17,0,0
FILEFLAGSMASK 0x0L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -31,12 +31,12 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "MacTypePatch for DirectWrite Hook"
VALUE "FileVersion", "1.16.0.0"
VALUE "FileVersion", "1.17.0.0"
VALUE "InternalName", "EasyHK32.dll"
VALUE "LegalCopyright", "Copyright (C) 2016 silight"
VALUE "OriginalFilename", "EasyHK32.dll"
VALUE "ProductName", "MacTypePatch for DirectWrite Hook"
VALUE "ProductVersion", "1.16.0.0"
VALUE "ProductVersion", "1.17.0.0"
END
END
BLOCK "VarFileInfo"
Expand Down
8 changes: 4 additions & 4 deletions resource64.rc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,16,0,0
PRODUCTVERSION 1,16,0,0
FILEVERSION 1,17,0,0
PRODUCTVERSION 1,17,0,0
FILEFLAGSMASK 0x0L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -31,12 +31,12 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "MacTypePatch for DirectWrite Hook"
VALUE "FileVersion", "1.16.0.0"
VALUE "FileVersion", "1.17.0.0"
VALUE "InternalName", "EasyHK64.dll"
VALUE "LegalCopyright", "Copyright (C) 2016 silight"
VALUE "OriginalFilename", "EasyHK64.dll"
VALUE "ProductName", "MacTypePatch for DirectWrite Hook"
VALUE "ProductVersion", "1.16.0.0"
VALUE "ProductVersion", "1.17.0.0"
END
END
BLOCK "VarFileInfo"
Expand Down
151 changes: 150 additions & 1 deletion src/direct2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,43 @@ namespace Impl_ID2D1Device4
}
}

namespace Impl_ID2D1DeviceContext
{
static void WINAPI DrawGlyphRun(
ID2D1DeviceContext *This,
D2D1_POINT_2F baselineOrigin,
CONST DWRITE_GLYPH_RUN *glyphRun,
CONST DWRITE_GLYPH_RUN_DESCRIPTION *glyphRunDescription,
ID2D1Brush *foregroundBrush,
DWRITE_MEASURING_MODE measuringMode
) {
if (GeneralParams.ForceNoHinting) {
D2D1_MATRIX_3X2_F prev;
This->GetTransform(&prev);
D2D1_MATRIX_3X2_F rotate = prev;
rotate.m12 += 1.0f / 0xFFFF;
rotate.m21 += 1.0f / 0xFFFF;
This->SetTransform(&rotate);
This->DrawGlyphRun(
baselineOrigin,
glyphRun,
glyphRunDescription,
foregroundBrush,
measuringMode
);
This->SetTransform(&prev);
} else {
This->DrawGlyphRun(
baselineOrigin,
glyphRun,
glyphRunDescription,
foregroundBrush,
measuringMode
);
}
}
}

namespace Impl_ID2D1Factory
{
static HRESULT WINAPI CreateWicBitmapRenderTarget(
Expand Down Expand Up @@ -285,7 +322,109 @@ namespace Impl_ID2D1RenderTarget
}
return hr;
}


static void WINAPI DrawText(
ID2D1RenderTarget* This,
CONST WCHAR *string,
UINT32 stringLength,
IDWriteTextFormat *textFormat,
CONST D2D1_RECT_F *layoutRect,
ID2D1Brush *defaultForegroundBrush,
D2D1_DRAW_TEXT_OPTIONS options,
DWRITE_MEASURING_MODE measuringMode
) {
if (GeneralParams.ForceNoHinting) {
D2D1_MATRIX_3X2_F prev;
This->GetTransform(&prev);
D2D1_MATRIX_3X2_F rotate = prev;
rotate.m12 += 1.0f / 0xFFFF;
rotate.m21 += 1.0f / 0xFFFF;
This->SetTransform(&rotate);
This->DrawText(
string,
stringLength,
textFormat,
layoutRect,
defaultForegroundBrush,
options,
measuringMode
);
This->SetTransform(&prev);
} else {
This->DrawText(
string,
stringLength,
textFormat,
layoutRect,
defaultForegroundBrush,
options,
measuringMode
);
}
}

static void WINAPI DrawTextLayout(
ID2D1RenderTarget* This,
D2D1_POINT_2F origin,
IDWriteTextLayout *textLayout,
ID2D1Brush *defaultForegroundBrush,
D2D1_DRAW_TEXT_OPTIONS options
) {
if (GeneralParams.ForceNoHinting) {
D2D1_MATRIX_3X2_F prev;
This->GetTransform(&prev);
D2D1_MATRIX_3X2_F rotate = prev;
rotate.m12 += 1.0f / 0xFFFF;
rotate.m21 += 1.0f / 0xFFFF;
This->SetTransform(&rotate);
This->DrawTextLayout(
origin,
textLayout,
defaultForegroundBrush,
options
);
This->SetTransform(&prev);
} else {
This->DrawTextLayout(
origin,
textLayout,
defaultForegroundBrush,
options
);
}
}

static void WINAPI DrawGlyphRun(
ID2D1RenderTarget* This,
D2D1_POINT_2F baselineOrigin,
CONST DWRITE_GLYPH_RUN *glyphRun,
ID2D1Brush *foregroundBrush,
DWRITE_MEASURING_MODE measuringMode
) {
if (GeneralParams.ForceNoHinting) {
D2D1_MATRIX_3X2_F prev;
This->GetTransform(&prev);
D2D1_MATRIX_3X2_F rotate = prev;
rotate.m12 += 1.0f / 0xFFFF;
rotate.m21 += 1.0f / 0xFFFF;
This->SetTransform(&rotate);
This->DrawGlyphRun(
baselineOrigin,
glyphRun,
foregroundBrush,
measuringMode
);
This->SetTransform(&prev);
} else {
This->DrawGlyphRun(
baselineOrigin,
glyphRun,
foregroundBrush,
measuringMode
);
}
}

static void WINAPI SetTextAntialiasMode(
ID2D1RenderTarget* This,
D2D1_TEXT_ANTIALIAS_MODE textAntialiasMode
Expand Down Expand Up @@ -364,10 +503,18 @@ static void hookID2D1Factory5(ID2D1Factory5* pD2D1Factory5) {
static void hookID2D1RenderTarget(ID2D1RenderTarget* pD2D1RenderTarget) {
void** v = getVtbl(pD2D1RenderTarget);
hook(v[12], Impl_ID2D1RenderTarget::CreateCompatibleRenderTarget);
hook(v[27], Impl_ID2D1RenderTarget::DrawText);
hook(v[28], Impl_ID2D1RenderTarget::DrawTextLayout);
hook(v[29], Impl_ID2D1RenderTarget::DrawGlyphRun);
hook(v[34], Impl_ID2D1RenderTarget::SetTextAntialiasMode);
hook(v[36], Impl_ID2D1RenderTarget::SetTextRenderingParams);
}

static void hookID2D1DeviceContext(ID2D1DeviceContext* pD2D1DeviceContext) {
void** v = getVtbl(pD2D1DeviceContext);
hook(v[82], Impl_ID2D1DeviceContext::DrawGlyphRun);
}



static void hookID2D1DeviceIfStill(ID2D1Device* pD2D1Device) {
Expand Down Expand Up @@ -395,6 +542,7 @@ static void hookID2D1DeviceContextIfStill2(ID2D1DeviceContext* pD2D1DeviceContex
auto lock = globalMutex.getLock();
if (insertVtbl(vtbl)) {
hookID2D1RenderTarget(pD2D1DeviceContext);
hookID2D1DeviceContext(pD2D1DeviceContext);
}
}

Expand All @@ -419,6 +567,7 @@ static void hookID2D1DeviceContextIfStill(ID2D1DeviceContext* pD2D1DeviceContext
auto lock = globalMutex.getLock();
if (insertVtbl(vtbl)) {
hookID2D1RenderTarget(pD2D1DeviceContext);
hookID2D1DeviceContext(pD2D1DeviceContext);
hookIfImplemented(pD2D1DeviceContext, hookID2D1RenderTargetIfStill2);

ID2D1Factory* pD2D1Factory;
Expand Down
87 changes: 72 additions & 15 deletions src/directwrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,34 @@ namespace Impl_IDWriteBitmapRenderTarget
) {
HRESULT hr = E_FAIL;
if (FAILED(hr)) {
hr = This->DrawGlyphRun(
baselineOriginX,
baselineOriginY,
measuringMode,
glyphRun,
DirectWriteParams.getDWriteRenderingParams(),
textColor,
blackBoxRect
);
if (GeneralParams.ForceNoHinting) {
DWRITE_MATRIX prev;
This->GetCurrentTransform(&prev);
DWRITE_MATRIX rotate = prev;
rotate.m12 += 1.0f / 0xFFFF;
rotate.m21 += 1.0f / 0xFFFF;
This->SetCurrentTransform(&rotate);
hr = This->DrawGlyphRun(
baselineOriginX,
baselineOriginY,
measuringMode,
glyphRun,
DirectWriteParams.getDWriteRenderingParams(),
textColor,
blackBoxRect
);
This->SetCurrentTransform(&prev);
} else {
hr = This->DrawGlyphRun(
baselineOriginX,
baselineOriginY,
measuringMode,
glyphRun,
DirectWriteParams.getDWriteRenderingParams(),
textColor,
blackBoxRect
);
}
}
if (FAILED(hr)) {
hr = This->DrawGlyphRun(
Expand Down Expand Up @@ -66,7 +85,7 @@ namespace Impl_IDWriteFactory
}
return hr;
}

static HRESULT WINAPI GetGdiInterop(
IDWriteFactory* This,
IDWriteGdiInterop** gdiInterop
Expand Down Expand Up @@ -98,7 +117,11 @@ namespace Impl_IDWriteFactory
if (transform) {
m = *transform;
m.m11 *= pixelsPerDip;
m.m12 *= pixelsPerDip;
m.m21 *= pixelsPerDip;
m.m22 *= pixelsPerDip;
m.dx *= pixelsPerDip;
m.dy *= pixelsPerDip;
} else {
m.m11 = pixelsPerDip;
m.m22 = pixelsPerDip;
Expand All @@ -117,12 +140,23 @@ namespace Impl_IDWriteFactory
f->Release();
}
}

if (FAILED(hr) && renderingMode != DWRITE_RENDERING_MODE_ALIASED) {
DWRITE_MATRIX m;
DWRITE_MATRIX const* pm = transform;
if (GeneralParams.ForceNoHinting) {
if (transform) {
m = *transform;
m.m12 += 1.0f / 0xFFFF;
m.m21 += 1.0f / 0xFFFF;
} else {
m = { 1, 1.0f / 0xFFFF, 1.0f / 0xFFFF, 1 };
}
pm = &m;
}
hr = This->CreateGlyphRunAnalysis(
glyphRun,
pixelsPerDip,
transform,
pm,
DirectWriteParams.RenderingMode,
measuringMode,
baselineOriginX,
Expand Down Expand Up @@ -183,9 +217,21 @@ namespace Impl_IDWriteFactory2
}
}
if (FAILED(hr) && renderingMode != DWRITE_RENDERING_MODE_ALIASED) {
DWRITE_MATRIX m;
DWRITE_MATRIX const* pm = transform;
if (GeneralParams.ForceNoHinting) {
if (transform) {
m = *transform;
m.m12 += 1.0f / 0xFFFF;
m.m21 += 1.0f / 0xFFFF;
} else {
m = { 1, 1.0f / 0xFFFF, 1.0f / 0xFFFF, 1 };
}
pm = &m;
}
hr = This->CreateGlyphRunAnalysis(
glyphRun,
transform,
pm,
DirectWriteParams.RenderingMode,
measuringMode,
DirectWriteParams.GridFitMode,
Expand Down Expand Up @@ -231,9 +277,21 @@ namespace Impl_IDWriteFactory3
) {
HRESULT hr = E_FAIL;
if (FAILED(hr) && renderingMode != DWRITE_RENDERING_MODE1_ALIASED) {
DWRITE_MATRIX m;
DWRITE_MATRIX const* pm = transform;
if (GeneralParams.ForceNoHinting) {
if (transform) {
m = *transform;
m.m12 += 1.0f / 0xFFFF;
m.m21 += 1.0f / 0xFFFF;
} else {
m = { 1, 1.0f / 0xFFFF, 1.0f / 0xFFFF, 1 };
}
pm = &m;
}
hr = This->CreateGlyphRunAnalysis(
glyphRun,
transform,
pm,
DirectWriteParams.RenderingMode1,
measuringMode,
DirectWriteParams.GridFitMode,
Expand Down Expand Up @@ -317,7 +375,6 @@ namespace Impl_IDWriteGlyphRunAnalysis

namespace Impl_IDWriteFontCollection
{

static HRESULT WINAPI FindFamilyName(
IDWriteFontCollection* This,
WCHAR const* familyName,
Expand Down
Loading

0 comments on commit 3d5df35

Please sign in to comment.