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

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

Issue 2858683002: Roll HarfBuzz to 1.4.6 (Closed)
Patch Set: Rebase Created 3 years, 7 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 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 0, /* x_ppem */ 1189 0, /* x_ppem */
1190 0, /* y_ppem */ 1190 0, /* y_ppem */
1191 1191
1192 0, /* num_coords */ 1192 0, /* num_coords */
1193 NULL, /* coords */ 1193 NULL, /* coords */
1194 1194
1195 const_cast<hb_font_funcs_t *> (&_hb_font_funcs_nil), /* klass */ 1195 const_cast<hb_font_funcs_t *> (&_hb_font_funcs_nil), /* klass */
1196 NULL, /* user_data */ 1196 NULL, /* user_data */
1197 NULL, /* destroy */ 1197 NULL, /* destroy */
1198 1198
1199 hb_font_t::NOTHING, /* dirty */
1200
1199 { 1201 {
1200 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, 1202 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID,
1201 #include "hb-shaper-list.hh" 1203 #include "hb-shaper-list.hh"
1202 #undef HB_SHAPER_IMPLEMENT 1204 #undef HB_SHAPER_IMPLEMENT
1203 } 1205 }
1204 }; 1206 };
1205 1207
1206 return const_cast<hb_font_t *> (&_hb_font_nil); 1208 return const_cast<hb_font_t *> (&_hb_font_nil);
1207 } 1209 }
1208 1210
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 void 1343 void
1342 hb_font_set_parent (hb_font_t *font, 1344 hb_font_set_parent (hb_font_t *font,
1343 hb_font_t *parent) 1345 hb_font_t *parent)
1344 { 1346 {
1345 if (font->immutable) 1347 if (font->immutable)
1346 return; 1348 return;
1347 1349
1348 if (!parent) 1350 if (!parent)
1349 parent = hb_font_get_empty (); 1351 parent = hb_font_get_empty ();
1350 1352
1353 if (parent == font->parent)
1354 return;
1355
1356 font->dirty |= font->PARENT;
1357
1351 hb_font_t *old = font->parent; 1358 hb_font_t *old = font->parent;
1352 1359
1353 font->parent = hb_font_reference (parent); 1360 font->parent = hb_font_reference (parent);
1354 1361
1355 hb_font_destroy (old); 1362 hb_font_destroy (old);
1356 } 1363 }
1357 1364
1358 /** 1365 /**
1359 * hb_font_get_parent: 1366 * hb_font_get_parent:
1360 * @font: a font. 1367 * @font: a font.
1361 * 1368 *
1362 * 1369 *
1363 * 1370 *
1364 * Return value: (transfer none): 1371 * Return value: (transfer none):
1365 * 1372 *
1366 * Since: 0.9.2 1373 * Since: 0.9.2
1367 **/ 1374 **/
1368 hb_font_t * 1375 hb_font_t *
1369 hb_font_get_parent (hb_font_t *font) 1376 hb_font_get_parent (hb_font_t *font)
1370 { 1377 {
1371 return font->parent; 1378 return font->parent;
1372 } 1379 }
1373 1380
1374 /** 1381 /**
1382 * hb_font_set_face:
1383 * @font: a font.
1384 * @face: new face.
1385 *
1386 * Sets font-face of @font.
1387 *
1388 * Since: 1.4.3
1389 **/
1390 void
1391 hb_font_set_face (hb_font_t *font,
1392 hb_face_t *face)
1393 {
1394 if (font->immutable)
1395 return;
1396
1397 if (unlikely (!face))
1398 face = hb_face_get_empty ();
1399
1400 if (font->face == face)
1401 return;
1402
1403 font->dirty |= font->FACE;
1404
1405 hb_face_t *old = font->face;
1406
1407 font->face = hb_face_reference (face);
1408
1409 hb_face_destroy (old);
1410 }
1411
1412 /**
1375 * hb_font_get_face: 1413 * hb_font_get_face:
1376 * @font: a font. 1414 * @font: a font.
1377 * 1415 *
1378 * 1416 *
1379 * 1417 *
1380 * Return value: (transfer none): 1418 * Return value: (transfer none):
1381 * 1419 *
1382 * Since: 0.9.2 1420 * Since: 0.9.2
1383 **/ 1421 **/
1384 hb_face_t * 1422 hb_face_t *
(...skipping 25 matching lines...) Expand all
1410 destroy (font_data); 1448 destroy (font_data);
1411 return; 1449 return;
1412 } 1450 }
1413 1451
1414 if (font->destroy) 1452 if (font->destroy)
1415 font->destroy (font->user_data); 1453 font->destroy (font->user_data);
1416 1454
1417 if (!klass) 1455 if (!klass)
1418 klass = hb_font_funcs_get_empty (); 1456 klass = hb_font_funcs_get_empty ();
1419 1457
1458 font->dirty |= font->FUNCS;
1459
1420 hb_font_funcs_reference (klass); 1460 hb_font_funcs_reference (klass);
1421 hb_font_funcs_destroy (font->klass); 1461 hb_font_funcs_destroy (font->klass);
1422 font->klass = klass; 1462 font->klass = klass;
1423 font->user_data = font_data; 1463 font->user_data = font_data;
1424 font->destroy = destroy; 1464 font->destroy = destroy;
1425 } 1465 }
1426 1466
1427 /** 1467 /**
1428 * hb_font_set_funcs_data: 1468 * hb_font_set_funcs_data:
1429 * @font: a font. 1469 * @font: a font.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 * Since: 0.9.2 1505 * Since: 0.9.2
1466 **/ 1506 **/
1467 void 1507 void
1468 hb_font_set_scale (hb_font_t *font, 1508 hb_font_set_scale (hb_font_t *font,
1469 int x_scale, 1509 int x_scale,
1470 int y_scale) 1510 int y_scale)
1471 { 1511 {
1472 if (font->immutable) 1512 if (font->immutable)
1473 return; 1513 return;
1474 1514
1515 if (font->x_scale == x_scale && font->y_scale == y_scale)
1516 return;
1517
1518 font->dirty |= font->SCALE;
1519
1475 font->x_scale = x_scale; 1520 font->x_scale = x_scale;
1476 font->y_scale = y_scale; 1521 font->y_scale = y_scale;
1477 } 1522 }
1478 1523
1479 /** 1524 /**
1480 * hb_font_get_scale: 1525 * hb_font_get_scale:
1481 * @font: a font. 1526 * @font: a font.
1482 * @x_scale: (out): 1527 * @x_scale: (out):
1483 * @y_scale: (out): 1528 * @y_scale: (out):
1484 * 1529 *
(...skipping 21 matching lines...) Expand all
1506 * Since: 0.9.2 1551 * Since: 0.9.2
1507 **/ 1552 **/
1508 void 1553 void
1509 hb_font_set_ppem (hb_font_t *font, 1554 hb_font_set_ppem (hb_font_t *font,
1510 unsigned int x_ppem, 1555 unsigned int x_ppem,
1511 unsigned int y_ppem) 1556 unsigned int y_ppem)
1512 { 1557 {
1513 if (font->immutable) 1558 if (font->immutable)
1514 return; 1559 return;
1515 1560
1561 if (font->x_ppem == x_ppem && font->y_ppem == y_ppem)
1562 return;
1563
1564 font->dirty |= font->PPEM;
1565
1516 font->x_ppem = x_ppem; 1566 font->x_ppem = x_ppem;
1517 font->y_ppem = y_ppem; 1567 font->y_ppem = y_ppem;
1518 } 1568 }
1519 1569
1520 /** 1570 /**
1521 * hb_font_get_ppem: 1571 * hb_font_get_ppem:
1522 * @font: a font. 1572 * @font: a font.
1523 * @x_ppem: (out): 1573 * @x_ppem: (out):
1524 * @y_ppem: (out): 1574 * @y_ppem: (out):
1525 * 1575 *
(...skipping 12 matching lines...) Expand all
1538 1588
1539 /* 1589 /*
1540 * Variations 1590 * Variations
1541 */ 1591 */
1542 1592
1543 static void 1593 static void
1544 _hb_font_adopt_var_coords_normalized (hb_font_t *font, 1594 _hb_font_adopt_var_coords_normalized (hb_font_t *font,
1545 int *coords, /* 2.14 normalized */ 1595 int *coords, /* 2.14 normalized */
1546 unsigned int coords_length) 1596 unsigned int coords_length)
1547 { 1597 {
1598 if (font->num_coords == coords_length &&
1599 (coords_length == 0 ||
1600 0 == memcmp (font->coords, coords, coords_length * sizeof (coords[0]))))
1601 {
1602 free (coords);
1603 return;
1604 }
1605
1606 font->dirty |= font->VARIATIONS;
1607
1548 free (font->coords); 1608 free (font->coords);
1549 1609
1550 font->coords = coords; 1610 font->coords = coords;
1551 font->num_coords = coords_length; 1611 font->num_coords = coords_length;
1552 } 1612 }
1553 1613
1554 /** 1614 /**
1555 * hb_font_set_variations: 1615 * hb_font_set_variations:
1556 * 1616 *
1557 * Since: 1.4.2 1617 * Since: 1.4.2
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 if (unlikely (coords_length && !copy)) 1680 if (unlikely (coords_length && !copy))
1621 return; 1681 return;
1622 1682
1623 if (coords_length) 1683 if (coords_length)
1624 memcpy (copy, coords, coords_length * sizeof (coords[0])); 1684 memcpy (copy, coords, coords_length * sizeof (coords[0]));
1625 1685
1626 _hb_font_adopt_var_coords_normalized (font, copy, coords_length); 1686 _hb_font_adopt_var_coords_normalized (font, copy, coords_length);
1627 } 1687 }
1628 1688
1629 /** 1689 /**
1630 * hb_font_set_var_coords_normalized: 1690 * hb_font_get_var_coords_normalized:
1631 * 1691 *
1632 * Return value is valid as long as variation coordinates of the font 1692 * Return value is valid as long as variation coordinates of the font
1633 * are not modified. 1693 * are not modified.
1634 * 1694 *
1635 * Since: 1.4.2 1695 * Since: 1.4.2
1636 */ 1696 */
1637 const int * 1697 const int *
1638 hb_font_get_var_coords_normalized (hb_font_t *font, 1698 hb_font_get_var_coords_normalized (hb_font_t *font,
1639 unsigned int *length) 1699 unsigned int *length)
1640 { 1700 {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 trampoline_destroy); 1824 trampoline_destroy);
1765 1825
1766 trampoline_reference (&trampoline->closure); 1826 trampoline_reference (&trampoline->closure);
1767 hb_font_funcs_set_variation_glyph_func (ffuncs, 1827 hb_font_funcs_set_variation_glyph_func (ffuncs,
1768 hb_font_get_variation_glyph_trampoline , 1828 hb_font_get_variation_glyph_trampoline ,
1769 trampoline, 1829 trampoline,
1770 trampoline_destroy); 1830 trampoline_destroy);
1771 } 1831 }
1772 1832
1773 #endif /* HB_DISABLE_DEPRECATED */ 1833 #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