Mercurial > projects > dwt-win
diff dwt/graphics/FontData.d @ 23:f5482da87ed8
Image, ImageData
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 27 Jan 2008 17:43:55 +0100 |
parents | eca0c8261b9f |
children | 9a64a7781bab |
line wrap: on
line diff
--- a/dwt/graphics/FontData.d Sat Jan 26 19:05:32 2008 +0100 +++ b/dwt/graphics/FontData.d Sun Jan 27 17:43:55 2008 +0100 @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Port to the D programming language: + * Frank Benoit <benoit@tionex.de> *******************************************************************************/ module dwt.graphics.FontData; @@ -52,7 +54,7 @@ */ public final class FontData { - + /** * A Win32 LOGFONT struct * (Warning: This field is platform dependent) @@ -64,7 +66,7 @@ * </p> */ public LOGFONT data; - + /** * The height of the font data in points * (Warning: This field is platform dependent) @@ -84,7 +86,7 @@ private static FontData s_this; -/** +/** * Constructs a new uninitialized font data. */ public this() { @@ -98,7 +100,7 @@ /** * Constructs a new font data given the Windows <code>LOGFONT</code> * that it should represent. - * + * * @param data the <code>LOGFONT</code> for the result */ this(LOGFONT* data, float height) { @@ -112,7 +114,7 @@ * method. * <p> * Note that the representation varies between platforms, - * and a FontData can only be created from a string that was + * and a FontData can only be created from a string that was * generated on the same platform. * </p> * @@ -132,16 +134,16 @@ if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT); char[] version1 = string.substring(start, end); try { - if (Integer.parseInt(version1) !is 1) DWT.error(DWT.ERROR_INVALID_ARGUMENT); + if (Integer.parseInt(version1) !is 1) DWT.error(DWT.ERROR_INVALID_ARGUMENT); } catch (NumberFormatException e) { DWT.error(DWT.ERROR_INVALID_ARGUMENT); } - + start = end + 1; end = string.indexOf('|', start); if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT); char[] name = string.substring(start, end); - + start = end + 1; end = string.indexOf('|', start); if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT); @@ -151,7 +153,7 @@ } catch (NumberFormatException e) { DWT.error(DWT.ERROR_INVALID_ARGUMENT); } - + start = end + 1; end = string.indexOf('|', start); if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT); @@ -246,9 +248,9 @@ } } -/** +/** * Constructs a new font data given a font name, - * the height of the desired font in points, + * the height of the desired font in points, * and a font style. * * @param name the name of the font (must not be null) @@ -301,7 +303,7 @@ * This code is intentionally commented. When creating * a FontData, lfHeight is not necessarily set. Instead * we check the height field which is always set. - */ + */ // data.lfHeight is lf.lfHeight && height is fd.height && data.lfWidth is lf.lfWidth && @@ -382,7 +384,7 @@ * given language/country locale, the variant portion of the * locale will determine the character set. * </p> - * + * * @return the <code>String</code> representing a Locale object * @since 3.0 */ @@ -400,14 +402,14 @@ if (variant !is null) { buffer.append (variant); } - + char[] result = buffer.toString (); int length_ = result.length; if (length_ > 0) { if (result.charAt (length_ - 1) is sep) { result = result.substring (0, length_ - 1); } - } + } return result; } @@ -425,12 +427,12 @@ } /** - * Returns the style of the receiver which is a bitwise OR of + * Returns the style of the receiver which is a bitwise OR of * one or more of the <code>DWT</code> constants NORMAL, BOLD * and ITALIC. * * @return the style of this <code>FontData</code> - * + * * @see #setStyle */ public int getStyle() { @@ -441,8 +443,8 @@ } /** - * Returns an integer hash code for the receiver. Any two - * objects that return <code>true</code> when passed to + * Returns an integer hash code for the receiver. Any two + * objects that return <code>true</code> when passed to * <code>equals</code> must return the same value for this * method. * @@ -469,7 +471,7 @@ * @exception IllegalArgumentException <ul> * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li> * </ul> - * + * * @see #getHeight */ public void setHeight(int height) { @@ -495,17 +497,17 @@ * given language/country locale, the variant portion of the * locale will determine the character set. * </p> - * + * * @param locale the <code>String</code> representing a Locale object * @see java.util.Locale#toString */ -public void setLocale(char[] locale) { +public void setLocale(char[] locale) { lang = country = variant = null; if (locale !is null) { char sep = '_'; int length_ = locale.length; int firstSep, secondSep; - + firstSep = locale.indexOf(sep); if (firstSep is -1) { firstSep = secondSep = length_; @@ -542,7 +544,7 @@ * </p> * <p> * On platforms that do not support font foundries, only the face name - * (for example, "courier") is used in <code>setName()</code> and + * (for example, "courier") is used in <code>setName()</code> and * <code>getName()</code>. * </p> * @@ -565,7 +567,7 @@ /** * Sets the style of the receiver to the argument which must - * be a bitwise OR of one or more of the <code>DWT</code> + * be a bitwise OR of one or more of the <code>DWT</code> * constants NORMAL, BOLD and ITALIC. All other style bits are * ignored. * @@ -588,7 +590,7 @@ /** * Returns a string representation of the receiver which is suitable - * for constructing an equivalent instance using the + * for constructing an equivalent instance using the * <code>FontData(String)</code> constructor. * * @return a string representation of the FontData @@ -604,30 +606,30 @@ buffer.append("|"); //$NON-NLS-1$ buffer.append(to!(char[])(getStyle())); buffer.append("|"); //$NON-NLS-1$ - buffer.append("WINDOWS|1|"); //$NON-NLS-1$ + buffer.append("WINDOWS|1|"); //$NON-NLS-1$ buffer.append(to!(char[])(data.lfHeight)); buffer.append("|"); //$NON-NLS-1$ buffer.append(to!(char[])(data.lfWidth)); buffer.append("|"); //$NON-NLS-1$ buffer.append(to!(char[])(data.lfEscapement)); buffer.append("|"); //$NON-NLS-1$ - buffer.append(to!(char[])(data.lfOrientation)); + buffer.append(to!(char[])(data.lfOrientation)); buffer.append("|"); //$NON-NLS-1$ - buffer.append(to!(char[])(data.lfWeight)); + buffer.append(to!(char[])(data.lfWeight)); buffer.append("|"); //$NON-NLS-1$ buffer.append(to!(char[])(data.lfItalic)); buffer.append("|"); //$NON-NLS-1$ buffer.append(to!(char[])(data.lfUnderline)); buffer.append("|"); //$NON-NLS-1$ - buffer.append(to!(char[])(data.lfStrikeOut)); + buffer.append(to!(char[])(data.lfStrikeOut)); buffer.append("|"); //$NON-NLS-1$ - buffer.append(to!(char[])(data.lfCharSet)); + buffer.append(to!(char[])(data.lfCharSet)); buffer.append("|"); //$NON-NLS-1$ buffer.append(to!(char[])(data.lfOutPrecision)); buffer.append("|"); //$NON-NLS-1$ - buffer.append(to!(char[])(data.lfClipPrecision)); + buffer.append(to!(char[])(data.lfClipPrecision)); buffer.append("|"); //$NON-NLS-1$ - buffer.append(to!(char[])(data.lfQuality)); + buffer.append(to!(char[])(data.lfQuality)); buffer.append("|"); //$NON-NLS-1$ buffer.append(to!(char[])(data.lfPitchAndFamily)); buffer.append("|"); //$NON-NLS-1$ @@ -635,7 +637,7 @@ return buffer.toString(); } -/** +/** * Invokes platform specific functionality to allocate a new font data. * <p> * <b>IMPORTANT:</b> This method is <em>not</em> part of the public