133 AwtFont::AwtFont(int num, JNIEnv *env, jobject javaFont)
134 {
135 if (num == 0) { // not multi-font
136 num = 1;
137 }
138
139 m_hFontNum = num;
140 m_hFont = new HFONT[num];
141
142 for (int i = 0; i < num; i++) {
143 m_hFont[i] = NULL;
144 }
145
146 m_textInput = -1;
147 m_ascent = -1;
148 m_overhang = 0;
149 }
150
151 AwtFont::~AwtFont()
152 {
153 }
154
155 void AwtFont::Dispose() {
156 for (int i = 0; i < m_hFontNum; i++) {
157 HFONT font = m_hFont[i];
158 if (font != NULL && fontCache.Search(font)) {
159 fontCache.Remove(font);
160 /* NOTE: delete of windows HFONT happens in FontCache::Remove
161 only when the final reference to the font is disposed */
162 } else if (font != NULL) {
163 // if font was not in cache, its not shared and we delete it now
164 VERIFY(::DeleteObject(font));
165 }
166 }
167 delete[] m_hFont;
168
169 AwtObject::Dispose();
170 }
171
172 static void pDataDisposeMethod(JNIEnv *env, jlong pData)
173 {
174 TRY_NO_VERIFY;
175
176 AwtObject::_Dispose((PDATA)pData);
177
178 CATCH_BAD_ALLOC;
179 }
180
181 AwtFont* AwtFont::GetFont(JNIEnv *env, jobject font,
182 jint angle, jfloat awScale)
183 {
184 jlong pData = env->GetLongField(font, AwtFont::pDataID);
185 AwtFont* awtFont = (AwtFont*)jlong_to_ptr(pData);
186
187 if (awtFont != NULL) {
|
133 AwtFont::AwtFont(int num, JNIEnv *env, jobject javaFont)
134 {
135 if (num == 0) { // not multi-font
136 num = 1;
137 }
138
139 m_hFontNum = num;
140 m_hFont = new HFONT[num];
141
142 for (int i = 0; i < num; i++) {
143 m_hFont[i] = NULL;
144 }
145
146 m_textInput = -1;
147 m_ascent = -1;
148 m_overhang = 0;
149 }
150
151 AwtFont::~AwtFont()
152 {
153 delete[] m_hFont;
154 }
155
156 void AwtFont::Dispose() {
157 for (int i = 0; i < m_hFontNum; i++) {
158 HFONT font = m_hFont[i];
159 if (font != NULL && fontCache.Search(font)) {
160 fontCache.Remove(font);
161 /* NOTE: delete of windows HFONT happens in FontCache::Remove
162 only when the final reference to the font is disposed */
163 } else if (font != NULL) {
164 // if font was not in cache, its not shared and we delete it now
165 DASSERT(::GetObjectType(font) == OBJ_FONT);
166 VERIFY(::DeleteObject(font));
167 }
168 m_hFont[i] = NULL;
169 }
170
171 AwtObject::Dispose();
172 }
173
174 static void pDataDisposeMethod(JNIEnv *env, jlong pData)
175 {
176 TRY_NO_VERIFY;
177
178 AwtObject::_Dispose((PDATA)pData);
179
180 CATCH_BAD_ALLOC;
181 }
182
183 AwtFont* AwtFont::GetFont(JNIEnv *env, jobject font,
184 jint angle, jfloat awScale)
185 {
186 jlong pData = env->GetLongField(font, AwtFont::pDataID);
187 AwtFont* awtFont = (AwtFont*)jlong_to_ptr(pData);
188
189 if (awtFont != NULL) {
|