|
1 /******************************************************************************* |
|
2 * Copyright (c) 2000, 2007 IBM Corporation and others. |
|
3 * Portion Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
4 * All rights reserved. This program and the accompanying materials |
|
5 * are made available under the terms of the Eclipse Public License v1.0 |
|
6 * which accompanies this distribution, and is available at |
|
7 * http://www.eclipse.org/legal/epl-v10.html |
|
8 * |
|
9 * Contributors: |
|
10 * IBM Corporation - initial API and implementation |
|
11 * Nokia Corporation - Qt implementation |
|
12 *******************************************************************************/ |
|
13 package org.eclipse.swt.graphics; |
|
14 |
|
15 |
|
16 import org.eclipse.swt.*; |
|
17 import org.eclipse.swt.internal.qt.OS; |
|
18 import org.eclipse.swt.internal.qt.QtSupplementaryFontData; |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 * Instances of this class describe operating system fonts. |
|
26 * <p> |
|
27 * For platform-independent behaviour, use the get and set methods |
|
28 * corresponding to the following properties: |
|
29 * <dl> |
|
30 * <dt>height</dt><dd>the height of the font in points</dd> |
|
31 * <dt>name</dt><dd>the face name of the font, which may include the foundry</dd> |
|
32 * <dt>style</dt><dd>A bitwise combination of NORMAL, ITALIC and BOLD</dd> |
|
33 * </dl> |
|
34 * If extra, platform-dependent functionality is required: |
|
35 * <ul> |
|
36 * <li>On <em>Windows</em>, the data member of the <code>FontData</code> |
|
37 * corresponds to a Windows <code>LOGFONT</code> structure whose fields |
|
38 * may be retrieved and modified.</li> |
|
39 * <li>On <em>X</em>, the fields of the <code>FontData</code> correspond |
|
40 * to the entries in the font's XLFD name and may be retrieved and modified. |
|
41 * </ul> |
|
42 * Application code does <em>not</em> need to explicitly release the |
|
43 * resources managed by each instance when those instances are no longer |
|
44 * required, and thus no <code>dispose()</code> method is provided. |
|
45 * |
|
46 * @see Font |
|
47 */ |
|
48 public final class FontData { |
|
49 /** |
|
50 * the font name |
|
51 */ |
|
52 String name; |
|
53 |
|
54 /** |
|
55 * The height of the font data in points |
|
56 */ |
|
57 int height; |
|
58 |
|
59 /** |
|
60 * the font style |
|
61 */ |
|
62 int style; |
|
63 |
|
64 /** |
|
65 * The locales of the font |
|
66 */ |
|
67 String lang, country, variant; |
|
68 |
|
69 QtSupplementaryFontData extraFontData; |
|
70 String xlfd; |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 /** |
|
77 * Constructs a new uninitialized font data. |
|
78 */ |
|
79 public FontData () { |
|
80 this("", Device.FONT_DEF_HEIGHT, SWT.NORMAL); |
|
81 } |
|
82 |
|
83 //The characters in the string must all be decimal digits |
|
84 // the value must be given with radix 10 |
|
85 |
|
86 /** |
|
87 * Constructs a new FontData given a string representation |
|
88 * in the form generated by the <code>FontData.toString</code> |
|
89 * method. |
|
90 * <p> |
|
91 * Note that the representation varies between platforms, |
|
92 * and a FontData can only be created from a string that was |
|
93 * generated on the same platform. |
|
94 * </p> |
|
95 * |
|
96 * @param string the string representation of a <code>FontData</code> (must not be null) |
|
97 * |
|
98 * @exception IllegalArgumentException <ul> |
|
99 * <li>ERROR_NULL_ARGUMENT - if the argument is null</li> |
|
100 * <li>ERROR_INVALID_ARGUMENT - if the argument does not represent a valid description</li> |
|
101 * </ul> |
|
102 * |
|
103 * @see #toString |
|
104 */ |
|
105 public FontData(String string) { |
|
106 if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
|
107 parseFontDescriptor(string); |
|
108 updateFontData(); |
|
109 |
|
110 } |
|
111 |
|
112 /** |
|
113 * Constructs a new font data given a font name, |
|
114 * the height of the desired font in points, |
|
115 * and a font style. |
|
116 * |
|
117 * @param name the name of the font (must not be null) |
|
118 * @param height the font height in points |
|
119 * @param style a bit or combination of NORMAL, BOLD, ITALIC |
|
120 * |
|
121 * @exception IllegalArgumentException <ul> |
|
122 * <li>ERROR_NULL_ARGUMENT - when the font name is null</li> |
|
123 * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li> |
|
124 * </ul> |
|
125 */ |
|
126 public FontData(String name, int height, int style) { |
|
127 if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
|
128 if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
|
129 setName(name); |
|
130 setHeight(height); |
|
131 setStyle(style); |
|
132 } |
|
133 |
|
134 /** |
|
135 * Compares the argument to the receiver, and returns true |
|
136 * if they represent the <em>same</em> object using a class |
|
137 * specific comparison. |
|
138 * |
|
139 * @param object the object to compare with this object |
|
140 * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise |
|
141 * |
|
142 * @see #hashCode |
|
143 */ |
|
144 public boolean equals(Object object) { |
|
145 if (object == this) |
|
146 return true; |
|
147 if (!(object instanceof FontData)) |
|
148 return false; |
|
149 |
|
150 FontData data = (FontData) object; |
|
151 |
|
152 if (!((xlfd == null && data.xlfd == null) || (xlfd != null && data.xlfd != null))) |
|
153 return false; |
|
154 |
|
155 if (!((extraFontData == null && data.extraFontData == null) || (extraFontData != null && data.extraFontData != null))) |
|
156 return false; |
|
157 |
|
158 if (xlfd != null) { |
|
159 return xlfd.trim().equals(data.xlfd.trim()); |
|
160 } |
|
161 |
|
162 boolean mainFontStyleEqual = name.equals(data.name) |
|
163 && height == data.height && style == data.style; |
|
164 if (mainFontStyleEqual && extraFontData != null) { |
|
165 return mainFontStyleEqual |
|
166 && extraFontData.underline == data.extraFontData.underline |
|
167 && extraFontData.overline == data.extraFontData.overline |
|
168 && extraFontData.strikeOut == data.extraFontData.strikeOut |
|
169 && extraFontData.stretch == data.extraFontData.stretch |
|
170 && extraFontData.fixedPitch == data.extraFontData.fixedPitch |
|
171 && extraFontData.style == data.extraFontData.style |
|
172 && extraFontData.weight == data.extraFontData.weight |
|
173 && extraFontData.styleStrategy == data.extraFontData.styleStrategy; |
|
174 } else { |
|
175 return mainFontStyleEqual; |
|
176 } |
|
177 } |
|
178 |
|
179 /** |
|
180 * Returns the height of the receiver in points. |
|
181 * |
|
182 * @return the height of this FontData |
|
183 * |
|
184 * @see #setHeight(int) |
|
185 */ |
|
186 public int getHeight() { |
|
187 return height; |
|
188 } |
|
189 |
|
190 /** |
|
191 * Returns the locale of the receiver. |
|
192 * <p> |
|
193 * The locale determines which platform character set this |
|
194 * font is going to use. Widgets and graphics operations that |
|
195 * use this font will convert UNICODE strings to the platform |
|
196 * character set of the specified locale. |
|
197 * </p> |
|
198 * <p> |
|
199 * On platforms where there are multiple character sets for a |
|
200 * given language/country locale, the variant portion of the |
|
201 * locale will determine the character set. |
|
202 * </p> |
|
203 * |
|
204 * @return the <code>String</code> representing a Locale object |
|
205 * @since 3.0 |
|
206 */ |
|
207 public String getLocale () { |
|
208 StringBuffer buffer = new StringBuffer (); |
|
209 char sep = '_'; |
|
210 if (lang != null) { |
|
211 buffer.append (lang); |
|
212 buffer.append (sep); |
|
213 } |
|
214 if (country != null) { |
|
215 buffer.append (country); |
|
216 buffer.append (sep); |
|
217 } |
|
218 if (variant != null) { |
|
219 buffer.append (variant); |
|
220 } |
|
221 |
|
222 String result = buffer.toString (); |
|
223 int length = result.length (); |
|
224 if (length > 0) { |
|
225 if (result.charAt (length - 1) == sep) { |
|
226 result = result.substring (0, length - 1); |
|
227 } |
|
228 } |
|
229 return result; |
|
230 } |
|
231 |
|
232 /** |
|
233 * Returns the name of the receiver. |
|
234 * On platforms that support font foundries, the return value will |
|
235 * be the foundry followed by a dash ("-") followed by the face name. |
|
236 * |
|
237 * @return the name of this <code>FontData</code> |
|
238 * |
|
239 * @see #setName |
|
240 */ |
|
241 public String getName() { |
|
242 return name; |
|
243 } |
|
244 |
|
245 /** |
|
246 * Returns the style of the receiver which is a bitwise OR of |
|
247 * one or more of the <code>SWT</code> constants NORMAL, BOLD |
|
248 * and ITALIC. |
|
249 * |
|
250 * @return the style of this <code>FontData</code> |
|
251 * |
|
252 * @see #setStyle |
|
253 */ |
|
254 public int getStyle() { |
|
255 return style; |
|
256 } |
|
257 |
|
258 /** |
|
259 * Returns an integer hash code for the receiver. Any two |
|
260 * objects that return <code>true</code> when passed to |
|
261 * <code>equals</code> must return the same value for this |
|
262 * method. |
|
263 * |
|
264 * @return the receiver's hash |
|
265 * |
|
266 * @see #equals |
|
267 */ |
|
268 public int hashCode () { |
|
269 return name.hashCode() ^ height ^ style; |
|
270 } |
|
271 |
|
272 |
|
273 void parseFontDescriptor(String string) { |
|
274 int start = 0; |
|
275 int end = string.indexOf('|'); |
|
276 if (end == -1) |
|
277 SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
|
278 String version1 = string.substring(start, end); |
|
279 try { |
|
280 if (Integer.parseInt(version1) != 1) |
|
281 SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
|
282 } catch (NumberFormatException e) { |
|
283 SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
|
284 } |
|
285 |
|
286 start = end + 1; |
|
287 end = string.indexOf('|', start); |
|
288 if (end == -1) |
|
289 SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
|
290 String name = string.substring(start, end); |
|
291 |
|
292 start = end + 1; |
|
293 end = string.indexOf('|', start); |
|
294 if (end == -1) |
|
295 SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
|
296 int height = 0; |
|
297 try { |
|
298 height = Integer.parseInt(string.substring(start, end)); |
|
299 } catch (NumberFormatException e) { |
|
300 SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
|
301 } |
|
302 |
|
303 start = end + 1; |
|
304 end = string.indexOf('|', start); |
|
305 if (end == -1) |
|
306 SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
|
307 int style = 0; |
|
308 try { |
|
309 style = Integer.parseInt(string.substring(start, end)); |
|
310 } catch (NumberFormatException e) { |
|
311 SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
|
312 } |
|
313 |
|
314 start = end + 1; |
|
315 end = string.indexOf('|', start); |
|
316 setName(name); |
|
317 setHeight(height); |
|
318 setStyle(style); |
|
319 if (end == -1) |
|
320 return; |
|
321 String platform = string.substring(start, end); |
|
322 |
|
323 start = end + 1; |
|
324 end = string.indexOf('|', start); |
|
325 if (end == -1) |
|
326 return; |
|
327 String version2 = string.substring(start, end); |
|
328 |
|
329 if (platform.trim().toUpperCase().equals("QT") && version2.equals("1")) { |
|
330 try { |
|
331 extraFontData = new QtSupplementaryFontData(); |
|
332 start = end + 1; |
|
333 end = string.indexOf('|', start); |
|
334 if (end == -1) |
|
335 return; |
|
336 extraFontData.underline = Integer.parseInt(string.substring( |
|
337 start, end)); |
|
338 start = end + 1; |
|
339 end = string.indexOf('|', start); |
|
340 if (end == -1) |
|
341 return; |
|
342 extraFontData.overline = Integer.parseInt(string.substring( |
|
343 start, end)); |
|
344 start = end + 1; |
|
345 end = string.indexOf('|', start); |
|
346 if (end == -1) |
|
347 return; |
|
348 extraFontData.strikeOut = Integer.parseInt(string.substring( |
|
349 start, end)); |
|
350 start = end + 1; |
|
351 end = string.indexOf('|', start); |
|
352 if (end == -1) |
|
353 return; |
|
354 int stretch = Integer.parseInt(string.substring(start, end)); |
|
355 if (stretch > 0) { |
|
356 if (stretch > 4000) { |
|
357 stretch = 4000; |
|
358 } |
|
359 extraFontData.stretch = stretch; |
|
360 } |
|
361 start = end + 1; |
|
362 end = string.indexOf('|', start); |
|
363 if (end == -1) { |
|
364 extraFontData = null; |
|
365 return; |
|
366 } |
|
367 extraFontData.fixedPitch = Integer.parseInt(string.substring( |
|
368 start, end)); |
|
369 start = end + 1; |
|
370 end = string.indexOf('|', start); |
|
371 if (end == -1) |
|
372 return; |
|
373 int fontStyle = Integer.parseInt(string.substring(start, end)); |
|
374 if (fontStyle == OS.QFONT_STYLE_NORMAL |
|
375 || fontStyle == OS.QFONT_STYLE_ITALIC |
|
376 || fontStyle == OS.QFONT_STYLE_OBLIQUE) { |
|
377 extraFontData.style = fontStyle; |
|
378 } |
|
379 start = end + 1; |
|
380 end = string.indexOf('|', start); |
|
381 if (end == -1) |
|
382 return; |
|
383 int weight = Integer.parseInt(string.substring(start, end)); |
|
384 if (weight > -1) { |
|
385 if (weight > 99) { |
|
386 weight = 99; |
|
387 } |
|
388 extraFontData.weight = weight; |
|
389 } |
|
390 start = end + 1; |
|
391 end = string.indexOf('|', start); |
|
392 if (end == -1) |
|
393 return; |
|
394 int styleStrategy = Integer.parseInt(string.substring(start, |
|
395 end)); |
|
396 int[] strategies = new int[] { |
|
397 OS.QFONT_STYLESTRATEGY_PREFERDEFALUT, |
|
398 OS.QFONT_STYLESTRATEGY_PREFERBITMAP, |
|
399 OS.QFONT_STYLESTRATEGY_PREFERDEVICE, |
|
400 OS.QFONT_STYLESTRATEGY_PREFEROUTLINE, |
|
401 OS.QFONT_STYLESTRATEGY_FORCEOUTLINE, |
|
402 OS.QFONT_STYLESTRATEGY_NOANTIALIAS, |
|
403 OS.QFONT_STYLESTRATEGY_PREFERANTIALIAS, |
|
404 OS.QFONT_STYLESTRATEGY_OPENGLCOMPATIABLE, |
|
405 OS.QFONT_STYLESTRATEGY_NOFONTMERGING }; |
|
406 boolean isValidStrategy = (styleStrategy == OS.QFONT_STYLESTRATEGY_PREFERQUALITY || styleStrategy == OS.QFONT_STYLESTRATEGY_PREFERMATCH) ? true |
|
407 : false; |
|
408 for (int i = 0; i < strategies.length; i++) { |
|
409 if ((styleStrategy & strategies[i]) == 0) { |
|
410 continue; |
|
411 } else { |
|
412 if (styleStrategy == strategies[i] |
|
413 || styleStrategy == (strategies[i] | OS.QFONT_STYLESTRATEGY_PREFERQUALITY) |
|
414 || styleStrategy == (strategies[i] | OS.QFONT_STYLESTRATEGY_PREFERMATCH)) { |
|
415 isValidStrategy = true; |
|
416 } |
|
417 break; |
|
418 } |
|
419 } |
|
420 if (isValidStrategy) { |
|
421 extraFontData.styleStrategy = styleStrategy; |
|
422 } |
|
423 } catch (NumberFormatException e) { |
|
424 extraFontData = null; |
|
425 } |
|
426 } else if (platform.trim().toUpperCase().equals("X11") |
|
427 && OS.windowServer == OS.WS_X11) { |
|
428 start = end + 1; |
|
429 end = string.indexOf('|', start); |
|
430 if (end == -1) |
|
431 return; |
|
432 xlfd = string.substring(start, end); |
|
433 if (xlfd.length() < 1) { |
|
434 xlfd = null; |
|
435 } |
|
436 } |
|
437 |
|
438 } |
|
439 |
|
440 |
|
441 /** |
|
442 * Sets the height of the receiver. The parameter is |
|
443 * specified in terms of points, where a point is one |
|
444 * seventy-second of an inch. |
|
445 * |
|
446 * @param height the height of the <code>FontData</code> |
|
447 * |
|
448 * @exception IllegalArgumentException <ul> |
|
449 * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li> |
|
450 * </ul> |
|
451 * |
|
452 * @see #getHeight |
|
453 */ |
|
454 public void setHeight(int height) { |
|
455 if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
|
456 this.height = height; |
|
457 } |
|
458 |
|
459 /** |
|
460 * Sets the locale of the receiver. |
|
461 * <p> |
|
462 * The locale determines which platform character set this |
|
463 * font is going to use. Widgets and graphics operations that |
|
464 * use this font will convert UNICODE strings to the platform |
|
465 * character set of the specified locale. |
|
466 * </p> |
|
467 * <p> |
|
468 * On platforms where there are multiple character sets for a |
|
469 * given language/country locale, the variant portion of the |
|
470 * locale will determine the character set. |
|
471 * </p> |
|
472 * |
|
473 * @param locale the <code>String</code> representing a Locale object |
|
474 * @see java.util.Locale#toString |
|
475 */ |
|
476 public void setLocale(String locale) { |
|
477 lang = country = variant = null; |
|
478 if (locale != null) { |
|
479 char sep = '_'; |
|
480 int length = locale.length(); |
|
481 int firstSep, secondSep; |
|
482 |
|
483 firstSep = locale.indexOf(sep); |
|
484 if (firstSep == -1) { |
|
485 firstSep = secondSep = length; |
|
486 } else { |
|
487 secondSep = locale.indexOf(sep, firstSep + 1); |
|
488 if (secondSep == -1) secondSep = length; |
|
489 } |
|
490 if (firstSep > 0) lang = locale.substring(0, firstSep); |
|
491 if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep); |
|
492 if (length > secondSep + 1) variant = locale.substring(secondSep + 1); |
|
493 } |
|
494 } |
|
495 |
|
496 /** |
|
497 * Sets the name of the receiver. |
|
498 * <p> |
|
499 * Some platforms support font foundries. On these platforms, the name |
|
500 * of the font specified in setName() may have one of the following forms: |
|
501 * <ol> |
|
502 * <li>a face name (for example, "courier")</li> |
|
503 * <li>a foundry followed by a dash ("-") followed by a face name (for example, "adobe-courier")</li> |
|
504 * </ol> |
|
505 * In either case, the name returned from getName() will include the |
|
506 * foundry. |
|
507 * </p> |
|
508 * <p> |
|
509 * On platforms that do not support font foundries, only the face name |
|
510 * (for example, "courier") is used in <code>setName()</code> and |
|
511 * <code>getName()</code>. |
|
512 * </p> |
|
513 * |
|
514 * @param name the name of the font data (must not be null) |
|
515 * @exception IllegalArgumentException <ul> |
|
516 * <li>ERROR_NULL_ARGUMENT - when the font name is null</li> |
|
517 * </ul> |
|
518 * |
|
519 * @see #getName |
|
520 */ |
|
521 public void setName(String name) { |
|
522 if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
|
523 this.name = name; |
|
524 } |
|
525 |
|
526 /** |
|
527 * Sets the style of the receiver to the argument which must |
|
528 * be a bitwise OR of one or more of the <code>SWT</code> |
|
529 * constants NORMAL, BOLD and ITALIC. All other style bits are |
|
530 * ignored. |
|
531 * |
|
532 * @param style the new style for this <code>FontData</code> |
|
533 * |
|
534 * @see #getStyle |
|
535 */ |
|
536 public void setStyle(int style) { |
|
537 this.style = style; |
|
538 } |
|
539 |
|
540 /** |
|
541 * Returns a string representation of the receiver which is suitable |
|
542 * for constructing an equivalent instance using the |
|
543 * <code>FontData(String)</code> constructor. |
|
544 * |
|
545 * @return a string representation of the FontData |
|
546 * |
|
547 * @see FontData |
|
548 */ |
|
549 public String toString() { |
|
550 StringBuffer buffer = new StringBuffer(); |
|
551 buffer.append("1|"); |
|
552 buffer.append(getName()); |
|
553 buffer.append("|"); |
|
554 buffer.append(getHeight()); |
|
555 buffer.append("|"); |
|
556 buffer.append(getStyle()); |
|
557 buffer.append("|"); |
|
558 if (xlfd != null) { |
|
559 buffer.append("X11|1|"); |
|
560 buffer.append(xlfd); |
|
561 buffer.append("|"); |
|
562 } else if (extraFontData != null) { |
|
563 buffer.append("QT|1|"); |
|
564 buffer.append(extraFontData.overline); |
|
565 buffer.append("|"); |
|
566 buffer.append(extraFontData.underline); |
|
567 buffer.append("|"); |
|
568 buffer.append(extraFontData.strikeOut); |
|
569 buffer.append("|"); |
|
570 buffer.append(extraFontData.stretch); |
|
571 buffer.append("|"); |
|
572 buffer.append(extraFontData.fixedPitch); |
|
573 buffer.append("|"); |
|
574 buffer.append(extraFontData.style); |
|
575 buffer.append("|"); |
|
576 buffer.append(extraFontData.weight); |
|
577 buffer.append("|"); |
|
578 buffer.append(extraFontData.styleStrategy); |
|
579 buffer.append("|"); |
|
580 } |
|
581 return buffer.toString(); |
|
582 } |
|
583 |
|
584 void updateFontData() { |
|
585 if (extraFontData == null && xlfd == null) |
|
586 return; |
|
587 |
|
588 boolean italic = (style & SWT.ITALIC) != 0; |
|
589 int weight = OS.QT_FONTNORMAL; |
|
590 if ((style & SWT.BOLD) != 0) { |
|
591 weight = OS.QT_FONTBOLD; |
|
592 } |
|
593 int fontHandle = OS.QFont_new(name, height, weight, italic); |
|
594 |
|
595 if (xlfd != null) { |
|
596 OS.QFont_setRawName(fontHandle, xlfd); |
|
597 |
|
598 } else { |
|
599 if (extraFontData.underline > -1) { |
|
600 OS.QFont_setUnderline(fontHandle, |
|
601 extraFontData.underline > 0 ? true : false); |
|
602 } |
|
603 if (extraFontData.overline > -1) { |
|
604 OS.QFont_setOverline(fontHandle, |
|
605 extraFontData.overline > 0 ? true : false); |
|
606 } |
|
607 if (extraFontData.strikeOut > -1) { |
|
608 OS.QFont_setStrikeOut(fontHandle, |
|
609 extraFontData.strikeOut > 0 ? true : false); |
|
610 } |
|
611 if (extraFontData.stretch > -1) { |
|
612 OS.QFont_setStretch(fontHandle, extraFontData.stretch); |
|
613 } |
|
614 if (extraFontData.fixedPitch > -1) { |
|
615 OS.QFont_setFixedPitch(fontHandle, |
|
616 extraFontData.fixedPitch > 0 ? true : false); |
|
617 } |
|
618 if (extraFontData.style > -1) { |
|
619 OS.QFont_setStyle(fontHandle, extraFontData.style); |
|
620 } |
|
621 if (extraFontData.weight > -1) { |
|
622 OS.QFont_setWeight(fontHandle, extraFontData.weight); |
|
623 } |
|
624 if (extraFontData.styleStrategy > -1) { |
|
625 OS.QFont_setStyleStrategy(fontHandle, |
|
626 extraFontData.styleStrategy); |
|
627 } |
|
628 } |
|
629 |
|
630 name = OS.QFont_family(fontHandle); |
|
631 height = OS.QFont_pointSize(fontHandle); |
|
632 weight = OS.QFont_weight(fontHandle); |
|
633 italic = OS.QFont_italic(fontHandle); |
|
634 style = SWT.NORMAL; |
|
635 if (weight > OS.QT_FONTNORMAL) |
|
636 style |= SWT.BOLD; |
|
637 if (italic == true) |
|
638 style |= SWT.ITALIC; |
|
639 if (extraFontData != null) { |
|
640 extraFontData.underline = OS.QFont_underline(fontHandle) == true ? 1 |
|
641 : 0; |
|
642 extraFontData.overline = OS.QFont_overline(fontHandle) == true ? 1 |
|
643 : 0; |
|
644 extraFontData.strikeOut = OS.QFont_strikeOut(fontHandle) == true ? 1 |
|
645 : 0; |
|
646 extraFontData.stretch = OS.QFont_stretch(fontHandle); |
|
647 extraFontData.fixedPitch = OS.QFont_fixedPitch(fontHandle) == true ? 1 |
|
648 : 0; |
|
649 extraFontData.style = OS.QFont_style(fontHandle); |
|
650 extraFontData.weight = OS.QFont_weight(fontHandle); |
|
651 extraFontData.styleStrategy = OS.QFont_styleStrategy(fontHandle); |
|
652 OS.QFont_delete(fontHandle); |
|
653 } |
|
654 } |
|
655 } |