Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: third_party/harfbuzz-ng/src/hb-font.cc

Issue 1867053004: Roll HarfBuzz to 1.2.6 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Roll to 1.2.6 instead Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-font.h ('k') | third_party/harfbuzz-ng/src/hb-font-private.hh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright © 2009 Red Hat, Inc. 2 * Copyright © 2009 Red Hat, Inc.
3 * Copyright © 2012 Google, Inc. 3 * Copyright © 2012 Google, Inc.
4 * 4 *
5 * This is part of HarfBuzz, a text shaping library. 5 * This is part of HarfBuzz, a text shaping library.
6 * 6 *
7 * Permission is hereby granted, without written agreement and without 7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this 8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the 9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in 10 * above copyright notice and the following two paragraphs appear in
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 hb_bool_t ret = font->parent->get_font_v_extents (metrics); 86 hb_bool_t ret = font->parent->get_font_v_extents (metrics);
87 if (ret) { 87 if (ret) {
88 metrics->ascender = font->parent_scale_x_distance (metrics->ascender); 88 metrics->ascender = font->parent_scale_x_distance (metrics->ascender);
89 metrics->descender = font->parent_scale_x_distance (metrics->descender); 89 metrics->descender = font->parent_scale_x_distance (metrics->descender);
90 metrics->line_gap = font->parent_scale_x_distance (metrics->line_gap); 90 metrics->line_gap = font->parent_scale_x_distance (metrics->line_gap);
91 } 91 }
92 return ret; 92 return ret;
93 } 93 }
94 94
95 static hb_bool_t 95 static hb_bool_t
96 hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED, 96 hb_font_get_nominal_glyph_nil (hb_font_t *font HB_UNUSED,
97 » » void *font_data HB_UNUSED, 97 » » » void *font_data HB_UNUSED,
98 » » hb_codepoint_t unicode, 98 » » » hb_codepoint_t unicode,
99 » » hb_codepoint_t variation_selector, 99 » » » hb_codepoint_t *glyph,
100 » » hb_codepoint_t *glyph, 100 » » » void *user_data HB_UNUSED)
101 » » void *user_data HB_UNUSED)
102 { 101 {
103 *glyph = 0; 102 *glyph = 0;
104 return false; 103 return false;
105 } 104 }
106 static hb_bool_t 105 static hb_bool_t
107 hb_font_get_glyph_parent (hb_font_t *font, 106 hb_font_get_nominal_glyph_parent (hb_font_t *font,
108 » » » void *font_data HB_UNUSED, 107 » » » » void *font_data HB_UNUSED,
109 » » » hb_codepoint_t unicode, 108 » » » » hb_codepoint_t unicode,
110 » » » hb_codepoint_t variation_selector, 109 » » » » hb_codepoint_t *glyph,
111 » » » hb_codepoint_t *glyph, 110 » » » » void *user_data HB_UNUSED)
112 » » » void *user_data HB_UNUSED)
113 { 111 {
114 return font->parent->get_glyph (unicode, variation_selector, glyph); 112 return font->parent->get_nominal_glyph (unicode, glyph);
115 } 113 }
116 114
115 static hb_bool_t
116 hb_font_get_variation_glyph_nil (hb_font_t *font HB_UNUSED,
117 void *font_data HB_UNUSED,
118 hb_codepoint_t unicode,
119 hb_codepoint_t variation_selector,
120 hb_codepoint_t *glyph,
121 void *user_data HB_UNUSED)
122 {
123 *glyph = 0;
124 return false;
125 }
126 static hb_bool_t
127 hb_font_get_variation_glyph_parent (hb_font_t *font,
128 void *font_data HB_UNUSED,
129 hb_codepoint_t unicode,
130 hb_codepoint_t variation_selector,
131 hb_codepoint_t *glyph,
132 void *user_data HB_UNUSED)
133 {
134 return font->parent->get_variation_glyph (unicode, variation_selector, glyph);
135 }
136
137
117 static hb_position_t 138 static hb_position_t
118 hb_font_get_glyph_h_advance_nil (hb_font_t *font HB_UNUSED, 139 hb_font_get_glyph_h_advance_nil (hb_font_t *font HB_UNUSED,
119 void *font_data HB_UNUSED, 140 void *font_data HB_UNUSED,
120 hb_codepoint_t glyph, 141 hb_codepoint_t glyph,
121 void *user_data HB_UNUSED) 142 void *user_data HB_UNUSED)
122 { 143 {
123 return font->x_scale; 144 return font->x_scale;
124 } 145 }
125 static hb_position_t 146 static hb_position_t
126 hb_font_get_glyph_h_advance_parent (hb_font_t *font, 147 hb_font_get_glyph_h_advance_parent (hb_font_t *font,
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 * 636 *
616 * Return value: 637 * Return value:
617 * 638 *
618 * Since: 0.9.2 639 * Since: 0.9.2
619 **/ 640 **/
620 hb_bool_t 641 hb_bool_t
621 hb_font_get_glyph (hb_font_t *font, 642 hb_font_get_glyph (hb_font_t *font,
622 hb_codepoint_t unicode, hb_codepoint_t variation_selector, 643 hb_codepoint_t unicode, hb_codepoint_t variation_selector,
623 hb_codepoint_t *glyph) 644 hb_codepoint_t *glyph)
624 { 645 {
625 return font->get_glyph (unicode, variation_selector, glyph); 646 if (unlikely (variation_selector))
647 return font->get_variation_glyph (unicode, variation_selector, glyph);
648 return font->get_nominal_glyph (unicode, glyph);
626 } 649 }
627 650
628 /** 651 /**
652 * hb_font_get_nominal_glyph:
653 * @font: a font.
654 * @unicode:
655 * @glyph: (out):
656 *
657 *
658 *
659 * Return value:
660 *
661 * Since: 1.2.3
662 **/
663 hb_bool_t
664 hb_font_get_nominal_glyph (hb_font_t *font,
665 hb_codepoint_t unicode,
666 hb_codepoint_t *glyph)
667 {
668 return font->get_nominal_glyph (unicode, glyph);
669 }
670
671 /**
672 * hb_font_get_variation_glyph:
673 * @font: a font.
674 * @unicode:
675 * @variation_selector:
676 * @glyph: (out):
677 *
678 *
679 *
680 * Return value:
681 *
682 * Since: 1.2.3
683 **/
684 hb_bool_t
685 hb_font_get_variation_glyph (hb_font_t *font,
686 hb_codepoint_t unicode, hb_codepoint_t variation_se lector,
687 hb_codepoint_t *glyph)
688 {
689 return font->get_variation_glyph (unicode, variation_selector, glyph);
690 }
691
692 /**
629 * hb_font_get_glyph_h_advance: 693 * hb_font_get_glyph_h_advance:
630 * @font: a font. 694 * @font: a font.
631 * @glyph: 695 * @glyph:
632 * 696 *
633 * 697 *
634 * 698 *
635 * Return value: 699 * Return value:
636 * 700 *
637 * Since: 0.9.2 701 * Since: 0.9.2
638 **/ 702 **/
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 * Since: 0.9.2 1529 * Since: 0.9.2
1466 **/ 1530 **/
1467 void 1531 void
1468 hb_font_get_ppem (hb_font_t *font, 1532 hb_font_get_ppem (hb_font_t *font,
1469 unsigned int *x_ppem, 1533 unsigned int *x_ppem,
1470 unsigned int *y_ppem) 1534 unsigned int *y_ppem)
1471 { 1535 {
1472 if (x_ppem) *x_ppem = font->x_ppem; 1536 if (x_ppem) *x_ppem = font->x_ppem;
1473 if (y_ppem) *y_ppem = font->y_ppem; 1537 if (y_ppem) *y_ppem = font->y_ppem;
1474 } 1538 }
1539
1540
1541 #ifndef HB_DISABLE_DEPRECATED
1542
1543 /*
1544 * Deprecated get_glyph_func():
1545 */
1546
1547 struct hb_trampoline_closure_t
1548 {
1549 void *user_data;
1550 hb_destroy_func_t destroy;
1551 unsigned int ref_count;
1552 };
1553
1554 template <typename FuncType>
1555 struct hb_trampoline_t
1556 {
1557 hb_trampoline_closure_t closure; /* Must be first. */
1558 FuncType func;
1559 };
1560
1561 template <typename FuncType>
1562 static hb_trampoline_t<FuncType> *
1563 trampoline_create (FuncType func,
1564 void *user_data,
1565 hb_destroy_func_t destroy)
1566 {
1567 typedef hb_trampoline_t<FuncType> trampoline_t;
1568
1569 trampoline_t *trampoline = (trampoline_t *) calloc (1, sizeof (trampoline_t));
1570
1571 if (unlikely (!trampoline))
1572 return NULL;
1573
1574 trampoline->closure.user_data = user_data;
1575 trampoline->closure.destroy = destroy;
1576 trampoline->closure.ref_count = 1;
1577 trampoline->func = func;
1578
1579 return trampoline;
1580 }
1581
1582 static void
1583 trampoline_reference (hb_trampoline_closure_t *closure)
1584 {
1585 closure->ref_count++;
1586 }
1587
1588 static void
1589 trampoline_destroy (void *user_data)
1590 {
1591 hb_trampoline_closure_t *closure = (hb_trampoline_closure_t *) user_data;
1592
1593 if (--closure->ref_count)
1594 return;
1595
1596 if (closure->destroy)
1597 closure->destroy (closure->user_data);
1598 free (closure);
1599 }
1600
1601 typedef hb_trampoline_t<hb_font_get_glyph_func_t> hb_font_get_glyph_trampoline_t ;
1602
1603 static hb_bool_t
1604 hb_font_get_nominal_glyph_trampoline (hb_font_t *font,
1605 void *font_data,
1606 hb_codepoint_t unicode,
1607 hb_codepoint_t *glyph,
1608 void *user_data)
1609 {
1610 hb_font_get_glyph_trampoline_t *trampoline = (hb_font_get_glyph_trampoline_t * ) user_data;
1611 return trampoline->func (font, font_data, unicode, 0, glyph, trampoline->closu re.user_data);
1612 }
1613
1614 static hb_bool_t
1615 hb_font_get_variation_glyph_trampoline (hb_font_t *font,
1616 void *font_data,
1617 hb_codepoint_t unicode,
1618 hb_codepoint_t variation_selector,
1619 hb_codepoint_t *glyph,
1620 void *user_data)
1621 {
1622 hb_font_get_glyph_trampoline_t *trampoline = (hb_font_get_glyph_trampoline_t * ) user_data;
1623 return trampoline->func (font, font_data, unicode, variation_selector, glyph, trampoline->closure.user_data);
1624 }
1625
1626 /**
1627 * hb_font_funcs_set_glyph_func:
1628 * @ffuncs: font functions.
1629 * @func: (closure user_data) (destroy destroy) (scope notified):
1630 * @user_data:
1631 * @destroy:
1632 *
1633 * Deprecated. Use hb_font_funcs_set_nominal_glyph_func() and
1634 * hb_font_funcs_set_variation_glyph_func() instead.
1635 *
1636 * Since: 0.9.2
1637 * Deprecated: 1.2.3
1638 **/
1639 void
1640 hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
1641 hb_font_get_glyph_func_t func,
1642 void *user_data, hb_destroy_func_t destroy)
1643 {
1644 hb_font_get_glyph_trampoline_t *trampoline;
1645
1646 trampoline = trampoline_create (func, user_data, destroy);
1647 if (unlikely (!trampoline))
1648 {
1649 if (destroy)
1650 destroy (user_data);
1651 return;
1652 }
1653
1654 hb_font_funcs_set_nominal_glyph_func (ffuncs,
1655 hb_font_get_nominal_glyph_trampoline,
1656 trampoline,
1657 trampoline_destroy);
1658
1659 trampoline_reference (&trampoline->closure);
1660 hb_font_funcs_set_variation_glyph_func (ffuncs,
1661 hb_font_get_variation_glyph_trampoline ,
1662 trampoline,
1663 trampoline_destroy);
1664 }
1665
1666 #endif /* HB_DISABLE_DEPRECATED */
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-font.h ('k') | third_party/harfbuzz-ng/src/hb-font-private.hh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698