惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
量子位
小众软件
小众软件
C
Cybersecurity and Infrastructure Security Agency CISA
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tenable Blog
V
Vulnerabilities – Threatpost
Know Your Adversary
Know Your Adversary
T
Threat Research - Cisco Blogs
Latest news
Latest news
Spread Privacy
Spread Privacy
C
Cyber Attacks, Cyber Crime and Cyber Security
NISL@THU
NISL@THU
T
Tor Project blog
Hacker News: Ask HN
Hacker News: Ask HN
V2EX - 技术
V2EX - 技术
T
The Exploit Database - CXSecurity.com
博客园 - 三生石上(FineUI控件)
K
Kaspersky official blog
Cyberwarzone
Cyberwarzone
博客园 - 叶小钗
博客园 - 聂微东
Last Week in AI
Last Week in AI
爱范儿
爱范儿
腾讯CDC
博客园 - Franky
美团技术团队
J
Java Code Geeks
O
OpenAI News
L
Lohrmann on Cybersecurity
Simon Willison's Weblog
Simon Willison's Weblog
有赞技术团队
有赞技术团队
T
Threatpost
G
GRAHAM CLULEY
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
宝玉的分享
宝玉的分享
I
Intezer
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
S
Security @ Cisco Blogs
Forbes - Security
Forbes - Security
N
News | PayPal Newsroom
Stack Overflow Blog
Stack Overflow Blog
Scott Helme
Scott Helme
H
Hacker News: Front Page
Cloudbric
Cloudbric

inkscape:windows_ci_14x commits

Update WIndows dependencies to r180 (995a0ec3) · Commits · René de Hesselle / inkscape · GitLab Fix Welcome dialog stacking up when run more than once (eab9c6d5) · Commits · René de Hesselle / inkscape · GitLab Edit label and tooltip for Preserve Shape setting (4c992ff3) · Commits · René de Hesselle / inkscape · GitLab Fix keyboard navigation in Objects dialog (38acd49e) · Commits · René de Hesselle / inkscape · GitLab update translations (9f8f2fec) · Commits · René de Hesselle / inkscape · GitLab Fix missing signal blocking in page toolbar (d5533a4b) · Commits · René de Hesselle / inkscape · GitLab Convert libuemf to a git submodule (22344d42) · Commits · René de Hesselle / inkscape · GitLab update translations (f5993d7c) · Commits · René de Hesselle / inkscape · GitLab update translations (fcd03438) · Commits · René de Hesselle / inkscape · GitLab Fix: request display update when removing child from group (6908c07a) · Commits · René de Hesselle / inkscape · GitLab Make po submodule shallow (90eced57) · Commits · René de Hesselle / inkscape · GitLab 1.4.3 (0d15f750) · Commits · René de Hesselle / inkscape · GitLab update translations (4d3a6d61) · Commits · René de Hesselle / inkscape · GitLab Update tutorials and man page for Inkscape 1.4.3 (excluding French) (bec26502) · Commits · René de Hesselle / inkscape · GitLab Add GioWin32-2.0.typelib to Windows (eb2146c6) · Commits · René de Hesselle / inkscape · GitLab Revert the backport of a fix causing regressions in textPath (7d1c0165) · Commits · René de Hesselle / inkscape · GitLab update translations (8a1e7745) · Commits · René de Hesselle / inkscape · GitLab Update Windows dependencies to r168 (9500139e) · Commits · René de Hesselle / inkscape · GitLab Build GraphicsMagick on Windows ourselves again (2ea69ea8) · Commits · René de Hesselle / inkscape · GitLab Prepare 1.4.3 (e2afff01) · Commits · René de Hesselle / inkscape · GitLab Update docs for 1.4.3rc (ea3d7619) · Commits · René de Hesselle / inkscape · GitLab Fix crash on MacOS when opening file by right clicking on file. (fe96d51c) · Commits · René de Hesselle / inkscape · GitLab Update macOS build pipeline to v0.82-2-g21f3e2d (56605ae7) · Commits · René de Hesselle / inkscape · GitLab Fix commands toolbar glitching at exact size (b8376295) · Commits · René de Hesselle / inkscape · GitLab Add commands toolbar to automatic toolbar policy (c37cea70) · Commits · René de Hesselle / inkscape · GitLab update translations (dfc0fde0) · Commits · René de Hesselle / inkscape · GitLab Fix welcome dialog graphics (8d76d570) · Commits · René de Hesselle / inkscape · GitLab Fix code getting items under cursor (441f5bfb) · Commits · René de Hesselle / inkscape · GitLab Make libdepixelize a submodule (09a2712d) · Commits · René de Hesselle / inkscape · GitLab Add missed 1.4.3 artwork (9d406cab) · Commits · René de Hesselle / inkscape · GitLab Batch updates to layer selector (5433ba34) · Commits · René de Hesselle / inkscape · GitLab Set Pango context language to undetermined (bc80df21) · Commits · René de Hesselle / inkscape · GitLab Update macOS build pipeline to 0.82 (7348d729) · Commits · René de Hesselle / inkscape · GitLab Make popovers stay open on spinbutton activate (03c3f33d) · Commits · René de Hesselle / inkscape · GitLab Add 'webp' to the list of file formats that Inkscape can import on MacOS. (76e716a7) · Commits · René de Hesselle / inkscape · GitLab Fix crash in LPE path Parameters (ae36951b) · Commits · René de Hesselle / inkscape · GitLab Add 'jpg' and 'jpeg' to the list of file formats that Inkscape can import on MacOS. (81feda7b) · Commits · René de Hesselle / inkscape · GitLab Fix action accidentally marked for translation (a1a3cc5a) · Commits · René de Hesselle / inkscape · GitLab SPLPEItem: ref group objects before recursion (d8cf3584) · Commits · René de Hesselle / inkscape · GitLab
Handle `xml:lang`/`lang` attribute updates (7fa5d668) · Commits · René de Hesselle / inkscape · GitLab
Alvin Wong · 2025-12-06 · via inkscape:windows_ci_14x commits
Commit 7fa5d668 authored by alvinhochun's avatar alvinhochun Committed by Willy (Wen-Wei) Kao
Browse files

