Mercurial > projects > dwt-mac
diff dwt/graphics/Font.d @ 36:db5a898b2119
Fixed a lot of compile errors
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Tue, 07 Oct 2008 12:56:18 +0200 |
parents | 93b13b15f0b1 |
children | 642f460a0908 |
line wrap: on
line diff
--- a/dwt/graphics/Font.d Sun Sep 14 23:32:29 2008 +0200 +++ b/dwt/graphics/Font.d Tue Oct 07 12:56:18 2008 +0200 @@ -21,7 +21,8 @@ import dwt.internal.cocoa.NSString; import tango.stdc.stringz; -import tango.text.convert.Utf; +import tango.text.convert.Format; +static import tango.text.convert.Utf; import dwt.dwthelper.utils; import dwt.graphics.Device; @@ -44,6 +45,8 @@ */ public final class Font : Resource { + alias Resource.init_ init_; + /** * the handle to the OS font resource * (Warning: This field is platform dependent) @@ -81,8 +84,8 @@ public this(Device device, FontData fd) { super(device); if (fd is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); - init(fd.getName(), fd.getHeightF(), fd.getStyle(), fd.nsName); - init(); + init_(fd.getName(), fd.getHeightF(), fd.getStyle(), fd.nsName); + init_(); } /** @@ -116,8 +119,8 @@ if (fds[i] is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT); } FontData fd = fds[0]; - init(fd.getName(), fd.getHeightF(), fd.getStyle(), fd.nsName); - init(); + init_(fd.getName(), fd.getHeightF(), fd.getStyle(), fd.nsName); + init_(); } /** @@ -144,14 +147,14 @@ */ public this(Device device, String name, int height, int style) { super(device); - init(name, height, style, null); - init(); + init_(name, height, style, null); + init_(); } /*public*/ this(Device device, String name, float height, int style) { super(device); - init(name, height, style, null); - init(); + init_(name, height, style, null); + init_(); } void destroy() { @@ -169,7 +172,7 @@ * * @see #hashCode */ -public bool opEquals(Object object) { +public int opEquals(Object object) { if (object is this) return true; if (!( null !is cast(Font)object )) return false; Font font = cast(Font)object; @@ -194,18 +197,18 @@ if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); NSString family = handle.familyName(); wchar[] buffer1 = new wchar[family.length()]; - family.getCharacters_(buffer1); - String name = buffer1.toString().dup; + family.getCharacters_(buffer1.ptr); + String name = tango.text.convert.Utf.toString(buffer1).dup; NSString str = handle.fontName(); wchar[] buffer = new wchar[str.length()]; - str.getCharacters_(buffer); - String nsName = buffer.toString().dup; + str.getCharacters_(buffer.ptr); + String nsName = tango.text.convert.Utf.toString(buffer).dup; int style = DWT.NORMAL; if (nsName.indexOf("Italic") !is -1) style |= DWT.ITALIC; if (nsName.indexOf("Bold") !is -1) style |= DWT.BOLD; FontData data = new FontData(name, handle.pointSize(), style); data.nsName = nsName; - return new FontData[][data]; + return [data]; } /** @@ -242,24 +245,24 @@ * @see #equals */ public hash_t toHash() { - return handle !is null ? handle.id : 0; + return handle !is null ? cast(hash_t) handle.id_ : 0; } alias toHash hashCode; -void init(String name, float height, int style, String nsName) { +void init_(String name, float height, int style, String nsName) { //if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT); if (nsName !is null) { handle = NSFont.static_fontWithName_size_(NSString.stringWith(nsName), cast(CGFloat) height); } else { nsName = name; - if ((style & DWT.BOLD) !is 0) nsName += " Bold"; - if ((style & DWT.ITALIC) !is 0) nsName += " Italic"; + if ((style & DWT.BOLD) !is 0) nsName ~= " Bold"; + if ((style & DWT.ITALIC) !is 0) nsName ~= " Italic"; handle = NSFont.static_fontWithName_size_(NSString.stringWith(nsName), cast(CGFloat) height); if (handle is null && (style & DWT.ITALIC) !is 0) { nsName = name; - if ((style & DWT.BOLD) !is 0) nsName += " Bold"; + if ((style & DWT.BOLD) !is 0) nsName ~= " Bold"; handle = NSFont.static_fontWithName_size_(NSString.stringWith(nsName), cast(CGFloat) height); } if (handle is null && (style & DWT.BOLD) !is 0) { @@ -295,7 +298,7 @@ */ public String toString () { if (isDisposed()) return "Font {*DISPOSED*}"; - return "Font {" ~ handle ~ "}"; + return Format("Font {{}{}" , handle , "}"); } }