diff options
| author | Kenichi Handa | 2008-07-09 07:38:55 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2008-07-09 07:38:55 +0000 |
| commit | 41fa3e2c20c5f64470b41df18fd7a9cf5dd0c7c9 (patch) | |
| tree | 2150c1154f7c1b2d6b5fa604699b7e38165b1cf3 | |
| parent | e5d059785625b81a635990f298667f51db41d2aa (diff) | |
| download | emacs-41fa3e2c20c5f64470b41df18fd7a9cf5dd0c7c9.tar.gz emacs-41fa3e2c20c5f64470b41df18fd7a9cf5dd0c7c9.zip | |
(xfont_text_extents): Fix initial setting of metrics.
| -rw-r--r-- | src/xfont.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/xfont.c b/src/xfont.c index 6d529c9b54a..92370d4b15d 100644 --- a/src/xfont.c +++ b/src/xfont.c | |||
| @@ -728,11 +728,11 @@ xfont_text_extents (font, code, nglyphs, metrics) | |||
| 728 | { | 728 | { |
| 729 | XFontStruct *xfont = ((struct xfont_info *) font)->xfont; | 729 | XFontStruct *xfont = ((struct xfont_info *) font)->xfont; |
| 730 | int width = 0; | 730 | int width = 0; |
| 731 | int i, x; | 731 | int i, first, x; |
| 732 | 732 | ||
| 733 | if (metrics) | 733 | if (metrics) |
| 734 | bzero (metrics, sizeof (struct font_metrics)); | 734 | bzero (metrics, sizeof (struct font_metrics)); |
| 735 | for (i = 0, x = 0; i < nglyphs; i++) | 735 | for (i = 0, x = 0, first = 1; i < nglyphs; i++) |
| 736 | { | 736 | { |
| 737 | XChar2b char2b; | 737 | XChar2b char2b; |
| 738 | static XCharStruct *pcm; | 738 | static XCharStruct *pcm; |
| @@ -743,14 +743,31 @@ xfont_text_extents (font, code, nglyphs, metrics) | |||
| 743 | pcm = xfont_get_pcm (xfont, &char2b); | 743 | pcm = xfont_get_pcm (xfont, &char2b); |
| 744 | if (! pcm) | 744 | if (! pcm) |
| 745 | continue; | 745 | continue; |
| 746 | if (metrics->lbearing > width + pcm->lbearing) | 746 | if (first) |
| 747 | metrics->lbearing = width + pcm->lbearing; | 747 | { |
| 748 | if (metrics->rbearing < width + pcm->rbearing) | 748 | if (metrics) |
| 749 | metrics->rbearing = width + pcm->rbearing; | 749 | { |
| 750 | if (metrics->ascent < pcm->ascent) | 750 | metrics->lbearing = pcm->lbearing; |
| 751 | metrics->ascent = pcm->ascent; | 751 | metrics->rbearing = pcm->rbearing; |
| 752 | if (metrics->descent < pcm->descent) | 752 | metrics->ascent = pcm->ascent; |
| 753 | metrics->descent = pcm->descent; | 753 | metrics->descent = pcm->descent; |
| 754 | } | ||
| 755 | first = 0; | ||
| 756 | } | ||
| 757 | else | ||
| 758 | { | ||
| 759 | if (metrics) | ||
| 760 | { | ||
| 761 | if (metrics->lbearing > width + pcm->lbearing) | ||
| 762 | metrics->lbearing = width + pcm->lbearing; | ||
| 763 | if (metrics->rbearing < width + pcm->rbearing) | ||
| 764 | metrics->rbearing = width + pcm->rbearing; | ||
| 765 | if (metrics->ascent < pcm->ascent) | ||
| 766 | metrics->ascent = pcm->ascent; | ||
| 767 | if (metrics->descent < pcm->descent) | ||
| 768 | metrics->descent = pcm->descent; | ||
| 769 | } | ||
| 770 | } | ||
| 754 | width += pcm->width; | 771 | width += pcm->width; |
| 755 | } | 772 | } |
| 756 | if (metrics) | 773 | if (metrics) |