📄 pango-attributes.c
字号:
PangoAttribute *pango_attr_size_new_absolute (int size){ return pango_attr_size_new_internal (size, TRUE);}/** * pango_attr_style_new: * @style: the slant style * * Create a new font slant style attribute. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). **/PangoAttribute *pango_attr_style_new (PangoStyle style){ static const PangoAttrClass klass = { PANGO_ATTR_STYLE, pango_attr_int_copy, pango_attr_int_destroy, pango_attr_int_equal }; return pango_attr_int_new (&klass, (int)style);}/** * pango_attr_weight_new: * @weight: the weight * * Create a new font weight attribute. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). **/PangoAttribute *pango_attr_weight_new (PangoWeight weight){ static const PangoAttrClass klass = { PANGO_ATTR_WEIGHT, pango_attr_int_copy, pango_attr_int_destroy, pango_attr_int_equal }; return pango_attr_int_new (&klass, (int)weight);}/** * pango_attr_variant_new: * @variant: the variant * * Create a new font variant attribute (normal or small caps) * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). **/PangoAttribute *pango_attr_variant_new (PangoVariant variant){ static const PangoAttrClass klass = { PANGO_ATTR_VARIANT, pango_attr_int_copy, pango_attr_int_destroy, pango_attr_int_equal }; return pango_attr_int_new (&klass, (int)variant);}/** * pango_attr_stretch_new: * @stretch: the stretch * * Create a new font stretch attribute * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). **/PangoAttribute *pango_attr_stretch_new (PangoStretch stretch){ static const PangoAttrClass klass = { PANGO_ATTR_STRETCH, pango_attr_int_copy, pango_attr_int_destroy, pango_attr_int_equal }; return pango_attr_int_new (&klass, (int)stretch);}static PangoAttribute *pango_attr_font_desc_copy (const PangoAttribute *attr){ const PangoAttrFontDesc *desc_attr = (const PangoAttrFontDesc *)attr; return pango_attr_font_desc_new (desc_attr->desc);}static voidpango_attr_font_desc_destroy (PangoAttribute *attr){ PangoAttrFontDesc *desc_attr = (PangoAttrFontDesc *)attr; pango_font_description_free (desc_attr->desc); g_slice_free (PangoAttrFontDesc, desc_attr);}static gbooleanpango_attr_font_desc_equal (const PangoAttribute *attr1, const PangoAttribute *attr2){ const PangoAttrFontDesc *desc_attr1 = (const PangoAttrFontDesc *)attr1; const PangoAttrFontDesc *desc_attr2 = (const PangoAttrFontDesc *)attr2; return pango_font_description_equal (desc_attr1->desc, desc_attr2->desc);}/** * pango_attr_font_desc_new: * @desc: the font description * * Create a new font description attribute. This attribute * allows setting family, style, weight, variant, stretch, * and size simultaneously. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). **/PangoAttribute *pango_attr_font_desc_new (const PangoFontDescription *desc){ static const PangoAttrClass klass = { PANGO_ATTR_FONT_DESC, pango_attr_font_desc_copy, pango_attr_font_desc_destroy, pango_attr_font_desc_equal }; PangoAttrFontDesc *result = g_slice_new (PangoAttrFontDesc); result->attr.klass = &klass; result->desc = pango_font_description_copy (desc); return (PangoAttribute *)result;}/** * pango_attr_underline_new: * @underline: the underline style. * * Create a new underline-style attribute. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). **/PangoAttribute *pango_attr_underline_new (PangoUnderline underline){ static const PangoAttrClass klass = { PANGO_ATTR_UNDERLINE, pango_attr_int_copy, pango_attr_int_destroy, pango_attr_int_equal }; return pango_attr_int_new (&klass, (int)underline);}/** * pango_attr_underline_color_new: * @red: the red value (ranging from 0 to 65535) * @green: the green value * @blue: the blue value * * Create a new underline color attribute. This attribute * modifies the color of underlines. If not set, underlines * will use the foreground color. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). * * Since: 1.8 **/PangoAttribute *pango_attr_underline_color_new (guint16 red, guint16 green, guint16 blue){ static const PangoAttrClass klass = { PANGO_ATTR_UNDERLINE_COLOR, pango_attr_color_copy, pango_attr_color_destroy, pango_attr_color_equal }; return pango_attr_color_new (&klass, red, green, blue);}/** * pango_attr_strikethrough_new: * @strikethrough: %TRUE if the text should be struck-through. * * Create a new strike-through attribute. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). **/PangoAttribute *pango_attr_strikethrough_new (gboolean strikethrough){ static const PangoAttrClass klass = { PANGO_ATTR_STRIKETHROUGH, pango_attr_int_copy, pango_attr_int_destroy, pango_attr_int_equal }; return pango_attr_int_new (&klass, (int)strikethrough);}/** * pango_attr_strikethrough_color_new: * @red: the red value (ranging from 0 to 65535) * @green: the green value * @blue: the blue value * * Create a new strikethrough color attribute. This attribute * modifies the color of strikethrough lines. If not set, strikethrough * lines will use the foreground color. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). * * Since: 1.8 **/PangoAttribute *pango_attr_strikethrough_color_new (guint16 red, guint16 green, guint16 blue){ static const PangoAttrClass klass = { PANGO_ATTR_STRIKETHROUGH_COLOR, pango_attr_color_copy, pango_attr_color_destroy, pango_attr_color_equal }; return pango_attr_color_new (&klass, red, green, blue);}/** * pango_attr_rise_new: * @rise: the amount that the text should be displaced vertically, * in Pango units. Positive values displace the text upwards. * * Create a new baseline displacement attribute. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). **/PangoAttribute *pango_attr_rise_new (int rise){ static const PangoAttrClass klass = { PANGO_ATTR_RISE, pango_attr_int_copy, pango_attr_int_destroy, pango_attr_int_equal }; return pango_attr_int_new (&klass, (int)rise);}/** * pango_attr_scale_new: * @scale_factor: factor to scale the font * * Create a new font size scale attribute. The base font for the * affected text will have its size multiplied by @scale_factor. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). **/PangoAttribute*pango_attr_scale_new (double scale_factor){ static const PangoAttrClass klass = { PANGO_ATTR_SCALE, pango_attr_float_copy, pango_attr_float_destroy, pango_attr_float_equal }; return pango_attr_float_new (&klass, scale_factor);}/** * pango_attr_fallback_new: * @enable_fallback: %TRUE if we should fall back on other fonts * for characters the active font is missing. * * Create a new font fallback attribute. * * If fallback is disabled, characters will only be used from the * closest matching font on the system. No fallback will be done to * other fonts on the system that might contain the characters in the * text. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). * * Since: 1.4 **/PangoAttribute *pango_attr_fallback_new (gboolean enable_fallback){ static const PangoAttrClass klass = { PANGO_ATTR_FALLBACK, pango_attr_int_copy, pango_attr_int_destroy, pango_attr_int_equal, }; return pango_attr_int_new (&klass, (int)enable_fallback);}/** * pango_attr_letter_spacing_new: * @letter_spacing: amount of extra space to add between graphemes * of the text, in Pango units. * * Create a new letter-spacing attribute. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). * * Since: 1.6 **/PangoAttribute *pango_attr_letter_spacing_new (int letter_spacing){ static const PangoAttrClass klass = { PANGO_ATTR_LETTER_SPACING, pango_attr_int_copy, pango_attr_int_destroy, pango_attr_int_equal }; return pango_attr_int_new (&klass, letter_spacing);}static PangoAttribute *pango_attr_shape_copy (const PangoAttribute *attr){ const PangoAttrShape *shape_attr = (PangoAttrShape *)attr; gpointer data; if (shape_attr->copy_func) data = shape_attr->copy_func (shape_attr->data); else data = shape_attr->data; return pango_attr_shape_new_with_data (&shape_attr->ink_rect, &shape_attr->logical_rect, data, shape_attr->copy_func, shape_attr->destroy_func);}static voidpango_attr_shape_destroy (PangoAttribute *attr){ PangoAttrShape *shape_attr = (PangoAttrShape *)attr; if (shape_attr->destroy_func) shape_attr->destroy_func (shape_attr->data); g_slice_free (PangoAttrShape, shape_attr);}static gbooleanpango_attr_shape_equal (const PangoAttribute *attr1, const PangoAttribute *attr2){ const PangoAttrShape *shape_attr1 = (const PangoAttrShape *)attr1; const PangoAttrShape *shape_attr2 = (const PangoAttrShape *)attr2; return (shape_attr1->logical_rect.x == shape_attr2->logical_rect.x && shape_attr1->logical_rect.y == shape_attr2->logical_rect.y && shape_attr1->logical_rect.width == shape_attr2->logical_rect.width && shape_attr1->logical_rect.height == shape_attr2->logical_rect.height && shape_attr1->ink_rect.x == shape_attr2->ink_rect.x && shape_attr1->ink_rect.y == shape_attr2->ink_rect.y && shape_attr1->ink_rect.width == shape_attr2->ink_rect.width && shape_attr1->ink_rect.height == shape_attr2->ink_rect.height && shape_attr1->data == shape_attr2->data);}/** * pango_attr_shape_new_with_data: * @ink_rect: ink rectangle to assign to each character * @logical_rect: logical rectangle to assign to each character * @data: user data pointer * @copy_func: function to copy @data when the attribute * is copied. If %NULL, @data is simply copied * as a pointer. * @destroy_func: function to free @data when the attribute * is freed, or %NULL * * Like pango_attr_shape_new(), but a user data pointer is also * provided; this pointer can be accessed when later * rendering the glyph. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). * * Since: 1.8 **/PangoAttribute *pango_attr_shape_new_with_data (const PangoRectangle *ink_rect, const PangoRectangle *logical_rect, gpointer data, PangoAttrDataCopyFunc copy_func, GDestroyNotify destroy_func){ static const PangoAttrClass klass = { PANGO_ATTR_SHAPE, pango_attr_shape_copy, pango_attr_shape_destroy, pango_attr_shape_equal }; PangoAttrShape *result; g_return_val_if_fail (ink_rect != NULL, NULL); g_return_val_if_fail (logical_rect != NULL, NULL); result = g_slice_new (PangoAttrShape); result->attr.klass = &klass; result->ink_rect = *ink_rect; result->logical_rect = *logical_rect; result->data = data; result->copy_func = copy_func; result->destroy_func = destroy_func; return (PangoAttribute *)result;}/** * pango_attr_shape_new: * @ink_rect: ink rectangle to assign to each character * @logical_rect: logical rectangle to assign to each character * * Create a new shape attribute. A shape is used to impose a * particular ink and logical rectangle on the result of shaping a * particular glyph. This might be used, for instance, for * embedding a picture or a widget inside a #PangoLayout. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). **/PangoAttribute *pango_attr_shape_new (const PangoRectangle *ink_rect, const PangoRectangle *logical_rect){ g_return_val_if_fail (ink_rect != NULL, NULL); g_return_val_if_fail (logical_rect != NULL, NULL); return pango_attr_shape_new_with_data (ink_rect, logical_rect, NULL, NULL, NULL);}/** * pango_attr_gravity_new: * @gravity: the gravity value; should not be %PANGO_GRAVITY_AUTO. * * Create a new gravity attribute. * * Return value: the newly allocated #PangoAttribute, which should be * freed with pango_attribute_destroy(). * * Since: 1.16 **/PangoAttribute *pango_attr_gravity_new (PangoGravity gravity){ static const PangoAttrClass klass = { PANGO_ATTR_GRAVITY, pango_attr_int_copy, pango_attr_int_destroy, pango_attr_int_equal }; g_return_val_if_fail (gravity != PANGO_GRAVITY_AUTO, NULL); return pango_attr_int_new (&klass, (int)gravity);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -