< prev index next >
src/java.desktop/windows/native/libawt/windows/awt_Font.cpp
Print this page
*** 396,405 ****
--- 396,437 ----
*p = 0;
}
}
+ static int ScaleUpX(float x) {
+ int deviceIndex = AwtWin32GraphicsDevice::DeviceIndexForWindow(
+ ::GetDesktopWindow());
+ Devices::InstanceAccess devices;
+ AwtWin32GraphicsDevice *device = devices->GetDevice(deviceIndex);
+ return device == NULL ? x : device->ScaleUpX(x);
+ }
+
+ static int ScaleUpY(int y) {
+ int deviceIndex = AwtWin32GraphicsDevice::DeviceIndexForWindow(
+ ::GetDesktopWindow());
+ Devices::InstanceAccess devices;
+ AwtWin32GraphicsDevice *device = devices->GetDevice(deviceIndex);
+ return device == NULL ? y : device->ScaleUpY(y);
+ }
+
+ static int ScaleDownX(int x) {
+ int deviceIndex = AwtWin32GraphicsDevice::DeviceIndexForWindow(
+ ::GetDesktopWindow());
+ Devices::InstanceAccess devices;
+ AwtWin32GraphicsDevice *device = devices->GetDevice(deviceIndex);
+ return device == NULL ? x : device->ScaleDownX(x);
+ }
+
+ static int ScaleDownY(int y) {
+ int deviceIndex = AwtWin32GraphicsDevice::DeviceIndexForWindow(
+ ::GetDesktopWindow());
+ Devices::InstanceAccess devices;
+ AwtWin32GraphicsDevice *device = devices->GetDevice(deviceIndex);
+ return device == NULL ? y : device->ScaleDownY(y);
+ }
+
static HFONT CreateHFont_sub(LPCWSTR name, int style, int height,
int angle=0, float awScale=1.0f)
{
LOGFONTW logFont;
*** 422,432 ****
logFont.lfWeight = (style & java_awt_Font_BOLD) ? FW_BOLD : FW_NORMAL;
logFont.lfItalic = (style & java_awt_Font_ITALIC) != 0;
logFont.lfUnderline = 0;//(style & java_awt_Font_UNDERLINE) != 0;
// Get point size
! logFont.lfHeight = -height;
// Set font name
WCHAR tmpname[80];
wcscpy(tmpname, name);
WCHAR* delimit = wcschr(tmpname, L',');
--- 454,464 ----
logFont.lfWeight = (style & java_awt_Font_BOLD) ? FW_BOLD : FW_NORMAL;
logFont.lfItalic = (style & java_awt_Font_ITALIC) != 0;
logFont.lfUnderline = 0;//(style & java_awt_Font_UNDERLINE) != 0;
// Get point size
! logFont.lfHeight = ScaleUpY(-height);
// Set font name
WCHAR tmpname[80];
wcscpy(tmpname, name);
WCHAR* delimit = wcschr(tmpname, L',');
*** 449,459 ****
oldFont = (HFONT)::SelectObject(hDC, oldFont);
if (oldFont != NULL) { // should be the same as hFont
VERIFY(::DeleteObject(oldFont));
}
avgWidth = tm.tmAveCharWidth;
! logFont.lfWidth = (LONG)((fabs)(avgWidth*awScale));
hFont = ::CreateFontIndirect(&logFont);
DASSERT(hFont != NULL);
VERIFY(::ReleaseDC(0, hDC));
}
--- 481,491 ----
oldFont = (HFONT)::SelectObject(hDC, oldFont);
if (oldFont != NULL) { // should be the same as hFont
VERIFY(::DeleteObject(oldFont));
}
avgWidth = tm.tmAveCharWidth;
! logFont.lfWidth = (LONG) ScaleUpX((fabs) (avgWidth * awScale));
hFont = ::CreateFontIndirect(&logFont);
DASSERT(hFont != NULL);
VERIFY(::ReleaseDC(0, hDC));
}
*** 533,555 ****
awtFont->m_ascent = metrics.tmAscent;
int ascent = metrics.tmAscent;
int descent = metrics.tmDescent;
int leading = metrics.tmExternalLeading;
! env->SetIntField(fontMetrics, AwtFont::ascentID, ascent);
! env->SetIntField(fontMetrics, AwtFont::descentID, descent);
! env->SetIntField(fontMetrics, AwtFont::leadingID, leading);
! env->SetIntField(fontMetrics, AwtFont::heightID, metrics.tmAscent +
! metrics.tmDescent + leading);
! env->SetIntField(fontMetrics, AwtFont::maxAscentID, ascent);
! env->SetIntField(fontMetrics, AwtFont::maxDescentID, descent);
int maxHeight = ascent + descent + leading;
! env->SetIntField(fontMetrics, AwtFont::maxHeightID, maxHeight);
int maxAdvance = metrics.tmMaxCharWidth;
! env->SetIntField(fontMetrics, AwtFont::maxAdvanceID, maxAdvance);
awtFont->m_overhang = metrics.tmOverhang;
jint intWidths[256];
memset(intWidths, 0, 256 * sizeof(int));
--- 565,588 ----
awtFont->m_ascent = metrics.tmAscent;
int ascent = metrics.tmAscent;
int descent = metrics.tmDescent;
int leading = metrics.tmExternalLeading;
!
! env->SetIntField(fontMetrics, AwtFont::ascentID, ScaleDownY(ascent));
! env->SetIntField(fontMetrics, AwtFont::descentID, ScaleDownY(descent));
! env->SetIntField(fontMetrics, AwtFont::leadingID, ScaleDownX(leading));
! env->SetIntField(fontMetrics, AwtFont::heightID,
! ScaleDownY(metrics.tmAscent + metrics.tmDescent + leading));
! env->SetIntField(fontMetrics, AwtFont::maxAscentID, ScaleDownY(ascent));
! env->SetIntField(fontMetrics, AwtFont::maxDescentID, ScaleDownY(descent));
int maxHeight = ascent + descent + leading;
! env->SetIntField(fontMetrics, AwtFont::maxHeightID, ScaleDownY(maxHeight));
int maxAdvance = metrics.tmMaxCharWidth;
! env->SetIntField(fontMetrics, AwtFont::maxAdvanceID, ScaleDownX(maxAdvance));
awtFont->m_overhang = metrics.tmOverhang;
jint intWidths[256];
memset(intWidths, 0, 256 * sizeof(int));
*** 816,825 ****
--- 849,859 ----
HDC hDC = ::GetDC(0); DASSERT(hDC != NULL);
jobject font = env->GetObjectField(self, AwtFont::fontID);
long ret = AwtFont::getMFStringWidth(hDC, font, str);
+ ret = ScaleDownX(ret);
VERIFY(::ReleaseDC(0, hDC));
return ret;
CATCH_BAD_ALLOC_RET(0);
}
*** 922,932 ****
}
throw;
}
env->ReleasePrimitiveArrayCritical(str, pStrBody, 0);
! return result;
CATCH_BAD_ALLOC_RET(0);
}
--- 956,966 ----
}
throw;
}
env->ReleasePrimitiveArrayCritical(str, pStrBody, 0);
! return ScaleDownX(result);
CATCH_BAD_ALLOC_RET(0);
}
< prev index next >