/* * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "applib/graphics/gtypes.h" #include "applib/graphics/perimeter.h" #include "applib/fonts/fonts.h" #include #include //! @addtogroup Graphics //! @{ //! @addtogroup TextDrawing Drawing Text //! \brief Functions to draw text into a graphics context //! //! See \ref GraphicsContext for more information about the graphics context. //! //! Other drawing functions and related documentation: //! * \ref Drawing //! * \ref PathDrawing //! * \ref GraphicsTypes //! @{ //! Text overflow mode controls the way text overflows when the string that is drawn does not fit //! inside the area constraint. //! @see graphics_draw_text //! @see text_layer_set_overflow_mode typedef enum { //! On overflow, wrap words to a new line below the current one. Once vertical space is consumed, //! the last line may be clipped. GTextOverflowModeWordWrap, //! On overflow, wrap words to a new line below the current one. //! Once vertical space is consumed, truncate as needed to fit a trailing ellipsis (...). //! Clipping may occur if the vertical space cannot accomodate the first line of text. GTextOverflowModeTrailingEllipsis, //! Acts like \ref GTextOverflowModeTrailingEllipsis, plus trims leading and trailing newlines, //! while treating all other newlines as spaces. GTextOverflowModeFill } GTextOverflowMode; //! Text alignment controls the way the text is aligned inside the box the text is drawn into. //! @see graphics_draw_text //! @see text_layer_set_text_alignment typedef enum { //! Aligns the text to the left of the drawing box GTextAlignmentLeft, //! Aligns the text centered inside the drawing box GTextAlignmentCenter, //! Aligns the text to the right of the drawing box GTextAlignmentRight, } GTextAlignment; //! @internal typedef enum { GVerticalAlignmentTop, GVerticalAlignmentCenter, GVerticalAlignmentBottom, } GVerticalAlignment; typedef struct { //! Invalidate the cache if these parameters have changed uint32_t hash; GRect box; GFont font; GTextOverflowMode overflow_mode; GTextAlignment alignment; //! Cached parameters GSize max_used_size; //