Guest User

Untitled

a guest
May 21st, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.35 KB | None | 0 0
  1. --- cairo-1.10.2.orig/src/cairo-ft-font.c 2011-01-30 11:05:56.709210029 +0000
  2. +++ cairo-1.10.2/src/cairo-ft-font.c 2011-01-30 11:42:31.169860095 +0000
  3. @@ -1578,6 +1578,7 @@
  4. #ifdef FC_HINT_STYLE
  5. int hintstyle;
  6. #endif
  7. + int lcd_filter;
  8.  
  9. _cairo_font_options_init_default (&ft_options.base);
  10. ft_options.load_flags = FT_LOAD_DEFAULT;
  11. @@ -1587,81 +1588,125 @@
  12. #define FC_EMBEDDED_BITMAP "embeddedbitmap"
  13. #endif
  14.  
  15. +#ifndef FcUndefined
  16. +#define FcUndefined -1
  17. +#endif
  18. /* Check whether to force use of embedded bitmaps */
  19. if (FcPatternGetBool (pattern,
  20. FC_EMBEDDED_BITMAP, 0, &bitmap) != FcResultMatch)
  21. - bitmap = FcFalse;
  22. + bitmap = FcUndefined;
  23.  
  24. - /* disable antialiasing if requested */
  25. - if (FcPatternGetBool (pattern,
  26. - FC_ANTIALIAS, 0, &antialias) != FcResultMatch)
  27. - antialias = FcTrue;
  28. -
  29. - if (antialias) {
  30. - cairo_subpixel_order_t subpixel_order;
  31. - int lcd_filter;
  32. -
  33. - /* disable hinting if requested */
  34. - if (FcPatternGetBool (pattern,
  35. - FC_HINTING, 0, &hinting) != FcResultMatch)
  36. - hinting = FcTrue;
  37. -
  38. - if (FcPatternGetInteger (pattern,
  39. - FC_RGBA, 0, &rgba) != FcResultMatch)
  40. - rgba = FC_RGBA_UNKNOWN;
  41. + if (FcPatternGetInteger (pattern,
  42. + FC_RGBA, 0, &rgba) != FcResultMatch)
  43. + rgba = FC_RGBA_UNKNOWN;
  44. +
  45. + /* Checking if antialias property was delivered from FontConfig */
  46. + if (FcPatternGetBool (pattern, FC_ANTIALIAS, 0, &antialias) != FcResultMatch)
  47. + antialias = FcUndefined;
  48. +
  49. + /*
  50. + * There are several cases of FontConfig setting we have to deal with
  51. + * a) antialias == true, rgba == rgb/bgr/vrgb/vbgr
  52. + * b) antialias == true, rgba == none
  53. + * c) antialias == true, rgba undefined
  54. + * d) antialias == false
  55. + * e) antialias == undefined, rgba == rgb/bgr/vrgb/vbgr
  56. + * f) antialias == undefined, rgba == none
  57. + * g) antialias == undefined, rgba undefined
  58. + *
  59. + * They are processed in following manner:
  60. + * a-c) antialias is defined and is true
  61. + * In such case we have to decide what type of antialias to select: GRAY or SUBPIXEL.
  62. + * This is done based on the subpixel_order property.
  63. + * - CAIRO_ANTIALIAS_GRAY when rgba is FC_RGBA_NONE
  64. + * - CAIRO_ANTIALIAS_SUBPIXEL otherwise (if the rgba is rgb/bgr/vrgb/vbgr
  65. + * or subpixel wasn't defined in FC at all)
  66. + *
  67. + * d) antialias property is defined and is false
  68. + * In such case we set the CAIRO_ANTIALIAS_NONE
  69. + *
  70. + * e-g) antialias property is not defined
  71. + * - the subpixel_order was specified in FC - very unlikely scenario,
  72. + * but in such case we are assuming antialiasing should be switched on.
  73. + * Type of antialias is set it to CAIRO_ANTIALIAS_GRAY or CAIRO_ANTIALIAS_SUBPIXEL
  74. + * based on the rgba type.
  75. + * - the subpixel_order was not specified as well - we are setting CAIRO_ANTIALIAS_DEFAULT
  76. + */
  77. + if ( (antialias == FcTrue) ||
  78. + ( (antialias == FcUndefined) && (rgba != FC_RGBA_UNKNOWN) ) ) {
  79. + if (rgba == FC_RGBA_NONE) {
  80. + ft_options.base.antialias = CAIRO_ANTIALIAS_GRAY;
  81. + ft_options.base.subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
  82. + } else {
  83. + ft_options.base.antialias = CAIRO_ANTIALIAS_SUBPIXEL;
  84. + /* ft_options.base.subpixel_order will be set later */
  85. + }
  86. + } else if (antialias == FcFalse) {
  87. + ft_options.base.antialias = CAIRO_ANTIALIAS_NONE;
  88. + ft_options.base.subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
  89. + } /* Antialias property not defined in Fontconfig and rgba is not set.
  90. + * Not doing anything - staying with CAIRO_ANTIALIAS_DEFAULT */
  91.  
  92. + if ( ft_options.base.antialias == CAIRO_ANTIALIAS_SUBPIXEL ) {
  93. switch (rgba) {
  94. case FC_RGBA_RGB:
  95. - subpixel_order = CAIRO_SUBPIXEL_ORDER_RGB;
  96. + ft_options.base.subpixel_order = CAIRO_SUBPIXEL_ORDER_RGB;
  97. break;
  98. case FC_RGBA_BGR:
  99. - subpixel_order = CAIRO_SUBPIXEL_ORDER_BGR;
  100. + ft_options.base.subpixel_order = CAIRO_SUBPIXEL_ORDER_BGR;
  101. break;
  102. case FC_RGBA_VRGB:
  103. - subpixel_order = CAIRO_SUBPIXEL_ORDER_VRGB;
  104. + ft_options.base.subpixel_order = CAIRO_SUBPIXEL_ORDER_VRGB;
  105. break;
  106. case FC_RGBA_VBGR:
  107. - subpixel_order = CAIRO_SUBPIXEL_ORDER_VBGR;
  108. + ft_options.base.subpixel_order = CAIRO_SUBPIXEL_ORDER_VBGR;
  109. break;
  110. case FC_RGBA_UNKNOWN:
  111. case FC_RGBA_NONE:
  112. default:
  113. - subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
  114. + ft_options.base.subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
  115. break;
  116. }
  117. + }
  118.  
  119. - if (subpixel_order != CAIRO_SUBPIXEL_ORDER_DEFAULT) {
  120. - ft_options.base.subpixel_order = subpixel_order;
  121. - ft_options.base.antialias = CAIRO_ANTIALIAS_SUBPIXEL;
  122. - }
  123. -
  124. - if (FcPatternGetInteger (pattern,
  125. - FC_LCD_FILTER, 0, &lcd_filter) == FcResultMatch)
  126. - {
  127. - switch (lcd_filter) {
  128. - case FC_LCD_NONE:
  129. - ft_options.base.lcd_filter = CAIRO_LCD_FILTER_NONE;
  130. - break;
  131. - case FC_LCD_DEFAULT:
  132. - ft_options.base.lcd_filter = CAIRO_LCD_FILTER_FIR5;
  133. - break;
  134. - case FC_LCD_LIGHT:
  135. - ft_options.base.lcd_filter = CAIRO_LCD_FILTER_FIR3;
  136. - break;
  137. - case FC_LCD_LEGACY:
  138. - ft_options.base.lcd_filter = CAIRO_LCD_FILTER_INTRA_PIXEL;
  139. - break;
  140. - }
  141. + if (FcPatternGetInteger (pattern, FC_LCD_FILTER, 0, &lcd_filter) == FcResultMatch) {
  142. + switch (lcd_filter) {
  143. + case FC_LCD_NONE:
  144. + ft_options.base.lcd_filter = CAIRO_LCD_FILTER_NONE;
  145. + break;
  146. + case FC_LCD_DEFAULT:
  147. + ft_options.base.lcd_filter = CAIRO_LCD_FILTER_FIR5;
  148. + break;
  149. + case FC_LCD_LIGHT:
  150. + ft_options.base.lcd_filter = CAIRO_LCD_FILTER_FIR3;
  151. + break;
  152. + case FC_LCD_LEGACY:
  153. + ft_options.base.lcd_filter = CAIRO_LCD_FILTER_INTRA_PIXEL;
  154. + break;
  155. }
  156. -
  157. -#ifdef FC_HINT_STYLE
  158. - if (FcPatternGetInteger (pattern,
  159. - FC_HINT_STYLE, 0, &hintstyle) != FcResultMatch)
  160. - hintstyle = FC_HINT_FULL;
  161. -
  162. - if (!hinting)
  163. - hintstyle = FC_HINT_NONE;
  164. -
  165. + } /* No LCD_FILTER property in FontConfig - staying with default CAIRO_LCD_FILTER_DEFAULT. */
  166. +
  167. + /*
  168. + * Processing hinting information
  169. + * Hinting should be processed also when no antialias information delivered from FontConfig
  170. + */
  171. + if (FcPatternGetBool (pattern, FC_HINTING, 0, &hinting) != FcResultMatch)
  172. + hinting = FcUndefined;
  173. +
  174. + /*
  175. + * If hininng is forced off, setting CAIRO_HINT_STYLE_NONE
  176. + * If hinting is not forced off, processing hintstyle and setting appropiate style
  177. + * If hinting is not forced off nor hintstyle defined,
  178. + * staing with the default CAIRO_HINT_STYLE_DEFAUT
  179. + * defined by _cairo_font_options_init_default
  180. + */
  181. + if (hinting == FcFalse)
  182. + ft_options.base.hint_style = CAIRO_HINT_STYLE_NONE;
  183. +
  184. +#ifdef FC_HINT_STYLE
  185. + if ( (hinting != FcFalse) &&
  186. + (FcPatternGetInteger (pattern,
  187. + FC_HINT_STYLE, 0, &hintstyle) == FcResultMatch) ) {
  188. switch (hintstyle) {
  189. case FC_HINT_NONE:
  190. ft_options.base.hint_style = CAIRO_HINT_STYLE_NONE;
  191. @@ -1677,46 +1722,39 @@
  192. ft_options.base.hint_style = CAIRO_HINT_STYLE_FULL;
  193. break;
  194. }
  195. -#else /* !FC_HINT_STYLE */
  196. - if (!hinting) {
  197. - ft_options.base.hint_style = CAIRO_HINT_STYLE_NONE;
  198. - }
  199. + }
  200. #endif /* FC_HINT_STYLE */
  201.  
  202. - /* Force embedded bitmaps off if no hinting requested */
  203. - if (ft_options.base.hint_style == CAIRO_HINT_STYLE_NONE)
  204. - bitmap = FcFalse;
  205. -
  206. - if (!bitmap)
  207. - ft_options.load_flags |= FT_LOAD_NO_BITMAP;
  208. + /* Force embedded bitmaps off if no hinting requested */
  209. + if (ft_options.base.hint_style == CAIRO_HINT_STYLE_NONE)
  210. + bitmap = FcFalse;
  211.  
  212. - } else {
  213. - ft_options.base.antialias = CAIRO_ANTIALIAS_NONE;
  214. - }
  215. + if (bitmap == FcFalse)
  216. + ft_options.load_flags |= FT_LOAD_NO_BITMAP;
  217.  
  218. /* force autohinting if requested */
  219. if (FcPatternGetBool (pattern,
  220. FC_AUTOHINT, 0, &autohint) != FcResultMatch)
  221. - autohint = FcFalse;
  222. + autohint = FcUndefined;
  223.  
  224. - if (autohint)
  225. + if (autohint == FcTrue)
  226. ft_options.load_flags |= FT_LOAD_FORCE_AUTOHINT;
  227.  
  228. if (FcPatternGetBool (pattern,
  229. FC_VERTICAL_LAYOUT, 0, &vertical_layout) != FcResultMatch)
  230. - vertical_layout = FcFalse;
  231. + vertical_layout = FcUndefined;
  232.  
  233. - if (vertical_layout)
  234. + if (vertical_layout == FcTrue)
  235. ft_options.load_flags |= FT_LOAD_VERTICAL_LAYOUT;
  236.  
  237. #ifndef FC_EMBOLDEN
  238. #define FC_EMBOLDEN "embolden"
  239. #endif
  240. - if (FcPatternGetBool (pattern,
  241. + if (FcPatternGetBool (pattern,
  242. FC_EMBOLDEN, 0, &embolden) != FcResultMatch)
  243. - embolden = FcFalse;
  244. -
  245. - if (embolden)
  246. + embolden = FcUndefined;
  247. +
  248. + if (embolden == FcTrue)
  249. ft_options.extra_flags |= CAIRO_FT_OPTIONS_EMBOLDEN;
  250.  
  251. *ret = ft_options;
  252. @@ -1736,31 +1774,38 @@
  253. if (load_flags & FT_LOAD_NO_HINTING)
  254. other->base.hint_style = CAIRO_HINT_STYLE_NONE;
  255.  
  256. - if (other->base.antialias == CAIRO_ANTIALIAS_NONE ||
  257. - options->base.antialias == CAIRO_ANTIALIAS_NONE) {
  258. - options->base.antialias = CAIRO_ANTIALIAS_NONE;
  259. - options->base.subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
  260. - }
  261. -
  262. - if (other->base.antialias == CAIRO_ANTIALIAS_SUBPIXEL &&
  263. - (options->base.antialias == CAIRO_ANTIALIAS_DEFAULT ||
  264. - options->base.antialias == CAIRO_ANTIALIAS_GRAY)) {
  265. - options->base.antialias = CAIRO_ANTIALIAS_SUBPIXEL;
  266. - options->base.subpixel_order = other->base.subpixel_order;
  267. + /* If others structure defines settings for antialiasing, we are processing them */
  268. + if (other->base.antialias != CAIRO_ANTIALIAS_DEFAULT) {
  269. + if ( other->base.antialias == CAIRO_ANTIALIAS_NONE ) {
  270. + /* Force antialias off */
  271. + options->base.antialias = CAIRO_ANTIALIAS_NONE;
  272. + options->base.subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
  273. + } else {
  274. + /* Force antialias on */
  275. +
  276. + /* If antialias==CAIRO_ANTIALIAS_SUBPIXEL is set,
  277. + * but the subpixel_order is set to CAIRO_SUBPIXEL_ORDER_DEFAULT,
  278. + * we have to determine what type of antialiasing will be used based
  279. + * on current subpixel order */
  280. + if ( (other->base.subpixel_order == CAIRO_SUBPIXEL_ORDER_DEFAULT) &&
  281. + (other->base.antialias == CAIRO_ANTIALIAS_SUBPIXEL) ) {
  282. + if (options->base.subpixel_order == CAIRO_SUBPIXEL_ORDER_DEFAULT)
  283. + options->base.antialias = CAIRO_ANTIALIAS_GRAY;
  284. + else
  285. + options->base.antialias = CAIRO_ANTIALIAS_SUBPIXEL;
  286. + } else {
  287. + options->base.subpixel_order = other->base.subpixel_order;
  288. + options->base.antialias = other->base.antialias;
  289. + }
  290. + }
  291. }
  292. -
  293. - if (options->base.hint_style == CAIRO_HINT_STYLE_DEFAULT)
  294. +
  295. + if (other->base.hint_style != CAIRO_HINT_STYLE_DEFAULT)
  296. options->base.hint_style = other->base.hint_style;
  297.  
  298. - if (other->base.hint_style == CAIRO_HINT_STYLE_NONE)
  299. - options->base.hint_style = CAIRO_HINT_STYLE_NONE;
  300. -
  301. - if (options->base.lcd_filter == CAIRO_LCD_FILTER_DEFAULT)
  302. + if (other->base.lcd_filter != CAIRO_LCD_FILTER_DEFAULT)
  303. options->base.lcd_filter = other->base.lcd_filter;
  304.  
  305. - if (other->base.lcd_filter == CAIRO_LCD_FILTER_NONE)
  306. - options->base.lcd_filter = CAIRO_LCD_FILTER_NONE;
  307. -
  308. if (options->base.antialias == CAIRO_ANTIALIAS_NONE) {
  309. if (options->base.hint_style == CAIRO_HINT_STYLE_NONE)
  310. load_flags |= FT_LOAD_NO_HINTING;
Add Comment
Please, Sign In to add comment