ServerFont: keep style if possible when setting face flags

The current style probably has the correct style flags portion. Getting
a new style in that case is unnecessary, and problematic with some font
families that have several fonts mapping to the same style flag
(SemiBold, Bold and ExtraBold are all B_BOLD_FACE, for example): the
chosen one might be different than the one already set.

Fixes #17229

Change-Id: Ie8e73627cc0547df9d624a8fac07f521fc983d06
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4416
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
(cherry picked from commit 910ebfc4f5)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4896
Reviewed-by: Máximo Castañeda <antiswen@yahoo.es>
This commit is contained in:
Máximo Castañeda 2021-09-02 19:32:22 +02:00 committed by Adrien Destugues
parent c8394c8111
commit 7e242ef503

View File

@ -311,6 +311,11 @@ ServerFont::SetFace(uint16 face)
// FontStyle class takes care of mapping the font style name to the Be
// API face flags in FontStyle::_TranslateStyleToFace().
if (fStyle->PreservedFace(face) == face) {
fFace = face;
return B_OK;
}
BReference <FontStyle> style;
uint16 familyID = FamilyID();
if (gFontManager->Lock()) {