w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

cairo-ft-font.c
Go to the documentation of this file.
1 /* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
2 /* cairo - a vector graphics library with display and print output
3  *
4  * Copyright © 2000 Keith Packard
5  * Copyright © 2005 Red Hat, Inc
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it either under the terms of the GNU Lesser General Public
9  * License version 2.1 as published by the Free Software Foundation
10  * (the "LGPL") or, at your option, under the terms of the Mozilla
11  * Public License Version 1.1 (the "MPL"). If you do not alter this
12  * notice, a recipient may use your version of this file under either
13  * the MPL or the LGPL.
14  *
15  * You should have received a copy of the LGPL along with this library
16  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
18  * You should have received a copy of the MPL along with this library
19  * in the file COPYING-MPL-1.1
20  *
21  * The contents of this file are subject to the Mozilla Public License
22  * Version 1.1 (the "License"); you may not use this file except in
23  * compliance with the License. You may obtain a copy of the License at
24  * http://www.mozilla.org/MPL/
25  *
26  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
27  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
28  * the specific language governing rights and limitations.
29  *
30  * The Original Code is the cairo graphics library.
31  *
32  * The Initial Developer of the Original Code is Red Hat, Inc.
33  *
34  * Contributor(s):
35  * Graydon Hoare <graydon@redhat.com>
36  * Owen Taylor <otaylor@redhat.com>
37  * Keith Packard <keithp@keithp.com>
38  * Carl Worth <cworth@cworth.org>
39  */
40 
41 #define _DEFAULT_SOURCE /* for strdup() */
42 #include "cairoint.h"
43 
44 #include "cairo-error-private.h"
46 #include "cairo-ft-private.h"
47 #include "cairo-pattern-private.h"
48 #include "cairo-pixman-private.h"
49 
50 #include <float.h>
51 
53 
54 #include <ft2build.h>
55 #include FT_FREETYPE_H
56 #include FT_OUTLINE_H
57 #include FT_IMAGE_H
58 #include FT_BITMAP_H
59 #include FT_TRUETYPE_TABLES_H
60 #include FT_XFREE86_H
61 #include FT_MULTIPLE_MASTERS_H
62 #if HAVE_FT_GLYPHSLOT_EMBOLDEN
63 #include FT_SYNTHESIS_H
64 #endif
65 
66 #if HAVE_FT_LIBRARY_SETLCDFILTER
67 #include FT_LCD_FILTER_H
68 #endif
69 
70 #if HAVE_UNISTD_H
71 #include <unistd.h>
72 #else
73 #define R_OK 0 /* check existence only on windows */
74 #endif
75 
76 /* Fontconfig version older than 2.6 didn't have these options */
77 #ifndef FC_LCD_FILTER
78 #define FC_LCD_FILTER "lcdfilter"
79 #endif
80 /* Some Ubuntu versions defined FC_LCD_FILTER without defining the following */
81 #ifndef FC_LCD_NONE
82 #define FC_LCD_NONE 0
83 #define FC_LCD_DEFAULT 1
84 #define FC_LCD_LIGHT 2
85 #define FC_LCD_LEGACY 3
86 #endif
87 
88 /* FreeType version older than 2.3.5(?) didn't have these options */
89 #ifndef FT_LCD_FILTER_NONE
90 #define FT_LCD_FILTER_NONE 0
91 #define FT_LCD_FILTER_DEFAULT 1
92 #define FT_LCD_FILTER_LIGHT 2
93 #define FT_LCD_FILTER_LEGACY 16
94 #endif
95 
96 #define DOUBLE_FROM_26_6(t) ((double)(t) / 64.0)
97 #define DOUBLE_TO_16_16(d) ((FT_Fixed)((d) * 65536.0))
98 #define DOUBLE_FROM_16_16(t) ((double)(t) / 65536.0)
99 
100 /* This is the max number of FT_face objects we keep open at once
101  */
102 #define MAX_OPEN_FACES 10
103 
104 /**
105  * SECTION:cairo-ft
106  * @Title: FreeType Fonts
107  * @Short_Description: Font support for FreeType
108  * @See_Also: #cairo_font_face_t
109  *
110  * The FreeType font backend is primarily used to render text on GNU/Linux
111  * systems, but can be used on other platforms too.
112  **/
113 
114 /**
115  * CAIRO_HAS_FT_FONT:
116  *
117  * Defined if the FreeType font backend is available.
118  * This macro can be used to conditionally compile backend-specific code.
119  *
120  * Since: 1.0
121  **/
122 
123 /**
124  * CAIRO_HAS_FC_FONT:
125  *
126  * Defined if the Fontconfig-specific functions of the FreeType font backend
127  * are available.
128  * This macro can be used to conditionally compile backend-specific code.
129  *
130  * Since: 1.10
131  **/
132 
133 /*
134  * The simple 2x2 matrix is converted into separate scale and shape
135  * factors so that hinting works right
136  */
137 
138 typedef struct _cairo_ft_font_transform {
139  double x_scale, y_scale;
140  double shape[2][2];
142 
143 /*
144  * We create an object that corresponds to a single font on the disk;
145  * (identified by a filename/id pair) these are shared between all
146  * fonts using that file. For cairo_ft_font_face_create_for_ft_face(), we
147  * just create a one-off version with a permanent face value.
148  */
149 
151 
154 
155  cairo_bool_t from_face; /* was the FT_Face provided by user? */
156  FT_Face face; /* provided or cached face */
157 
158  /* only set if from_face is false */
159  char *filename;
160  int id;
161 
162  /* We temporarily scale the unscaled font as needed */
165  double x_scale; /* Extracted X scale factor */
166  double y_scale; /* Extracted Y scale factor */
167  cairo_bool_t have_shape; /* true if the current scale has a non-scale component*/
170 
171  unsigned int have_color_set : 1;
172  unsigned int have_color : 1; /* true if the font contains color glyphs */
173  FT_Fixed *variations; /* variation settings that FT_Face came */
174 
176  int lock_count;
177 
178  cairo_ft_font_face_t *faces; /* Linked list of faces for this font */
179 };
180 
181 static int
182 _cairo_ft_unscaled_font_keys_equal (const void *key_a,
183  const void *key_b);
184 
185 static void
187 
188 typedef struct _cairo_ft_options {
190  unsigned int load_flags; /* flags for FT_Load_Glyph */
191  unsigned int synth_flags;
193 
194 static void
196  const cairo_ft_options_t *other)
197 {
199  options->load_flags = other->load_flags;
200  options->synth_flags = other->synth_flags;
201 }
202 
203 static void
205 {
207 }
208 
209 struct _cairo_ft_font_face {
211 
215 
216 #if CAIRO_HAS_FC_FONT
217  FcPattern *pattern; /* if pattern is set, the above fields will be NULL */
220 #endif
221 };
222 
224 
225 #if CAIRO_HAS_FC_FONT
226 static cairo_status_t
228  FcPattern *pattern);
229 
230 static cairo_font_face_t *
232  const cairo_matrix_t *font_matrix,
233  const cairo_matrix_t *ctm,
235 
236 #endif
237 
238 static cairo_status_t
240 {
241  /* Currently we don't get many (any?) useful statuses here.
242  * Populate as needed. */
243  switch (error)
244  {
245  case FT_Err_Out_Of_Memory:
246  return CAIRO_STATUS_NO_MEMORY;
247  default:
249  }
250 }
251 
252 /*
253  * We maintain a hash table to map file/id => #cairo_ft_unscaled_font_t.
254  * The hash table itself isn't limited in size. However, we limit the
255  * number of FT_Face objects we keep around; when we've exceeded that
256  * limit and need to create a new FT_Face, we dump the FT_Face from a
257  * random #cairo_ft_unscaled_font_t which has an unlocked FT_Face, (if
258  * there are any).
259  */
260 
261 typedef struct _cairo_ft_unscaled_font_map {
264  int num_open_faces;
266 
268 
269 
270 static FT_Face
272 
273 static void
275 
276 static cairo_bool_t
278 
279 
280 static void
283 {
284  if (unscaled->face) {
285  FT_Done_Face (unscaled->face);
286  unscaled->face = NULL;
287  unscaled->have_scale = FALSE;
288 
289  font_map->num_open_faces--;
290  }
291 }
292 
293 static cairo_status_t
295 {
297 
298  /* This function is only intended to be called from
299  * _cairo_ft_unscaled_font_map_lock. So we'll crash if we can
300  * detect some other call path. */
302 
304  if (unlikely (font_map == NULL))
306 
307  font_map->hash_table =
309 
310  if (unlikely (font_map->hash_table == NULL))
311  goto FAIL;
312 
313  if (unlikely (FT_Init_FreeType (&font_map->ft_library)))
314  goto FAIL;
315 
316  font_map->num_open_faces = 0;
317 
319  return CAIRO_STATUS_SUCCESS;
320 
321 FAIL:
322  if (font_map->hash_table)
323  _cairo_hash_table_destroy (font_map->hash_table);
324  free (font_map);
325 
327 }
328 
329 
330 static void
332 {
335 
336  _cairo_hash_table_remove (font_map->hash_table,
337  &unscaled->base.hash_entry);
338 
339  if (! unscaled->from_face)
341 
343  free (unscaled);
344 }
345 
346 static void
348 {
350 
351  CAIRO_MUTEX_LOCK (_cairo_ft_unscaled_font_map_mutex);
354  CAIRO_MUTEX_UNLOCK (_cairo_ft_unscaled_font_map_mutex);
355 
356  if (font_map != NULL) {
357  _cairo_hash_table_foreach (font_map->hash_table,
359  font_map);
360  assert (font_map->num_open_faces == 0);
361 
362  FT_Done_FreeType (font_map->ft_library);
363 
364  _cairo_hash_table_destroy (font_map->hash_table);
365 
366  free (font_map);
367  }
368 }
369 
372 {
373  CAIRO_MUTEX_LOCK (_cairo_ft_unscaled_font_map_mutex);
374 
377  CAIRO_MUTEX_UNLOCK (_cairo_ft_unscaled_font_map_mutex);
378  return NULL;
379  }
380  }
381 
383 }
384 
385 static void
387 {
388  CAIRO_MUTEX_UNLOCK (_cairo_ft_unscaled_font_map_mutex);
389 }
390 
391 static void
393  cairo_bool_t from_face,
394  char *filename,
395  int id,
396  FT_Face face)
397 {
398  size_t hash;
399 
400  key->from_face = from_face;
401  key->filename = filename;
402  key->id = id;
403  key->face = face;
404 
406  /* the constants are just arbitrary primes */
407  hash += ((size_t) id) * 1607;
408  hash += ((size_t) face) * 2137;
409 
410  key->base.hash_entry.hash = hash;
411 }
412 
413 /**
414  * _cairo_ft_unscaled_font_init:
415  *
416  * Initialize a #cairo_ft_unscaled_font_t.
417  *
418  * There are two basic flavors of #cairo_ft_unscaled_font_t, one
419  * created from an FT_Face and the other created from a filename/id
420  * pair. These two flavors are identified as from_face and !from_face.
421  *
422  * To initialize a from_face font, pass filename==%NULL, id=0 and the
423  * desired face.
424  *
425  * To initialize a !from_face font, pass the filename/id as desired
426  * and face==%NULL.
427  *
428  * Note that the code handles these two flavors in very distinct
429  * ways. For example there is a hash_table mapping
430  * filename/id->#cairo_unscaled_font_t in the !from_face case, but no
431  * parallel in the from_face case, (where the calling code would have
432  * to do its own mapping to ensure similar sharing).
433  **/
434 static cairo_status_t
436  cairo_bool_t from_face,
437  const char *filename,
438  int id,
439  FT_Face face)
440 {
443 
444  unscaled->variations = NULL;
445 
446  if (from_face) {
447  unscaled->from_face = TRUE;
449 
450 
451  unscaled->have_color = FT_HAS_COLOR (face) != 0;
452  unscaled->have_color_set = TRUE;
453 
454 #ifdef HAVE_FT_GET_VAR_DESIGN_COORDINATES
455  {
456  FT_MM_Var *ft_mm_var;
457  if (0 == FT_Get_MM_Var (face, &ft_mm_var))
458  {
459  unscaled->variations = calloc (ft_mm_var->num_axis, sizeof (FT_Fixed));
460  if (unscaled->variations)
461  FT_Get_Var_Design_Coordinates (face, ft_mm_var->num_axis, unscaled->variations);
462  }
463  }
464 #endif
465  } else {
466  char *filename_copy;
467 
468  unscaled->from_face = FALSE;
469  unscaled->face = NULL;
470 
471  filename_copy = strdup (filename);
472  if (unlikely (filename_copy == NULL))
474 
475  _cairo_ft_unscaled_font_init_key (unscaled, FALSE, filename_copy, id, NULL);
476 
477  unscaled->have_color_set = FALSE;
478  }
479 
480  unscaled->have_scale = FALSE;
481  CAIRO_MUTEX_INIT (unscaled->mutex);
482  unscaled->lock_count = 0;
483 
484  unscaled->faces = NULL;
485 
486  return CAIRO_STATUS_SUCCESS;
487 }
488 
489 /**
490  * _cairo_ft_unscaled_font_fini:
491  *
492  * Free all data associated with a #cairo_ft_unscaled_font_t.
493  *
494  * CAUTION: The unscaled->face field must be %NULL before calling this
495  * function. This is because the #cairo_ft_unscaled_font_t_map keeps a
496  * count of these faces (font_map->num_open_faces) so it maintains the
497  * unscaled->face field while it has its lock held. See
498  * _font_map_release_face_lock_held().
499  **/
500 static void
502 {
503  assert (unscaled->face == NULL);
504 
505  free (unscaled->filename);
506  unscaled->filename = NULL;
507 
508  free (unscaled->variations);
509 
510  CAIRO_MUTEX_FINI (unscaled->mutex);
511 }
512 
513 static int
515  const void *key_b)
516 {
517  const cairo_ft_unscaled_font_t *unscaled_a = key_a;
518  const cairo_ft_unscaled_font_t *unscaled_b = key_b;
519 
520  if (unscaled_a->id == unscaled_b->id &&
521  unscaled_a->from_face == unscaled_b->from_face)
522  {
523  if (unscaled_a->from_face)
524  return unscaled_a->face == unscaled_b->face;
525 
526  if (unscaled_a->filename == NULL && unscaled_b->filename == NULL)
527  return TRUE;
528  else if (unscaled_a->filename == NULL || unscaled_b->filename == NULL)
529  return FALSE;
530  else
531  return (strcmp (unscaled_a->filename, unscaled_b->filename) == 0);
532  }
533 
534  return FALSE;
535 }
536 
537 /* Finds or creates a #cairo_ft_unscaled_font_t for the filename/id from
538  * pattern. Returns a new reference to the unscaled font.
539  */
540 static cairo_status_t
542  char *filename,
543  int id,
546 {
550 
552  if (unlikely (font_map == NULL))
554 
556 
557  /* Return existing unscaled font if it exists in the hash table. */
559  &key.base.hash_entry);
560  if (unscaled != NULL) {
562  goto DONE;
563  }
564 
565  /* Otherwise create it and insert into hash table. */
567  if (unlikely (unscaled == NULL)) {
569  goto UNWIND_FONT_MAP_LOCK;
570  }
571 
573  if (unlikely (status))
574  goto UNWIND_UNSCALED_MALLOC;
575 
576  assert (unscaled->base.hash_entry.hash == key.base.hash_entry.hash);
578  &unscaled->base.hash_entry);
579  if (unlikely (status))
580  goto UNWIND_UNSCALED_FONT_INIT;
581 
582 DONE:
584  *out = unscaled;
585  return CAIRO_STATUS_SUCCESS;
586 
587 UNWIND_UNSCALED_FONT_INIT:
589 UNWIND_UNSCALED_MALLOC:
590  free (unscaled);
591 UNWIND_FONT_MAP_LOCK:
593  return status;
594 }
595 
596 
597 #if CAIRO_HAS_FC_FONT
598 static cairo_status_t
601 {
603  char *filename = NULL;
604  int id = 0;
605  FcResult ret;
606 
608  if (ret == FcResultMatch)
609  goto DONE;
610  if (ret == FcResultOutOfMemory)
612 
614  if (ret == FcResultOutOfMemory)
616  if (ret == FcResultMatch) {
617  if (access (filename, R_OK) == 0) {
618  /* If FC_INDEX is not set, we just use 0 */
620  if (ret == FcResultOutOfMemory)
622 
623  goto DONE;
624  } else
626  }
627 
628  /* The pattern contains neither a face nor a filename, resolve it later. */
629  *out = NULL;
630  return CAIRO_STATUS_SUCCESS;
631 
632 DONE:
634  filename, id, font_face,
635  out);
636 }
637 #endif
638 
639 static cairo_status_t
642 {
644 }
645 
646 static cairo_bool_t
647 _cairo_ft_unscaled_font_destroy (void *abstract_font)
648 {
649  cairo_ft_unscaled_font_t *unscaled = abstract_font;
651 
653  /* All created objects must have been mapped in the font map. */
654  assert (font_map != NULL);
655 
656  if (! _cairo_reference_count_dec_and_test (&unscaled->base.ref_count)) {
657  /* somebody recreated the font whilst we waited for the lock */
659  return FALSE;
660  }
661 
662  _cairo_hash_table_remove (font_map->hash_table,
663  &unscaled->base.hash_entry);
664 
665  if (unscaled->from_face) {
666  /* See comments in _ft_font_face_destroy about the "zombie" state
667  * for a _ft_font_face.
668  */
669  if (unscaled->faces && unscaled->faces->unscaled == NULL) {
670  assert (unscaled->faces->next == NULL);
671  cairo_font_face_destroy (&unscaled->faces->base);
672  }
673  } else {
675  }
676  unscaled->face = NULL;
677 
679 
681  return TRUE;
682 }
683 
684 static cairo_bool_t
686 {
688 
689  return (!unscaled->from_face && unscaled->lock_count == 0 && unscaled->face);
690 }
691 
692 /* Ensures that an unscaled font has a face object. If we exceed
693  * MAX_OPEN_FACES, try to close some.
694  *
695  * This differs from _cairo_ft_scaled_font_lock_face in that it doesn't
696  * set the scale on the face, but just returns it at the last scale.
697  */
698 static cairo_warn FT_Face
700 {
702  FT_Face face = NULL;
703  FT_Error error;
704 
705  CAIRO_MUTEX_LOCK (unscaled->mutex);
706  unscaled->lock_count++;
707 
708  if (unscaled->face)
709  return unscaled->face;
710 
711  /* If this unscaled font was created from an FT_Face then we just
712  * returned it above. */
713  assert (!unscaled->from_face);
714 
716  {
717  assert (font_map != NULL);
718 
719  while (font_map->num_open_faces >= MAX_OPEN_FACES)
720  {
722 
725  if (entry == NULL)
726  break;
727 
729  }
730  }
732 
733  error = FT_New_Face (font_map->ft_library,
734  unscaled->filename,
735  unscaled->id,
736  &face);
737  if (error)
738  {
739  unscaled->lock_count--;
740  CAIRO_MUTEX_UNLOCK (unscaled->mutex);
742  return NULL;
743  }
744 
745  unscaled->face = face;
746 
747  unscaled->have_color = FT_HAS_COLOR (face) != 0;
748  unscaled->have_color_set = TRUE;
749 
750  font_map->num_open_faces++;
751 
752  return face;
753 }
754 
755 
756 /* Unlock unscaled font locked with _cairo_ft_unscaled_font_lock_face
757  */
758 static void
760 {
761  assert (unscaled->lock_count > 0);
762 
763  unscaled->lock_count--;
764 
765  CAIRO_MUTEX_UNLOCK (unscaled->mutex);
766 }
767 
768 
769 static cairo_status_t
773 {
775  double x_scale, y_scale;
776  cairo_matrix_t normalized = *scale;
777 
778  /* The font matrix has x and y "scale" components which we extract and
779  * use as character scale values. These influence the way freetype
780  * chooses hints, as well as selecting different bitmaps in
781  * hand-rendered fonts. We also copy the normalized matrix to
782  * freetype's transformation.
783  */
784 
786  &x_scale, &y_scale,
787  1);
788  if (unlikely (status))
789  return status;
790 
791  /* FreeType docs say this about x_scale and y_scale:
792  * "A character width or height smaller than 1pt is set to 1pt;"
793  * So, we cap them from below at 1.0 and let the FT transform
794  * take care of sub-1.0 scaling. */
795  if (x_scale < 1.0)
796  x_scale = 1.0;
797  if (y_scale < 1.0)
798  y_scale = 1.0;
799 
800  if (unscaled && (unscaled->face->face_flags & FT_FACE_FLAG_SCALABLE) == 0) {
801  double min_distance = DBL_MAX;
802  cairo_bool_t magnify = TRUE;
803  int i;
804  double best_x_size = 0;
805  double best_y_size = 0;
806 
807  for (i = 0; i < unscaled->face->num_fixed_sizes; i++) {
808  double x_size = unscaled->face->available_sizes[i].x_ppem / 64.;
809  double y_size = unscaled->face->available_sizes[i].y_ppem / 64.;
810  double distance = y_size - y_scale;
811 
812  /*
813  * distance is positive if current strike is larger than desired
814  * size, and negative if smaller.
815  *
816  * We like to prefer down-scaling to upscaling.
817  */
818 
819  if ((magnify && distance >= 0) || fabs (distance) <= min_distance) {
820  magnify = distance < 0;
821  min_distance = fabs (distance);
822  best_x_size = x_size;
823  best_y_size = y_size;
824  }
825  }
826 
827  x_scale = best_x_size;
828  y_scale = best_y_size;
829  }
830 
831  sf->x_scale = x_scale;
832  sf->y_scale = y_scale;
833 
834  cairo_matrix_scale (&normalized, 1.0 / x_scale, 1.0 / y_scale);
835 
836  _cairo_matrix_get_affine (&normalized,
837  &sf->shape[0][0], &sf->shape[0][1],
838  &sf->shape[1][0], &sf->shape[1][1],
839  NULL, NULL);
840 
841  return CAIRO_STATUS_SUCCESS;
842 }
843 
844 /* Temporarily scales an unscaled font to the give scale. We catch
845  * scaling to the same size, since changing a FT_Face is expensive.
846  */
847 static cairo_status_t
850 {
853  FT_Matrix mat;
854  FT_Error error;
855 
856  assert (unscaled->face != NULL);
857 
858  if (unscaled->have_scale &&
859  scale->xx == unscaled->current_scale.xx &&
860  scale->yx == unscaled->current_scale.yx &&
861  scale->xy == unscaled->current_scale.xy &&
862  scale->yy == unscaled->current_scale.yy)
863  return CAIRO_STATUS_SUCCESS;
864 
865  unscaled->have_scale = TRUE;
866  unscaled->current_scale = *scale;
867 
869  if (unlikely (status))
870  return status;
871 
872  unscaled->x_scale = sf.x_scale;
873  unscaled->y_scale = sf.y_scale;
874 
875  mat.xx = DOUBLE_TO_16_16(sf.shape[0][0]);
876  mat.yx = - DOUBLE_TO_16_16(sf.shape[0][1]);
877  mat.xy = - DOUBLE_TO_16_16(sf.shape[1][0]);
878  mat.yy = DOUBLE_TO_16_16(sf.shape[1][1]);
879 
880  unscaled->have_shape = (mat.xx != 0x10000 ||
881  mat.yx != 0x00000 ||
882  mat.xy != 0x00000 ||
883  mat.yy != 0x10000);
884 
885  unscaled->Current_Shape = mat;
886  cairo_matrix_init (&unscaled->current_shape,
887  sf.shape[0][0], sf.shape[0][1],
888  sf.shape[1][0], sf.shape[1][1],
889  0.0, 0.0);
890 
891  FT_Set_Transform(unscaled->face, &mat, NULL);
892 
894  sf.x_scale * 64.0 + .5,
895  sf.y_scale * 64.0 + .5,
896  0, 0);
897  if (error)
899 
900  return CAIRO_STATUS_SUCCESS;
901 }
902 
903 /* we sometimes need to convert the glyph bitmap in a FT_GlyphSlot
904  * into a different format. For example, we want to convert a
905  * FT_PIXEL_MODE_LCD or FT_PIXEL_MODE_LCD_V bitmap into a 32-bit
906  * ARGB or ABGR bitmap.
907  *
908  * this function prepares a target descriptor for this operation.
909  *
910  * input :: target bitmap descriptor. The function will set its
911  * 'width', 'rows' and 'pitch' fields, and only these
912  *
913  * slot :: the glyph slot containing the source bitmap. this
914  * function assumes that slot->format == FT_GLYPH_FORMAT_BITMAP
915  *
916  * mode :: the requested final rendering mode. supported values are
917  * MONO, NORMAL (i.e. gray), LCD and LCD_V
918  *
919  * the function returns the size in bytes of the corresponding buffer,
920  * it's up to the caller to allocate the corresponding memory block
921  * before calling _fill_xrender_bitmap
922  *
923  * it also returns -1 in case of error (e.g. incompatible arguments,
924  * like trying to convert a gray bitmap into a monochrome one)
925  */
926 static int
930 {
931  FT_Bitmap *ftbit;
932  int width, height, pitch;
933 
934  if (slot->format != FT_GLYPH_FORMAT_BITMAP)
935  return -1;
936 
937  /* compute the size of the final bitmap */
938  ftbit = &slot->bitmap;
939 
940  width = ftbit->width;
941  height = ftbit->rows;
942  pitch = (width + 3) & ~3;
943 
944  switch (ftbit->pixel_mode) {
945  case FT_PIXEL_MODE_MONO:
946  if (mode == FT_RENDER_MODE_MONO) {
947  pitch = (((width + 31) & ~31) >> 3);
948  break;
949  }
950  /* fall-through */
951 
952  case FT_PIXEL_MODE_GRAY:
953  if (mode == FT_RENDER_MODE_LCD ||
955  {
956  /* each pixel is replicated into a 32-bit ARGB value */
957  pitch = width * 4;
958  }
959  break;
960 
961  case FT_PIXEL_MODE_LCD:
962  if (mode != FT_RENDER_MODE_LCD)
963  return -1;
964 
965  /* horz pixel triplets are packed into 32-bit ARGB values */
966  width /= 3;
967  pitch = width * 4;
968  break;
969 
970  case FT_PIXEL_MODE_LCD_V:
971  if (mode != FT_RENDER_MODE_LCD_V)
972  return -1;
973 
974  /* vert pixel triplets are packed into 32-bit ARGB values */
975  height /= 3;
976  pitch = width * 4;
977  break;
978 
979  case FT_PIXEL_MODE_BGRA:
980  /* each pixel is replicated into a 32-bit ARGB value */
981  pitch = width * 4;
982  break;
983 
984  default: /* unsupported source format */
985  return -1;
986  }
987 
988  target->width = width;
989  target->rows = height;
990  target->pitch = pitch;
991  target->buffer = NULL;
992 
993  return pitch * height;
994 }
995 
996 /* this functions converts the glyph bitmap found in a FT_GlyphSlot
997  * into a different format (see _compute_xrender_bitmap_size)
998  *
999  * you should call this function after _compute_xrender_bitmap_size
1000  *
1001  * target :: target bitmap descriptor. Note that its 'buffer' pointer
1002  * must point to memory allocated by the caller
1003  *
1004  * slot :: the glyph slot containing the source bitmap
1005  *
1006  * mode :: the requested final rendering mode
1007  *
1008  * bgr :: boolean, set if BGR or VBGR pixel ordering is needed
1009  */
1010 static void
1014  int bgr)
1015 {
1016  FT_Bitmap *ftbit = &slot->bitmap;
1017  unsigned char *srcLine = ftbit->buffer;
1018  unsigned char *dstLine = target->buffer;
1019  int src_pitch = ftbit->pitch;
1020  int width = target->width;
1021  int height = target->rows;
1022  int pitch = target->pitch;
1023  int subpixel;
1024  int h;
1025 
1026  subpixel = (mode == FT_RENDER_MODE_LCD ||
1028 
1029  if (src_pitch < 0)
1030  srcLine -= src_pitch * (ftbit->rows - 1);
1031 
1032  target->pixel_mode = ftbit->pixel_mode;
1033 
1034  switch (ftbit->pixel_mode) {
1035  case FT_PIXEL_MODE_MONO:
1036  if (subpixel) {
1037  /* convert mono to ARGB32 values */
1038 
1039  for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch) {
1040  int x;
1041 
1042  for (x = 0; x < width; x++) {
1043  if (srcLine[(x >> 3)] & (0x80 >> (x & 7)))
1044  ((unsigned int *) dstLine)[x] = 0xffffffffU;
1045  }
1046  }
1047  target->pixel_mode = FT_PIXEL_MODE_LCD;
1048 
1049  } else if (mode == FT_RENDER_MODE_NORMAL) {
1050  /* convert mono to 8-bit gray */
1051 
1052  for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch) {
1053  int x;
1054 
1055  for (x = 0; x < width; x++) {
1056  if (srcLine[(x >> 3)] & (0x80 >> (x & 7)))
1057  dstLine[x] = 0xff;
1058  }
1059  }
1060  target->pixel_mode = FT_PIXEL_MODE_GRAY;
1061 
1062  } else {
1063  /* copy mono to mono */
1064 
1065  int bytes = (width + 7) >> 3;
1066 
1067  for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch)
1068  memcpy (dstLine, srcLine, bytes);
1069  }
1070  break;
1071 
1072  case FT_PIXEL_MODE_GRAY:
1073  if (subpixel) {
1074  /* convert gray to ARGB32 values */
1075 
1076  for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch) {
1077  int x;
1078  unsigned int *dst = (unsigned int *) dstLine;
1079 
1080  for (x = 0; x < width; x++) {
1081  unsigned int pix = srcLine[x];
1082 
1083  pix |= (pix << 8);
1084  pix |= (pix << 16);
1085 
1086  dst[x] = pix;
1087  }
1088  }
1089  target->pixel_mode = FT_PIXEL_MODE_LCD;
1090  } else {
1091  /* copy gray into gray */
1092 
1093  for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch)
1094  memcpy (dstLine, srcLine, width);
1095  }
1096  break;
1097 
1098  case FT_PIXEL_MODE_LCD:
1099  if (!bgr) {
1100  /* convert horizontal RGB into ARGB32 */
1101 
1102  for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch) {
1103  int x;
1104  unsigned char *src = srcLine;
1105  unsigned int *dst = (unsigned int *) dstLine;
1106 
1107  for (x = 0; x < width; x++, src += 3) {
1108  unsigned int pix;
1109 
1110  pix = ((unsigned int)src[0] << 16) |
1111  ((unsigned int)src[1] << 8) |
1112  ((unsigned int)src[2] ) |
1113  ((unsigned int)src[1] << 24) ;
1114 
1115  dst[x] = pix;
1116  }
1117  }
1118  } else {
1119  /* convert horizontal BGR into ARGB32 */
1120 
1121  for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch) {
1122 
1123  int x;
1124  unsigned char *src = srcLine;
1125  unsigned int *dst = (unsigned int *) dstLine;
1126 
1127  for (x = 0; x < width; x++, src += 3) {
1128  unsigned int pix;
1129 
1130  pix = ((unsigned int)src[2] << 16) |
1131  ((unsigned int)src[1] << 8) |
1132  ((unsigned int)src[0] ) |
1133  ((unsigned int)src[1] << 24) ;
1134 
1135  dst[x] = pix;
1136  }
1137  }
1138  }
1139  break;
1140 
1141  case FT_PIXEL_MODE_LCD_V:
1142  /* convert vertical RGB into ARGB32 */
1143  if (!bgr) {
1144 
1145  for (h = height; h > 0; h--, srcLine += 3 * src_pitch, dstLine += pitch) {
1146  int x;
1147  unsigned char* src = srcLine;
1148  unsigned int* dst = (unsigned int *) dstLine;
1149 
1150  for (x = 0; x < width; x++, src += 1) {
1151  unsigned int pix;
1152  pix = ((unsigned int)src[0] << 16) |
1153  ((unsigned int)src[src_pitch] << 8) |
1154  ((unsigned int)src[src_pitch*2] ) |
1155  ((unsigned int)src[src_pitch] << 24) ;
1156  dst[x] = pix;
1157  }
1158  }
1159  } else {
1160 
1161  for (h = height; h > 0; h--, srcLine += 3*src_pitch, dstLine += pitch) {
1162  int x;
1163  unsigned char *src = srcLine;
1164  unsigned int *dst = (unsigned int *) dstLine;
1165 
1166  for (x = 0; x < width; x++, src += 1) {
1167  unsigned int pix;
1168 
1169  pix = ((unsigned int)src[src_pitch * 2] << 16) |
1170  ((unsigned int)src[src_pitch] << 8) |
1171  ((unsigned int)src[0] ) |
1172  ((unsigned int)src[src_pitch] << 24) ;
1173 
1174  dst[x] = pix;
1175  }
1176  }
1177  }
1178  break;
1179 
1180  case FT_PIXEL_MODE_BGRA:
1181  for (h = height; h > 0; h--, srcLine += src_pitch, dstLine += pitch)
1182  memcpy (dstLine, srcLine, width * 4);
1183  break;
1184 
1185  default:
1186  assert (0);
1187  }
1188 }
1189 
1190 
1191 /* Fills in val->image with an image surface created from @bitmap
1192  */
1193 static cairo_status_t
1196  cairo_bool_t own_buffer,
1197  cairo_font_options_t *font_options,
1199 {
1200  unsigned int width, height;
1201  unsigned char *data;
1202  int format = CAIRO_FORMAT_A8;
1203  int stride;
1205  cairo_bool_t component_alpha = FALSE;
1206 
1207  width = bitmap->width;
1208  height = bitmap->rows;
1209 
1210  if (width == 0 || height == 0) {
1213  return (*surface)->base.status;
1214  }
1215 
1216  switch (bitmap->pixel_mode) {
1217  case FT_PIXEL_MODE_MONO:
1218  stride = (((width + 31) & ~31) >> 3);
1219  if (own_buffer) {
1220  data = bitmap->buffer;
1221  assert (stride == bitmap->pitch);
1222  } else {
1224  if (!data)
1226 
1227  if (stride == bitmap->pitch) {
1228  memcpy (data, bitmap->buffer, stride * height);
1229  } else {
1230  int i;
1231  unsigned char *source, *dest;
1232 
1233  source = bitmap->buffer;
1234  dest = data;
1235  for (i = height; i; i--) {
1236  memcpy (dest, source, bitmap->pitch);
1237  memset (dest + bitmap->pitch, '\0', stride - bitmap->pitch);
1238 
1239  source += bitmap->pitch;
1240  dest += stride;
1241  }
1242  }
1243  }
1244 
1245 #ifndef WORDS_BIGENDIAN
1246  {
1247  uint8_t *d = data;
1248  int count = stride * height;
1249 
1250  while (count--) {
1251  *d = CAIRO_BITSWAP8 (*d);
1252  d++;
1253  }
1254  }
1255 #endif
1257  break;
1258 
1259  case FT_PIXEL_MODE_LCD:
1260  case FT_PIXEL_MODE_LCD_V:
1261  case FT_PIXEL_MODE_GRAY:
1262  if (font_options->antialias != CAIRO_ANTIALIAS_SUBPIXEL ||
1263  bitmap->pixel_mode == FT_PIXEL_MODE_GRAY)
1264  {
1265  stride = bitmap->pitch;
1266 
1267  /* We don't support stride not multiple of 4. */
1268  if (stride & 3)
1269  {
1270  assert (!own_buffer);
1271  goto convert;
1272  }
1273 
1274  if (own_buffer) {
1275  data = bitmap->buffer;
1276  } else {
1278  if (!data)
1280 
1281  memcpy (data, bitmap->buffer, stride * height);
1282  }
1283 
1285  } else {
1286  data = bitmap->buffer;
1287  stride = bitmap->pitch;
1289  component_alpha = TRUE;
1290  }
1291  break;
1292  case FT_PIXEL_MODE_BGRA:
1293  stride = width * 4;
1294  if (own_buffer) {
1295  data = bitmap->buffer;
1296  } else {
1298  if (!data)
1300 
1301  memcpy (data, bitmap->buffer, stride * height);
1302  }
1303 
1304  if (!_cairo_is_little_endian ())
1305  {
1306  /* Byteswap. */
1307  unsigned int i, count = height * width;
1308  uint32_t *p = (uint32_t *) data;
1309  for (i = 0; i < count; i++)
1310  p[i] = be32_to_cpu (p[i]);
1311  }
1313  break;
1314  case FT_PIXEL_MODE_GRAY2:
1315  case FT_PIXEL_MODE_GRAY4:
1316  convert:
1317  if (!own_buffer && library)
1318  {
1319  /* This is pretty much the only case that we can get in here. */
1320  /* Convert to 8bit grayscale. */
1321 
1322  FT_Bitmap tmp;
1323  FT_Int align;
1324  FT_Error error;
1325 
1327 
1329 
1330  FT_Bitmap_New( &tmp );
1331 
1333  if (error)
1335 
1337  *bitmap = tmp;
1338 
1339  stride = bitmap->pitch;
1341  if (!data)
1343 
1344  if (bitmap->num_grays != 256)
1345  {
1346  unsigned int x, y;
1347  unsigned int mul = 255 / (bitmap->num_grays - 1);
1348  FT_Byte *p = bitmap->buffer;
1349  for (y = 0; y < height; y++) {
1350  for (x = 0; x < width; x++)
1351  p[x] *= mul;
1352  p += bitmap->pitch;
1353  }
1354  }
1355 
1356  memcpy (data, bitmap->buffer, stride * height);
1357  break;
1358  }
1359  /* These could be triggered by very rare types of TrueType fonts */
1360  default:
1361  if (own_buffer)
1362  free (bitmap->buffer);
1364  }
1365 
1366  /* XXX */
1369  format,
1370  width, height, stride);
1371  if (image->base.status) {
1372  free (data);
1373  return (*surface)->base.status;
1374  }
1375 
1376  if (component_alpha)
1377  pixman_image_set_component_alpha (image->pixman_image, TRUE);
1378 
1380 
1382 
1383  return CAIRO_STATUS_SUCCESS;
1384 }
1385 
1386 /* Converts an outline FT_GlyphSlot into an image
1387  *
1388  * This could go through _render_glyph_bitmap as well, letting
1389  * FreeType convert the outline to a bitmap, but doing it ourselves
1390  * has two minor advantages: first, we save a copy of the bitmap
1391  * buffer: we can directly use the buffer that FreeType renders
1392  * into.
1393  *
1394  * Second, it may help when we add support for subpixel
1395  * rendering: the Xft code does it this way. (Keith thinks that
1396  * it may also be possible to get the subpixel rendering with
1397  * FT_Render_Glyph: something worth looking into in more detail
1398  * when we add subpixel support. If so, we may want to eliminate
1399  * this version of the code path entirely.
1400  */
1401 static cairo_status_t
1403  cairo_font_options_t *font_options,
1405 {
1406  int rgba = FC_RGBA_UNKNOWN;
1407  int lcd_filter = FT_LCD_FILTER_LEGACY;
1408  FT_GlyphSlot glyphslot = face->glyph;
1409  FT_Outline *outline = &glyphslot->outline;
1410  FT_Bitmap bitmap;
1411  FT_BBox cbox;
1412  unsigned int width, height;
1414  FT_Error error;
1415  FT_Library library = glyphslot->library;
1416  FT_Render_Mode render_mode = FT_RENDER_MODE_NORMAL;
1417 
1418  switch (font_options->antialias) {
1419  case CAIRO_ANTIALIAS_NONE:
1420  render_mode = FT_RENDER_MODE_MONO;
1421  break;
1422 
1424  case CAIRO_ANTIALIAS_BEST:
1425  switch (font_options->subpixel_order) {
1429  render_mode = FT_RENDER_MODE_LCD;
1430  break;
1431 
1434  render_mode = FT_RENDER_MODE_LCD_V;
1435  break;
1436  }
1437 
1438  switch (font_options->lcd_filter) {
1439  case CAIRO_LCD_FILTER_NONE:
1440  lcd_filter = FT_LCD_FILTER_NONE;
1441  break;
1444  lcd_filter = FT_LCD_FILTER_LEGACY;
1445  break;
1446  case CAIRO_LCD_FILTER_FIR3:
1447  lcd_filter = FT_LCD_FILTER_LIGHT;
1448  break;
1449  case CAIRO_LCD_FILTER_FIR5:
1450  lcd_filter = FT_LCD_FILTER_DEFAULT;
1451  break;
1452  }
1453 
1454  break;
1455 
1457  case CAIRO_ANTIALIAS_GRAY:
1458  case CAIRO_ANTIALIAS_GOOD:
1459  case CAIRO_ANTIALIAS_FAST:
1460  render_mode = FT_RENDER_MODE_NORMAL;
1461  }
1462 
1463  FT_Outline_Get_CBox (outline, &cbox);
1464 
1465  cbox.xMin &= -64;
1466  cbox.yMin &= -64;
1467  cbox.xMax = (cbox.xMax + 63) & -64;
1468  cbox.yMax = (cbox.yMax + 63) & -64;
1469 
1470  width = (unsigned int) ((cbox.xMax - cbox.xMin) >> 6);
1471  height = (unsigned int) ((cbox.yMax - cbox.yMin) >> 6);
1472 
1473  if (width * height == 0) {
1475  /* Looks like fb handles zero-sized images just fine */
1476  switch (render_mode) {
1477  case FT_RENDER_MODE_MONO:
1479  break;
1480  case FT_RENDER_MODE_LCD:
1481  case FT_RENDER_MODE_LCD_V:
1483  break;
1484  case FT_RENDER_MODE_LIGHT:
1485  case FT_RENDER_MODE_NORMAL:
1486  case FT_RENDER_MODE_MAX:
1487  default:
1489  break;
1490  }
1491 
1492  (*surface) = (cairo_image_surface_t *)
1494  pixman_image_set_component_alpha ((*surface)->pixman_image, TRUE);
1495  if ((*surface)->base.status)
1496  return (*surface)->base.status;
1497  } else {
1498 
1499  int bitmap_size;
1500 
1501  switch (render_mode) {
1502  case FT_RENDER_MODE_LCD:
1503  if (font_options->subpixel_order == CAIRO_SUBPIXEL_ORDER_BGR)
1504  rgba = FC_RGBA_BGR;
1505  else
1506  rgba = FC_RGBA_RGB;
1507  break;
1508 
1509  case FT_RENDER_MODE_LCD_V:
1510  if (font_options->subpixel_order == CAIRO_SUBPIXEL_ORDER_VBGR)
1511  rgba = FC_RGBA_VBGR;
1512  else
1513  rgba = FC_RGBA_VRGB;
1514  break;
1515 
1516  case FT_RENDER_MODE_MONO:
1517  case FT_RENDER_MODE_LIGHT:
1518  case FT_RENDER_MODE_NORMAL:
1519  case FT_RENDER_MODE_MAX:
1520  default:
1521  break;
1522  }
1523 
1524 #if HAVE_FT_LIBRARY_SETLCDFILTER
1525  FT_Library_SetLcdFilter (library, lcd_filter);
1526 #endif
1527 
1528  error = FT_Render_Glyph (face->glyph, render_mode);
1529 
1530 #if HAVE_FT_LIBRARY_SETLCDFILTER
1532 #endif
1533 
1534  if (error)
1536 
1537  bitmap_size = _compute_xrender_bitmap_size (&bitmap,
1538  face->glyph,
1539  render_mode);
1540  if (bitmap_size < 0)
1542 
1543  bitmap.buffer = calloc (1, bitmap_size);
1544  if (bitmap.buffer == NULL)
1546 
1547  _fill_xrender_bitmap (&bitmap, face->glyph, render_mode,
1548  (rgba == FC_RGBA_BGR || rgba == FC_RGBA_VBGR));
1549 
1550  /* Note:
1551  * _get_bitmap_surface will free bitmap.buffer if there is an error
1552  */
1553  status = _get_bitmap_surface (&bitmap, NULL, TRUE, font_options, surface);
1554  if (unlikely (status))
1555  return status;
1556 
1557  /* Note: the font's coordinate system is upside down from ours, so the
1558  * Y coordinate of the control box needs to be negated. Moreover, device
1559  * offsets are position of glyph origin relative to top left while xMin
1560  * and yMax are offsets of top left relative to origin. Another negation.
1561  */
1562  cairo_surface_set_device_offset (&(*surface)->base,
1563  (double)-glyphslot->bitmap_left,
1564  (double)+glyphslot->bitmap_top);
1565  }
1566 
1567  return CAIRO_STATUS_SUCCESS;
1568 }
1569 
1570 /* Converts a bitmap (or other) FT_GlyphSlot into an image */
1571 static cairo_status_t
1573  cairo_font_options_t *font_options,
1575 {
1576  FT_GlyphSlot glyphslot = face->glyph;
1578  FT_Error error;
1579 
1580  /* According to the FreeType docs, glyphslot->format could be
1581  * something other than FT_GLYPH_FORMAT_OUTLINE or
1582  * FT_GLYPH_FORMAT_BITMAP. Calling FT_Render_Glyph gives FreeType
1583  * the opportunity to convert such to
1584  * bitmap. FT_GLYPH_FORMAT_COMPOSITE will not be encountered since
1585  * we avoid the FT_LOAD_NO_RECURSE flag.
1586  */
1588  /* XXX ignoring all other errors for now. They are not fatal, typically
1589  * just a glyph-not-found. */
1590  if (error == FT_Err_Out_Of_Memory)
1592 
1593  status = _get_bitmap_surface (&glyphslot->bitmap,
1594  glyphslot->library,
1595  FALSE, font_options,
1596  surface);
1597  if (unlikely (status))
1598  return status;
1599 
1600  /*
1601  * Note: the font's coordinate system is upside down from ours, so the
1602  * Y coordinate of the control box needs to be negated. Moreover, device
1603  * offsets are position of glyph origin relative to top left while
1604  * bitmap_left and bitmap_top are offsets of top left relative to origin.
1605  * Another negation.
1606  */
1607  cairo_surface_set_device_offset (&(*surface)->base,
1608  -glyphslot->bitmap_left,
1609  +glyphslot->bitmap_top);
1610 
1611  return CAIRO_STATUS_SUCCESS;
1612 }
1613 
1614 static cairo_status_t
1617 {
1618  cairo_matrix_t original_to_transformed;
1619  cairo_matrix_t transformed_to_original;
1620  cairo_image_surface_t *old_image;
1622  double x[4], y[4];
1623  double origin_x, origin_y;
1624  int orig_width, orig_height;
1625  int i;
1626  int x_min, y_min, x_max, y_max;
1627  int width, height;
1630 
1631  /* We want to compute a transform that takes the origin
1632  * (device_x_offset, device_y_offset) to 0,0, then applies
1633  * the "shape" portion of the font transform
1634  */
1635  original_to_transformed = *shape;
1636 
1637  cairo_surface_get_device_offset (&(*surface)->base, &origin_x, &origin_y);
1638  orig_width = (*surface)->width;
1639  orig_height = (*surface)->height;
1640 
1641  cairo_matrix_translate (&original_to_transformed,
1642  -origin_x, -origin_y);
1643 
1644  /* Find the bounding box of the original bitmap under that
1645  * transform
1646  */
1647  x[0] = 0; y[0] = 0;
1648  x[1] = orig_width; y[1] = 0;
1649  x[2] = orig_width; y[2] = orig_height;
1650  x[3] = 0; y[3] = orig_height;
1651 
1652  for (i = 0; i < 4; i++)
1653  cairo_matrix_transform_point (&original_to_transformed,
1654  &x[i], &y[i]);
1655 
1656  x_min = floor (x[0]); y_min = floor (y[0]);
1657  x_max = ceil (x[0]); y_max = ceil (y[0]);
1658 
1659  for (i = 1; i < 4; i++) {
1660  if (x[i] < x_min)
1661  x_min = floor (x[i]);
1662  else if (x[i] > x_max)
1663  x_max = ceil (x[i]);
1664  if (y[i] < y_min)
1665  y_min = floor (y[i]);
1666  else if (y[i] > y_max)
1667  y_max = ceil (y[i]);
1668  }
1669 
1670  /* Adjust the transform so that the bounding box starts at 0,0 ...
1671  * this gives our final transform from original bitmap to transformed
1672  * bitmap.
1673  */
1674  original_to_transformed.x0 -= x_min;
1675  original_to_transformed.y0 -= y_min;
1676 
1677  /* Create the transformed bitmap */
1678  width = x_max - x_min;
1679  height = y_max - y_min;
1680 
1681  transformed_to_original = original_to_transformed;
1682  status = cairo_matrix_invert (&transformed_to_original);
1683  if (unlikely (status))
1684  return status;
1685 
1686  if ((*surface)->format == CAIRO_FORMAT_ARGB32 &&
1687  !pixman_image_get_component_alpha ((*surface)->pixman_image))
1689  else
1691  if (unlikely (image->status))
1692  return image->status;
1693 
1694  /* Draw the original bitmap transformed into the new bitmap
1695  */
1696  _cairo_pattern_init_for_surface (&pattern, &(*surface)->base);
1697  cairo_pattern_set_matrix (&pattern.base, &transformed_to_original);
1698 
1701  &pattern.base,
1702  NULL);
1703 
1704  _cairo_pattern_fini (&pattern.base);
1705 
1706  if (unlikely (status)) {
1708  return status;
1709  }
1710 
1711  /* Now update the cache entry for the new bitmap, recomputing
1712  * the origin based on the final transform.
1713  */
1714  cairo_matrix_transform_point (&original_to_transformed,
1715  &origin_x, &origin_y);
1716 
1717  old_image = (*surface);
1718  (*surface) = (cairo_image_surface_t *)image;
1719 
1720  /* Note: we converted subpixel-rendered RGBA images to grayscale,
1721  * so, no need to copy component alpha to new image. */
1722 
1723  cairo_surface_destroy (&old_image->base);
1724 
1725  cairo_surface_set_device_offset (&(*surface)->base,
1726  _cairo_lround (origin_x),
1727  _cairo_lround (origin_y));
1728  return CAIRO_STATUS_SUCCESS;
1729 }
1730 
1733 #if 0
1734  _cairo_ft_unscaled_font_create_glyph
1735 #endif
1736 };
1737 
1738 /* #cairo_ft_scaled_font_t */
1739 
1740 typedef struct _cairo_ft_scaled_font {
1745 
1747 
1748 #if CAIRO_HAS_FC_FONT
1749 /* The load flags passed to FT_Load_Glyph control aspects like hinting and
1750  * antialiasing. Here we compute them from the fields of a FcPattern.
1751  */
1752 static void
1754 {
1755  FcBool antialias, vertical_layout, hinting, autohint, bitmap, embolden;
1756  cairo_ft_options_t ft_options;
1757  int rgba;
1758 #ifdef FC_HINT_STYLE
1759  int hintstyle;
1760 #endif
1761  char *variations;
1762 
1763  _cairo_font_options_init_default (&ft_options.base);
1764  ft_options.load_flags = FT_LOAD_DEFAULT;
1765  ft_options.synth_flags = 0;
1766 
1767 #ifndef FC_EMBEDDED_BITMAP
1768 #define FC_EMBEDDED_BITMAP "embeddedbitmap"
1769 #endif
1770 
1771  /* Check whether to force use of embedded bitmaps */
1774  bitmap = FcFalse;
1775 
1776  /* disable antialiasing if requested */
1779  antialias = FcTrue;
1780 
1781  if (antialias) {
1782  cairo_subpixel_order_t subpixel_order;
1783  int lcd_filter;
1784 
1785  /* disable hinting if requested */
1787  FC_HINTING, 0, &hinting) != FcResultMatch)
1788  hinting = FcTrue;
1789 
1791  FC_RGBA, 0, &rgba) != FcResultMatch)
1792  rgba = FC_RGBA_UNKNOWN;
1793 
1794  switch (rgba) {
1795  case FC_RGBA_RGB:
1796  subpixel_order = CAIRO_SUBPIXEL_ORDER_RGB;
1797  break;
1798  case FC_RGBA_BGR:
1799  subpixel_order = CAIRO_SUBPIXEL_ORDER_BGR;
1800  break;
1801  case FC_RGBA_VRGB:
1802  subpixel_order = CAIRO_SUBPIXEL_ORDER_VRGB;
1803  break;
1804  case FC_RGBA_VBGR:
1805  subpixel_order = CAIRO_SUBPIXEL_ORDER_VBGR;
1806  break;
1807  case FC_RGBA_UNKNOWN:
1808  case FC_RGBA_NONE:
1809  default:
1810  subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
1811  break;
1812  }
1813 
1814  if (subpixel_order != CAIRO_SUBPIXEL_ORDER_DEFAULT) {
1815  ft_options.base.subpixel_order = subpixel_order;
1817  }
1818 
1820  FC_LCD_FILTER, 0, &lcd_filter) == FcResultMatch)
1821  {
1822  switch (lcd_filter) {
1823  case FC_LCD_NONE:
1824  ft_options.base.lcd_filter = CAIRO_LCD_FILTER_NONE;
1825  break;
1826  case FC_LCD_DEFAULT:
1827  ft_options.base.lcd_filter = CAIRO_LCD_FILTER_FIR5;
1828  break;
1829  case FC_LCD_LIGHT:
1830  ft_options.base.lcd_filter = CAIRO_LCD_FILTER_FIR3;
1831  break;
1832  case FC_LCD_LEGACY:
1834  break;
1835  }
1836  }
1837 
1838 #ifdef FC_HINT_STYLE
1840  FC_HINT_STYLE, 0, &hintstyle) != FcResultMatch)
1841  hintstyle = FC_HINT_FULL;
1842 
1843  if (!hinting)
1844  hintstyle = FC_HINT_NONE;
1845 
1846  switch (hintstyle) {
1847  case FC_HINT_NONE:
1848  ft_options.base.hint_style = CAIRO_HINT_STYLE_NONE;
1849  break;
1850  case FC_HINT_SLIGHT:
1852  break;
1853  case FC_HINT_MEDIUM:
1854  default:
1856  break;
1857  case FC_HINT_FULL:
1858  ft_options.base.hint_style = CAIRO_HINT_STYLE_FULL;
1859  break;
1860  }
1861 #else /* !FC_HINT_STYLE */
1862  if (!hinting) {
1863  ft_options.base.hint_style = CAIRO_HINT_STYLE_NONE;
1864  }
1865 #endif /* FC_HINT_STYLE */
1866 
1867  /* Force embedded bitmaps off if no hinting requested */
1868  if (ft_options.base.hint_style == CAIRO_HINT_STYLE_NONE)
1869  bitmap = FcFalse;
1870 
1871  if (!bitmap)
1872  ft_options.load_flags |= FT_LOAD_NO_BITMAP;
1873 
1874  } else {
1875  ft_options.base.antialias = CAIRO_ANTIALIAS_NONE;
1876  }
1877 
1878  /* force autohinting if requested */
1880  FC_AUTOHINT, 0, &autohint) != FcResultMatch)
1881  autohint = FcFalse;
1882 
1883  if (autohint)
1884  ft_options.load_flags |= FT_LOAD_FORCE_AUTOHINT;
1885 
1887  FC_VERTICAL_LAYOUT, 0, &vertical_layout) != FcResultMatch)
1888  vertical_layout = FcFalse;
1889 
1890  if (vertical_layout)
1891  ft_options.load_flags |= FT_LOAD_VERTICAL_LAYOUT;
1892 
1893 #ifndef FC_EMBOLDEN
1894 #define FC_EMBOLDEN "embolden"
1895 #endif
1897  FC_EMBOLDEN, 0, &embolden) != FcResultMatch)
1898  embolden = FcFalse;
1899 
1900  if (embolden)
1901  ft_options.synth_flags |= CAIRO_FT_SYNTHESIZE_BOLD;
1902 
1903 #ifndef FC_FONT_VARIATIONS
1904 #define FC_FONT_VARIATIONS "fontvariations"
1905 #endif
1907  ft_options.base.variations = strdup (variations);
1908  }
1909 
1910  *ret = ft_options;
1911 }
1912 #endif
1913 
1914 static void
1917 {
1918  int load_flags = other->load_flags;
1919  int load_target = FT_LOAD_TARGET_NORMAL;
1920 
1921  /* clear load target mode */
1922  load_flags &= ~(FT_LOAD_TARGET_(FT_LOAD_TARGET_MODE(other->load_flags)));
1923 
1924  if (load_flags & FT_LOAD_NO_HINTING)
1925  other->base.hint_style = CAIRO_HINT_STYLE_NONE;
1926 
1927  if (other->base.antialias == CAIRO_ANTIALIAS_NONE ||
1928  options->base.antialias == CAIRO_ANTIALIAS_NONE) {
1929  options->base.antialias = CAIRO_ANTIALIAS_NONE;
1930  options->base.subpixel_order = CAIRO_SUBPIXEL_ORDER_DEFAULT;
1931  }
1932 
1933  if (other->base.antialias == CAIRO_ANTIALIAS_SUBPIXEL &&
1934  (options->base.antialias == CAIRO_ANTIALIAS_DEFAULT ||
1935  options->base.antialias == CAIRO_ANTIALIAS_GRAY)) {
1936  options->base.antialias = CAIRO_ANTIALIAS_SUBPIXEL;
1937  options->base.subpixel_order = other->base.subpixel_order;
1938  }
1939 
1940  if (options->base.hint_style == CAIRO_HINT_STYLE_DEFAULT)
1941  options->base.hint_style = other->base.hint_style;
1942 
1943  if (other->base.hint_style == CAIRO_HINT_STYLE_NONE)
1944  options->base.hint_style = CAIRO_HINT_STYLE_NONE;
1945 
1946  if (options->base.lcd_filter == CAIRO_LCD_FILTER_DEFAULT)
1947  options->base.lcd_filter = other->base.lcd_filter;
1948 
1949  if (other->base.lcd_filter == CAIRO_LCD_FILTER_NONE)
1950  options->base.lcd_filter = CAIRO_LCD_FILTER_NONE;
1951 
1952  if (options->base.antialias == CAIRO_ANTIALIAS_NONE) {
1953  if (options->base.hint_style == CAIRO_HINT_STYLE_NONE)
1954  load_flags |= FT_LOAD_NO_HINTING;
1955  else
1956  load_target = FT_LOAD_TARGET_MONO;
1957  load_flags |= FT_LOAD_MONOCHROME;
1958  } else {
1959  switch (options->base.hint_style) {
1960  case CAIRO_HINT_STYLE_NONE:
1961  load_flags |= FT_LOAD_NO_HINTING;
1962  break;
1964  load_target = FT_LOAD_TARGET_LIGHT;
1965  break;
1967  break;
1968  case CAIRO_HINT_STYLE_FULL:
1970  if (options->base.antialias == CAIRO_ANTIALIAS_SUBPIXEL) {
1971  switch (options->base.subpixel_order) {
1975  load_target = FT_LOAD_TARGET_LCD;
1976  break;
1979  load_target = FT_LOAD_TARGET_LCD_V;
1980  break;
1981  }
1982  }
1983  break;
1984  }
1985  }
1986 
1987  if (other->base.variations) {
1988  if (options->base.variations) {
1989  char *p;
1990 
1991  /* 'merge' variations by concatenating - later entries win */
1992  p = malloc (strlen (other->base.variations) + strlen (options->base.variations) + 2);
1993  p[0] = 0;
1994  strcat (p, other->base.variations);
1995  strcat (p, ",");
1996  strcat (p, options->base.variations);
1997  free (options->base.variations);
1998  options->base.variations = p;
1999  }
2000  else {
2001  options->base.variations = strdup (other->base.variations);
2002  }
2003  }
2004 
2005  options->load_flags = load_flags | load_target;
2006  options->synth_flags = other->synth_flags;
2007 }
2008 
2009 static cairo_status_t
2010 _cairo_ft_font_face_scaled_font_create (void *abstract_font_face,
2011  const cairo_matrix_t *font_matrix,
2012  const cairo_matrix_t *ctm,
2014  cairo_scaled_font_t **font_out)
2015 {
2016  cairo_ft_font_face_t *font_face = abstract_font_face;
2017  cairo_ft_scaled_font_t *scaled_font;
2018  FT_Face face;
2020  cairo_font_extents_t fs_metrics;
2023 
2024  assert (font_face->unscaled);
2025 
2027  if (unlikely (face == NULL)) /* backend error */
2029 
2030  scaled_font = _cairo_malloc (sizeof (cairo_ft_scaled_font_t));
2031  if (unlikely (scaled_font == NULL)) {
2033  goto FAIL;
2034  }
2035 
2036  scaled_font->unscaled = unscaled = font_face->unscaled;
2038 
2040  _cairo_ft_options_merge (&scaled_font->ft_options, &font_face->ft_options);
2041 
2042  status = _cairo_scaled_font_init (&scaled_font->base,
2043  &font_face->base,
2044  font_matrix, ctm, options,
2046  if (unlikely (status))
2047  goto CLEANUP_SCALED_FONT;
2048 
2050  &scaled_font->base.scale);
2051  if (unlikely (status)) {
2052  /* This can only fail if we encounter an error with the underlying
2053  * font, so propagate the error back to the font-face. */
2056  free (scaled_font);
2057  return status;
2058  }
2059 
2060 
2061  metrics = &face->size->metrics;
2062 
2063  /*
2064  * Get to unscaled metrics so that the upper level can get back to
2065  * user space
2066  *
2067  * Also use this path for bitmap-only fonts. The other branch uses
2068  * face members that are only relevant for scalable fonts. This is
2069  * detected by simply checking for units_per_EM==0.
2070  */
2071  if (scaled_font->base.options.hint_metrics != CAIRO_HINT_METRICS_OFF ||
2072  face->units_per_EM == 0) {
2073  double x_factor, y_factor;
2074 
2075  if (unscaled->x_scale == 0)
2076  x_factor = 0;
2077  else
2078  x_factor = 1 / unscaled->x_scale;
2079 
2080  if (unscaled->y_scale == 0)
2081  y_factor = 0;
2082  else
2083  y_factor = 1 / unscaled->y_scale;
2084 
2085  fs_metrics.ascent = DOUBLE_FROM_26_6(metrics->ascender) * y_factor;
2086  fs_metrics.descent = DOUBLE_FROM_26_6(- metrics->descender) * y_factor;
2087  fs_metrics.height = DOUBLE_FROM_26_6(metrics->height) * y_factor;
2088  if (!_cairo_ft_scaled_font_is_vertical (&scaled_font->base)) {
2089  fs_metrics.max_x_advance = DOUBLE_FROM_26_6(metrics->max_advance) * x_factor;
2090  fs_metrics.max_y_advance = 0;
2091  } else {
2092  fs_metrics.max_x_advance = 0;
2093  fs_metrics.max_y_advance = DOUBLE_FROM_26_6(metrics->max_advance) * y_factor;
2094  }
2095  } else {
2096  double scale = face->units_per_EM;
2097 
2098  fs_metrics.ascent = face->ascender / scale;
2099  fs_metrics.descent = - face->descender / scale;
2100  fs_metrics.height = face->height / scale;
2101  if (!_cairo_ft_scaled_font_is_vertical (&scaled_font->base)) {
2102  fs_metrics.max_x_advance = face->max_advance_width / scale;
2103  fs_metrics.max_y_advance = 0;
2104  } else {
2105  fs_metrics.max_x_advance = 0;
2106  fs_metrics.max_y_advance = face->max_advance_height / scale;
2107  }
2108  }
2109 
2110  status = _cairo_scaled_font_set_metrics (&scaled_font->base, &fs_metrics);
2111  if (unlikely (status))
2112  goto CLEANUP_SCALED_FONT;
2113 
2115 
2116  *font_out = &scaled_font->base;
2117  return CAIRO_STATUS_SUCCESS;
2118 
2119  CLEANUP_SCALED_FONT:
2121  free (scaled_font);
2122  FAIL:
2125  return CAIRO_STATUS_SUCCESS; /* non-backend error */
2126 }
2127 
2130 {
2131  return scaled_font->backend == &_cairo_ft_scaled_font_backend;
2132 }
2133 
2134 static void
2135 _cairo_ft_scaled_font_fini (void *abstract_font)
2136 {
2137  cairo_ft_scaled_font_t *scaled_font = abstract_font;
2138 
2139  if (scaled_font == NULL)
2140  return;
2141 
2142  _cairo_unscaled_font_destroy (&scaled_font->unscaled->base);
2143 }
2144 
2145 static int
2147 {
2149  cairo_fixed_t x, y;
2150 
2151  x = _cairo_fixed_from_26_6 (to->x);
2152  y = _cairo_fixed_from_26_6 (to->y);
2153 
2155  return 1;
2157  return 1;
2158 
2159  return 0;
2160 }
2161 
2162 static int
2164 {
2166  cairo_fixed_t x, y;
2167 
2168  x = _cairo_fixed_from_26_6 (to->x);
2169  y = _cairo_fixed_from_26_6 (to->y);
2170 
2172  return 1;
2173 
2174  return 0;
2175 }
2176 
2177 static int
2179 {
2181 
2182  cairo_fixed_t x0, y0;
2183  cairo_fixed_t x1, y1;
2184  cairo_fixed_t x2, y2;
2185  cairo_fixed_t x3, y3;
2186  cairo_point_t conic;
2187 
2189  return 1;
2190 
2191  conic.x = _cairo_fixed_from_26_6 (control->x);
2192  conic.y = _cairo_fixed_from_26_6 (control->y);
2193 
2194  x3 = _cairo_fixed_from_26_6 (to->x);
2195  y3 = _cairo_fixed_from_26_6 (to->y);
2196 
2197  x1 = x0 + 2.0/3.0 * (conic.x - x0);
2198  y1 = y0 + 2.0/3.0 * (conic.y - y0);
2199 
2200  x2 = x3 + 2.0/3.0 * (conic.x - x3);
2201  y2 = y3 + 2.0/3.0 * (conic.y - y3);
2202 
2204  x1, y1,
2205  x2, y2,
2206  x3, y3) != CAIRO_STATUS_SUCCESS)
2207  return 1;
2208 
2209  return 0;
2210 }
2211 
2212 static int
2213 _cubic_to (FT_Vector *control1, FT_Vector *control2,
2214  FT_Vector *to, void *closure)
2215 {
2217  cairo_fixed_t x0, y0;
2218  cairo_fixed_t x1, y1;
2219  cairo_fixed_t x2, y2;
2220 
2221  x0 = _cairo_fixed_from_26_6 (control1->x);
2222  y0 = _cairo_fixed_from_26_6 (control1->y);
2223 
2224  x1 = _cairo_fixed_from_26_6 (control2->x);
2225  y1 = _cairo_fixed_from_26_6 (control2->y);
2226 
2227  x2 = _cairo_fixed_from_26_6 (to->x);
2228  y2 = _cairo_fixed_from_26_6 (to->y);
2229 
2231  x0, y0,
2232  x1, y1,
2233  x2, y2) != CAIRO_STATUS_SUCCESS)
2234  return 1;
2235 
2236  return 0;
2237 }
2238 
2239 static cairo_status_t
2242  cairo_path_fixed_t **pathp)
2243 {
2244  static const FT_Outline_Funcs outline_funcs = {
2249  0, /* shift */
2250  0, /* delta */
2251  };
2252  static const FT_Matrix invert_y = {
2253  DOUBLE_TO_16_16 (1.0), 0,
2254  0, DOUBLE_TO_16_16 (-1.0),
2255  };
2256 
2260 
2262  if (!path)
2264 
2265  glyph = face->glyph;
2266 
2267  /* Font glyphs have an inverted Y axis compared to cairo. */
2268  FT_Outline_Transform (&glyph->outline, &invert_y);
2269  if (FT_Outline_Decompose (&glyph->outline, &outline_funcs, path)) {
2272  }
2273 
2275  if (unlikely (status)) {
2277  return status;
2278  }
2279 
2280  *pathp = path;
2281 
2282  return CAIRO_STATUS_SUCCESS;
2283 }
2284 
2285 /*
2286  * Translate glyph to match its metrics.
2287  */
2288 static void
2291 {
2292  cairo_ft_scaled_font_t *scaled_font = abstract_font;
2293  FT_Vector vector;
2294 
2295  vector.x = glyph->metrics.vertBearingX - glyph->metrics.horiBearingX;
2296  vector.y = -glyph->metrics.vertBearingY - glyph->metrics.horiBearingY;
2297 
2298  if (glyph->format == FT_GLYPH_FORMAT_OUTLINE) {
2299  FT_Vector_Transform (&vector, &scaled_font->unscaled->Current_Shape);
2300  FT_Outline_Translate(&glyph->outline, vector.x, vector.y);
2301  } else if (glyph->format == FT_GLYPH_FORMAT_BITMAP) {
2302  glyph->bitmap_left += vector.x / 64;
2303  glyph->bitmap_top += vector.y / 64;
2304  }
2305 }
2306 
2307 static void
2309  cairo_ft_scaled_font_t *scaled_font)
2310 {
2311  FT_MM_Var *ft_mm_var;
2312  FT_Error ret;
2313  unsigned int instance_id = scaled_font->unscaled->id >> 16;
2314 
2315  ret = FT_Get_MM_Var (face, &ft_mm_var);
2316  if (ret == 0) {
2317  FT_Fixed *current_coords;
2318  FT_Fixed *coords;
2319  unsigned int i;
2320  const char *p;
2321 
2322  coords = malloc (sizeof (FT_Fixed) * ft_mm_var->num_axis);
2323  /* FIXME check coords. */
2324 
2325  if (scaled_font->unscaled->variations)
2326  {
2327  memcpy (coords, scaled_font->unscaled->variations, ft_mm_var->num_axis * sizeof (*coords));
2328  }
2329  else if (instance_id && instance_id <= ft_mm_var->num_namedstyles)
2330  {
2331  FT_Var_Named_Style *instance = &ft_mm_var->namedstyle[instance_id - 1];
2332  memcpy (coords, instance->coords, ft_mm_var->num_axis * sizeof (*coords));
2333  }
2334  else
2335  for (i = 0; i < ft_mm_var->num_axis; i++)
2336  coords[i] = ft_mm_var->axis[i].def;
2337 
2338  p = scaled_font->ft_options.base.variations;
2339  while (p && *p) {
2340  const char *start;
2341  const char *end, *end2;
2342  FT_ULong tag;
2343  double value;
2344 
2345  while (_cairo_isspace (*p)) p++;
2346 
2347  start = p;
2348  end = strchr (p, ',');
2349  if (end && (end - p < 6))
2350  goto skip;
2351 
2352  tag = FT_MAKE_TAG(p[0], p[1], p[2], p[3]);
2353 
2354  p += 4;
2355  while (_cairo_isspace (*p)) p++;
2356  if (*p == '=') p++;
2357 
2358  if (p - start < 5)
2359  goto skip;
2360 
2361  value = _cairo_strtod (p, (char **) &end2);
2362 
2363  while (end2 && _cairo_isspace (*end2)) end2++;
2364 
2365  if (end2 && (*end2 != ',' && *end2 != '\0'))
2366  goto skip;
2367 
2368  for (i = 0; i < ft_mm_var->num_axis; i++) {
2369  if (ft_mm_var->axis[i].tag == tag) {
2370  coords[i] = (FT_Fixed)(value*65536);
2371  break;
2372  }
2373  }
2374 
2375 skip:
2376  p = end ? end + 1 : NULL;
2377  }
2378 
2379  current_coords = malloc (sizeof (FT_Fixed) * ft_mm_var->num_axis);
2380 #ifdef HAVE_FT_GET_VAR_DESIGN_COORDINATES
2381  ret = FT_Get_Var_Design_Coordinates (face, ft_mm_var->num_axis, current_coords);
2382  if (ret == 0) {
2383  for (i = 0; i < ft_mm_var->num_axis; i++) {
2384  if (coords[i] != current_coords[i])
2385  break;
2386  }
2387  if (i == ft_mm_var->num_axis)
2388  goto done;
2389  }
2390 #endif
2391 
2393 done:
2394  free (coords);
2395  free (current_coords);
2396  free (ft_mm_var);
2397  }
2398 }
2399 
2400 static cairo_int_status_t
2402  cairo_scaled_glyph_t *scaled_glyph,
2403  FT_Face face,
2404  int load_flags,
2405  cairo_bool_t use_em_size,
2406  cairo_bool_t vertical_layout)
2407 {
2408  FT_Error error;
2410 
2411  if (use_em_size) {
2412  cairo_matrix_t em_size;
2414  status = _cairo_ft_unscaled_font_set_scale (scaled_font->unscaled, &em_size);
2415  } else {
2417  &scaled_font->base.scale);
2418  }
2419  if (unlikely (status))
2420  return status;
2421 
2422  cairo_ft_apply_variations (face, scaled_font);
2423 
2425  _cairo_scaled_glyph_index(scaled_glyph),
2426  load_flags);
2427  /* XXX ignoring all other errors for now. They are not fatal, typically
2428  * just a glyph-not-found. */
2429  if (error == FT_Err_Out_Of_Memory)
2431 
2432  /*
2433  * synthesize glyphs if requested
2434  */
2435 #if HAVE_FT_GLYPHSLOT_EMBOLDEN
2436  if (scaled_font->ft_options.synth_flags & CAIRO_FT_SYNTHESIZE_BOLD)
2438 #endif
2439 
2440 #if HAVE_FT_GLYPHSLOT_OBLIQUE
2443 #endif
2444 
2445  if (vertical_layout)
2447 
2448  return CAIRO_STATUS_SUCCESS;
2449 }
2450 
2451 static cairo_int_status_t
2452 _cairo_ft_scaled_glyph_init (void *abstract_font,
2453  cairo_scaled_glyph_t *scaled_glyph,
2455 {
2456  cairo_text_extents_t fs_metrics;
2457  cairo_ft_scaled_font_t *scaled_font = abstract_font;
2458  cairo_ft_unscaled_font_t *unscaled = scaled_font->unscaled;
2460  FT_Face face;
2461  int load_flags = scaled_font->ft_options.load_flags;
2463  double x_factor, y_factor;
2464  cairo_bool_t vertical_layout = FALSE;
2466  cairo_bool_t scaled_glyph_loaded = FALSE;
2467 
2469  if (!face)
2471 
2472  /* Ignore global advance unconditionally */
2474 
2475  if ((info & CAIRO_SCALED_GLYPH_INFO_PATH) != 0 &&
2478  load_flags |= FT_LOAD_NO_BITMAP;
2479  }
2480 
2481  /*
2482  * Don't pass FT_LOAD_VERTICAL_LAYOUT to FT_Load_Glyph here as
2483  * suggested by freetype people.
2484  */
2485  if (load_flags & FT_LOAD_VERTICAL_LAYOUT) {
2486  load_flags &= ~~FT_LOAD_VERTICAL_LAYOUT;
2487  vertical_layout = TRUE;
2488  }
2489 
2490  load_flags |= FT_LOAD_COLOR;
2491 
2492 
2494 
2495  cairo_bool_t hint_metrics = scaled_font->base.options.hint_metrics != CAIRO_HINT_METRICS_OFF;
2496 
2498  scaled_glyph,
2499  face,
2500  load_flags,
2501  !hint_metrics,
2502  vertical_layout);
2503  if (unlikely (status))
2504  goto FAIL;
2505 
2506  glyph = face->glyph;
2507  scaled_glyph_loaded = hint_metrics;
2508 
2509  /*
2510  * Compute font-space metrics
2511  */
2512  metrics = &glyph->metrics;
2513 
2514  if (unscaled->x_scale == 0)
2515  x_factor = 0;
2516  else
2517  x_factor = 1 / unscaled->x_scale;
2518 
2519  if (unscaled->y_scale == 0)
2520  y_factor = 0;
2521  else
2522  y_factor = 1 / unscaled->y_scale;
2523 
2524  /*
2525  * Note: Y coordinates of the horizontal bearing need to be negated.
2526  *
2527  * Scale metrics back to glyph space from the scaled glyph space returned
2528  * by FreeType
2529  *
2530  * If we want hinted metrics but aren't asking for hinted glyphs from
2531  * FreeType, then we need to do the metric hinting ourselves.
2532  */
2533 
2534  if (hint_metrics && (load_flags & FT_LOAD_NO_HINTING))
2535  {
2536  FT_Pos x1, x2;
2537  FT_Pos y1, y2;
2538  FT_Pos advance;
2539 
2540  if (!vertical_layout) {
2541  x1 = (metrics->horiBearingX) & -64;
2542  x2 = (metrics->horiBearingX + metrics->width + 63) & -64;
2543  y1 = (-metrics->horiBearingY) & -64;
2544  y2 = (-metrics->horiBearingY + metrics->height + 63) & -64;
2545 
2546  advance = ((metrics->horiAdvance + 32) & -64);
2547 
2548  fs_metrics.x_bearing = DOUBLE_FROM_26_6 (x1) * x_factor;
2549  fs_metrics.y_bearing = DOUBLE_FROM_26_6 (y1) * y_factor;
2550 
2551  fs_metrics.width = DOUBLE_FROM_26_6 (x2 - x1) * x_factor;
2552  fs_metrics.height = DOUBLE_FROM_26_6 (y2 - y1) * y_factor;
2553 
2554  fs_metrics.x_advance = DOUBLE_FROM_26_6 (advance) * x_factor;
2555  fs_metrics.y_advance = 0;
2556  } else {
2557  x1 = (metrics->vertBearingX) & -64;
2558  x2 = (metrics->vertBearingX + metrics->width + 63) & -64;
2559  y1 = (metrics->vertBearingY) & -64;
2560  y2 = (metrics->vertBearingY + metrics->height + 63) & -64;
2561 
2562  advance = ((metrics->vertAdvance + 32) & -64);
2563 
2564  fs_metrics.x_bearing = DOUBLE_FROM_26_6 (x1) * x_factor;
2565  fs_metrics.y_bearing = DOUBLE_FROM_26_6 (y1) * y_factor;
2566 
2567  fs_metrics.width = DOUBLE_FROM_26_6 (x2 - x1) * x_factor;
2568  fs_metrics.height = DOUBLE_FROM_26_6 (y2 - y1) * y_factor;
2569 
2570  fs_metrics.x_advance = 0;
2571  fs_metrics.y_advance = DOUBLE_FROM_26_6 (advance) * y_factor;
2572  }
2573  } else {
2574  fs_metrics.width = DOUBLE_FROM_26_6 (metrics->width) * x_factor;
2575  fs_metrics.height = DOUBLE_FROM_26_6 (metrics->height) * y_factor;
2576 
2577  if (!vertical_layout) {
2578  fs_metrics.x_bearing = DOUBLE_FROM_26_6 (metrics->horiBearingX) * x_factor;
2579  fs_metrics.y_bearing = DOUBLE_FROM_26_6 (-metrics->horiBearingY) * y_factor;
2580 
2581  if (hint_metrics || glyph->format != FT_GLYPH_FORMAT_OUTLINE)
2582  fs_metrics.x_advance = DOUBLE_FROM_26_6 (metrics->horiAdvance) * x_factor;
2583  else
2584  fs_metrics.x_advance = DOUBLE_FROM_16_16 (glyph->linearHoriAdvance) * x_factor;
2585  fs_metrics.y_advance = 0 * y_factor;
2586  } else {
2587  fs_metrics.x_bearing = DOUBLE_FROM_26_6 (metrics->vertBearingX) * x_factor;
2588  fs_metrics.y_bearing = DOUBLE_FROM_26_6 (metrics->vertBearingY) * y_factor;
2589 
2590  fs_metrics.x_advance = 0 * x_factor;
2591  if (hint_metrics || glyph->format != FT_GLYPH_FORMAT_OUTLINE)
2592  fs_metrics.y_advance = DOUBLE_FROM_26_6 (metrics->vertAdvance) * y_factor;
2593  else
2594  fs_metrics.y_advance = DOUBLE_FROM_16_16 (glyph->linearVertAdvance) * y_factor;
2595  }
2596  }
2597 
2598  _cairo_scaled_glyph_set_metrics (scaled_glyph,
2599  &scaled_font->base,
2600  &fs_metrics);
2601  }
2602 
2603 LOAD:
2606 
2607  if (!scaled_glyph_loaded) {
2609  scaled_glyph,
2610  face,
2611  load_flags,
2612  FALSE,
2613  vertical_layout);
2614  if (unlikely (status))
2615  goto FAIL;
2616 
2617  glyph = face->glyph;
2618  scaled_glyph_loaded = TRUE;
2619  }
2620 
2621  if (glyph->format == FT_GLYPH_FORMAT_OUTLINE) {
2622  status = _render_glyph_outline (face, &scaled_font->ft_options.base,
2623  &surface);
2624  } else {
2625  status = _render_glyph_bitmap (face, &scaled_font->ft_options.base,
2626  &surface);
2627  if (likely (status == CAIRO_STATUS_SUCCESS) &&
2628  unscaled->have_shape)
2629  {
2630  status = _transform_glyph_bitmap (&unscaled->current_shape,
2631  &surface);
2632  if (unlikely (status))
2633  cairo_surface_destroy (&surface->base);
2634  }
2635  }
2636  if (unlikely (status))
2637  goto FAIL;
2638 
2639  if (pixman_image_get_format (surface->pixman_image) == PIXMAN_a8r8g8b8 &&
2640  !pixman_image_get_component_alpha (surface->pixman_image)) {
2642  &scaled_font->base,
2643  surface);
2644  } else {
2645  _cairo_scaled_glyph_set_surface (scaled_glyph,
2646  &scaled_font->base,
2647  surface);
2648  }
2649  }
2650 
2652  ((scaled_glyph->has_info & CAIRO_SCALED_GLYPH_INFO_SURFACE) == 0)) {
2653  /*
2654  * A kludge -- load again, without color.
2655  * No need to load the metrics again, though
2656  */
2657  scaled_glyph_loaded = FALSE;
2658  info &= ~~CAIRO_SCALED_GLYPH_INFO_METRICS;
2659  load_flags &= ~~FT_LOAD_COLOR;
2660  goto LOAD;
2661  }
2662 
2664  cairo_path_fixed_t *path = NULL; /* hide compiler warning */
2665 
2666  /*
2667  * A kludge -- the above code will trash the outline,
2668  * so reload it. This will probably never occur though
2669  */
2671  scaled_glyph_loaded = FALSE;
2672  load_flags |= FT_LOAD_NO_BITMAP;
2673  }
2674 
2675  if (!scaled_glyph_loaded) {
2677  scaled_glyph,
2678  face,
2679  load_flags,
2680  FALSE,
2681  vertical_layout);
2682  if (unlikely (status))
2683  goto FAIL;
2684 
2685  glyph = face->glyph;
2686  }
2687 
2688  if (glyph->format == FT_GLYPH_FORMAT_OUTLINE)
2690  &path);
2691  else
2693 
2694  if (unlikely (status))
2695  goto FAIL;
2696 
2697  _cairo_scaled_glyph_set_path (scaled_glyph,
2698  &scaled_font->base,
2699  path);
2700  }
2701  FAIL:
2703 
2704  return status;
2705 }
2706 
2707 static unsigned long
2708 _cairo_ft_ucs4_to_index (void *abstract_font,
2709  uint32_t ucs4)
2710 {
2711  cairo_ft_scaled_font_t *scaled_font = abstract_font;
2712  cairo_ft_unscaled_font_t *unscaled = scaled_font->unscaled;
2713  FT_Face face;
2714  FT_UInt index;
2715 
2717  if (!face)
2718  return 0;
2719 
2720 #if CAIRO_HAS_FC_FONT
2721  index = FcFreeTypeCharIndex (face, ucs4);
2722 #else
2723  index = FT_Get_Char_Index (face, ucs4);
2724 #endif
2725 
2727  return index;
2728 }
2729 
2730 static cairo_int_status_t
2731 _cairo_ft_load_truetype_table (void *abstract_font,
2732  unsigned long tag,
2733  long offset,
2734  unsigned char *buffer,
2735  unsigned long *length)
2736 {
2737  cairo_ft_scaled_font_t *scaled_font = abstract_font;
2738  cairo_ft_unscaled_font_t *unscaled = scaled_font->unscaled;
2739  FT_Face face;
2741 
2742  /* We don't support the FreeType feature of loading a table
2743  * without specifying the size since this may overflow our
2744  * buffer. */
2745  assert (length != NULL);
2746 
2747  if (_cairo_ft_scaled_font_is_vertical (&scaled_font->base))
2749 
2750 #if HAVE_FT_LOAD_SFNT_TABLE
2752  if (!face)
2754 
2755  if (FT_IS_SFNT (face)) {
2756  if (buffer == NULL)
2757  *length = 0;
2758 
2759  if (FT_Load_Sfnt_Table (face, tag, offset, buffer, length) == 0)
2761  }
2762 
2764 #endif
2765 
2766  return status;
2767 }
2768 
2769 static cairo_int_status_t
2770 _cairo_ft_index_to_ucs4(void *abstract_font,
2771  unsigned long index,
2772  uint32_t *ucs4)
2773 {
2774  cairo_ft_scaled_font_t *scaled_font = abstract_font;
2775  cairo_ft_unscaled_font_t *unscaled = scaled_font->unscaled;
2776  FT_Face face;
2777  FT_ULong charcode;
2778  FT_UInt gindex;
2779 
2781  if (!face)
2783 
2784  *ucs4 = (uint32_t) -1;
2785  charcode = FT_Get_First_Char(face, &gindex);
2786  while (gindex != 0) {
2787  if (gindex == index) {
2788  *ucs4 = charcode;
2789  break;
2790  }
2791  charcode = FT_Get_Next_Char (face, charcode, &gindex);
2792  }
2793 
2795 
2796  return CAIRO_STATUS_SUCCESS;
2797 }
2798 
2799 static cairo_int_status_t
2800 _cairo_ft_is_synthetic (void *abstract_font,
2801  cairo_bool_t *is_synthetic)
2802 {
2804  cairo_ft_scaled_font_t *scaled_font = abstract_font;
2805  cairo_ft_unscaled_font_t *unscaled = scaled_font->unscaled;
2806  FT_Face face;
2807  FT_Error error;
2808 
2809  if (scaled_font->ft_options.synth_flags != 0) {
2810  *is_synthetic = TRUE;
2811  return status;
2812  }
2813 
2814  *is_synthetic = FALSE;
2816  if (!face)
2818 
2820  FT_MM_Var *mm_var = NULL;
2821  FT_Fixed *coords = NULL;
2822  int num_axis;
2823 
2824  /* If this is an MM or variable font we can't assume the current outlines
2825  * are the same as the font tables */
2826  *is_synthetic = TRUE;
2827 
2828  error = FT_Get_MM_Var (face, &mm_var);
2829  if (error) {
2831  goto cleanup;
2832  }
2833 
2834  num_axis = mm_var->num_axis;
2835  coords = _cairo_malloc_ab (num_axis, sizeof(FT_Fixed));
2836  if (!coords) {
2838  goto cleanup;
2839  }
2840 
2841 #if FREETYPE_MAJOR > 2 || ( FREETYPE_MAJOR == 2 && FREETYPE_MINOR >= 8)
2842  /* If FT_Get_Var_Blend_Coordinates() is available, we can check if the
2843  * current design coordinates are the default coordinates. In this case
2844  * the current outlines match the font tables.
2845  */
2846  {
2847  int i;
2848 
2850  *is_synthetic = FALSE;
2851  for (i = 0; i < num_axis; i++) {
2852  if (coords[i]) {
2853  *is_synthetic = TRUE;
2854  break;
2855  }
2856  }
2857  }
2858 #endif
2859 
2860  cleanup:
2861  free (coords);
2862 #if HAVE_FT_DONE_MM_VAR
2863  FT_Done_MM_Var (face->glyph->library, mm_var);
2864 #else
2865  free (mm_var);
2866 #endif
2867  }
2868 
2870 
2871  return status;
2872 }
2873 
2874 static cairo_int_status_t
2875 _cairo_index_to_glyph_name (void *abstract_font,
2876  char **glyph_names,
2877  int num_glyph_names,
2878  unsigned long glyph_index,
2879  unsigned long *glyph_array_index)
2880 {
2881  cairo_ft_scaled_font_t *scaled_font = abstract_font;
2882  cairo_ft_unscaled_font_t *unscaled = scaled_font->unscaled;
2883  FT_Face face;
2884  char buffer[256]; /* PLRM spcifies max name length of 127 */
2885  FT_Error error;
2886  int i;
2887 
2889  if (!face)
2891 
2893 
2895 
2896  if (error != FT_Err_Ok) {
2897  /* propagate fatal errors from FreeType */
2898  if (error == FT_Err_Out_Of_Memory)
2900 
2902  }
2903 
2904  /* FT first numbers the glyphs in the order they are read from the
2905  * Type 1 font. Then if .notdef is not the first glyph, the first
2906  * glyph is swapped with .notdef to ensure that .notdef is at
2907  * glyph index 0.
2908  *
2909  * As all but two glyphs in glyph_names already have the same
2910  * index as the FT glyph index, we first check if
2911  * glyph_names[glyph_index] is the name we are looking for. If not
2912  * we fall back to searching the entire array.
2913  */
2914 
2915  if ((long)glyph_index < num_glyph_names &&
2916  strcmp (glyph_names[glyph_index], buffer) == 0)
2917  {
2918  *glyph_array_index = glyph_index;
2919 
2920  return CAIRO_STATUS_SUCCESS;
2921  }
2922 
2923  for (i = 0; i < num_glyph_names; i++) {
2924  if (strcmp (glyph_names[i], buffer) == 0) {
2925  *glyph_array_index = i;
2926 
2927  return CAIRO_STATUS_SUCCESS;
2928  }
2929  }
2930 
2932 }
2933 
2934 static cairo_bool_t
2936 {
2937 #if HAVE_FT_GET_X11_FONT_FORMAT
2938  const char *font_format = FT_Get_X11_Font_Format (face);
2939  if (font_format &&
2940  (strcmp (font_format, "Type 1") == 0 ||
2941  strcmp (font_format, "CFF") == 0))
2942  {
2943  return TRUE;
2944  }
2945 #endif
2946 
2947  return FALSE;
2948 }
2949 
2950 static cairo_int_status_t
2951 _cairo_ft_load_type1_data (void *abstract_font,
2952  long offset,
2953  unsigned char *buffer,
2954  unsigned long *length)
2955 {
2956  cairo_ft_scaled_font_t *scaled_font = abstract_font;
2957  cairo_ft_unscaled_font_t *unscaled = scaled_font->unscaled;
2958  FT_Face face;
2960  unsigned long available_length;
2961  unsigned long ret;
2962 
2963  assert (length != NULL);
2964 
2965  if (_cairo_ft_scaled_font_is_vertical (&scaled_font->base))
2967 
2969  if (!face)
2971 
2972 #if HAVE_FT_LOAD_SFNT_TABLE
2973  if (FT_IS_SFNT (face)) {
2975  goto unlock;
2976  }
2977 #endif
2978 
2979  if (! _ft_is_type1 (face)) {
2981  goto unlock;
2982  }
2983 
2984  available_length = MAX (face->stream->size - offset, 0);
2985  if (!buffer) {
2986  *length = available_length;
2987  } else {
2988  if (*length > available_length) {
2990  } else if (face->stream->read != NULL) {
2991  /* Note that read() may be implemented as a macro, thanks POSIX!, so we
2992  * need to wrap the following usage in parentheses in order to
2993  * disambiguate it for the pre-processor - using the verbose function
2994  * pointer dereference for clarity.
2995  */
2996  ret = (* face->stream->read) (face->stream,
2997  offset,
2998  buffer,
2999  *length);
3000  if (ret != *length)
3002  } else {
3004  }
3005  }
3006 
3007  unlock:
3009 
3010  return status;
3011 }
3012 
3013 static cairo_bool_t
3015 {
3017 
3018  if (!unscaled->have_color_set) {
3019  FT_Face face;
3021  if (unlikely (face == NULL))
3022  return FALSE;
3024  }
3025 
3026  return unscaled->have_color;
3027 }
3028 
3033  NULL, /* text_to_glyphs */
3041 };
3042 
3043 /* #cairo_ft_font_face_t */
3044 
3045 #if CAIRO_HAS_FC_FONT
3046 static cairo_font_face_t *
3048 
3049 static cairo_status_t
3051  cairo_font_face_t **font_face_out)
3052 {
3054  FcPattern *pattern;
3055  int fcslant;
3056  int fcweight;
3057 
3058  pattern = FcPatternCreate ();
3059  if (!pattern) {
3061  return font_face->status;
3062  }
3063 
3065  FC_FAMILY, (unsigned char *) toy_face->family))
3066  {
3068  goto FREE_PATTERN;
3069  }
3070 
3071  switch (toy_face->slant)
3072  {
3074  fcslant = FC_SLANT_ITALIC;
3075  break;
3077  fcslant = FC_SLANT_OBLIQUE;
3078  break;
3080  default:
3081  fcslant = FC_SLANT_ROMAN;
3082  break;
3083  }
3084 
3085  if (!FcPatternAddInteger (pattern, FC_SLANT, fcslant)) {
3087  goto FREE_PATTERN;
3088  }
3089 
3090  switch (toy_face->weight)
3091  {
3093  fcweight = FC_WEIGHT_BOLD;
3094  break;
3096  default:
3097  fcweight = FC_WEIGHT_MEDIUM;
3098  break;
3099  }
3100 
3101  if (!FcPatternAddInteger (pattern, FC_WEIGHT, fcweight)) {
3103  goto FREE_PATTERN;
3104  }
3105 
3107 
3108  FREE_PATTERN:
3110 
3111  *font_face_out = font_face;
3112  return font_face->status;
3113 }
3114 #endif
3115 
3116 static cairo_bool_t
3117 _cairo_ft_font_face_destroy (void *abstract_face)
3118 {
3119  cairo_ft_font_face_t *font_face = abstract_face;
3120 
3121  /* When destroying a face created by cairo_ft_font_face_create_for_ft_face,
3122  * we have a special "zombie" state for the face when the unscaled font
3123  * is still alive but there are no other references to a font face with
3124  * the same FT_Face.
3125  *
3126  * We go from:
3127  *
3128  * font_face ------> unscaled
3129  * <-....weak....../
3130  *
3131  * To:
3132  *
3133  * font_face <------- unscaled
3134  */
3135 
3136  if (font_face->unscaled &&
3137  font_face->unscaled->from_face &&
3138  font_face->next == NULL &&
3139  font_face->unscaled->faces == font_face &&
3140  CAIRO_REFERENCE_COUNT_GET_VALUE (&font_face->unscaled->base.ref_count) > 1)
3141  {
3142  _cairo_unscaled_font_destroy (&font_face->unscaled->base);
3143  font_face->unscaled = NULL;
3144 
3145  return FALSE;
3146  }
3147 
3148  if (font_face->unscaled) {
3149  cairo_ft_font_face_t *tmp_face = NULL;
3150  cairo_ft_font_face_t *last_face = NULL;
3151 
3152  /* Remove face from linked list */
3153  for (tmp_face = font_face->unscaled->faces;
3154  tmp_face;
3155  tmp_face = tmp_face->next)
3156  {
3157  if (tmp_face == font_face) {
3158  if (last_face)
3159  last_face->next = tmp_face->next;
3160  else
3161  font_face->unscaled->faces = tmp_face->next;
3162  }
3163 
3164  last_face = tmp_face;
3165  }
3166 
3167  _cairo_unscaled_font_destroy (&font_face->unscaled->base);
3168  font_face->unscaled = NULL;
3169  }
3170 
3171  _cairo_ft_options_fini (&font_face->ft_options);
3172 
3173 #if CAIRO_HAS_FC_FONT
3174  if (font_face->pattern) {
3175  FcPatternDestroy (font_face->pattern);
3176  cairo_font_face_destroy (font_face->resolved_font_face);
3177  }
3178 #endif
3179 
3180  return TRUE;
3181 }
3182 
3183 static cairo_font_face_t *
3185  const cairo_matrix_t *font_matrix,
3186  const cairo_matrix_t *ctm,
3188 {
3189  cairo_ft_font_face_t *font_face = abstract_face;
3190 
3191  /* The handling of font options is different depending on how the
3192  * font face was created. When the user creates a font face with
3193  * cairo_ft_font_face_create_for_ft_face(), then the load flags
3194  * passed in augment the load flags for the options. But for
3195  * cairo_ft_font_face_create_for_pattern(), the load flags are
3196  * derived from a pattern where the user has called
3197  * cairo_ft_font_options_substitute(), so *just* use those load
3198  * flags and ignore the options.
3199  */
3200 
3201 #if CAIRO_HAS_FC_FONT
3202  /* If we have an unresolved pattern, resolve it and create
3203  * unscaled font. Otherwise, use the ones stored in font_face.
3204  */
3205  if (font_face->pattern) {
3206  cairo_font_face_t *resolved;
3207 
3208  /* Cache the resolved font whilst the FcConfig remains consistent. */
3209  resolved = font_face->resolved_font_face;
3210  if (resolved != NULL) {
3211  if (! FcInitBringUptoDate ()) {
3214  }
3215 
3216  if (font_face->resolved_config == FcConfigGetCurrent ())
3217  return cairo_font_face_reference (resolved);
3218 
3219  cairo_font_face_destroy (resolved);
3220  font_face->resolved_font_face = NULL;
3221  }
3222 
3223  resolved = _cairo_ft_resolve_pattern (font_face->pattern,
3224  font_matrix,
3225  ctm,
3226  options);
3227  if (unlikely (resolved->status))
3228  return resolved;
3229 
3230  font_face->resolved_font_face = cairo_font_face_reference (resolved);
3231  font_face->resolved_config = FcConfigGetCurrent ();
3232 
3233  return resolved;
3234  }
3235 #endif
3236 
3237  return abstract_face;
3238 }
3239 
3242 #if CAIRO_HAS_FC_FONT
3244 #else
3245  NULL,
3246 #endif
3250 };
3251 
3252 #if CAIRO_HAS_FC_FONT
3253 static cairo_font_face_t *
3255 {
3257 
3259  if (unlikely (font_face == NULL)) {
3262  }
3263 
3264  font_face->unscaled = NULL;
3265 
3266  _get_pattern_ft_options (pattern, &font_face->ft_options);
3267 
3268  font_face->next = NULL;
3269 
3270  font_face->pattern = FcPatternDuplicate (pattern);
3271  if (unlikely (font_face->pattern == NULL)) {
3272  free (font_face);
3275  }
3276 
3277  font_face->resolved_font_face = NULL;
3278  font_face->resolved_config = NULL;
3279 
3281 
3282  return &font_face->base;
3283 }
3284 #endif
3285 
3286 static cairo_font_face_t *
3288  cairo_ft_options_t *ft_options)
3289 {
3290  cairo_ft_font_face_t *font_face, **prev_font_face;
3291 
3292  /* Looked for an existing matching font face */
3293  for (font_face = unscaled->faces, prev_font_face = &unscaled->faces;
3294  font_face;
3295  prev_font_face = &font_face->next, font_face = font_face->next)
3296  {
3297  if (font_face->ft_options.load_flags == ft_options->load_flags &&
3298  font_face->ft_options.synth_flags == ft_options->synth_flags &&
3299  cairo_font_options_equal (&font_face->ft_options.base, &ft_options->base))
3300  {
3301  if (font_face->base.status) {
3302  /* The font_face has been left in an error state, abandon it. */
3303  *prev_font_face = font_face->next;
3304  break;
3305  }
3306 
3307  if (font_face->unscaled == NULL) {
3308  /* Resurrect this "zombie" font_face (from
3309  * _cairo_ft_font_face_destroy), switching its unscaled_font
3310  * from owner to ownee. */
3311  font_face->unscaled = unscaled;
3313  return &font_face->base;
3314  } else
3315  return cairo_font_face_reference (&font_face->base);
3316  }
3317  }
3318 
3319  /* No match found, create a new one */
3321  if (unlikely (!font_face)) {
3324  }
3325 
3326  font_face->unscaled = unscaled;
3328 
3329  _cairo_ft_options_init_copy (&font_face->ft_options, ft_options);
3330 
3331  if (unscaled->faces && unscaled->faces->unscaled == NULL) {
3332  /* This "zombie" font_face (from _cairo_ft_font_face_destroy)
3333  * is no longer needed. */
3334  assert (unscaled->from_face && unscaled->faces->next == NULL);
3335  cairo_font_face_destroy (&unscaled->faces->base);
3336  unscaled->faces = NULL;
3337  }
3338 
3339  font_face->next = unscaled->faces;
3340  unscaled->faces = font_face;
3341 
3342 #if CAIRO_HAS_FC_FONT
3343  font_face->pattern = NULL;
3344 #endif
3345 
3347 
3348  return &font_face->base;
3349 }
3350 
3351 /* implement the platform-specific interface */
3352 
3353 #if CAIRO_HAS_FC_FONT
3354 static cairo_status_t
3356  FcPattern *pattern)
3357 {
3358  FcValue v;
3359 
3360  if (options->antialias != CAIRO_ANTIALIAS_DEFAULT)
3361  {
3363  {
3364  if (! FcPatternAddBool (pattern,
3365  FC_ANTIALIAS,
3366  options->antialias != CAIRO_ANTIALIAS_NONE))
3368 
3369  if (options->antialias != CAIRO_ANTIALIAS_SUBPIXEL) {
3373  }
3374  }
3375  }
3376 
3377  if (options->antialias != CAIRO_ANTIALIAS_DEFAULT)
3378  {
3379  if (FcPatternGet (pattern, FC_RGBA, 0, &v) == FcResultNoMatch)
3380  {
3381  int rgba;
3382 
3383  if (options->antialias == CAIRO_ANTIALIAS_SUBPIXEL) {
3384  switch (options->subpixel_order) {
3387  default:
3388  rgba = FC_RGBA_RGB;
3389  break;
3391  rgba = FC_RGBA_BGR;
3392  break;
3394  rgba = FC_RGBA_VRGB;
3395  break;
3397  rgba = FC_RGBA_VBGR;
3398  break;
3399  }
3400  } else {
3401  rgba = FC_RGBA_NONE;
3402  }
3403 
3404  if (! FcPatternAddInteger (pattern, FC_RGBA, rgba))
3406  }
3407  }
3408 
3409  if (options->lcd_filter != CAIRO_LCD_FILTER_DEFAULT)
3410  {
3412  {
3413  int lcd_filter;
3414 
3415  switch (options->lcd_filter) {
3416  case CAIRO_LCD_FILTER_NONE:
3417  lcd_filter = FT_LCD_FILTER_NONE;
3418  break;
3421  lcd_filter = FT_LCD_FILTER_LEGACY;
3422  break;
3423  case CAIRO_LCD_FILTER_FIR3:
3424  lcd_filter = FT_LCD_FILTER_LIGHT;
3425  break;
3426  default:
3427  case CAIRO_LCD_FILTER_FIR5:
3428  lcd_filter = FT_LCD_FILTER_DEFAULT;
3429  break;
3430  }
3431 
3432  if (! FcPatternAddInteger (pattern, FC_LCD_FILTER, lcd_filter))
3434  }
3435  }
3436 
3437  if (options->hint_style != CAIRO_HINT_STYLE_DEFAULT)
3438  {
3440  {
3441  if (! FcPatternAddBool (pattern,
3442  FC_HINTING,
3443  options->hint_style != CAIRO_HINT_STYLE_NONE))
3445  }
3446 
3447 #ifdef FC_HINT_STYLE
3449  {
3450  int hint_style;
3451 
3452  switch (options->hint_style) {
3453  case CAIRO_HINT_STYLE_NONE:
3454  hint_style = FC_HINT_NONE;
3455  break;
3457  hint_style = FC_HINT_SLIGHT;
3458  break;
3460  hint_style = FC_HINT_MEDIUM;
3461  break;
3462  case CAIRO_HINT_STYLE_FULL:
3464  default:
3465  hint_style = FC_HINT_FULL;
3466  break;
3467  }
3468 
3469  if (! FcPatternAddInteger (pattern, FC_HINT_STYLE, hint_style))
3471  }
3472 #endif
3473  }
3474 
3475  return CAIRO_STATUS_SUCCESS;
3476 }
3477 
3478 /**
3479  * cairo_ft_font_options_substitute:
3480  * @options: a #cairo_font_options_t object
3481  * @pattern: an existing #FcPattern
3482  *
3483  * Add options to a #FcPattern based on a #cairo_font_options_t font
3484  * options object. Options that are already in the pattern, are not overridden,
3485  * so you should call this function after calling FcConfigSubstitute() (the
3486  * user's settings should override options based on the surface type), but
3487  * before calling FcDefaultSubstitute().
3488  *
3489  * Since: 1.0
3490  **/
3491 void
3493  FcPattern *pattern)
3494 {
3496  return;
3497 
3499 }
3500 
3501 static cairo_font_face_t *
3503  const cairo_matrix_t *font_matrix,
3504  const cairo_matrix_t *ctm,
3505  const cairo_font_options_t *font_options)
3506 {
3508 
3510  FcPattern *resolved;
3512  FcResult result;
3514  cairo_ft_options_t ft_options;
3516 
3517  scale = *ctm;
3518  scale.x0 = scale.y0 = 0;
3520  font_matrix,
3521  &scale);
3522 
3524  if (unlikely (status))
3526 
3528  if (pattern == NULL)
3530 
3531  if (! FcPatternAddDouble (pattern, FC_PIXEL_SIZE, sf.y_scale)) {
3533  goto FREE_PATTERN;
3534  }
3535 
3538  goto FREE_PATTERN;
3539  }
3540 
3542  if (status) {
3544  goto FREE_PATTERN;
3545  }
3546 
3548 
3550  if (unlikely (status)) {
3552  goto FREE_PATTERN;
3553  }
3554 
3555  if (unscaled == NULL) {
3556  resolved = FcFontMatch (NULL, pattern, &result);
3557  if (!resolved) {
3558  /* We failed to find any font. Substitute twin so that the user can
3559  * see something (and hopefully recognise that the font is missing)
3560  * and not just receive a NO_MEMORY error during rendering.
3561  */
3563  goto FREE_PATTERN;
3564  }
3565 
3567  if (unlikely (status || unscaled == NULL)) {
3569  goto FREE_RESOLVED;
3570  }
3571  } else
3572  resolved = pattern;
3573 
3574  _get_pattern_ft_options (resolved, &ft_options);
3576  _cairo_ft_options_fini (&ft_options);
3578 
3579 FREE_RESOLVED:
3580  if (resolved != pattern)
3581  FcPatternDestroy (resolved);
3582 
3583 FREE_PATTERN:
3585 
3586  return font_face;
3587 }
3588 
3589 /**
3590  * cairo_ft_font_face_create_for_pattern:
3591  * @pattern: A fontconfig pattern. Cairo makes a copy of the pattern
3592  * if it needs to. You are free to modify or free @pattern after this call.
3593  *
3594  * Creates a new font face for the FreeType font backend based on a
3595  * fontconfig pattern. This font can then be used with
3596  * cairo_set_font_face() or cairo_scaled_font_create(). The
3597  * #cairo_scaled_font_t returned from cairo_scaled_font_create() is
3598  * also for the FreeType backend and can be used with functions such
3599  * as cairo_ft_scaled_font_lock_face().
3600  *
3601  * Font rendering options are represented both here and when you
3602  * call cairo_scaled_font_create(). Font options that have a representation
3603  * in a #FcPattern must be passed in here; to modify #FcPattern
3604  * appropriately to reflect the options in a #cairo_font_options_t, call
3605  * cairo_ft_font_options_substitute().
3606  *
3607  * The pattern's FC_FT_FACE element is inspected first and if that is set,
3608  * that will be the FreeType font face associated with the returned cairo
3609  * font face. Otherwise the FC_FILE element is checked. If it's set,
3610  * that and the value of the FC_INDEX element (defaults to zero) of @pattern
3611  * are used to load a font face from file.
3612  *
3613  * If both steps from the previous paragraph fails, @pattern will be passed
3614  * to FcConfigSubstitute, FcDefaultSubstitute, and finally FcFontMatch,
3615  * and the resulting font pattern is used.
3616  *
3617  * If the FC_FT_FACE element of @pattern is set, the user is responsible
3618  * for making sure that the referenced FT_Face remains valid for the life
3619  * time of the returned #cairo_font_face_t. See
3620  * cairo_ft_font_face_create_for_ft_face() for an example of how to couple
3621  * the life time of the FT_Face to that of the cairo font-face.
3622  *
3623  * Return value: a newly created #cairo_font_face_t. Free with
3624  * cairo_font_face_destroy() when you are done using it.
3625  *
3626  * Since: 1.0
3627  **/
3630 {
3633  cairo_ft_options_t ft_options;
3635 
3637  if (unlikely (status)) {
3640  else
3642  }
3643  if (unlikely (unscaled == NULL)) {
3644  /* Store the pattern. We will resolve it and create unscaled
3645  * font when creating scaled fonts */
3647  }
3648 
3649  _get_pattern_ft_options (pattern, &ft_options);
3651  _cairo_ft_options_fini (&ft_options);
3653 
3654  return font_face;
3655 }
3656 #endif
3657 
3658 /**
3659  * cairo_ft_font_face_create_for_ft_face:
3660  * @face: A FreeType face object, already opened. This must
3661  * be kept around until the face's ref_count drops to
3662  * zero and it is freed. Since the face may be referenced
3663  * internally to Cairo, the best way to determine when it
3664  * is safe to free the face is to pass a
3665  * #cairo_destroy_func_t to cairo_font_face_set_user_data()
3666  * @load_flags: flags to pass to FT_Load_Glyph when loading
3667  * glyphs from the font. These flags are OR'ed together with
3668  * the flags derived from the #cairo_font_options_t passed
3669  * to cairo_scaled_font_create(), so only a few values such
3670  * as %FT_LOAD_VERTICAL_LAYOUT, and %FT_LOAD_FORCE_AUTOHINT
3671  * are useful. You should not pass any of the flags affecting
3672  * the load target, such as %FT_LOAD_TARGET_LIGHT.
3673  *
3674  * Creates a new font face for the FreeType font backend from a
3675  * pre-opened FreeType face. This font can then be used with
3676  * cairo_set_font_face() or cairo_scaled_font_create(). The
3677  * #cairo_scaled_font_t returned from cairo_scaled_font_create() is
3678  * also for the FreeType backend and can be used with functions such
3679  * as cairo_ft_scaled_font_lock_face(). Note that Cairo may keep a reference
3680  * to the FT_Face alive in a font-cache and the exact lifetime of the reference
3681  * depends highly upon the exact usage pattern and is subject to external
3682  * factors. You must not call FT_Done_Face() before the last reference to the
3683  * #cairo_font_face_t has been dropped.
3684  *
3685  * As an example, below is how one might correctly couple the lifetime of
3686  * the FreeType face object to the #cairo_font_face_t.
3687  *
3688  * <informalexample><programlisting>
3689  * static const cairo_user_data_key_t key;
3690  *
3691  * font_face = cairo_ft_font_face_create_for_ft_face (ft_face, 0);
3692  * status = cairo_font_face_set_user_data (font_face, &key,
3693  * ft_face, (cairo_destroy_func_t) FT_Done_Face);
3694  * if (status) {
3695  * cairo_font_face_destroy (font_face);
3696  * FT_Done_Face (ft_face);
3697  * return ERROR;
3698  * }
3699  * </programlisting></informalexample>
3700  *
3701  * Return value: a newly created #cairo_font_face_t. Free with
3702  * cairo_font_face_destroy() when you are done using it.
3703  *
3704  * Since: 1.0
3705  **/
3708  int load_flags)
3709 {
3712  cairo_ft_options_t ft_options;
3714 
3716  if (unlikely (status))
3718 
3719  ft_options.load_flags = load_flags;
3720  ft_options.synth_flags = 0;
3721  _cairo_font_options_init_default (&ft_options.base);
3722 
3725 
3726  return font_face;
3727 }
3728 
3729 /**
3730  * cairo_ft_font_face_set_synthesize:
3731  * @font_face: The #cairo_ft_font_face_t object to modify
3732  * @synth_flags: the set of synthesis options to enable
3733  *
3734  * FreeType provides the ability to synthesize different glyphs from a base
3735  * font, which is useful if you lack those glyphs from a true bold or oblique
3736  * font. See also #cairo_ft_synthesize_t.
3737  *
3738  * Since: 1.12
3739  **/
3740 void
3742  unsigned int synth_flags)
3743 {
3745 
3746  if (font_face->backend->type != CAIRO_FONT_TYPE_FT)
3747  return;
3748 
3750  ft->ft_options.synth_flags |= synth_flags;
3751 }
3752 
3753 /**
3754  * cairo_ft_font_face_unset_synthesize:
3755  * @font_face: The #cairo_ft_font_face_t object to modify
3756  * @synth_flags: the set of synthesis options to disable
3757  *
3758  * See cairo_ft_font_face_set_synthesize().
3759  *
3760  * Since: 1.12
3761  **/
3762 void
3764  unsigned int synth_flags)
3765 {
3767 
3768  if (font_face->backend->type != CAIRO_FONT_TYPE_FT)
3769  return;
3770 
3772  ft->ft_options.synth_flags &= ~~synth_flags;
3773 }
3774 
3775 /**
3776  * cairo_ft_font_face_get_synthesize:
3777  * @font_face: The #cairo_ft_font_face_t object to query
3778  *
3779  * See #cairo_ft_synthesize_t.
3780  *
3781  * Returns: the current set of synthesis options.
3782  *
3783  * Since: 1.12
3784  **/
3785 unsigned int
3787 {
3789 
3790  if (font_face->backend->type != CAIRO_FONT_TYPE_FT)
3791  return 0;
3792 
3794  return ft->ft_options.synth_flags;
3795 }
3796 
3797 /**
3798  * cairo_ft_scaled_font_lock_face:
3799  * @scaled_font: A #cairo_scaled_font_t from the FreeType font backend. Such an
3800  * object can be created by calling cairo_scaled_font_create() on a
3801  * FreeType backend font face (see cairo_ft_font_face_create_for_pattern(),
3802  * cairo_ft_font_face_create_for_ft_face()).
3803  *
3804  * cairo_ft_scaled_font_lock_face() gets the #FT_Face object from a FreeType
3805  * backend font and scales it appropriately for the font and applies OpenType
3806  * font variations if applicable. You must
3807  * release the face with cairo_ft_scaled_font_unlock_face()
3808  * when you are done using it. Since the #FT_Face object can be
3809  * shared between multiple #cairo_scaled_font_t objects, you must not
3810  * lock any other font objects until you unlock this one. A count is
3811  * kept of the number of times cairo_ft_scaled_font_lock_face() is
3812  * called. cairo_ft_scaled_font_unlock_face() must be called the same number
3813  * of times.
3814  *
3815  * You must be careful when using this function in a library or in a
3816  * threaded application, because freetype's design makes it unsafe to
3817  * call freetype functions simultaneously from multiple threads, (even
3818  * if using distinct FT_Face objects). Because of this, application
3819  * code that acquires an FT_Face object with this call must add its
3820  * own locking to protect any use of that object, (and which also must
3821  * protect any other calls into cairo as almost any cairo function
3822  * might result in a call into the freetype library).
3823  *
3824  * Return value: The #FT_Face object for @font, scaled appropriately,
3825  * or %NULL if @scaled_font is in an error state (see
3826  * cairo_scaled_font_status()) or there is insufficient memory.
3827  *
3828  * Since: 1.0
3829  **/
3830 FT_Face
3832 {
3833  cairo_ft_scaled_font_t *scaled_font = (cairo_ft_scaled_font_t *) abstract_font;
3834  FT_Face face;
3836 
3837  if (! _cairo_scaled_font_is_ft (abstract_font)) {
3839  return NULL;
3840  }
3841 
3842  if (scaled_font->base.status)
3843  return NULL;
3844 
3846  if (unlikely (face == NULL)) {
3848  return NULL;
3849  }
3850 
3852  &scaled_font->base.scale);
3853  if (unlikely (status)) {
3855  status = _cairo_scaled_font_set_error (&scaled_font->base, status);
3856  return NULL;
3857  }
3858 
3859  cairo_ft_apply_variations (face, scaled_font);
3860 
3861  /* Note: We deliberately release the unscaled font's mutex here,
3862  * so that we are not holding a lock across two separate calls to
3863  * cairo function, (which would give the application some
3864  * opportunity for creating deadlock. This is obviously unsafe,
3865  * but as documented, the user must add manual locking when using
3866  * this function. */
3867  CAIRO_MUTEX_UNLOCK (scaled_font->unscaled->mutex);
3868 
3869  return face;
3870 }
3871 
3872 /**
3873  * cairo_ft_scaled_font_unlock_face:
3874  * @scaled_font: A #cairo_scaled_font_t from the FreeType font backend. Such an
3875  * object can be created by calling cairo_scaled_font_create() on a
3876  * FreeType backend font face (see cairo_ft_font_face_create_for_pattern(),
3877  * cairo_ft_font_face_create_for_ft_face()).
3878  *
3879  * Releases a face obtained with cairo_ft_scaled_font_lock_face().
3880  *
3881  * Since: 1.0
3882  **/
3883 void
3885 {
3886  cairo_ft_scaled_font_t *scaled_font = (cairo_ft_scaled_font_t *) abstract_font;
3887 
3888  if (! _cairo_scaled_font_is_ft (abstract_font)) {
3890  return;
3891  }
3892 
3893  if (scaled_font->base.status)
3894  return;
3895 
3896  /* Note: We released the unscaled font's mutex at the end of
3897  * cairo_ft_scaled_font_lock_face, so we have to acquire it again
3898  * as _cairo_ft_unscaled_font_unlock_face expects it to be held
3899  * when we call into it. */
3900  CAIRO_MUTEX_LOCK (scaled_font->unscaled->mutex);
3901 
3903 }
3904 
3905 static cairo_bool_t
3907 {
3908  cairo_ft_scaled_font_t *ft_scaled_font;
3909 
3910  if (!_cairo_scaled_font_is_ft (scaled_font))
3911  return FALSE;
3912 
3913  ft_scaled_font = (cairo_ft_scaled_font_t *) scaled_font;
3914  if (ft_scaled_font->ft_options.load_flags & FT_LOAD_VERTICAL_LAYOUT)
3915  return TRUE;
3916  return FALSE;
3917 }
3918 
3919 unsigned int
3921 {
3922  cairo_ft_scaled_font_t *ft_scaled_font;
3923 
3924  if (! _cairo_scaled_font_is_ft (scaled_font))
3925  return 0;
3926 
3927  ft_scaled_font = (cairo_ft_scaled_font_t *) scaled_font;
3928  return ft_scaled_font->ft_options.load_flags;
3929 }
3930 
3931 void
3933 {
3935 }
#define strdup
Definition: Utility.h:167
int source[257]
Definition: afm2tfm.c:928
#define y0
#define convert
Definition: aptex-macros.h:489
#define width(a)
Definition: aptex-macros.h:198
#define x3
#define count(a)
Definition: aptex-macros.h:781
#define x0
#define height(a)
Definition: aptex-macros.h:200
#define advance
Definition: aptex-macros.h:464
#define y3
#define mode
Definition: aptex-macros.h:510
static FT_Face font_face[65536]
Definition: aptex-src.c:20633
#define hash
Definition: aptex.h:388
unsigned long _cairo_hash_string(const char *c)
Definition: cairo-cache.c:319
#define cairo_warn
cairo_status_t _cairo_error(cairo_status_t status)
Definition: cairo-error.c:65
enum _cairo_int_status cairo_int_status_t
#define _cairo_error_throw(status)
@ CAIRO_INT_STATUS_UNSUPPORTED
static cairo_fixed_t _cairo_fixed_from_26_6(uint32_t i)
int32_t cairo_fixed_t
cairo_font_face_t * _cairo_font_face_twin_create_fallback(void)
void _cairo_unscaled_font_destroy(cairo_unscaled_font_t *unscaled_font)
void _cairo_unscaled_font_init(cairo_unscaled_font_t *unscaled_font, const cairo_unscaled_font_backend_t *backend)
cairo_unscaled_font_t * _cairo_unscaled_font_reference(cairo_unscaled_font_t *unscaled_font)
const cairo_font_face_t _cairo_font_face_nil
void cairo_font_face_destroy(cairo_font_face_t *font_face)
void _cairo_font_face_init(cairo_font_face_t *font_face, const cairo_font_face_backend_t *backend)
const cairo_font_face_t _cairo_font_face_nil_file_not_found
cairo_font_face_t * cairo_font_face_reference(cairo_font_face_t *font_face)
cairo_bool_t cairo_font_options_equal(const cairo_font_options_t *options, const cairo_font_options_t *other)
void _cairo_font_options_fini(cairo_font_options_t *options)
void _cairo_font_options_init_copy(cairo_font_options_t *options, const cairo_font_options_t *other)
cairo_status_t cairo_font_options_status(cairo_font_options_t *options)
void _cairo_font_options_init_default(cairo_font_options_t *options)
#define FC_RGBA_VBGR
#define FC_LCD_DEFAULT
#define FC_HINT_FULL
#define FC_LCD_LEGACY
#define FC_LCD_LIGHT
#define FC_RGBA_NONE
#define FC_RGBA_UNKNOWN
#define FC_HINT_SLIGHT
#define FC_HINT_MEDIUM
#define FC_LCD_NONE
#define FC_RGBA_RGB
#define FC_RGBA_VRGB
#define FC_HINT_NONE
#define FC_RGBA_BGR
void cairo_ft_font_face_unset_synthesize(cairo_font_face_t *font_face, unsigned int synth_flags)
struct _cairo_ft_scaled_font cairo_ft_scaled_font_t
struct _cairo_ft_options cairo_ft_options_t
unsigned int cairo_ft_font_face_get_synthesize(cairo_font_face_t *font_face)
cairo_font_face_t * cairo_ft_font_face_create_for_ft_face(FT_Face face, int load_flags)
void _cairo_ft_font_reset_static_data(void)
FT_Face cairo_ft_scaled_font_lock_face(cairo_scaled_font_t *abstract_font)
const cairo_font_face_backend_t _cairo_ft_font_face_backend
unsigned int _cairo_ft_scaled_font_get_load_flags(cairo_scaled_font_t *scaled_font)
struct _cairo_ft_font_transform cairo_ft_font_transform_t
void cairo_ft_font_face_set_synthesize(cairo_font_face_t *font_face, unsigned int synth_flags)
void cairo_ft_scaled_font_unlock_face(cairo_scaled_font_t *abstract_font)
struct _cairo_ft_unscaled_font_map cairo_ft_unscaled_font_map_t
cairo_bool_t _cairo_scaled_font_is_ft(cairo_scaled_font_t *scaled_font)
cairo_status_t _cairo_hash_table_insert(cairo_hash_table_t *hash_table, cairo_hash_entry_t *entry)
Definition: cairo-hash.c:455
void _cairo_hash_table_remove(cairo_hash_table_t *hash_table, cairo_hash_entry_t *key)
Definition: cairo-hash.c:520
void _cairo_hash_table_destroy(cairo_hash_table_t *hash_table)
Definition: cairo-hash.c:214
cairo_hash_table_t * _cairo_hash_table_create(cairo_hash_keys_equal_func_t keys_equal)
Definition: cairo-hash.c:163
void * _cairo_hash_table_lookup(cairo_hash_table_t *hash_table, cairo_hash_entry_t *key)
Definition: cairo-hash.c:338
void _cairo_hash_table_foreach(cairo_hash_table_t *hash_table, cairo_hash_callback_func_t hash_callback, void *closure)
Definition: cairo-hash.c:555
void * _cairo_hash_table_random_entry(cairo_hash_table_t *hash_table, cairo_hash_predicate_func_t predicate)
Definition: cairo-hash.c:402
int cairo_format_stride_for_width(cairo_format_t format, int width)
cairo_surface_t * cairo_image_surface_create(cairo_format_t format, int width, int height)
cairo_surface_t * cairo_image_surface_create_for_data(unsigned char *data, cairo_format_t format, int width, int height, int stride)
void _cairo_image_surface_assume_ownership_of_data(cairo_image_surface_t *surface)
#define _cairo_malloc_ab(a, size)
#define _cairo_malloc(size)
void cairo_matrix_init_scale(cairo_matrix_t *matrix, double sx, double sy)
Definition: cairo-matrix.c:219
cairo_status_t cairo_matrix_invert(cairo_matrix_t *matrix)
Definition: cairo-matrix.c:586
void _cairo_matrix_get_affine(const cairo_matrix_t *matrix, double *xx, double *yx, double *xy, double *yy, double *x0, double *y0)
Definition: cairo-matrix.c:144
void cairo_matrix_init(cairo_matrix_t *matrix, double xx, double yx, double xy, double yy, double x0, double y0)
Definition: cairo-matrix.c:111
void cairo_matrix_transform_point(const cairo_matrix_t *matrix, double *x, double *y)
Definition: cairo-matrix.c:410
void cairo_matrix_translate(cairo_matrix_t *matrix, double tx, double ty)
Definition: cairo-matrix.c:197
cairo_status_t _cairo_matrix_compute_basis_scale_factors(const cairo_matrix_t *matrix, double *basis_scale, double *normal_scale, cairo_bool_t x_basis)
Definition: cairo-matrix.c:674
void cairo_matrix_scale(cairo_matrix_t *matrix, double sx, double sy)
Definition: cairo-matrix.c:242
void cairo_matrix_multiply(cairo_matrix_t *result, const cairo_matrix_t *a, const cairo_matrix_t *b)
Definition: cairo-matrix.c:331
double _cairo_strtod(const char *nptr, char **endptr)
Definition: cairo-misc.c:830
#define CAIRO_MUTEX_FINI
#define CAIRO_MUTEX_UNLOCK
cairo_mutex_impl_t cairo_mutex_t
#define CAIRO_MUTEX_LOCK
#define CAIRO_MUTEX_INIT
cairo_status_t _cairo_path_fixed_curve_to(cairo_path_fixed_t *path, cairo_fixed_t x0, cairo_fixed_t y0, cairo_fixed_t x1, cairo_fixed_t y1, cairo_fixed_t x2, cairo_fixed_t y2)
cairo_status_t _cairo_path_fixed_move_to(cairo_path_fixed_t *path, cairo_fixed_t x, cairo_fixed_t y)
cairo_status_t _cairo_path_fixed_line_to(cairo_path_fixed_t *path, cairo_fixed_t x, cairo_fixed_t y)
cairo_path_fixed_t * _cairo_path_fixed_create(void)
cairo_status_t _cairo_path_fixed_close_path(cairo_path_fixed_t *path)
cairo_bool_t _cairo_path_fixed_get_current_point(cairo_path_fixed_t *path, cairo_fixed_t *x, cairo_fixed_t *y)
void _cairo_path_fixed_destroy(cairo_path_fixed_t *path)
void _cairo_pattern_fini(cairo_pattern_t *pattern)
void _cairo_pattern_init_for_surface(cairo_surface_pattern_t *pattern, cairo_surface_t *surface)
void cairo_pattern_set_matrix(cairo_pattern_t *pattern, const cairo_matrix_t *matrix)
#define CAIRO_REFERENCE_COUNT_GET_VALUE(RC)
#define _cairo_reference_count_dec_and_test(RC)
cairo_status_t _cairo_scaled_font_set_error(cairo_scaled_font_t *scaled_font, cairo_status_t status)
cairo_status_t _cairo_scaled_font_init(cairo_scaled_font_t *scaled_font, cairo_font_face_t *font_face, const cairo_matrix_t *font_matrix, const cairo_matrix_t *ctm, const cairo_font_options_t *options, const cairo_scaled_font_backend_t *backend)
void _cairo_scaled_glyph_set_surface(cairo_scaled_glyph_t *scaled_glyph, cairo_scaled_font_t *scaled_font, cairo_image_surface_t *surface)
cairo_scaled_font_t * _cairo_scaled_font_create_in_error(cairo_status_t status)
void _cairo_scaled_glyph_set_metrics(cairo_scaled_glyph_t *scaled_glyph, cairo_scaled_font_t *scaled_font, cairo_text_extents_t *fs_metrics)
void _cairo_scaled_glyph_set_path(cairo_scaled_glyph_t *scaled_glyph, cairo_scaled_font_t *scaled_font, cairo_path_fixed_t *path)
cairo_status_t _cairo_scaled_font_set_metrics(cairo_scaled_font_t *scaled_font, cairo_font_extents_t *fs_metrics)
void _cairo_scaled_glyph_set_color_surface(cairo_scaled_glyph_t *scaled_glyph, cairo_scaled_font_t *scaled_font, cairo_image_surface_t *surface)
void cairo_surface_destroy(cairo_surface_t *surface)
void cairo_surface_set_device_offset(cairo_surface_t *surface, double x_offset, double y_offset)
void cairo_surface_get_device_offset(cairo_surface_t *surface, double *x_offset, double *y_offset)
cairo_status_t _cairo_surface_paint(cairo_surface_t *surface, cairo_operator_t op, const cairo_pattern_t *source, const cairo_clip_t *clip)
@ CAIRO_LCD_FILTER_FIR5
@ CAIRO_LCD_FILTER_INTRA_PIXEL
@ CAIRO_LCD_FILTER_DEFAULT
@ CAIRO_LCD_FILTER_FIR3
@ CAIRO_LCD_FILTER_NONE
@ CAIRO_FONT_SLANT_ITALIC
Definition: cairo.h:1265
@ CAIRO_FONT_SLANT_OBLIQUE
Definition: cairo.h:1266
@ CAIRO_FONT_SLANT_NORMAL
Definition: cairo.h:1264
@ CAIRO_SUBPIXEL_ORDER_RGB
Definition: cairo.h:1304
@ CAIRO_SUBPIXEL_ORDER_VBGR
Definition: cairo.h:1307
@ CAIRO_SUBPIXEL_ORDER_BGR
Definition: cairo.h:1305
@ CAIRO_SUBPIXEL_ORDER_DEFAULT
Definition: cairo.h:1303
@ CAIRO_SUBPIXEL_ORDER_VRGB
Definition: cairo.h:1306
int cairo_bool_t
Definition: cairo.h:107
@ CAIRO_STATUS_SUCCESS
Definition: cairo.h:315
@ CAIRO_STATUS_INVALID_FORMAT
Definition: cairo.h:332
@ CAIRO_STATUS_FILE_NOT_FOUND
Definition: cairo.h:334
@ CAIRO_STATUS_FREETYPE_ERROR
Definition: cairo.h:356
@ CAIRO_STATUS_NO_MEMORY
Definition: cairo.h:317
@ CAIRO_STATUS_READ_ERROR
Definition: cairo.h:326
@ CAIRO_STATUS_FONT_TYPE_MISMATCH
Definition: cairo.h:341
@ CAIRO_HINT_METRICS_OFF
Definition: cairo.h:1359
@ CAIRO_ANTIALIAS_SUBPIXEL
Definition: cairo.h:715
@ CAIRO_ANTIALIAS_DEFAULT
Definition: cairo.h:710
@ CAIRO_ANTIALIAS_BEST
Definition: cairo.h:720
@ CAIRO_ANTIALIAS_GOOD
Definition: cairo.h:719
@ CAIRO_ANTIALIAS_FAST
Definition: cairo.h:718
@ CAIRO_ANTIALIAS_NONE
Definition: cairo.h:713
@ CAIRO_ANTIALIAS_GRAY
Definition: cairo.h:714
@ CAIRO_OPERATOR_SOURCE
Definition: cairo.h:616
enum _cairo_status cairo_status_t
@ CAIRO_FONT_TYPE_FT
Definition: cairo.h:1574
enum _cairo_format cairo_format_t
@ CAIRO_FORMAT_A8
Definition: cairo.h:420
@ CAIRO_FORMAT_ARGB32
Definition: cairo.h:418
@ CAIRO_FORMAT_A1
Definition: cairo.h:421
enum _cairo_subpixel_order cairo_subpixel_order_t
@ CAIRO_HINT_STYLE_SLIGHT
Definition: cairo.h:1337
@ CAIRO_HINT_STYLE_DEFAULT
Definition: cairo.h:1335
@ CAIRO_HINT_STYLE_MEDIUM
Definition: cairo.h:1338
@ CAIRO_HINT_STYLE_NONE
Definition: cairo.h:1336
@ CAIRO_HINT_STYLE_FULL
Definition: cairo.h:1339
@ CAIRO_FONT_WEIGHT_BOLD
Definition: cairo.h:1280
@ CAIRO_FONT_WEIGHT_NORMAL
Definition: cairo.h:1279
static cairo_bool_t _cairo_is_little_endian(void)
Definition: cairoint.h:202
enum _cairo_scaled_glyph_info cairo_scaled_glyph_info_t
static int _cairo_isspace(int c)
Definition: cairoint.h:280
#define CAIRO_BITSWAP8(c)
Definition: cairoint.h:178
#define _cairo_debug_check_image_surface_is_defined(X)
Definition: cairoint.h:2125
static int _cairo_lround(double r)
Definition: cairoint.h:767
@ CAIRO_SCALED_GLYPH_INFO_COLOR_SURFACE
Definition: cairoint.h:487
@ CAIRO_SCALED_GLYPH_INFO_PATH
Definition: cairoint.h:485
@ CAIRO_SCALED_GLYPH_INFO_SURFACE
Definition: cairoint.h:484
@ CAIRO_SCALED_GLYPH_INFO_METRICS
Definition: cairoint.h:483
static uint32_t be32_to_cpu(uint32_t v)
Definition: cairoint.h:242
#define _cairo_scaled_glyph_index(g)
Definition: cairoint.h:431
static struct brw_reg stride(struct brw_reg reg, uint32_t vstride, uint32_t width, uint32_t hstride)
void cairo_ft_font_options_substitute(const cairo_font_options_t *options, FcPattern *pattern)
static cairo_status_t _cairo_ft_font_options_substitute(const cairo_font_options_t *options, FcPattern *pattern)
static cairo_status_t _cairo_ft_unscaled_font_create_for_pattern(FcPattern *pattern, cairo_ft_unscaled_font_t **out)
cairo_font_face_t * cairo_ft_font_face_create_for_pattern(FcPattern *pattern)
static cairo_font_face_t * _cairo_ft_font_face_create_for_pattern(FcPattern *pattern)
static cairo_font_face_t * _cairo_ft_resolve_pattern(FcPattern *pattern, const cairo_matrix_t *font_matrix, const cairo_matrix_t *ctm, const cairo_font_options_t *options)
static cairo_status_t _cairo_ft_font_face_create_for_toy(cairo_toy_font_face_t *toy_face, cairo_font_face_t **font_face_out)
static void _get_pattern_ft_options(FcPattern *pattern, cairo_ft_options_t *ret)
@ CAIRO_FT_SYNTHESIZE_OBLIQUE
Definition: cairo-ft.h:80
@ CAIRO_FT_SYNTHESIZE_BOLD
Definition: cairo-ft.h:79
static cairo_int_status_t _cairo_ft_load_type1_data(void *abstract_font, long offset, unsigned char *buffer, unsigned long *length)
static cairo_status_t _get_bitmap_surface(FT_Bitmap *bitmap, FT_Library library, cairo_bool_t own_buffer, cairo_font_options_t *font_options, cairo_image_surface_t **surface)
static cairo_int_status_t _cairo_ft_scaled_glyph_init(void *abstract_font, cairo_scaled_glyph_t *scaled_glyph, cairo_scaled_glyph_info_t info)
static cairo_status_t _transform_glyph_bitmap(cairo_matrix_t *shape, cairo_image_surface_t **surface)
static int _compute_xrender_bitmap_size(FT_Bitmap *target, FT_GlyphSlot slot, FT_Render_Mode mode)
static void _cairo_ft_unscaled_font_init_key(cairo_ft_unscaled_font_t *key, cairo_bool_t from_face, char *filename, int id, FT_Face face)
#define R_OK
Definition: cairo-ft-font.c:73
static void _cairo_ft_unscaled_font_fini(cairo_ft_unscaled_font_t *unscaled)
static cairo_int_status_t _cairo_index_to_glyph_name(void *abstract_font, char **glyph_names, int num_glyph_names, unsigned long glyph_index, unsigned long *glyph_array_index)
static const cairo_unscaled_font_backend_t cairo_ft_unscaled_font_backend
static void cairo_ft_apply_variations(FT_Face face, cairo_ft_scaled_font_t *scaled_font)
#define FT_LCD_FILTER_DEFAULT
Definition: cairo-ft-font.c:91
static cairo_bool_t _ft_is_type1(FT_Face face)
static cairo_ft_unscaled_font_map_t * cairo_ft_unscaled_font_map
static cairo_ft_unscaled_font_map_t * _cairo_ft_unscaled_font_map_lock(void)
static cairo_status_t _render_glyph_bitmap(FT_Face face, cairo_font_options_t *font_options, cairo_image_surface_t **surface)
static cairo_status_t _cairo_ft_unscaled_font_map_create(void)
static cairo_int_status_t _cairo_ft_load_truetype_table(void *abstract_font, unsigned long tag, long offset, unsigned char *buffer, unsigned long *length)
#define DOUBLE_FROM_26_6(t)
Definition: cairo-ft-font.c:96
static cairo_status_t _compute_transform(cairo_ft_font_transform_t *sf, cairo_matrix_t *scale, cairo_ft_unscaled_font_t *unscaled)
static cairo_bool_t _cairo_ft_font_face_destroy(void *abstract_face)
static cairo_bool_t _cairo_ft_unscaled_font_destroy(void *abstract_font)
static cairo_status_t _cairo_ft_unscaled_font_create_from_face(FT_Face face, cairo_ft_unscaled_font_t **out)
static FT_Face _cairo_ft_unscaled_font_lock_face(cairo_ft_unscaled_font_t *unscaled)
static cairo_status_t _ft_to_cairo_error(FT_Error error)
static void _cairo_ft_options_init_copy(cairo_ft_options_t *options, const cairo_ft_options_t *other)
static void _cairo_ft_options_fini(cairo_ft_options_t *options)
static void _cairo_ft_options_merge(cairo_ft_options_t *options, cairo_ft_options_t *other)
static cairo_int_status_t _cairo_ft_is_synthetic(void *abstract_font, cairo_bool_t *is_synthetic)
static cairo_bool_t _cairo_ft_scaled_font_is_vertical(cairo_scaled_font_t *scaled_font)
static const cairo_scaled_font_backend_t _cairo_ft_scaled_font_backend
#define FT_LCD_FILTER_LEGACY
Definition: cairo-ft-font.c:93
static cairo_status_t _cairo_ft_font_face_scaled_font_create(void *abstract_font_face, const cairo_matrix_t *font_matrix, const cairo_matrix_t *ctm, const cairo_font_options_t *options, cairo_scaled_font_t **font_out)
static void _fill_xrender_bitmap(FT_Bitmap *target, FT_GlyphSlot slot, FT_Render_Mode mode, int bgr)
static cairo_bool_t _cairo_ft_has_color_glyphs(void *scaled)
#define FT_LCD_FILTER_LIGHT
Definition: cairo-ft-font.c:92
#define FT_LCD_FILTER_NONE
Definition: cairo-ft-font.c:90
static int _line_to(FT_Vector *to, void *closure)
static cairo_bool_t _has_unlocked_face(const void *entry)
static cairo_status_t _render_glyph_outline(FT_Face face, cairo_font_options_t *font_options, cairo_image_surface_t **surface)
static cairo_status_t _cairo_ft_unscaled_font_init(cairo_ft_unscaled_font_t *unscaled, cairo_bool_t from_face, const char *filename, int id, FT_Face face)
static int _conic_to(FT_Vector *control, FT_Vector *to, void *closure)
#define DOUBLE_TO_16_16(d)
Definition: cairo-ft-font.c:97
static void _cairo_ft_unscaled_font_unlock_face(cairo_ft_unscaled_font_t *unscaled)
static cairo_int_status_t _cairo_ft_scaled_glyph_load_glyph(cairo_ft_scaled_font_t *scaled_font, cairo_scaled_glyph_t *scaled_glyph, FT_Face face, int load_flags, cairo_bool_t use_em_size, cairo_bool_t vertical_layout)
static int _move_to(FT_Vector *to, void *closure)
#define MAX_OPEN_FACES
static cairo_font_face_t * _cairo_ft_font_face_get_implementation(void *abstract_face, const cairo_matrix_t *font_matrix, const cairo_matrix_t *ctm, const cairo_font_options_t *options)
static cairo_status_t _decompose_glyph_outline(FT_Face face, cairo_font_options_t *options, cairo_path_fixed_t **pathp)
static cairo_status_t _cairo_ft_unscaled_font_create_internal(cairo_bool_t from_face, char *filename, int id, FT_Face font_face, cairo_ft_unscaled_font_t **out)
static void _cairo_ft_unscaled_font_map_destroy(void)
static void _cairo_ft_scaled_glyph_vertical_layout_bearing_fix(void *abstract_font, FT_GlyphSlot glyph)
static cairo_font_face_t * _cairo_ft_font_face_create(cairo_ft_unscaled_font_t *unscaled, cairo_ft_options_t *ft_options)
static int _cubic_to(FT_Vector *control1, FT_Vector *control2, FT_Vector *to, void *closure)
static void _font_map_release_face_lock_held(cairo_ft_unscaled_font_map_t *font_map, cairo_ft_unscaled_font_t *unscaled)
static void _cairo_ft_scaled_font_fini(void *abstract_font)
static unsigned long _cairo_ft_ucs4_to_index(void *abstract_font, uint32_t ucs4)
#define DOUBLE_FROM_16_16(t)
Definition: cairo-ft-font.c:98
static cairo_int_status_t _cairo_ft_index_to_ucs4(void *abstract_font, unsigned long index, uint32_t *ucs4)
static void _cairo_ft_unscaled_font_map_pluck_entry(void *entry, void *closure)
#define FC_LCD_FILTER
Definition: cairo-ft-font.c:78
static void _cairo_ft_unscaled_font_map_unlock(void)
static cairo_status_t _cairo_ft_unscaled_font_set_scale(cairo_ft_unscaled_font_t *unscaled, cairo_matrix_t *scale)
static int _cairo_ft_unscaled_font_keys_equal(const void *key_a, const void *key_b)
@ FALSE
Definition: dd.h:101
@ TRUE
Definition: dd.h:102
#define free(a)
Definition: decNumber.cpp:310
#define control
Definition: devnag.c:323
static int id
Definition: bifont.c:66
int v
Definition: dviconv.c:10
int h
Definition: dviconv.c:9
#define skip(p, c)
Definition: ptexmac.h:70
int strcmp()
Definition: coll.cpp:143
#define info
Definition: dviinfo.c:42
#define error(a)
Definition: dviinfo.c:48
struct rect data
Definition: dvipdfm.c:64
int x_max
int y_min
int y_max
int x_min
#define FcPatternGetInteger
Definition: fcalias.h:334
#define FcPatternGetString
Definition: fcalias.h:338
#define FcConfigGetCurrent
Definition: fcalias.h:44
#define FcDefaultSubstitute
Definition: fcalias.h:134
#define FcPatternGet
Definition: fcalias.h:310
#define FcPatternCreate
Definition: fcalias.h:282
#define FcPatternAddString
Definition: fcalias.h:322
#define FcPatternDuplicate
Definition: fcalias.h:284
#define FcPatternAddInteger
Definition: fcalias.h:318
#define FcPatternGetBool
Definition: fcalias.h:344
#define FcConfigSubstitute
Definition: fcalias.h:76
#define FcPatternAddDouble
Definition: fcalias.h:320
#define FcPatternDestroy
Definition: fcalias.h:296
#define FcPatternAddBool
Definition: fcalias.h:328
#define FcFontMatch
Definition: fcalias.h:242
#define FcInitBringUptoDate
Definition: fcalias.h:176
#define FcPatternDel
Definition: fcalias.h:314
#define FcPatternGetFTFace
Definition: fcftalias.h:8
#define FcFreeTypeCharIndex
Definition: fcftalias.h:2
#define FC_WEIGHT_MEDIUM
Definition: fontconfig.h:151
unsigned char FcChar8
Definition: fontconfig.h:43
#define FC_SLANT_ITALIC
Definition: fontconfig.h:163
#define FC_FAMILY
Definition: fontconfig.h:79
#define FC_VERTICAL_LAYOUT
Definition: fontconfig.h:91
#define FC_FILE
Definition: fontconfig.h:96
#define FC_AUTOHINT
Definition: fontconfig.h:92
#define FcFalse
Definition: fontconfig.h:75
#define FC_RGBA
Definition: fontconfig.h:107
#define FC_WEIGHT
Definition: fontconfig.h:82
#define FC_HINTING
Definition: fontconfig.h:89
#define FC_SLANT
Definition: fontconfig.h:81
@ FcMatchPattern
Definition: fontconfig.h:290
enum _FcResult FcResult
#define FC_FT_FACE
Definition: fontconfig.h:98
#define FC_FONT_VARIATIONS
Definition: fontconfig.h:124
#define FC_INDEX
Definition: fontconfig.h:97
#define FC_HINT_STYLE
Definition: fontconfig.h:90
#define FC_SLANT_ROMAN
Definition: fontconfig.h:162
#define FC_PIXEL_SIZE
Definition: fontconfig.h:85
#define FC_SLANT_OBLIQUE
Definition: fontconfig.h:164
#define FcTrue
Definition: fontconfig.h:76
#define FC_EMBEDDED_BITMAP
Definition: fontconfig.h:120
@ FcResultMatch
Definition: fontconfig.h:241
@ FcResultNoMatch
Definition: fontconfig.h:241
@ FcResultOutOfMemory
Definition: fontconfig.h:242
int FcBool
Definition: fontconfig.h:46
#define FC_WEIGHT_BOLD
Definition: fontconfig.h:154
#define FC_EMBOLDEN
Definition: fontconfig.h:119
#define FC_ANTIALIAS
Definition: fontconfig.h:88
char pattern[8]
Definition: gemtopnm.c:50
__gmp_expr< mpf_t, __gmp_unary_expr< __gmp_expr< mpf_t, U >, __gmp_ceil_function > > ceil(const __gmp_expr< mpf_t, U > &expr)
Definition: gmpxx.h:3340
#define d(n)
Definition: gpos-common.c:151
#define strchr
Definition: gsftopk.c:59
#define memcpy(d, s, n)
Definition: gsftopk.c:64
FILE * out
Definition: hbf2gf.c:286
double y_scale
Definition: hbf2gf.c:275
pix
Definition: in_pcx.cpp:383
assert(pcxLoadImage24((char *)((void *) 0), fp, pinfo, hdr))
unsigned char * image
Definition: in_pcx.cpp:323
#define likely(x)
Definition: jbig2arith.cc:115
#define unlikely(x)
Definition: jbig2arith.cc:116
#define MAX(a, b)
Definition: jpegint.h:267
FT_Load_Glyph(FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: ftobjs.c:796
#define FT_LOAD_VERTICAL_LAYOUT
Definition: freetype.h:3026
#define FT_LOAD_TARGET_LCD_V
Definition: freetype.h:3141
#define FT_LOAD_TARGET_MODE(x)
Definition: freetype.h:3154
#define FT_LOAD_NO_BITMAP
Definition: freetype.h:3025
FT_Set_Transform(FT_Face face, FT_Matrix *matrix, FT_Vector *delta)
Definition: ftobjs.c:689
#define FT_LOAD_TARGET_MONO
Definition: freetype.h:3139
FT_New_Face(FT_Library library, const char *filepathname, FT_Long face_index, FT_Face *aface)
Definition: ftobjs.c:1468
#define FT_IS_SFNT(face)
Definition: freetype.h:1290
#define FT_LOAD_TARGET_NORMAL
Definition: freetype.h:3137
#define FT_FACE_FLAG_SCALABLE
Definition: freetype.h:1197
FT_Done_Face(FT_Face face)
Definition: ftobjs.c:2783
FT_Get_First_Char(FT_Face face, FT_UInt *agindex)
Definition: ftobjs.c:3760
enum FT_Render_Mode_ FT_Render_Mode
#define FT_LOAD_NO_HINTING
Definition: freetype.h:3023
FT_Get_Char_Index(FT_Face face, FT_ULong charcode)
Definition: ftobjs.c:3731
#define FT_LOAD_TARGET_(x)
Definition: freetype.h:3135
#define FT_LOAD_FORCE_AUTOHINT
Definition: freetype.h:3027
#define FT_LOAD_MONOCHROME
Definition: freetype.h:3033
#define FT_LOAD_DEFAULT
Definition: freetype.h:3021
FT_Get_Next_Char(FT_Face face, FT_ULong char_code, FT_UInt *agindex)
Definition: ftobjs.c:3785
#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH
Definition: freetype.h:3030
FT_Vector_Transform(FT_Vector *vector, const FT_Matrix *matrix)
Definition: ftoutln.c:683
FT_Get_Glyph_Name(FT_Face face, FT_UInt glyph_index, FT_Pointer buffer, FT_UInt buffer_max)
Definition: ftobjs.c:4110
FT_Render_Glyph(FT_GlyphSlot slot, FT_Render_Mode render_mode)
Definition: ftobjs.c:4796
#define FT_LOAD_TARGET_LCD
Definition: freetype.h:3140
#define FT_HAS_COLOR(face)
Definition: freetype.h:1449
FT_Done_FreeType(FT_Library library)
Definition: ftinit.c:235
#define FT_FACE_FLAG_MULTIPLE_MASTERS
Definition: freetype.h:1205
@ FT_RENDER_MODE_MONO
Definition: freetype.h:3251
@ FT_RENDER_MODE_NORMAL
Definition: freetype.h:3249
@ FT_RENDER_MODE_LIGHT
Definition: freetype.h:3250
@ FT_RENDER_MODE_MAX
Definition: freetype.h:3255
@ FT_RENDER_MODE_LCD_V
Definition: freetype.h:3253
@ FT_RENDER_MODE_LCD
Definition: freetype.h:3252
#define FT_LOAD_TARGET_LIGHT
Definition: freetype.h:3138
FT_Set_Char_Size(FT_Face face, FT_F26Dot6 char_width, FT_F26Dot6 char_height, FT_UInt horz_resolution, FT_UInt vert_resolution)
Definition: ftobjs.c:3331
#define FT_LOAD_COLOR
Definition: freetype.h:3037
FT_Init_FreeType(FT_Library *alibrary)
Definition: ftinit.c:199
FT_Bitmap_Convert(FT_Library library, const FT_Bitmap *source, FT_Bitmap *target, FT_Int alignment)
Definition: ftbitmap.c:515
FT_Bitmap_New(FT_Bitmap *abitmap)
Definition: ftbitmap.c:53
FT_Bitmap_Done(FT_Library library, FT_Bitmap *bitmap)
Definition: ftbitmap.c:1155
FT_Get_X11_Font_Format(FT_Face face)
Definition: ftfntfmt.c:42
int(* FT_Outline_ConicToFunc)(const FT_Vector *control, const FT_Vector *to, void *user)
Definition: ftimage.h:571
@ FT_PIXEL_MODE_GRAY2
Definition: ftimage.h:185
@ FT_PIXEL_MODE_LCD_V
Definition: ftimage.h:188
@ FT_PIXEL_MODE_MONO
Definition: ftimage.h:183
@ FT_PIXEL_MODE_GRAY
Definition: ftimage.h:184
@ FT_PIXEL_MODE_LCD
Definition: ftimage.h:187
@ FT_PIXEL_MODE_BGRA
Definition: ftimage.h:189
@ FT_PIXEL_MODE_GRAY4
Definition: ftimage.h:186
int(* FT_Outline_LineToFunc)(const FT_Vector *to, void *user)
Definition: ftimage.h:537
@ FT_GLYPH_FORMAT_OUTLINE
Definition: ftimage.h:749
@ FT_GLYPH_FORMAT_BITMAP
Definition: ftimage.h:748
int(* FT_Outline_CubicToFunc)(const FT_Vector *control1, const FT_Vector *control2, const FT_Vector *to, void *user)
Definition: ftimage.h:607
int(* FT_Outline_MoveToFunc)(const FT_Vector *to, void *user)
Definition: ftimage.h:508
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:57
FT_Library_SetLcdFilter(FT_Library library, FT_LcdFilter filter)
Definition: ftlcdfil.c:407
FT_Get_Var_Blend_Coordinates(FT_Face face, FT_UInt num_coords, FT_Fixed *coords)
Definition: ftmm.c:471
FT_Set_Var_Design_Coordinates(FT_Face face, FT_UInt num_coords, FT_Fixed *coords)
Definition: ftmm.c:265
FT_Get_Var_Design_Coordinates(FT_Face face, FT_UInt num_coords, FT_Fixed *coords)
Definition: ftmm.c:313
FT_Done_MM_Var(FT_Library library, FT_MM_Var *amaster)
Definition: ftmm.c:150
FT_Get_MM_Var(FT_Face face, FT_MM_Var **amaster)
Definition: ftmm.c:123
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
Definition: ftoutln.c:507
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
Definition: ftoutln.c:706
FT_BEGIN_HEADER FT_Outline_Decompose(FT_Outline *outline, const FT_Outline_Funcs *func_interface, void *user)
Definition: ftoutln.c:43
FT_Outline_Get_CBox(const FT_Outline *outline, FT_BBox *acbox)
Definition: ftoutln.c:457
FT_BEGIN_HEADER FT_GlyphSlot_Embolden(FT_GlyphSlot slot)
Definition: ftsynth.c:89
FT_GlyphSlot_Oblique(FT_GlyphSlot slot)
Definition: ftsynth.c:47
unsigned long FT_ULong
Definition: fttypes.h:253
unsigned char FT_Byte
Definition: fttypes.h:154
signed long FT_Fixed
Definition: fttypes.h:287
int FT_Error
Definition: fttypes.h:299
unsigned int FT_UInt
Definition: fttypes.h:231
#define FT_MAKE_TAG(_x1, _x2, _x3, _x4)
Definition: fttypes.h:488
signed int FT_Int
Definition: fttypes.h:220
#define NULL
Definition: ftobjs.h:61
FT_Load_Sfnt_Table(FT_Face face, FT_ULong tag, FT_Long offset, FT_Byte *buffer, FT_ULong *length)
Definition: ftobjs.c:4197
small capitals from c petite p
Definition: afcover.h:72
small capitals from c petite p scientific i
Definition: afcover.h:80
sizeof(AF_ModuleRec)
return FT_Err_Ok
Definition: ftbbox.c:526
FT_Face face
Definition: cffdrivr.c:659
FT_Library library
Definition: cffdrivr.c:660
#define DONE
Definition: inflate.c:9
#define LOAD
Definition: infutil.h:85