From: Po Lu Date: Sun, 9 Jan 2022 03:24:44 +0000 (+0000) Subject: Fix some problems with Haiku font display X-Git-Tag: emacs-29.0.90~3189 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8aad4cee326dff4c63b05eaf290c34a397067b93;p=emacs.git Fix some problems with Haiku font display * src/haiku_font_support.cc (BFont_char_bounds): Fix rounding errors. (BFont_open_pattern): Set size before setting family and style. --- diff --git a/src/haiku_font_support.cc b/src/haiku_font_support.cc index 6ea10b2e47c..e6d21c28fe5 100644 --- a/src/haiku_font_support.cc +++ b/src/haiku_font_support.cc @@ -159,9 +159,9 @@ BFont_char_bounds (void *font, const char *mb_str, int *advance, ft->GetEdges (mb_str, 1, &edge_info); ft->GetEscapements (mb_str, 1, &escapement); - *advance = std::ceil (escapement * size); - *lb = std::ceil (edge_info.left * size); - *rb = *advance + std::ceil (edge_info.right * size); + *advance = std::lrint (escapement * size); + *lb = std::lrint (edge_info.left * size); + *rb = *advance + std::lrint (edge_info.right * size); } /* The same, but for a variable amount of chars. */ @@ -534,14 +534,15 @@ BFont_open_pattern (struct haiku_font_pattern *pat, void **font, float size) font_family_style_matches_p (name, NULL, flags, pat, 1)) { BFont *ft = new BFont; + ft->SetSize (size); + ft->SetEncoding (B_UNICODE_UTF8); + ft->SetSpacing (B_BITMAP_SPACING); + if (ft->SetFamilyAndStyle (name, NULL) != B_OK) { delete ft; return 1; } - ft->SetSize (size); - ft->SetEncoding (B_UNICODE_UTF8); - ft->SetSpacing (B_BITMAP_SPACING); *font = (void *) ft; return 0; } @@ -553,14 +554,15 @@ BFont_open_pattern (struct haiku_font_pattern *pat, void **font, float size) font_family_style_matches_p (name, (char *) &sname, flags, pat)) { BFont *ft = new BFont; + ft->SetSize (size); + ft->SetEncoding (B_UNICODE_UTF8); + ft->SetSpacing (B_BITMAP_SPACING); + if (ft->SetFamilyAndStyle (name, sname) != B_OK) { delete ft; return 1; } - ft->SetSize (size); - ft->SetEncoding (B_UNICODE_UTF8); - ft->SetSpacing (B_BITMAP_SPACING); *font = (void *) ft; return 0; }