Mercurial > projects > dwt2
comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/graphics/Font.d @ 54:70388b0e6dad
[swt lin] compiles
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 27 Mar 2009 23:31:11 +0100 |
parents | f589fc20a5f9 |
children | 536e43f63c81 |
comparison
equal
deleted
inserted
replaced
53:7e78af7adab5 | 54:70388b0e6dad |
---|---|
138 * </ul> | 138 * </ul> |
139 * @exception SWTError <ul> | 139 * @exception SWTError <ul> |
140 * <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li> | 140 * <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li> |
141 * </ul> | 141 * </ul> |
142 */ | 142 */ |
143 public this(Device device, String name, int height, int style) { | 143 public this(Device device, in String name, int height, int style) { |
144 super(device); | 144 super(device); |
145 init_(name, height, style, null); | 145 init_(name, height, style, null); |
146 init_(); | 146 init_(); |
147 } | 147 } |
148 | 148 |
149 /*public*/ this(Device device, String name, float height, int style) { | 149 /*public*/ this(Device device, in String name, float height, int style) { |
150 super(device); | 150 super(device); |
151 init_(name, height, style, null); | 151 init_(name, height, style, null); |
152 init_(); | 152 init_(); |
153 } | 153 } |
154 | 154 |
190 */ | 190 */ |
191 public FontData[] getFontData() { | 191 public FontData[] getFontData() { |
192 if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); | 192 if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
193 | 193 |
194 auto family = OS.pango_font_description_get_family(handle); | 194 auto family = OS.pango_font_description_get_family(handle); |
195 String name = fromStringz( family ); | 195 String name = fromStringz( family )._idup(); |
196 float height = cast(float)OS.pango_font_description_get_size(handle) / OS.PANGO_SCALE; | 196 float height = cast(float)OS.pango_font_description_get_size(handle) / OS.PANGO_SCALE; |
197 int pangoStyle = OS.pango_font_description_get_style(handle); | 197 int pangoStyle = OS.pango_font_description_get_style(handle); |
198 int pangoWeight = OS.pango_font_description_get_weight(handle); | 198 int pangoWeight = OS.pango_font_description_get_weight(handle); |
199 int style = SWT.NORMAL; | 199 int style = SWT.NORMAL; |
200 if (pangoStyle is OS.PANGO_STYLE_ITALIC) style |= SWT.ITALIC; | 200 if (pangoStyle is OS.PANGO_STYLE_ITALIC) style |= SWT.ITALIC; |
201 if (pangoStyle is OS.PANGO_STYLE_OBLIQUE) style |= SWT.ROMAN; | 201 if (pangoStyle is OS.PANGO_STYLE_OBLIQUE) style |= SWT.ROMAN; |
202 if (pangoWeight >= OS.PANGO_WEIGHT_BOLD) style |= SWT.BOLD; | 202 if (pangoWeight >= OS.PANGO_WEIGHT_BOLD) style |= SWT.BOLD; |
203 auto fontString = OS.pango_font_description_to_string (handle); | 203 auto fontString = OS.pango_font_description_to_string (handle); |
204 auto buffer = fromStringz( fontString ).dup; | 204 auto buffer = fromStringz( fontString )._idup(); |
205 FontData data = new FontData( buffer , height, style); | 205 FontData data = new FontData( buffer , height, style); |
206 OS.g_free (fontString); | 206 OS.g_free (fontString); |
207 data.str = buffer; | 207 data.str = buffer; |
208 return [data]; | 208 return [data]; |
209 } | 209 } |
241 */ | 241 */ |
242 public override hash_t toHash() { | 242 public override hash_t toHash() { |
243 return cast(hash_t)/*64*/handle; | 243 return cast(hash_t)/*64*/handle; |
244 } | 244 } |
245 | 245 |
246 void init_(String name, float height, int style, char[] fontString) { | 246 void init_( in String name, float height, int style, in String fontString) { |
247 if (name is null) SWT.error(SWT.ERROR_NULL_ARGUMENT); | 247 if (name is null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
248 if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); | 248 if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
249 if (fontString !is null) { | 249 if (fontString !is null) { |
250 handle = OS.pango_font_description_from_string (toStringz(fontString)); | 250 handle = OS.pango_font_description_from_string (toStringz(fontString)); |
251 if (handle is null) SWT.error(SWT.ERROR_NO_HANDLES); | 251 if (handle is null) SWT.error(SWT.ERROR_NO_HANDLES); |