Handle `xml:lang`/`lang` attribute updates

The change of language needs to trigger descendant text objects to be
updated, since it is effectively a font change that may change the glyph
selection and even metrics.

The language handling in `SPObject` is refactored such that the
effective language of the object is dynamically inherited from its
parent(s) on demand, instead of cached in the `SPObject` itself.

Added test `test_sp-object-lang` to check the language handling.
Original line number Diff line number Diff line
@@ -1365,8 +1365,9 @@ void Layout::Calculator::_buildPangoItemizationForPara(ParagraphInfo *para) con

            // Set language
            SPObject * object = text_source->source;
            if (!object->lang.empty()) {
                PangoLanguage* language = pango_language_from_string(object->lang.c_str());
            char const *lang = object->getLanguage();
            if (lang && lang[0] != '\0') {
                PangoLanguage *language = pango_language_from_string(lang);
                PangoAttribute *attribute_language = pango_attr_language_new( language );
                pango_attr_list_insert(attributes_list, attribute_language);
            }
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include "live_effects/lpeobject.h"
#include "sp-factory.h"
#include "sp-font.h"
#include "sp-glyph.h"
#include "sp-paint-server.h"
#include "sp-root.h"
#include "sp-use.h"
@@ -229,6 +230,17 @@ std::string SPObject::getUrl() const {
    return "";
}

char const *SPObject::getLanguage() const
{
    if (_lang_attribute) {
        return _lang_attribute->c_str();
    }
    if (parent) {
        return parent->getLanguage();
    }
    return "";
}

Inkscape::XML::Node * SPObject::getRepr() {
    return repr;
}
@@ -788,11 +800,6 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) {
    object->readAttr(SPAttr::INKSCAPE_LABEL);
    object->readAttr(SPAttr::INKSCAPE_COLLECT);

    // Inherit if not set
    if (lang.empty() && object->parent) {
        lang = object->parent->lang;
    }

    if(object->cloned && (repr->attribute("id")) ) // The cases where this happens are when the "original" has no id. This happens
                                                   // if it is a SPString (a TextNode, e.g. in a <title>), or when importing
                                                   // stuff externally modified to have no id. 
@@ -1088,18 +1095,22 @@ void SPObject::set(SPAttr key, gchar const* value) {
            break;

        case SPAttr::LANG:
            if (value) {
                lang = value;
                // To do: sanity check
            }
        case SPAttr::XML_LANG: {
            // Note: An empty string _is_ valid for `xml:lang` and `lang`
            // `xml:lang` takes precedence
            if (key == SPAttr::LANG && getAttribute("xml:lang")) {
                break;

        case SPAttr::XML_LANG:
            if (value) {
                lang = value;
                // To do: sanity check
            }
            break;
            gchar const *lang_attr_value = value;
            if (key == SPAttr::XML_LANG && !lang_attr_value && !is<SPGlyph>(this)) {
                // Use `lang` only if `xml:lang` is not set.
                // Also SVG 1.1 <glyph> has a different spec for the `lang` attribute that should not be used.
                lang_attr_value = getAttribute("lang");
            }
            _lang_attribute = lang_attr_value ? std::make_optional(lang_attr_value) : std::nullopt;
            // To do: sanity check
            requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
        } break;

        case SPAttr::STYLE:
            object->style->readFromObject( object );
@@ -1199,6 +1210,18 @@ Inkscape::XML::Node* SPObject::write(Inkscape::XML::Document *doc, Inkscape::XML
            repr->setAttribute("xml:space", xml_space);
        }

        if (_lang_attribute) {
            repr->setAttribute("xml:lang", *_lang_attribute);
        } else {
            repr->removeAttribute("xml:lang");
            // SVG 1.1 <glyph> has a different spec for the `lang` attribute, so don't touch that.
            if (!is<SPGlyph>(this)) {
                // Only remove `lang` if removing `xml:lang`.
                // We can leave `lang` otherwise. It does not matter since `xml:lang` takes precedence.
                repr->removeAttribute("lang");
            }
        }

        if ( flags & SP_OBJECT_WRITE_EXT &&
             this->collectionPolicy() == SPObject::ALWAYS_COLLECT )
        {
Original line number Diff line number Diff line
@@ -168,7 +168,6 @@ public:
    unsigned int uflags : 8;
    unsigned int mflags : 8;
    SPIXmlSpace xml_space;
    Glib::ustring lang;
    unsigned int hrefcount{0};        /* number of xlink:href references */
    unsigned int _total_hrefcount{0}; /* our hrefcount + total descendants */
    SPDocument *document{nullptr};    /* Document we are part of */
@@ -178,6 +177,11 @@ private:
    char *id{nullptr};                  /* Our very own unique id */
    Inkscape::XML::Node *repr{nullptr}; /* Our xml representation */

    /**
     * The value of the `xml:lang` or `lang` attribute, if set.
     */
    std::optional<Glib::ustring> _lang_attribute;

public:
    int refCount{1};
    std::list<SPObject *> hrefList;
@@ -194,6 +198,24 @@ public:
     */
    std::string getUrl() const;

    /**
     * Get the value of the language attribute explicitly set on this object, if available.
     *
     * To get the effective language of this object, use getLanguage() instead.
     */
    std::optional<Glib::ustring> const &getLangAttribute() const { return _lang_attribute; }

    /**
     * Get the effective language of this object, either set by the `xml:lang`/`lang` attributes or inherited from
     * the parent.
     */
    char const *getLanguage() const;

    /**
     * Set the language of this object. Use std::nullopt to unset and inherit from the parent.
     */
    void setLanguage(std::optional<Glib::ustring> value) { _lang_attribute = std::move(value); }

    /**
     * Returns the XML representation of tree
     */
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ set(TEST_SOURCES
    oklab-color-test
    sp-item-test
    sp-object-test
    sp-object-lang-test
    sp-object-tags-test
    object-links-test
    object-set-test

File added.

Preview size limit exceeded, changes collapsed.