📄 pango-layout.c
字号:
layout->spacing = spacing; pango_layout_clear_lines (layout); }}/** * pango_layout_get_spacing: * @layout: a #PangoLayout * * Gets the amount of spacing in #PangoGlyphUnit between the lines of the * layout. * * Return value: the spacing. **/intpango_layout_get_spacing (PangoLayout *layout){ g_return_val_if_fail (layout != NULL, 0); return layout->spacing;}/** * pango_layout_set_attributes: * @layout: a #PangoLayout * @attrs: a #PangoAttrList * * Sets the text attributes for a layout object. * References @attrs, so the caller can unref its reference. **/voidpango_layout_set_attributes (PangoLayout *layout, PangoAttrList *attrs){ PangoAttrList *old_attrs; g_return_if_fail (layout != NULL); old_attrs = layout->attrs; layout->attrs = attrs; if (layout->attrs) pango_attr_list_ref (layout->attrs); pango_layout_clear_lines (layout); if (old_attrs) pango_attr_list_unref (old_attrs); layout->tab_width = -1;}/** * pango_layout_get_attributes: * @layout: a #PangoLayout * * Gets the attribute list for the layout, if any. * * Return value: a #PangoAttrList. **/PangoAttrList*pango_layout_get_attributes (PangoLayout *layout){ g_return_val_if_fail (PANGO_IS_LAYOUT (layout), NULL); return layout->attrs;}/** * pango_layout_set_font_description: * @layout: a #PangoLayout * @desc: the new #PangoFontDescription, or %NULL to unset the * current font description * * Sets the default font description for the layout. If no font * description is set on the layout, the font description from * the layout's context is used. **/voidpango_layout_set_font_description (PangoLayout *layout, const PangoFontDescription *desc){ g_return_if_fail (layout != NULL); if (desc != layout->font_desc) { if (layout->font_desc) pango_font_description_free (layout->font_desc); if (desc) layout->font_desc = pango_font_description_copy (desc); else layout->font_desc = NULL; pango_layout_clear_lines (layout); layout->tab_width = -1; }}/** * pango_layout_get_font_description: * @layout: a #PangoLayout * * Gets the font description for the layout, if any. * * Return value: a pointer to the layout's font description, * or %NULL if the font description from the layout's * context is inherited. This value is owned by the layout * and must not be modified or freed. * * Since: 1.8 **/G_CONST_RETURN PangoFontDescription *pango_layout_get_font_description (PangoLayout *layout){ g_return_val_if_fail (PANGO_IS_LAYOUT (layout), NULL); return layout->font_desc;}/** * pango_layout_set_justify: * @layout: a #PangoLayout * @justify: whether the lines in the layout should be justified. * * Sets whether each complete line should be stretched to * fill the entire width of the layout. This stretching is typically * done by adding whitespace, but for some scripts (such as Arabic), * the justification may be done in more complex ways, like extending * the characters. * * Note that this setting is not implemented and so is ignored in Pango * older than 1.18. **/voidpango_layout_set_justify (PangoLayout *layout, gboolean justify){ g_return_if_fail (layout != NULL); layout->justify = justify;}/** * pango_layout_get_justify: * @layout: a #PangoLayout * * Gets whether each complete line should be stretched to fill the entire * width of the layout. * * Return value: the justify. **/gbooleanpango_layout_get_justify (PangoLayout *layout){ g_return_val_if_fail (layout != NULL, FALSE); return layout->justify;}/** * pango_layout_set_auto_dir: * @layout: a #PangoLayout * @auto_dir: if %TRUE, compute the bidirectional base direction * from the layout's contents. * * Sets whether to calculate the bidirectional base direction * for the layout according to the contents of the layout; * when this flag is on (the default), then paragraphs in @layout that begin with strong right-to-left characters * (Arabic and Hebrew principally), will have right-to-left * layout, paragraphs with letters from other scripts will * have left-to-right layout. Paragraphs with only neutral * characters get their direction from the surrounding paragraphs. * * When %FALSE, the choice between left-to-right and * right-to-left layout is done according to the base direction * of the layout's #PangoContext. (See pango_context_set_base_dir()). * * When the auto-computed direction of a paragraph differs from the * base direction of the context, the interpretation of * %PANGO_ALIGN_LEFT and %PANGO_ALIGN_RIGHT are swapped. * * Since: 1.4 **/voidpango_layout_set_auto_dir (PangoLayout *layout, gboolean auto_dir){ g_return_if_fail (PANGO_IS_LAYOUT (layout)); auto_dir = auto_dir != FALSE; if (auto_dir != layout->auto_dir) { layout->auto_dir = auto_dir; pango_layout_clear_lines (layout); }}/** * pango_layout_get_auto_dir: * @layout: a #PangoLayout * * Gets whether to calculate the bidirectional base direction * for the layout according to the contents of the layout. * See pango_layout_set_auto_dir(). * * Return value: %TRUE if the bidirectional base direction * is computed from the layout's contents, %FALSE otherwise. * * Since: 1.4 **/gbooleanpango_layout_get_auto_dir (PangoLayout *layout){ g_return_val_if_fail (PANGO_IS_LAYOUT (layout), FALSE); return layout->auto_dir;}/** * pango_layout_set_alignment: * @layout: a #PangoLayout * @alignment: the alignment * * Sets the alignment for the layout: how partial lines are * positioned within the horizontal space available. **/voidpango_layout_set_alignment (PangoLayout *layout, PangoAlignment alignment){ g_return_if_fail (layout != NULL); layout->alignment = alignment;}/** * pango_layout_get_alignment: * @layout: a #PangoLayout * * Gets the alignment for the layout: how partial lines are * positioned within the horizontal space available. * * Return value: the alignment. **/PangoAlignmentpango_layout_get_alignment (PangoLayout *layout){ g_return_val_if_fail (layout != NULL, PANGO_ALIGN_LEFT); return layout->alignment;}/** * pango_layout_set_tabs: * @layout: a #PangoLayout * @tabs: a #PangoTabArray * * Sets the tabs to use for @layout, overriding the default tabs * (by default, tabs are every 8 spaces). If @tabs is %NULL, the default * tabs are reinstated. @tabs is copied into the layout; you must * free your copy of @tabs yourself. **/voidpango_layout_set_tabs (PangoLayout *layout, PangoTabArray *tabs){ g_return_if_fail (PANGO_IS_LAYOUT (layout)); if (layout->tabs) pango_tab_array_free (layout->tabs); layout->tabs = tabs ? pango_tab_array_copy (tabs) : NULL;}/** * pango_layout_get_tabs: * @layout: a #PangoLayout * * Gets the current #PangoTabArray used by this layout. If no * #PangoTabArray has been set, then the default tabs are in use * and %NULL is returned. Default tabs are every 8 spaces. * The return value should be freed with pango_tab_array_free(). * * Return value: a copy of the tabs for this layout, or %NULL. **/PangoTabArray*pango_layout_get_tabs (PangoLayout *layout){ g_return_val_if_fail (PANGO_IS_LAYOUT (layout), NULL); if (layout->tabs) return pango_tab_array_copy (layout->tabs); else return NULL;}/** * pango_layout_set_single_paragraph_mode: * @layout: a #PangoLayout * @setting: new setting * * If @setting is %TRUE, do not treat newlines and similar characters * as paragraph separators; instead, keep all text in a single paragraph, * and display a glyph for paragraph separator characters. Used when * you want to allow editing of newlines on a single text line. * **/voidpango_layout_set_single_paragraph_mode (PangoLayout *layout, gboolean setting){ g_return_if_fail (PANGO_IS_LAYOUT (layout)); setting = setting != FALSE; if (layout->single_paragraph != setting) { layout->single_paragraph = setting; pango_layout_clear_lines (layout); }}/** * pango_layout_get_single_paragraph_mode: * @layout: a #PangoLayout * * Obtains the value set by pango_layout_set_single_paragraph_mode(). * * Return value: %TRUE if the layout does not break paragraphs at * paragraph separator characters, %FALSE otherwise. **/gbooleanpango_layout_get_single_paragraph_mode (PangoLayout *layout){ g_return_val_if_fail (PANGO_IS_LAYOUT (layout), FALSE); return layout->single_paragraph;}/** * pango_layout_set_ellipsize: * @layout: a #PangoLayout * @ellipsize: the new ellipsization mode for @layout * * Sets the type of ellipsization being performed for @layout. * Depending on the ellipsization mode @ellipsize text is * removed from the start, middle, or end of lines so they * fit within the width of layout set with pango_layout_set_width (). * * If the layout contains characters such as newlines that * force it to be layed out in multiple lines, then each line * is ellipsized separately. * * Since: 1.6 **/voidpango_layout_set_ellipsize (PangoLayout *layout, PangoEllipsizeMode ellipsize){ g_return_if_fail (PANGO_IS_LAYOUT (layout)); if (ellipsize != layout->ellipsize) { layout->ellipsize = ellipsize; if (layout->is_ellipsized || layout->is_wrapped) pango_layout_clear_lines (layout); }}/** * pango_layout_get_ellipsize: * @layout: a #PangoLayout * * Gets the type of ellipsization being performed for @layout. * See pango_layout_set_ellipsize() * * Return value: the current ellipsization mode for @layout. * * Use pango_layout_is_ellipsized() to query whether any paragraphs * were actually ellipsized. * * Since: 1.6 **/PangoEllipsizeModepango_layout_get_ellipsize (PangoLayout *layout){ g_return_val_if_fail (PANGO_IS_LAYOUT (layout), PANGO_ELLIPSIZE_NONE); return layout->ellipsize;}/** * pango_layout_is_ellipsized: * @layout: a #PangoLayout * * Queries whether the layout had to ellipsize any paragraphs. * * This returns %TRUE if the ellipsization mode for @layout * is not %PANGO_ELLIPSIZE_NONE, a positive width is set on @layout, * and there are paragraphs exceeding that width that have to be * ellipsized. * * Return value: %TRUE if any paragraphs had to be ellipsized, %FALSE * otherwise. * * Since: 1.16 */gbooleanpango_layout_is_ellipsized (PangoLayout *layout){ g_return_val_if_fail (layout != NULL, FALSE); pango_layout_check_lines (layout); return layout->is_ellipsized;}/** * pango_layout_set_text: * @layout: a #PangoLayout * @text: a valid UTF-8 string * @length: maximum length of @text, in bytes. -1 indicates that * the string is nul-terminated and the length should be * calculated. The text will also be truncated on * encountering a nul-termination even when @length is * positive. * * Sets the text of the layout. **/voidpango_layout_set_text (PangoLayout *layout, const char *text, int length){ char *old_text, *start, *end; g_return_if_fail (layout != NULL); g_return_if_fail (length == 0 || text != NULL); old_text = layout->text; if (length < 0) layout->text = g_strdup (text); else if (length > 0) /* This is not exactly what we want. We don't need the padding... */ layout->text = g_strndup (text, length); else layout->text = g_malloc0 (1); layout->length = strlen (layout->text); /* validate it, and replace invalid bytes with '?' */ start = layout->text; for (;;) { gboolean valid; valid = g_utf8_validate (start, -1, (const char **)&end); if (!*end) break; if (!valid) *end++ = '?'; start = end; } if (start != layout->text) /* TODO: Write out the beginning excerpt of text? */ g_warning ("Invalid UTF-8 string passed to pango_layout_set_text()"); layout->n_chars = g_utf8_strlen (layout->text, -1); pango_layout_clear_lines (layout); g_free (old_text);}/** * pango_layout_get_text: * @layout: a #PangoLayout * * Gets the text in the layout. The returned text should not * be freed or modified. * * Return value: the text in the @layout. **/G_CONST_RETURN char*pango_layout_get_text (PangoLayout *layout){ g_return_val_if_fail (PANGO_IS_LAYOUT (layout), NULL); return layout->text;}/** * pango_layout_set_markup: * @layout: a #PangoLayout
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -