An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Align Windows fallback emoji icons through font metrics https://github.com/siyuan-note/siyuan/issues/20731
Daniel2e2cdd39d61e
diff --git a/app/src/assets/scss/component/_list.scss b/app/src/assets/scss/component/_list.scssindex ec16e87032..a96a75c927 100644--- a/app/src/assets/scss/component/_list.scss+++ b/app/src/assets/scss/component/_list.scss@@ -297,7 +297,7 @@text-align: center;font-size: 14px;- font-family: var(--b3-font-family-emoji);+ font-family: "Emojis File Tree", var(--b3-font-family-emoji);font-variant-emoji: emoji;margin-right: 4px;line-height: 22px;@@ -311,20 +311,12 @@align-items: center;justify-content: center;- body.body--windows & > .b3-list-item__emoji {- transform: translateY(var(--b3-file-tree-emoji-offset, 0px));- }-&:hover {color: var(--b3-theme-on-background);background-color: var(--b3-list-icon-hover);}}- &__emoji {- pointer-events: none;- }-&__hinttext {overflow: hidden;white-space: nowrap;diff --git a/app/src/emoji/fileTreeIcon.test.ts b/app/src/emoji/fileTreeIcon.test.tsindex b6904b0c98..c7e404ec5f 100644--- a/app/src/emoji/fileTreeIcon.test.ts+++ b/app/src/emoji/fileTreeIcon.test.ts@@ -74,16 +74,16 @@ describe("file tree icon", () => {});it("keeps the Emoji defaults when SVG icons are disabled", () => {- assert.equal(getFileTreeIconHTML("", "notebook", "", false, false), '<span class="b3-list-item__emoji">🗃</span>');- assert.equal(getFileTreeIconHTML("", "folder", "", false, false), '<span class="b3-list-item__emoji">📑</span>');- assert.equal(getFileTreeIconHTML("", "file", "", false, false), '<span class="b3-list-item__emoji">📄</span>');- assert.equal(getFileTreeIconHTML("", "lock", "", false, false), '<span class="b3-list-item__emoji">🔒️</span>');+ assert.equal(getFileTreeIconHTML("", "notebook", "", false, false), "🗃");+ assert.equal(getFileTreeIconHTML("", "folder", "", false, false), "📑");+ assert.equal(getFileTreeIconHTML("", "file", "", false, false), "📄");+ assert.equal(getFileTreeIconHTML("", "lock", "", false, false), "🔒️");assert.equal(getDocumentIconHTML("", "mobile-tabs__item-icon", false),'<span class="mobile-tabs__item-icon">📄</span>');});it("treats an explicitly configured icon as custom", () => {- assert.equal(getFileTreeIconHTML("1f4c4", "folder", "", false, true), '<span class="b3-list-item__emoji">📄</span>');+ assert.equal(getFileTreeIconHTML("1f4c4", "folder", "", false, true), "📄");assert.equal(getDocumentIconHTML("1f4c4", "mobile-tabs__item-icon", true),'<span class="mobile-tabs__item-icon">📄</span>');assert.equal(getFileTreeDefaultIconAttr("1f4c4", "folder"), "");@@ -111,13 +111,13 @@ describe("file tree icon", () => {updateFileTreeItemIcon(liElement, "1f4c4");assert.equal("defaultIcon" in dataset, false);- assert.equal(iconElement.innerHTML, '<span class="b3-list-item__emoji">📄</span>');+ assert.equal(iconElement.innerHTML, "📄");updateFileTreeItemIcon(liElement, "", "file");window.siyuan.config.fileTree.useSVGDefaultIcon = false;refreshDefaultFileTreeIcons({querySelectorAll: () => [liElement]} as unknown as ParentNode);assert.equal(dataset.defaultIcon, "file");- assert.equal(iconElement.innerHTML, '<span class="b3-list-item__emoji">📄</span>');+ assert.equal(iconElement.innerHTML, "📄");});it("refreshes locked notebook icons with the SVG setting", () => {@@ -131,17 +131,17 @@ describe("file tree icon", () => {assert.match(iconElement.innerHTML, /#iconLock/);window.siyuan.config.fileTree.useSVGDefaultIcon = false;refreshDefaultFileTreeIcons({querySelectorAll: () => [liElement]} as unknown as ParentNode);- assert.equal(iconElement.innerHTML, '<span class="b3-list-item__emoji">🔒️</span>');+ assert.equal(iconElement.innerHTML, "🔒️");});- it("keeps the compensation wrapper limited to emoji when switching icon kinds", () => {+ it("switches between bare emoji, images and SVG icons", () => {const iconElement = {classList: {contains: (value: string) => value === "b3-list-item__icon"}, innerHTML: ""};const liElement = {children: [iconElement],dataset: {} as Record<string, string>,} as unknown as HTMLElement;updateFileTreeItemIcon(liElement, "1f4c4", "file");- assert.equal(iconElement.innerHTML, '<span class="b3-list-item__emoji">📄</span>');+ assert.equal(iconElement.innerHTML, "📄");updateFileTreeItemIcon(liElement, "custom.png", "file");assert.equal(iconElement.innerHTML, '<img class="" src="/emojis/custom.png"/>');window.siyuan.config.fileTree.useSVGDefaultIcon = true;@@ -149,6 +149,6 @@ describe("file tree icon", () => {assert.equal(iconElement.innerHTML, '<svg><use xlink:href="#iconFile"></use></svg>');window.siyuan.config.fileTree.useSVGDefaultIcon = false;refreshDefaultFileTreeIcons({querySelectorAll: () => [liElement]} as unknown as ParentNode);- assert.equal(iconElement.innerHTML, '<span class="b3-list-item__emoji">📄</span>');+ assert.equal(iconElement.innerHTML, "📄");});});diff --git a/app/src/emoji/fileTreeIcon.ts b/app/src/emoji/fileTreeIcon.tsindex 6ab6d69bf3..b5897c253b 100644--- a/app/src/emoji/fileTreeIcon.ts+++ b/app/src/emoji/fileTreeIcon.ts@@ -28,11 +28,6 @@ const isDefaultIcon = (value: string | undefined): value is TFileTreeDefaultIconconst getDirectIconElement = (liElement: HTMLElement) => Array.from(liElement.children).find((item) =>item.classList.contains("b3-list-item__icon") || item.classList.contains("b3-list-item__graphic")) as HTMLElement | undefined;-const renderFileTreeEmoji = (icon: string, className: string, needSpan: boolean) => {- const html = unicode2Emoji(icon, className, needSpan);- return html && !html.startsWith("<") ? `<span class="b3-list-item__emoji">${html}</span>` : html;-};-export const getFileTreeDefaultIconAttr = (icon: string, defaultIcon: TFileTreeDefaultIcon, disabled = false) =>!icon && !disabled ? ` data-default-icon="${defaultIcon}"` : "";@@ -40,11 +35,11 @@ export const getFileTreeIconHTML = (icon: string, defaultIcon: TFileTreeDefaultIneedSpan = false, useSVGDefaultIcon =window.siyuan.config.fileTree.useSVGDefaultIcon === true) => {if (icon) {- return renderFileTreeEmoji(icon, className, needSpan);+ return unicode2Emoji(icon, className, needSpan);}if (!useSVGDefaultIcon) {- return renderFileTreeEmoji(getDefaultEmoji(defaultIcon), className, needSpan);+ return unicode2Emoji(getDefaultEmoji(defaultIcon), className, needSpan);}const classAttr = needSpan ? ` class="${escapeAttr(className)}"` : "";@@ -80,7 +75,7 @@ export const updateFileTreeItemIcon = (liElement: HTMLElement, icon: string,}if (icon) {delete liElement.dataset.defaultIcon;- iconElement.innerHTML = getFileTreeIconHTML(icon, defaultIcon);+ iconElement.innerHTML = unicode2Emoji(icon);return;}liElement.dataset.defaultIcon = defaultIcon;diff --git a/app/src/util/assets.test.ts b/app/src/util/assets.test.tsnew file mode 100644index 0000000000..58bcc7b49f--- /dev/null+++ b/app/src/util/assets.test.ts@@ -0,0 +1,47 @@+import * as assert from "node:assert/strict";+import {readFileSync} from "node:fs";+import {join} from "node:path";+import {test} from "node:test";+import {runInNewContext} from "node:vm";+import * as ts from "typescript";+import {getEmojiFontStyle} from "./emojiFont";++const source = ts.transpileModule(readFileSync(join(__dirname, "assets.ts"), "utf8"), {+ compilerOptions: {module: ts.ModuleKind.CommonJS},+}).outputText;++for (const [name, platformClass, win11, apple] of [+ ["Windows 11", "body--windows", true, false],+ ["Windows fallback", "body--windows", false, false],+ ["Linux", "body--linux", false, false],+ ["Android", "body--android", false, false],+ ["HarmonyOS", "body--harmony", false, false],+ ["macOS", "body--mac", false, true],+ ["iOS", "body--ios", false, true],+] as const) {+ test(`selects frontend emoji fonts for ${name} independently of the kernel host`, async () => {+ const exports = {} as typeof import("./assets");+ runInNewContext(source, {+ exports,+ window: {siyuan: {config: {system: {container: "android"}, editor: {fontSize: 16}}}},+ document: {},+ require: (id: string) => {+ if (id === "../protyle/util/compatibility") {+ return {isMac: () => platformClass === "body--mac", isIPad: () => false,+ isIPhone: () => apple, isWin11: async () => win11,+ resolvePlatformClass: () => platformClass};+ }+ if (id === "./emojiFont") {+ return {getEmojiFontStyle};+ }+ if (id === "./hostCapabilities") {+ return {getHostCapabilities: () => ({customAppearance: false})};+ }+ return new Proxy({}, {get: () => () => ""});+ },+ });+ const style = await exports.setInlineStyle(false, "");+ assert.equal(style.includes('font-family: "Emojis File Tree"'), platformClass === "body--windows" && !win11);+ assert.equal(style.includes('font-family: "Emojis Icon"'), win11);+ });+}diff --git a/app/src/util/assets.ts b/app/src/util/assets.tsindex 96013740c9..d877a684af 100644--- a/app/src/util/assets.ts+++ b/app/src/util/assets.ts@@ -15,7 +15,8 @@ import {isIPad,isIPhone,isMac,- isWin11+ isWin11,+ resolvePlatformClass} from "../protyle/util/compatibility";import {setCodeTheme} from "../protyle/render/util";import {refreshMermaidTheme} from "../protyle/render/mermaidRender";@@ -339,7 +340,8 @@ export const setInlineStyle = async (set = true, servePath = "../../../", exportif (set && allowCustomAppearance) {await ensureSelectedCustomFonts([...globalFonts, ...editorFonts, ...codeFonts]);}- const emojiPlatform = isMac() || isIPad() || isIPhone() ? "apple" : await isWin11() ? "windows11" : "other";+ const emojiPlatform = isMac() || isIPad() || isIPhone() ? "apple" : await isWin11() ? "windows11" :+ resolvePlatformClass() === "body--windows" ? "windows" : "other";let style = getEmojiFontStyle(emojiPlatform, servePath);style += getGlobalFontStyle(globalFonts);if (!set) {diff --git a/app/src/util/emojiFont.test.ts b/app/src/util/emojiFont.test.tsindex a3b45d1341..5f0e7e326d 100644--- a/app/src/util/emojiFont.test.ts+++ b/app/src/util/emojiFont.test.ts@@ -15,7 +15,7 @@ const getFace = (style: string, family: string) => style.split("@font-face").findescribe("Unicode 17 emoji fonts", () => {it("covers every code point of the 163 new fully qualified sequences in each platform override", () => {assert.equal(sequences.length, 163);- for (const platform of ["apple", "windows11", "other"] as const) {+ for (const platform of ["apple", "windows11", "windows", "other"] as const) {const style = getEmojiFontStyle(platform, "../../../");const firstFace = style.slice(0, style.indexOf("}"));assert.ok(firstFace.includes(NOTO_EMOJI_FONT_PATH));@@ -56,10 +56,19 @@ describe("Unicode 17 emoji fonts", () => {}});- it("compensates file tree emoji only when using the bundled Windows fallback", () => {+ it("aligns the bundled Windows file tree font without changing body or other platform metrics", () => {+ const windows = getEmojiFontStyle("windows", "");+ const treeFace = getFace(windows, "Emojis File Tree");+ assert.ok(treeFace.includes(`src: url(${NOTO_EMOJI_FONT_PATH})`));+ assert.ok(treeFace.includes("size-adjust: 92%"));+ assert.ok(treeFace.includes("ascent-override: 86%"));+ assert.ok(treeFace.includes("descent-override: 31%"));+ assert.ok(treeFace.includes("line-gap-override: 0%"));+ for (const family of ["Emojis", "Emojis Reset"]) {+ assert.equal(getFace(windows, family).trim(), getFace(getEmojiFontStyle("other", ""), family).trim());+ }for (const platform of ["apple", "windows11", "other"] as const) {- assert.ok(getEmojiFontStyle(platform, "").includes(- `--b3-file-tree-emoji-offset: ${platform === "other" ? "-1px" : "0px"}`));+ assert.equal(getFace(getEmojiFontStyle(platform, ""), "Emojis File Tree"), "");}});diff --git a/app/src/util/emojiFont.ts b/app/src/util/emojiFont.tsindex 42fda722cc..be6c10d7e8 100644--- a/app/src/util/emojiFont.ts+++ b/app/src/util/emojiFont.ts@@ -7,7 +7,7 @@ const UNICODE_17_EMOJI_RANGE = "U+200d, U+2640, U+2642, U+fe0f, U+1f3fb-1f3ff, Uconst DEJAVU_EMOJI_PRESENTATION_UNICODE_RANGE = "U+25fd-25fe, U+2614-2615, U+2648-2653, U+267f, U+2693, U+26a1, " +"U+26aa-26ab, U+1f0cf, U+1f311-1f318, U+1f42d-1f42e, U+1f431, U+1f435, U+1f600-1f64f";-export const getEmojiFontStyle = (platform: "apple" | "windows11" | "other", servePath: string) => {+export const getEmojiFontStyle = (platform: "apple" | "windows11" | "windows" | "other", servePath: string) => {let style;// Emojis Reset:覆盖正文和代码字体中的表情字形。// Emojis Additional:为系统表情字体补充指定字符和组合。@@ -97,6 +97,17 @@ export const getEmojiFontStyle = (platform: "apple" | "windows11" | "other", sersize-adjust: 92%;}`;}- // 内置字体分支供 Windows 文档树保留字形补偿,原生字体分支由字体度量完成对齐。- return `${style}\n:root { --b3-file-tree-emoji-offset: ${platform === "other" ? "-1px" : "0px"}; }`;+ if (platform === "windows") {+ // Windows 的 Noto 文档树图标通过字体度量对齐文字,正文和其他图标继续使用原有度量。+ // ascent/descent 的总和保持约 117%,仅改变基线,16px 字号时相当于上移约 1px。+ style += `\n@font-face {+ font-family: "Emojis File Tree";+ src: url(${servePath}${NOTO_EMOJI_FONT_PATH}) format("woff2");+ size-adjust: 92%;+ ascent-override: 86%;+ descent-override: 31%;+ line-gap-override: 0%;+}`;+ }+ return style;};diff --git a/app/tests/emojiFont.test.js b/app/tests/emojiFont.test.jsindex 76655b41ec..2cddc9489f 100644--- a/app/tests/emojiFont.test.js+++ b/app/tests/emojiFont.test.js@@ -28,14 +28,16 @@ const runElectron = async () => {const characters = [...sequences, ...oldSequences].map(sequence => String.fromCodePoint(...sequence.split("-").map(value => parseInt(value, 16))));win.webContents.debugger.attach("1.3");const command = (method, params) => win.webContents.debugger.sendCommand(method, params);- for (const platform of ["apple", "windows11", "other"]) {+ for (const platform of ["apple", "windows11", "windows", "other"]) {// 从导出目录加载真实 WOFF2,确保字体声明及相对路径能在离线页面使用。const html = `<html><meta charset="utf-8"><style>${getEmojiFontStyle(platform, "")}body { background: white; }.emoji { display: inline-block; font-size: 32px; margin: 3px; font-family: "Emojis Additional", "Emojis"; }.text { font-family: "Emojis Additional", "Emojis Reset", Arial, "Emojis"; }+.tree { font-family: "Emojis File Tree", "Emojis Additional", "Emojis"; }</style><body>${characters.map((char, index) => `<span id="emoji-${index}" class="emoji">${char}</span>`).join("")}<hr>${characters.map((char, index) => `<span id="text-${index}" class="emoji text">${char}</span>`).join("")}+<hr>${characters.map((char, index) => `<span id="tree-${index}" class="emoji tree">${char}</span>`).join("")}${characters.map((char, index) => `<span id="native-${index}" style='font-family:"Emojis"'>${char}</span>`).join("")}</body></html>`;const htmlPath = path.join(profile, `${platform}.html`);writeFileSync(htmlPath, html);@@ -44,13 +46,13 @@ ${characters.map((char, index) => `<span id="native-${index}" style='font-familyawait command("CSS.enable");await win.webContents.executeJavaScript("document.fonts.ready.then(() => true)");const {root} = await command("DOM.getDocument");- for (const context of ["emoji", "text"]) {+ for (const context of ["emoji", "text", "tree"]) {for (let index = 0; index < characters.length; index++) {const {nodeId} = await command("DOM.querySelector", {nodeId: root.nodeId, selector: `#${context}-${index}`});const {fonts} = await command("CSS.getPlatformFontsForNode", {nodeId});const label = `${platform}/${context}: ${[...sequences, ...oldSequences][index]}`;const glyphCount = fonts.reduce((count, font) => count + font.glyphCount, 0);- if (index < sequences.length || platform === "other") {+ if (index < sequences.length || platform === "other" || platform === "windows") {assert.equal(glyphCount, 1, `${label}: ${JSON.stringify(fonts)}`);assert.ok(fonts.every(font => font.isCustomFont), `${label}: ${JSON.stringify(fonts)}`);} else {diff --git a/app/tests/emojiIconAlignment.test.js b/app/tests/emojiIconAlignment.test.jsindex c03d8c1811..07b5aa3361 100644--- a/app/tests/emojiIconAlignment.test.js+++ b/app/tests/emojiIconAlignment.test.js@@ -18,7 +18,7 @@ const UNCALIBRATED_TOLERANCE = 1.5;// 独立格子里没有文字可参照,度量按文字对齐标定后会略微上移,这里只限制在可见范围内const STANDALONE_TOLERANCE = 2;-const icon = () => `<span class="b3-list-item__icon" id="icon"><span class="b3-list-item__emoji">${GLYPH}</span></span>`;+const icon = () => `<span class="b3-list-item__icon" id="icon">${GLYPH}</span>`;const text = (className) => `<span class="${className}" id="text">${TEXT}</span>`;// 每个图标位使用最贴近真实标记的结构;reference 指明该位置的对齐参照物@@ -175,7 +175,8 @@ const runElectron = async () => {await win.webContents.executeJavaScript(`document.fonts.ready.then(() => Promise.all([document.fonts.load('12px "Emojis Icon"'), document.fonts.load('14px "Emojis Icon"'),document.fonts.load('16px "Emojis Icon"'), document.fonts.load('19px "Emojis Icon"'),- document.fonts.load('20px "Emojis Icon"'), document.fonts.load('68px "Emojis Icon"')]))+ document.fonts.load('20px "Emojis Icon"'), document.fonts.load('68px "Emojis Icon"'),+ document.fonts.load('14px "Emojis File Tree"'), document.fonts.load('16px "Emojis File Tree"')])).then(() => new Promise(resolve => requestAnimationFrame(() =>requestAnimationFrame(() => setTimeout(resolve, 80)))))`);};@@ -183,7 +184,7 @@ const runElectron = async () => {// 文档树图标:逐字形核对与文字的对齐,并确认图片/SVG 图标不受影响for (const [platform, bodyClass, tolerance] of [["windows11", "body--windows", TEXT_TOLERANCE],- ["other", "body--windows", UNCALIBRATED_TOLERANCE],+ ["windows", "body--windows", UNCALIBRATED_TOLERANCE],["other", "body--linux", UNCALIBRATED_TOLERANCE],["other", "body--android", UNCALIBRATED_TOLERANCE],]) {@@ -207,8 +208,10 @@ const runElectron = async () => {const image = await win.webContents.capturePage();const size = image.getSize();const bitmap = image.getBitmap();+ const iconBoxes = new Map();for (const name of [...Object.keys(TREE_ICONS), "image", "svg"]) {const iconBox = await measure(win, `#icon-${name}`);+ iconBoxes.set(name, iconBox);if (name === "image" || name === "svg") {// 图片与 SVG 图标是替换元素,按 16px 居中,不参与墨迹对齐const child = await win.webContents.executeJavaScript(`(() => {@@ -224,24 +227,15 @@ const runElectron = async () => {`${name} graphic must stay centered`);continue;}- assert.equal(iconBox.childTag, "SPAN", `${name}: emoji glyph has a separate click-neutral wrapper`);- const shift = await win.webContents.executeJavaScript(`(() => {+ assert.equal(iconBox.childTag, null, `${name}: emoji glyph must not be wrapped`);+ const target = await win.webContents.executeJavaScript(`(() => {const icon = document.querySelector("#icon-${name}");- const emoji = icon.firstElementChild;- const before = emoji.getBoundingClientRect();- const pointerTarget = document.elementFromPoint(before.x + before.width / 2,- before.y + before.height / 2);- emoji.style.transform = "none";- const original = emoji.getBoundingClientRect();- emoji.style.transform = "";- return {delta: before.y - original.y, hitsIcon: pointerTarget === icon,- parentY: icon.getBoundingClientRect().y, parentHeight: icon.getBoundingClientRect().height};+ const rect = icon.getBoundingClientRect();+ return {transform: getComputedStyle(icon).transform,+ hitsIcon: document.elementFromPoint(rect.x + rect.width / 2, rect.y + rect.height / 2) === icon};})()`);- assert.equal(shift.delta, platform === "other" && bodyClass === "body--windows" ? -1 : 0,- `${platform}/${bodyClass}: only the Windows fallback shifts emoji ink`);- assert.equal(shift.hitsIcon, true, `${name}: glyph preserves the icon click target`);- assert.equal(shift.parentY, iconBox.y);- assert.equal(shift.parentHeight, iconBox.height);+ assert.equal(target.transform, "none", `${name}: alignment must not transform the icon`);+ assert.equal(target.hitsIcon, true, `${name}: glyph preserves the icon click target`);const textBox = await measure(win, `#text-${name}`);const iconInk = inkOf(bitmap, size, iconBox);const textInk = inkOf(bitmap, size, textBox);@@ -252,6 +246,28 @@ const runElectron = async () => {`${platform}/${fontSize}px ${name}: emoji ink center is ${delta.toFixed(2)}px ` +"off the adjacent text ink center");}+ if (platform === "windows") {+ // 与同一字体的正文度量对比,验证实际墨迹上移,且按钮盒子保持原位。+ await win.webContents.executeJavaScript(`(() => {+ document.querySelectorAll(".b3-list-item__icon").forEach(icon => {+ icon.style.fontFamily = "var(--b3-font-family-emoji)";+ });+ return new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));+ })()`);+ const originalImage = await win.webContents.capturePage();+ const originalBitmap = originalImage.getBitmap();+ for (const name of Object.keys(TREE_ICONS)) {+ const geometry = await measure(win, `#icon-${name}`);+ const corrected = inkOf(bitmap, size, geometry);+ const original = inkOf(originalBitmap, size, geometry);+ const shift = corrected.center - original.center;+ assert.ok(shift >= -1.5 && shift <= -0.5,+ `${lang}/${fontSize}px ${name}: font metrics shift ink by ${shift}px`);+ for (const field of ["x", "y", "width", "height"]) {+ assert.equal(geometry[field], iconBoxes.get(name)[field], `${name}: preserves button ${field}`);+ }+ }+ }}}@@ -266,8 +282,7 @@ const runElectron = async () => {const iconBox = await measure(win, "#icon");assert.ok(iconBox.fontFamily.includes('"Emojis Icon"'),`${site.name}: must use the icon emoji font, got ${iconBox.fontFamily}`);- assert.equal(iconBox.childTag, site.name === "document tree icon" ? "SPAN" : null,- `${site.name}: only file tree emoji use the compensation wrapper`);+ assert.equal(iconBox.childTag, null, `${site.name}: emoji glyph must not be wrapped`);const iconInk = inkOf(bitmap, size, iconBox);if (site.reference === "text") {const textInk = inkOf(bitmap, size, await measure(win, "#text"));