PageRenderTime 24ms CodeModel.GetById 21ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/cairo/library/cairo_font_options.e

http://github.com/tybor/Liberty
Specman e | 194 lines | 113 code | 28 blank | 53 comment | 3 complexity | 2013ba24b293c3554d450945352d2abe MD5 | raw file
  1note
  2	description: "Font Options -- How a font should be rendered."
  3	copyright: "[
  4					Copyright (C) 2007-2017: Paolo Redaelli,
  5											 Soluciones Informaticas Libres S.A. (Except),
  6											 Cairo team
  7					
  8					This library is free software; you can redistribute it and/or
  9					modify it under the terms of the GNU Lesser General Public License
 10					as published by the Free Software Foundation; either version 2.1 of
 11					the License, or (at your option) any later version.
 12					
 13					This library is distributed in the hope that it will be useful, but
 14					WITHOUT ANY WARRANTY; without even the implied warranty of
 15					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 16					Lesser General Public License for more details.
 17
 18					You should have received a copy of the GNU Lesser General Public
 19					License along with this library; if not, write to the Free Software
 20					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 21					02110-1301 USA
 22			]"
 23	date: "$Date:$"
 24	revision: "$Revision:$"
 25	wrapped_version: "1.2.4"
 26
 27class CAIRO_FONT_OPTIONS
 28	-- Font options describes how a font should be rendered.
 29
 30inherit
 31	C_STRUCT	redefine copy, is_equal end
 32
 33	MIXED_MEMORY_HANDLING redefine dispose end
 34
 35insert
 36	CAIRO_ANTIALIAS_TYPE
 37	CAIRO_HINT_STYLE
 38	CAIRO_HINT_METRICS
 39	CAIRO_SUBPIXEL_ORDER
 40	CAIRO_FONT_OPTIONS_EXTERNALS
 41	CAIRO_STATUS
 42
 43create {ANY} make, from_external_pointer
 44
 45feature {} -- Creation
 46
 47	make
 48			-- Create a new font options object with all options initialized to
 49			-- default values.
 50		do
 51			from_external_pointer (cairo_font_options_create)
 52			-- cairo_font_options_create returns a newly allocated
 53			-- cairo_font_options_t. Free with cairo_font_options_destroy(). This
 54			-- function always returns a valid pointer; if memory cannot be
 55			-- allocated, then a special error object is returned where all
 56			-- operations on the object do nothing. You can check for this with
 57			-- cairo_font_options_status().
 58		end
 59
 60feature {ANY} -- Disposing
 61	dispose
 62			-- Destroys a cairo_font_options_t
 63		do
 64			if not is_shared then 
 65				cairo_font_options_destroy (handle)
 66			end
 67			handle := default_pointer
 68		end
 69
 70feature {ANY} -- Access
 71
 72	status: INTEGER
 73			-- The status of this font options object 
 74		do
 75			Result := cairo_font_options_status(handle)
 76		ensure valid: ((Result = cairo_status_success) or else
 77							(Result = cairo_status_no_memory))
 78		end
 79
 80	hash: INTEGER_64
 81			-- An hash for the font options object; this value will be useful when
 82			--   storing an object containing a cairo_font_options_t in a hash table.
 83			-- Note: the hash value for the font options object is a
 84			-- 64-bit unsigned value_ it can be cast to a 32-bit type if
 85			-- a 32-bit hash value is needed.
 86		do
 87			Result := cairo_font_options_hash (handle)
 88		end
 89
 90	subpixel_order: INTEGER
 91			-- the subpixel order for the font options object. See the
 92			-- documentation for `CAIRO_SUBPIXEL_ORDER' for full details.
 93		do
 94			Result := cairo_font_options_get_subpixel_order (handle)
 95		end
 96
 97	antialias: INTEGER
 98			-- the antialising mode for the font options object.
 99		require
100			valid_antialias: is_valid_antialias_type (Result)
101		do
102			Result := cairo_font_options_get_antialias (handle)
103		end
104
105	hint_style: INTEGER
106			-- the hint style for font outlines for the font options
107			-- object. See `CAIRO_HINT_STYLE' for full details.
108		do
109			Result := cairo_font_options_get_hint_style (handle)
110		ensure is_valid_hint_style: is_valid_hint_style (Result)
111		end
112
113	hint_metrics: INTEGER
114			-- the metrics hinting mode for the font options object. See
115			-- `CAIRO_HINT_METRICS' for full details.
116		do
117			Result := cairo_font_options_get_hint_metrics (handle)
118		end
119
120feature {ANY} -- Comparison
121
122	copy (another: like Current)
123			-- Allocates a new font options object copying the option values from
124			-- `another'.
125		do
126			from_external_pointer (cairo_font_options_copy (another.handle))
127			-- cairo_font_options_copy returns a newly allocated
128			-- cairo_font_options_t. Free with cairo_font_options_destroy(). This
129			-- function always returns a valid pointer; if memory cannot be
130			-- allocated, then a special error object is returned where all
131			-- operations on the object do nothing. You can check for this with
132			-- cairo_font_options_status().
133		end
134
135	is_equal (another: like Current): BOOLEAN
136			-- Do all fields of the two font options objects match?
137		do
138			Result := (cairo_font_options_equal (handle, another.handle).to_boolean)
139		end
140
141feature {ANY} -- Operations
142
143	merge (another: CAIRO_FONT_OPTIONS)
144			-- Merges non-default options from other into options,
145			-- replacing existing values. This operation can be thought
146			-- of as somewhat similar to compositing other onto options
147			-- with the operation of `cairo_operation_over'.
148		require another_not_void: another /= Void
149		do
150			cairo_font_options_merge (handle,another.handle)
151		end
152
153	set_antialias (an_antialias: INTEGER)
154			-- Sets the antiliasing mode for the font options
155			-- object. This specifies the type of antialiasing to do when
156			-- rendering text.
157		require valid_antialias: is_valid_antialias_type (an_antialias)
158		do
159			cairo_font_options_set_antialias (handle,an_antialias)
160		end
161
162	set_subpixel_order (a_subpixel_order: INTEGER)
163			-- Sets the subpixel order for the font options object. The
164			-- subpixel order specifies the order of color elements
165			-- within each pixel on the display device when rendering
166			-- with an antialiasing mode of
167			-- `cairo_antialias_subpixel'. See CAIRO_SUBPIXEL_ORDER for
168			-- full details.
169		require is_valid_subpixel_order: is_valid_subpixel_order (a_subpixel_order)
170		do
171			cairo_font_options_set_subpixel_order (handle, a_subpixel_order)
172		end
173
174	set_hint_style (a_style: INTEGER)
175			-- Sets the hint style for font outlines for the font options
176			-- object. This controls whether to fit font outlines to the
177			-- pixel grid, and if so, whether to optimize for fidelity or
178			-- contrast. See `CAIRO_HINT_STYLE' for full details.
179		require is_valid_hint_style: is_valid_hint_style (a_style)
180		do
181			cairo_font_options_set_hint_style (handle, a_style)
182		end
183
184	set_hint_metrics (a_metrics: INTEGER)
185			-- Sets the metrics hinting mode for the font options
186			-- object. This controls whether metrics are quantized to
187			-- integer values in device units. See `CAIRO_HINT_METRICS'
188			-- for full details.
189		require is_valid_hint_metrics: is_valid_hint_metrics (a_metrics)
190		do
191			cairo_font_options_set_hint_metrics (handle, a_metrics)
192		end
193
194end -- class CAIRO_FONT_OPTIONS