/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

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