Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ void checkGDIP() {
protected void create (DeviceData data) {
}

int computePixels(float height) {
int computePixels(float height, int zoom) {
long hDC = internal_new_GC (null);
int pixels = -(int)(0.5f + (height * OS.GetDeviceCaps(hDC, OS.LOGPIXELSY) / 72f));
int pixels = -(int)(0.5f + (height / calculateFontConversionFactor(hDC, zoom)));
internal_dispose_GC (hDC, null);
return pixels;
}
Expand All @@ -271,9 +271,7 @@ float computePoints(LOGFONT logFont, long hFont) {
return computePoints(logFont, hFont, SWT.DEFAULT);
}

float computePoints(LOGFONT logFont, long hFont, int zoom) {
long hDC = internal_new_GC (null);

private float calculateFontConversionFactor(long hDC, int zoom) {
float conversionFactor = 72f;
if (isAutoScalable() && zoom != SWT.DEFAULT) {
// For auto scalable devices we need to use a dynamic
Expand All @@ -282,6 +280,13 @@ float computePoints(LOGFONT logFont, long hFont, int zoom) {
} else {
conversionFactor /= OS.GetDeviceCaps(hDC, OS.LOGPIXELSY);
}
return conversionFactor;
}

float computePoints(LOGFONT logFont, long hFont, int zoom) {
long hDC = internal_new_GC (null);

float conversionFactor = calculateFontConversionFactor(hDC, zoom);
int pixels = 0;
if (logFont.lfHeight > 0) {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,7 @@ void init (FontData fd) {
if (fd == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
LOGFONT logFont = fd.data;
int lfHeight = logFont.lfHeight;
logFont.lfHeight = device.computePixels(fd.height);

int primaryZoom = extractZoom(device);
if (zoom != primaryZoom) {
float scaleFactor = 1f * zoom / primaryZoom;
logFont.lfHeight *= scaleFactor;
}

logFont.lfHeight = device.computePixels(fd.height, zoom);
handle = OS.CreateFontIndirect(logFont);
logFont.lfHeight = lfHeight;
if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ private Font getScaledFont(int targetZoom) {
private Font scaleFont(int zoom) {
FontData fontData = baseFont.getFontData()[0];
int baseZoom = computeZoom(fontData);
int zoomScaleFactor = Math.round(1.0f * zoom / baseZoom);
fontData.data.lfHeight *= zoomScaleFactor;
fontData.data.lfHeight = Math.round(1.0f * fontData.data.lfHeight * zoom / baseZoom);
Font scaledFont = Font.win32_new(device, fontData, zoom);
addScaledFont(zoom, scaledFont);
return scaledFont;
Expand Down
Loading