Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7CE3C77B7A for ; Thu, 1 Jun 2023 16:31:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8A64E865CE; Thu, 1 Jun 2023 18:26:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="CTJBVdCJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B276086345; Thu, 1 Jun 2023 18:25:22 +0200 (CEST) Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 15AD586393 for ; Thu, 1 Jun 2023 18:25:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-33b36a9fdf8so3636045ab.2 for ; Thu, 01 Jun 2023 09:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685636690; x=1688228690; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HrzmjzW96RBA1t0rWzhi1Qx+9OwUAifeJKc2jexfcn4=; b=CTJBVdCJ3oukDRwhMJOck9qYPu7/8YFPBcGI7LPSDQAWyI6ukepUMvOgS1IeHI9YwY gVnos1kP63dGSy0xgUblGr8ccSyXZpHFtkgW4giIam/uQM8G7zD9zhvlApXMakpc73XT 0Kri7t/f3KB7E4f375p3z0jKeNJjilLvNJEho= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685636690; x=1688228690; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HrzmjzW96RBA1t0rWzhi1Qx+9OwUAifeJKc2jexfcn4=; b=R3cTzDeGaGiTgY/usAhDSbOD1HkkMgOWqcrPB/mYnCLa+U15L2mn9QAD3H6Gsblekb GuIVMK9Zc5x6FkCKPlJJIHpxEV67pDHn2gtD33Syee2tnVkkh6HLxdjXvRd/EyG58FAg QHV+Rczb59CSNwTqKsNK3d7am2gPTf3vREAZBKjjUNPA0G3T9rrvHZAFLnDMtU4iiQCV k1+QPtaDh5GJN2dJJDAdAX9Z2S4dQ4hYPOhxhansuL0xHj5vMoEALtW9HL86D/eMHYtp BlEFYhTYMfgZ+P9KGCOMUDCRXBHO/olTbMrdQNdA4Qzk+KiSx0bojqSF9M44XdMfCMch NQog== X-Gm-Message-State: AC+VfDyFUR4izLdg4iuNpZJn4Pi9TOLXrQC35pBRapQa53/PxZiJmSWe qwijaLKANNJY+4mqJ88VoRYSJvjbbCan3VimtJI= X-Google-Smtp-Source: ACHHUZ48Pi3l7WGal8Iza2TlpU9RdCnfGIiPoKEkaew+OrGGt0ylWQb0e6MON2gJ/xijhD1gw1BWoQ== X-Received: by 2002:a92:d34a:0:b0:32b:50d1:3403 with SMTP id a10-20020a92d34a000000b0032b50d13403mr6700850ilh.7.1685636689999; Thu, 01 Jun 2023 09:24:49 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id l1-20020a922901000000b0033a6e7ee4e3sm3862098ilg.1.2023.06.01.09.24.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 09:24:49 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Tom Rini , Simon Glass Subject: [PATCH 27/40] expo: Calculate text bounding-box correctly Date: Thu, 1 Jun 2023 10:22:51 -0600 Message-ID: <20230601162404.220488-26-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog In-Reply-To: <20230601162404.220488-1-sjg@chromium.org> References: <20230601162404.220488-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Rather than estimating, measure the text accurately, using the new vidconsole feature. This allows accurate placement of objects. Signed-off-by: Simon Glass --- boot/scene.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index dd1472d4f9aa..981a18b3ba1c 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -257,16 +257,30 @@ int scene_obj_get_hw(struct scene *scn, uint id, int *widthp) case SCENEOBJT_TEXT: { struct scene_obj_txt *txt = (struct scene_obj_txt *)obj; struct expo *exp = scn->expo; + struct vidconsole_bbox bbox; + const char *str; + int len, ret; + str = expo_get_str(exp, txt->str_id); + if (!str) + return log_msg_ret("str", -ENOENT); + len = strlen(str); + + /* if there is no console, make it up */ + if (!exp->cons) { + if (widthp) + *widthp = 8 * len; + return 16; + } + + ret = vidconsole_measure(scn->expo->cons, txt->font_name, + txt->font_size, str, &bbox); + if (ret) + return log_msg_ret("mea", ret); if (widthp) - *widthp = 16; /* fake value for now */ - if (txt->font_size) - return txt->font_size; - if (exp->display) - return video_default_font_height(exp->display); - - /* use a sensible default */ - return 16; + *widthp = bbox.x1; + + return bbox.y1; } } -- 2.41.0.rc0.172.g3f132b7071-goog