author | aivanov |
Thu, 14 Apr 2016 13:07:35 +0300 | |
changeset 37687 | bf6516a24734 |
parent 25859 | 3317bb8137f4 |
permissions | -rw-r--r-- |
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
18232
diff
changeset
|
2 |
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. |
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
4 |
* |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
10 |
* |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
15 |
* accompanied this code). |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
16 |
* |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
20 |
* |
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
24 |
*/ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
25 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
26 |
/* |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
27 |
* The function here is used to get a GDI rasterized LCD glyph and place it |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
28 |
* into the JDK glyph cache. The benefit is rendering fidelity for the |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
29 |
* most common cases, with no impact on the 2D rendering pipelines. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
30 |
* |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
31 |
* Requires that the font and graphics are unrotated, and the scale is |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
32 |
* a simple one, and the font is a TT font registered with windows. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
33 |
* Those conditions are established by the calling code. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
34 |
* |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
35 |
* This code |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
36 |
* - Receives the family name, style, and size of the font |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
37 |
* and creates a Font object. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
38 |
* - Create a surface from which we can get a DC : must be 16 bit or more. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
39 |
* Ideally we'd be able to specify the depth of this, but in practice we |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
40 |
* have to accept it will be the same as the default screen. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
41 |
* - Selects the GDI font on to the device |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
42 |
* - Uses GetGlyphOutline to estimate the bounds. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
43 |
* - Creates a DIB on to which to blit the image. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
44 |
* - Creates a GlyphInfo structure and copies the GDI glyph and offsets |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
45 |
* into the glyph which is returned. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
46 |
*/ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
47 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
48 |
#include <stdio.h> |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
49 |
#include <malloc.h> |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
50 |
#include <math.h> |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
51 |
#include <windows.h> |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
52 |
#include <winuser.h> |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
53 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
54 |
#include <jni.h> |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
55 |
#include <jni_util.h> |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
56 |
#include <jlong_md.h> |
18232 | 57 |
#include <sizecalc.h> |
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
58 |
#include <sun_font_FileFontStrike.h> |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
59 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
60 |
#include "fontscalerdefs.h" |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
61 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
62 |
/* Some of these are also defined in awtmsg.h but I don't want a dependency |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
63 |
* on that here. They are needed here - and in awtmsg.h - until we |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
64 |
* move up our build to define WIN32_WINNT >= 0x501 (ie XP), since MS |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
65 |
* headers will not define them otherwise. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
66 |
*/ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
67 |
#ifndef SPI_GETFONTSMOOTHINGTYPE |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
68 |
#define SPI_GETFONTSMOOTHINGTYPE 0x200A |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
69 |
#endif //SPI_GETFONTSMOOTHINGTYPE |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
70 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
71 |
#ifndef SPI_GETFONTSMOOTHINGCONTRAST |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
72 |
#define SPI_GETFONTSMOOTHINGCONTRAST 0x200C |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
73 |
#endif //SPI_GETFONTSMOOTHINGCONTRAST |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
74 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
75 |
#ifndef SPI_GETFONTSMOOTHINGORIENTATION |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
76 |
#define SPI_GETFONTSMOOTHINGORIENTATION 0x2012 |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
77 |
#endif //SPI_GETFONTSMOOTHINGORIENTATION |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
78 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
79 |
#ifndef FE_FONTSMOOTHINGORIENTATIONBGR |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
80 |
#define FE_FONTSMOOTHINGORIENTATIONBGR 0x0000 |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
81 |
#endif //FE_FONTSMOOTHINGORIENTATIONBGR |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
82 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
83 |
#ifndef FE_FONTSMOOTHINGORIENTATIONRGB |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
84 |
#define FE_FONTSMOOTHINGORIENTATIONRGB 0x0001 |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
85 |
#endif //FE_FONTSMOOTHINGORIENTATIONRGB |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
86 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
87 |
#define MIN_GAMMA 100 |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
88 |
#define MAX_GAMMA 220 |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
89 |
#define LCDLUTCOUNT (MAX_GAMMA-MIN_GAMMA+1) |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
90 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
91 |
static unsigned char* igLUTable[LCDLUTCOUNT]; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
92 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
93 |
static unsigned char* getIGTable(int gamma) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
94 |
int i, index; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
95 |
double ig; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
96 |
char *igTable; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
97 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
98 |
if (gamma < MIN_GAMMA) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
99 |
gamma = MIN_GAMMA; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
100 |
} else if (gamma > MAX_GAMMA) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
101 |
gamma = MAX_GAMMA; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
102 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
103 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
104 |
index = gamma - MIN_GAMMA; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
105 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
106 |
if (igLUTable[index] != NULL) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
107 |
return igLUTable[index]; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
108 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
109 |
igTable = (unsigned char*)malloc(256); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
110 |
if (igTable == NULL) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
111 |
return NULL; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
112 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
113 |
igTable[0] = 0; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
114 |
igTable[255] = 255; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
115 |
ig = ((double)gamma)/100.0; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
116 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
117 |
for (i=1;i<255;i++) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
118 |
igTable[i] = (unsigned char)(pow(((double)i)/255.0, ig)*255); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
119 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
120 |
igLUTable[index] = igTable; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
121 |
return igTable; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
122 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
123 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
124 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
125 |
JNIEXPORT jboolean JNICALL |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
126 |
Java_sun_font_FileFontStrike_initNative(JNIEnv *env, jclass unused) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
127 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
128 |
DWORD osVersion = GetVersion(); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
129 |
DWORD majorVersion = (DWORD)(LOBYTE(LOWORD(osVersion))); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
130 |
DWORD minorVersion = (DWORD)(HIBYTE(LOWORD(osVersion))); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
131 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
132 |
/* Need at least XP which is 5.1 */ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
133 |
if (majorVersion < 5 || (majorVersion == 5 && minorVersion < 1)) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
134 |
return JNI_FALSE; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
135 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
136 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
137 |
memset(igLUTable, 0, LCDLUTCOUNT); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
138 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
139 |
return JNI_TRUE; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
140 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
141 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
142 |
#ifndef CLEARTYPE_QUALITY |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
143 |
#define CLEARTYPE_QUALITY 5 |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
144 |
#endif |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
145 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
146 |
#ifndef CLEARTYPE_NATURAL_QUALITY |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
147 |
#define CLEARTYPE_NATURAL_QUALITY 6 |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
148 |
#endif |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
149 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
150 |
#define FREE_AND_RETURN \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
151 |
if (hDesktopDC != 0 && hWnd != 0) { \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
152 |
ReleaseDC(hWnd, hDesktopDC); \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
153 |
}\ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
154 |
if (hMemoryDC != 0) { \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
155 |
DeleteObject(hMemoryDC); \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
156 |
} \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
157 |
if (hBitmap != 0) { \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
158 |
DeleteObject(hBitmap); \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
159 |
} \ |
37687
bf6516a24734
8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly
aivanov
parents:
25859
diff
changeset
|
160 |
if (tmpBitmap != 0) { \ |
bf6516a24734
8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly
aivanov
parents:
25859
diff
changeset
|
161 |
DeleteObject(tmpBitmap); \ |
bf6516a24734
8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly
aivanov
parents:
25859
diff
changeset
|
162 |
} \ |
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
163 |
if (dibImage != NULL) { \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
164 |
free(dibImage); \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
165 |
} \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
166 |
if (glyphInfo != NULL) { \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
167 |
free(glyphInfo); \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
168 |
} \ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
169 |
return (jlong)0; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
170 |
/* end define */ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
171 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
172 |
JNIEXPORT jlong JNICALL |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
173 |
Java_sun_font_FileFontStrike__1getGlyphImageFromWindows |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
174 |
(JNIEnv *env, jobject unused, |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
175 |
jstring fontFamily, jint style, jint size, jint glyphCode, jboolean fm) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
176 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
177 |
GLYPHMETRICS glyphMetrics; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
178 |
LOGFONTW lf; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
179 |
BITMAPINFO bmi; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
180 |
TEXTMETRIC textMetric; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
181 |
RECT rect; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
182 |
int bytesWidth, dibBytesWidth, extra, imageSize, dibImageSize; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
183 |
unsigned char* dibImage = NULL, *rowPtr, *pixelPtr, *dibPixPtr, *dibRowPtr; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
184 |
unsigned char r,g,b; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
185 |
unsigned char* igTable; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
186 |
GlyphInfo* glyphInfo = NULL; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
187 |
int nameLen; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
188 |
LPWSTR name; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
189 |
HFONT oldFont, hFont; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
190 |
MAT2 mat2; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
191 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
192 |
unsigned short width; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
193 |
unsigned short height; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
194 |
short advanceX; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
195 |
short advanceY; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
196 |
int topLeftX; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
197 |
int topLeftY; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
198 |
int err; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
199 |
int bmWidth, bmHeight; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
200 |
int x, y; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
201 |
HBITMAP hBitmap = NULL, hOrigBM; |
37687
bf6516a24734
8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly
aivanov
parents:
25859
diff
changeset
|
202 |
HBITMAP tmpBitmap = NULL; |
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
203 |
int gamma, orient; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
204 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
205 |
HWND hWnd = NULL; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
206 |
HDC hDesktopDC = NULL; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
207 |
HDC hMemoryDC = NULL; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
208 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
209 |
hWnd = GetDesktopWindow(); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
210 |
hDesktopDC = GetWindowDC(hWnd); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
211 |
if (hDesktopDC == NULL) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
212 |
return (jlong)0; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
213 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
214 |
if (GetDeviceCaps(hDesktopDC, BITSPIXEL) < 15) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
215 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
216 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
217 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
218 |
hMemoryDC = CreateCompatibleDC(hDesktopDC); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
219 |
if (hMemoryDC == NULL || fontFamily == NULL) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
220 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
221 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
222 |
err = SetMapMode(hMemoryDC, MM_TEXT); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
223 |
if (err == 0) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
224 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
225 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
226 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
227 |
memset(&lf, 0, sizeof(LOGFONTW)); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
228 |
lf.lfHeight = -size; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
229 |
lf.lfWeight = (style & 1) ? FW_BOLD : FW_NORMAL; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
230 |
lf.lfItalic = (style & 2) ? 0xff : 0; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
231 |
lf.lfCharSet = DEFAULT_CHARSET; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
232 |
lf.lfQuality = CLEARTYPE_QUALITY; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
233 |
lf.lfOutPrecision = OUT_TT_PRECIS; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
234 |
lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
235 |
lf.lfPitchAndFamily = DEFAULT_PITCH; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
236 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
237 |
nameLen = (*env)->GetStringLength(env, fontFamily); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
238 |
name = (LPWSTR)alloca((nameLen+1)*2); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
239 |
if (name == NULL) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
240 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
241 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
242 |
(*env)->GetStringRegion(env, fontFamily, 0, nameLen, name); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
243 |
name[nameLen] = '\0'; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
244 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
245 |
if (nameLen < (sizeof(lf.lfFaceName) / sizeof(lf.lfFaceName[0]))) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
246 |
wcscpy(lf.lfFaceName, name); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
247 |
} else { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
248 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
249 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
250 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
251 |
hFont = CreateFontIndirectW(&lf); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
252 |
if (hFont == NULL) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
253 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
254 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
255 |
oldFont = SelectObject(hMemoryDC, hFont); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
256 |
|
37687
bf6516a24734
8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly
aivanov
parents:
25859
diff
changeset
|
257 |
tmpBitmap = CreateCompatibleBitmap(hDesktopDC, 1, 1); |
bf6516a24734
8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly
aivanov
parents:
25859
diff
changeset
|
258 |
if (tmpBitmap == NULL) { |
bf6516a24734
8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly
aivanov
parents:
25859
diff
changeset
|
259 |
FREE_AND_RETURN; |
bf6516a24734
8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly
aivanov
parents:
25859
diff
changeset
|
260 |
} |
bf6516a24734
8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly
aivanov
parents:
25859
diff
changeset
|
261 |
hOrigBM = (HBITMAP)SelectObject(hMemoryDC, tmpBitmap); |
bf6516a24734
8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly
aivanov
parents:
25859
diff
changeset
|
262 |
|
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
263 |
memset(&textMetric, 0, sizeof(TEXTMETRIC)); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
264 |
err = GetTextMetrics(hMemoryDC, &textMetric); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
265 |
if (err == 0) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
266 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
267 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
268 |
memset(&glyphMetrics, 0, sizeof(GLYPHMETRICS)); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
269 |
memset(&mat2, 0, sizeof(MAT2)); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
270 |
mat2.eM11.value = 1; mat2.eM22.value = 1; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
271 |
err = GetGlyphOutline(hMemoryDC, glyphCode, |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
272 |
GGO_METRICS|GGO_GLYPH_INDEX, |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
273 |
&glyphMetrics, |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
274 |
0, NULL, &mat2); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
275 |
if (err == GDI_ERROR) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
276 |
/* Probably no such glyph - ie the font wasn't the one we expected. */ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
277 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
278 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
279 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
280 |
width = (unsigned short)glyphMetrics.gmBlackBoxX; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
281 |
height = (unsigned short)glyphMetrics.gmBlackBoxY; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
282 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
283 |
/* Don't handle "invisible" glyphs in this code */ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
284 |
if (width <= 0 || height == 0) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
285 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
286 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
287 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
288 |
advanceX = glyphMetrics.gmCellIncX; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
289 |
advanceY = glyphMetrics.gmCellIncY; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
290 |
topLeftX = glyphMetrics.gmptGlyphOrigin.x; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
291 |
topLeftY = glyphMetrics.gmptGlyphOrigin.y; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
292 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
293 |
/* GetGlyphOutline pre-dates cleartype and I'm not sure that it will |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
294 |
* account for all pixels touched by the rendering. Need to widen, |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
295 |
* and also adjust by one the x position at which it is rendered. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
296 |
* The extra pixels of width are used as follows : |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
297 |
* One extra pixel at the left and the right will be needed to absorb |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
298 |
* the pixels that will be touched by filtering by GDI to compensate |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
299 |
* for colour fringing. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
300 |
* However there seem to be some cases where GDI renders two extra |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
301 |
* pixels to the right, so we add one additional pixel to the right, |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
302 |
* and in the code that copies this to the image cache we test for |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
303 |
* the (rare) cases when this is touched, and if its not reduce the |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
304 |
* stated image width for the blitting loops. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
305 |
* For fractional metrics : |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
306 |
* One extra pixel at each end to account for sub-pixel positioning used |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
307 |
* when fractional metrics is on in LCD mode. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
308 |
* The pixel at the left is needed so the blitting loop can index into |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
309 |
* that a byte at a time to more accurately position the glyph. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
310 |
* The pixel at the right is needed so that when such indexing happens, |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
311 |
* the blitting still can use the same width. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
312 |
* Consequently the width that is specified for the glyph is one less |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
313 |
* than that of the actual image. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
314 |
* Note that in the FM case as a consequence we need to adjust the |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
315 |
* position at which GDI renders, and the declared width of the glyph |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
316 |
* See the if (fm) {} cases in the code. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
317 |
* For the non-FM case, we not only save 3 bytes per row, but this |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
318 |
* prevents apparent glyph overlapping which affects the rendering |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
319 |
* performance of accelerated pipelines since it adds additional |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
320 |
* read-back requirements. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
321 |
*/ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
322 |
width+=3; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
323 |
if (fm) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
324 |
width+=1; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
325 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
326 |
/* DIB scanline must end on a DWORD boundary. We specify 3 bytes per pixel, |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
327 |
* so must round up as needed to a multiple of 4 bytes. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
328 |
*/ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
329 |
dibBytesWidth = bytesWidth = width*3; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
330 |
extra = dibBytesWidth % 4; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
331 |
if (extra != 0) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
332 |
dibBytesWidth += (4-extra); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
333 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
334 |
/* The glyph cache image must be a multiple of 3 bytes wide. */ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
335 |
extra = bytesWidth % 3; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
336 |
if (extra != 0) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
337 |
bytesWidth += (3-extra); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
338 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
339 |
bmWidth = width; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
340 |
bmHeight = height; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
341 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
342 |
/* Must use desktop DC to create a bitmap of that depth */ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
343 |
hBitmap = CreateCompatibleBitmap(hDesktopDC, bmWidth, bmHeight); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
344 |
if (hBitmap == NULL) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
345 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
346 |
} |
37687
bf6516a24734
8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly
aivanov
parents:
25859
diff
changeset
|
347 |
SelectObject(hMemoryDC, hBitmap); |
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
348 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
349 |
/* Fill in black */ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
350 |
rect.left = 0; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
351 |
rect.top = 0; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
352 |
rect.right = bmWidth; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
353 |
rect.bottom = bmHeight; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
354 |
FillRect(hMemoryDC, (LPRECT)&rect, GetStockObject(BLACK_BRUSH)); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
355 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
356 |
/* Set text color to white, background to black. */ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
357 |
SetBkColor(hMemoryDC, RGB(0,0,0)); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
358 |
SetTextColor(hMemoryDC, RGB(255,255,255)); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
359 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
360 |
/* adjust rendering position */ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
361 |
x = -topLeftX+1; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
362 |
if (fm) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
363 |
x += 1; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
364 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
365 |
y = topLeftY - textMetric.tmAscent; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
366 |
err = ExtTextOutW(hMemoryDC, x, y, ETO_GLYPH_INDEX|ETO_OPAQUE, |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
367 |
(LPRECT)&rect, (LPCWSTR)&glyphCode, 1, NULL); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
368 |
if (err == 0) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
369 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
370 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
371 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
372 |
/* Now get the image into a DIB. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
373 |
* MS docs for GetDIBits says the compatible bitmap must not be |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
374 |
* selected into a DC, so restore the original first. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
375 |
*/ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
376 |
SelectObject(hMemoryDC, hOrigBM); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
377 |
SelectObject(hMemoryDC, oldFont); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
378 |
DeleteObject(hFont); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
379 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
380 |
memset(&bmi, 0, sizeof(BITMAPINFO)); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
381 |
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
382 |
bmi.bmiHeader.biWidth = width; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
383 |
bmi.bmiHeader.biHeight = -height; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
384 |
bmi.bmiHeader.biPlanes = 1; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
385 |
bmi.bmiHeader.biBitCount = 24; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
386 |
bmi.bmiHeader.biCompression = BI_RGB; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
387 |
|
18232 | 388 |
dibImage = SAFE_SIZE_ARRAY_ALLOC(malloc, dibBytesWidth, height); |
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
389 |
if (dibImage == NULL) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
390 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
391 |
} |
18232 | 392 |
dibImageSize = dibBytesWidth*height; |
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
393 |
memset(dibImage, 0, dibImageSize); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
394 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
395 |
err = GetDIBits(hMemoryDC, hBitmap, 0, height, dibImage, |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
396 |
&bmi, DIB_RGB_COLORS); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
397 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
398 |
if (err == 0) { /* GetDIBits failed. */ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
399 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
400 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
401 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
402 |
err = SystemParametersInfo(SPI_GETFONTSMOOTHINGORIENTATION, 0, &orient, 0); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
403 |
if (err == 0) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
404 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
405 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
406 |
err = SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &gamma, 0); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
407 |
if (err == 0) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
408 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
409 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
410 |
igTable = getIGTable(gamma/10); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
411 |
if (igTable == NULL) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
412 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
413 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
414 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
415 |
/* Now copy glyph image into a GlyphInfo structure and return it. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
416 |
* NB the xadvance calculated here may be overwritten by the caller. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
417 |
* 1 is subtracted from the bitmap width to get the glyph width, since |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
418 |
* that extra "1" was added as padding, so the sub-pixel positioning of |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
419 |
* fractional metrics could index into it. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
420 |
*/ |
18232 | 421 |
glyphInfo = (GlyphInfo*)SAFE_SIZE_STRUCT_ALLOC(malloc, sizeof(GlyphInfo), |
422 |
bytesWidth, height); |
|
13140
5c57c463f224
7164282: check for NULL return from malloc is testing wrong variable name.
prr
parents:
5506
diff
changeset
|
423 |
if (glyphInfo == NULL) { |
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
424 |
FREE_AND_RETURN; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
425 |
} |
18232 | 426 |
imageSize = bytesWidth*height; |
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
427 |
glyphInfo->cellInfo = NULL; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
428 |
glyphInfo->rowBytes = bytesWidth; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
429 |
glyphInfo->width = width; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
430 |
if (fm) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
431 |
glyphInfo->width -= 1; // must subtract 1 |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
432 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
433 |
glyphInfo->height = height; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
434 |
glyphInfo->advanceX = advanceX; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
435 |
glyphInfo->advanceY = advanceY; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
436 |
glyphInfo->topLeftX = (float)(topLeftX-1); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
437 |
if (fm) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
438 |
glyphInfo->topLeftX -= 1; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
439 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
440 |
glyphInfo->topLeftY = (float)-topLeftY; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
441 |
glyphInfo->image = (unsigned char*)glyphInfo+sizeof(GlyphInfo); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
442 |
memset(glyphInfo->image, 0, imageSize); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
443 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
444 |
/* DIB 24bpp data is always stored in BGR order, but we usually |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
445 |
* need this in RGB, so we can't just memcpy and need to swap B and R. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
446 |
* Also need to apply inverse gamma adjustment here. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
447 |
* We re-use the variable "extra" to see if the last pixel is touched |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
448 |
* at all. If its not we can reduce the glyph image width. This comes |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
449 |
* into play in some cases where GDI touches more pixels than accounted |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
450 |
* for by increasing width by two pixels over the B&W image. Whilst |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
451 |
* the bytes are in the cache, it doesn't affect rendering performance |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
452 |
* of the hardware pipelines. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
453 |
*/ |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
454 |
extra = 0; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
455 |
if (fm) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
456 |
extra = 1; // always need it. |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
457 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
458 |
dibRowPtr = dibImage; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
459 |
rowPtr = glyphInfo->image; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
460 |
for (y=0;y<height;y++) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
461 |
pixelPtr = rowPtr; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
462 |
dibPixPtr = dibRowPtr; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
463 |
for (x=0;x<width;x++) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
464 |
if (orient == FE_FONTSMOOTHINGORIENTATIONRGB) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
465 |
b = *dibPixPtr++; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
466 |
g = *dibPixPtr++; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
467 |
r = *dibPixPtr++; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
468 |
} else { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
469 |
r = *dibPixPtr++; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
470 |
g = *dibPixPtr++; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
471 |
b = *dibPixPtr++; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
472 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
473 |
*pixelPtr++ = igTable[r]; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
474 |
*pixelPtr++ = igTable[g]; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
475 |
*pixelPtr++ = igTable[b]; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
476 |
if (!fm && (x==(width-1)) && (r|g|b)) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
477 |
extra = 1; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
478 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
479 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
480 |
dibRowPtr += dibBytesWidth; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
481 |
rowPtr += bytesWidth; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
482 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
483 |
if (!extra) { |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
484 |
glyphInfo->width -= 1; |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
485 |
} |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
486 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
487 |
free(dibImage); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
488 |
ReleaseDC(hWnd, hDesktopDC); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
489 |
DeleteObject(hMemoryDC); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
490 |
DeleteObject(hBitmap); |
37687
bf6516a24734
8146035: Windows - With LCD antialiasing, some glyphs are not rendered correctly
aivanov
parents:
25859
diff
changeset
|
491 |
DeleteObject(tmpBitmap); |
550
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
492 |
|
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
493 |
return ptr_to_jlong(glyphInfo); |
e85f91b9bb95
6656651: Windows Look and Feel LCD glyph images have some differences from native applications.
prr
parents:
diff
changeset
|
494 |
} |