Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

fix(svg-to-pptx): preserve text baselines across SVG and PPTX conversion

hugohe33d1b7dc62787
diff --git a/skills/ppt-master/scripts/docs/svg-pipeline.md b/skills/ppt-master/scripts/docs/svg-pipeline.md
index 665ca7f8..6dc41369 100644
--- a/skills/ppt-master/scripts/docs/svg-pipeline.md
+++ b/skills/ppt-master/scripts/docs/svg-pipeline.md
@@ -1067,6 +1067,39 @@ Requirements:
## Measuring, wrapping, and calibrating text before authoring
+Ordinary generated text frames preserve the SVG's first-line baseline using
+`svg_to_pptx/drawingml/text_baseline.py` and the bundled `font_metrics.json`.
+The metric table records numeric OpenType fields and source-font versions;
+export never reads installed fonts. The selected style uses `typo` metrics
+when `USE_TYPO_METRICS` is set, otherwise `win` metrics. Missing italic styles
+keep the matching bold face when present, then fall back to regular metrics;
+missing faces use an ascent ratio of 0.8. Font aliases resolve through the
+same mapping as emitted text runs.
+
+The first visual line combines the largest size-adjusted ascent and descent
+of its active Latin/CJK faces. Default spacing uses a 1.2-times-font-size
+line height; explicit `spcPts` spacing has a separate first-baseline model,
+including its transition at the natural line height. The renderer rounds
+explicit spacing and the final offset to whole points; the authored `spcPts`
+value stays intact. Preserved line breaks carry the preceding run's font
+properties so presentation defaults do not change line metrics. This behavior
+was measured in PowerPoint for Mac 16.113.2; other renderers and font versions
+can differ. SVG glyph bounds and checker measurements are not PPT frame offsets.
+
+Ordinary horizontal PPTX text imports use the same baseline model with font
+roles resolved from the source DrawingML, including theme fonts, and carry
+`data-pptx-text-baseline="metrics-v1"` on the SVG text element.
+Fixed line advances remain absolute; percentage spacing scales the natural
+line height, with 100% equivalent to the default spacing. Baseline coordinates
+retain enough precision to avoid accumulating inset drift on repeated edits.
+The marker survives line splitting and semantic-shape projection. When marked text is
+rebuilt inside an exact `data-pptx-frame`, export subtracts the shared baseline
+offset from the SVG y coordinate before reconstructing the top inset. Unmarked
+exact-frame text retains the earlier `0.85 * font-size` convention, so existing
+round-trip workspaces do not require migration. Unchanged source text bodies
+still restore their original XML. Native math, baseline-shifted runs, and
+vertical text retain their separate positioning models.
+
`text_measure.py` imports the same single-line DrawingML width estimator used by
the SVG quality checker.
Use Arial, Times New Roman, Georgia, Verdana, Calibri, Cambria, Trebuchet MS, or
diff --git a/skills/ppt-master/scripts/pptx_to_svg/txbody_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/txbody_to_svg.py
index 8fb3fdf4..cea75dbb 100644
--- a/skills/ppt-master/scripts/pptx_to_svg/txbody_to_svg.py
+++ b/skills/ppt-master/scripts/pptx_to_svg/txbody_to_svg.py
@@ -28,6 +28,7 @@ from unicodedata import east_asian_width
from xml.etree import ElementTree as ET
from hyperlink_contract import SOURCE_HREF_ATTR
+from svg_to_pptx.drawingml.text_baseline import drawingml_text_baseline_offset
from svg_to_pptx.drawingml.utils import detect_text_lang, is_cjk_char
from .color_resolver import ColorPalette, find_color_elem, resolve_color
@@ -69,6 +70,8 @@ class TextRun:
is_break: bool = False # marks an a:br within a paragraph
hyperlink_href: str | None = None
formula_latex: str | None = None
+ font_faces: dict[str, str] = field(default_factory=dict)
+ baseline_shifted: bool = False
HyperlinkResolver = Callable[[str, str], str | None]
@@ -90,6 +93,7 @@ class TextParagraph:
indent_px: float = 0.0
margin_left_px: float = 0.0
line_height_ratio: float = DEFAULT_LINE_HEIGHT_RATIO
+ line_spacing_px: float | None = None
space_before_px: float = 0.0
space_after_px: float = 0.0
empty_line_font_size_px: float = DEFAULT_FONT_SIZE_PX
@@ -206,6 +210,13 @@ def convert_txbody(
bottom_y = inner_y + inner_h
text_blocks: list[str] = []
+ # Semantic rebuilding can merge paragraphs back into one native body.
+ # Keep one baseline convention throughout that body when math or shifted
+ # runs require the exporter's separate vertical-extent model.
+ metrics_baseline = not any(
+ run.formula_latex is not None or run.baseline_shifted
+ for para in paragraphs for run in para.runs
+ )
for para, lines, height, before, after in zip(
paragraphs,
para_lines,
@@ -217,7 +228,10 @@ def convert_txbody(
visible_lines = _clip_lines_to_bottom(para, lines, cursor_y, bottom_y)
if visible_lines:
text_blocks.append(
- _emit_paragraph(para, visible_lines, inner_x, inner_w, cursor_y)
+ _emit_paragraph(
+ para, visible_lines, inner_x, inner_w, cursor_y,
+ metrics_baseline=metrics_baseline,
+ )
)
cursor_y += height + after
if cursor_y >= bottom_y:
@@ -668,6 +682,9 @@ def _parse_paragraph(
para.margin_left_px = _emu_px_attr_chain(para_style_chain, "marL", 0.0)
para.indent_px = _emu_px_attr_chain(para_style_chain, "indent", 0.0)
para.line_height_ratio = _line_height_ratio(para_style_chain)
+ line_spacing = _child_chain(para_style_chain, "a:lnSpc")
+ if line_spacing is not None and line_spacing.find("a:spcPts", NS) is not None:
+ para.line_spacing_px = _spacing_points_px((line_spacing,), "a:spcPts")
para.space_before_px = _spacing_points_px(para_style_chain, "a:spcBef/a:spcPts")
para.space_after_px = _spacing_points_px(para_style_chain, "a:spcAft/a:spcPts")
para.bullet_prefix = _resolve_bullet_prefix(
@@ -788,6 +805,8 @@ def _apply_norm_autofit(
for para in paragraphs:
para.empty_line_font_size_px *= font_scale
para.line_height_ratio *= line_scale
+ if para.line_spacing_px is not None:
+ para.line_spacing_px *= line_scale
for run in para.runs:
run.font_size_px *= font_scale
@@ -944,6 +963,11 @@ def _build_run(
strikethrough=strikethrough,
letter_spacing_px=letter_spacing_px,
hyperlink_href=hyperlink_href,
+ font_faces={
+ "latin": latin_face or "Segoe UI",
+ "ea": ea_face or latin_face or "Microsoft YaHei",
+ },
+ baseline_shifted=_attr_chain(style_chain, "baseline") not in {None, "0"},
)
@@ -996,7 +1020,7 @@ def _line_height_ratio(sources: tuple[ET.Element | None, ...]) -> float:
if spc_pct is None:
return DEFAULT_LINE_HEIGHT_RATIO
try:
- return float(spc_pct.attrib.get("val", "100000")) / 100000.0
+ return DEFAULT_LINE_HEIGHT_RATIO * float(spc_pct.attrib.get("val", "100000")) / 100000.0
except ValueError:
return DEFAULT_LINE_HEIGHT_RATIO
@@ -1492,6 +1516,8 @@ def _copy_run(run: TextRun, *, text: str) -> TextRun:
letter_spacing_px=run.letter_spacing_px,
hyperlink_href=run.hyperlink_href,
formula_latex=run.formula_latex,
+ font_faces=dict(run.font_faces),
+ baseline_shifted=run.baseline_shifted,
)
@@ -1499,7 +1525,7 @@ def _paragraph_height_from_lines(p: TextParagraph,
lines: list[list[TextRun]]) -> float:
"""Total px height after wrapping. Each line uses its own max font size."""
if not lines:
- return p.empty_line_font_size_px * p.line_height_ratio
+ return _line_height(p, [])
height = 0.0
for line in lines:
height += _line_height(p, line)
@@ -1507,6 +1533,8 @@ def _paragraph_height_from_lines(p: TextParagraph,
def _line_height(p: TextParagraph, line: list[TextRun]) -> float:
+ if p.line_spacing_px is not None:
+ return p.line_spacing_px
return _line_font_size(p, line) * p.line_height_ratio
@@ -1554,6 +1582,8 @@ def _emit_paragraph(
lines: list[list[TextRun]],
inner_x: float, inner_w: float,
top_y: float,
+ *,
+ metrics_baseline: bool,
) -> str:
"""Render a paragraph (already split into lines) as one <text> element.
@@ -1587,7 +1617,26 @@ def _emit_paragraph(
return ""
first_run = visible_lines[first_line_idx][0]
- first_baseline = top_y + 0.85 * first_run.font_size_px
+ baseline_offset = 0.85 * first_run.font_size_px
+ if metrics_baseline:
+ baseline_offset = drawingml_text_baseline_offset(
+ [
+ {
+ 'text': run.text,
+ 'font_size': run.font_size_px,
+ 'font_family': run.font_family,
+ 'font_faces': run.font_faces,
+ 'font_weight': '700' if run.bold else '400',
+ 'font_style': 'italic' if run.italic else 'normal',
+ }
+ for run in visible_lines[first_line_idx]
+ ],
+ {},
+ default_size=first_run.font_size_px,
+ line_spacing_px=para.line_spacing_px,
+ line_spacing_ratio=para.line_height_ratio / DEFAULT_LINE_HEIGHT_RATIO,
+ )
+ first_baseline = top_y + baseline_offset
spans: list[str] = []
for line_idx, line in enumerate(visible_lines):
@@ -1602,7 +1651,7 @@ def _emit_paragraph(
if line_advance is not None:
spans.append(
f'<tspan x="{fmt_num(anchor_x)}" '
- f'dy="{fmt_num(line_advance)}"></tspan>'
+ f'dy="{fmt_num(line_advance, 8)}"></tspan>'
)
continue
line_has_hyperlink = any(run.hyperlink_href for run in line)
@@ -1615,7 +1664,7 @@ def _emit_paragraph(
for run in line
)
position_attrs = (
- f' x="{fmt_num(anchor_x)}" dy="{fmt_num(line_advance)}"'
+ f' x="{fmt_num(anchor_x)}" dy="{fmt_num(line_advance, 8)}"'
if line_advance is not None
else ''
)
@@ -1627,19 +1676,21 @@ def _emit_paragraph(
if run.formula_latex is not None:
spans.append(
f'<tspan x="{fmt_num(anchor_x)}" '
- f'dy="{fmt_num(line_advance)}">'
+ f'dy="{fmt_num(line_advance, 8)}">'
f'{_run_tspan_markup(run)}</tspan>'
)
else:
spans.append(
f'<tspan x="{fmt_num(anchor_x)}" '
- f'dy="{fmt_num(line_advance)}"'
+ f'dy="{fmt_num(line_advance, 8)}"'
f'{attrs}>{_xml_escape(run.text)}</tspan>'
)
else:
spans.append(_run_tspan_markup(run))
base_attrs = _text_base_attrs(first_run, anchor_x, first_baseline, text_anchor)
+ if metrics_baseline:
+ base_attrs += ' data-pptx-text-baseline="metrics-v1"'
return f"<text{base_attrs}>{''.join(spans)}</text>"
@@ -1647,7 +1698,7 @@ def _text_base_attrs(run: TextRun | None, x: float, y: float,
text_anchor: str) -> str:
parts = [
f'x="{fmt_num(x)}"',
- f'y="{fmt_num(y)}"',
+ f'y="{fmt_num(y, 8)}"',
f'text-anchor="{text_anchor}"',
'xml:space="preserve"',
]
diff --git a/skills/ppt-master/scripts/svg_finalize/flatten_tspan.py b/skills/ppt-master/scripts/svg_finalize/flatten_tspan.py
index 498e2e5f..5d0b6cdd 100644
--- a/skills/ppt-master/scripts/svg_finalize/flatten_tspan.py
+++ b/skills/ppt-master/scripts/svg_finalize/flatten_tspan.py
@@ -175,6 +175,11 @@ def copy_text_attrs(
v = src_el.get(k)
if v is not None:
dst_el.set(k, v)
+ # A split row must retain the imported baseline/inset convention, even
+ # though the version marker is not an inherited SVG presentation property.
+ baseline_attr = "data-pptx-text-baseline"
+ if baseline_attr not in exclude and src_el.get(baseline_attr) is not None:
+ dst_el.set(baseline_attr, src_el.get(baseline_attr))
# xml:space preservation
xml_space = src_el.get("{http://www.w3.org/XML/1998/namespace}space")
if xml_space is not None and "{http://www.w3.org/XML/1998/namespace}space" not in exclude:
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py
index ab70fb16..9caa5e05 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py
@@ -51,6 +51,7 @@ from .hyperlinks import (
)
from .theme_colors import color_node_xml
from .theme_fonts import theme_font_tokens
+from .text_baseline import drawingml_text_baseline_offset
from .text_properties import (
drawingml_letter_spacing,
normalize_project_text_segments,
@@ -3091,6 +3092,12 @@ def _build_run_xml(
) -> str:
"""Build a single <a:r> XML from a run dict. Supports gradient fills on text."""
if run.get('_line_break'):
+ break_run = run.get('_line_break_run')
+ if break_run is not None:
+ properties = dict(break_run)
+ properties.pop(HYPERLINK_RID_KEY, None)
+ properties.pop(HYPERLINK_ACTION_KEY, None)
+ return f'<a:br>{_build_run_properties_xml(properties, default_fonts, ctx)}</a:br>'
return '<a:br/>'
text = str(run['text'])
inline_formula = run.get(_INLINE_FORMULA_KEY)
@@ -3382,6 +3389,50 @@ def convert_text(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:
font_size,
),
)
+ # Legacy imported frames retain their original baseline/inset convention.
+ # Native math and shifted runs retain their own vertical-extent model.
+ # Ordinary text instead needs PowerPoint's first-line baseline, which is
+ # distinct from the glyph bounds used above and by SVG quality checks.
+ metrics_baseline = (
+ elem.get('data-pptx-frame') is None
+ or elem.get('data-pptx-text-baseline') == 'metrics-v1'
+ )
+ if metrics_baseline and not any(
+ run.get(_INLINE_FORMULA_KEY) is not None or run.get('baseline_shift')
+ for run in runs
+ ):
+ first_line_runs = runs
+ last_line_runs = runs
+ if paragraph_runs is not None:
+ # Paragraph extraction replaces a typed marker with a native bullet
+ # that inherits the body font; its discarded run is not line ink.
+ first_line_runs, _bullet = _extract_text_bullet(visual_line_runs[0])
+ last_line_runs = paragraph_runs[-1]
+ for index, run in enumerate(last_line_runs):
+ if run.get('_line_break'):
+ last_line_runs = paragraph_runs[-1][index + 1:]
+ first_line_ascent = drawingml_text_baseline_offset(
+ first_line_runs,
+ fonts,
+ default_size=font_size,
+ line_spacing_px=line_height_px if paragraph_runs is not None else None,
+ language=ctx.primary_language,
+ )
+ largest_last_size = max(
+ (font_px_to_hpt(run.get('font_size', font_size)) / FONT_PX_TO_HUNDREDTHS_PT
+ for run in last_line_runs if run.get('text')),
+ default=font_size,
+ )
+ text_height += max(0.0, (largest_last_size - font_size) * 1.5)
+ # An unformatted break can inherit the presentation's default size
+ # instead of the preceding run, changing first-line ascent and advance.
+ for paragraph in paragraph_runs or []:
+ previous_run = None
+ for run in paragraph:
+ if run.get('_line_break') and previous_run is not None:
+ run['_line_break_run'] = previous_run
+ elif not run.get('_line_break'):
+ previous_run = run
padding = _textbox_padding(font_size)
# Adjust position based on text-anchor. This first box follows the visible
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/font_metrics.json b/skills/ppt-master/scripts/svg_to_pptx/drawingml/font_metrics.json
new file mode 100644
index 00000000..c4d07582
--- /dev/null
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/font_metrics.json
@@ -0,0 +1,1148 @@
+{
+ "schema": "ppt-master.font-metrics.v1",
+ "source": "Raw OpenType head, hhea, OS/2 and name tables. Unprefixed source_file names identify fonts bundled with Microsoft PowerPoint for Mac 16.113.2 (26092012); paths identify supplemental macOS system fonts or the Office CloudFonts cache. Numeric metrics only; no font outlines. Family keys use English legacy name ID 1, keeping weight variants separate. hhea/typo descents are signed; win descents are unsigned. SHA-256 identifies the complete source file, and face_index identifies a collection face.",
+ "families": {
+ "aptos": {
+ "regular": {
+ "face": "Aptos",
+ "source_file": "Aptos.ttf",
+ "face_index": 0,
+ "font_version": "Version 2.01;O365",
+ "sha256": "95980114fcfd42f2f9c446dae429b70582bf2f03097d68433ea9e7d85a49da0b",
+ "units_per_em": 2048,
+ "hhea": [1923, -577, 0],
+ "typo": [1923, -577, 0],
+ "win": [2068, 563],
+ "fsSelection": 192
+ },
+ "bold": {
+ "face": "Aptos Bold",
+ "source_file": "Aptos-Bold.ttf",
+ "face_index": 0,
+ "font_version": "Version 2.01;O365",
+ "sha256": "cf4b35ac6d81e0eb42ffa44c3829b710c058de6fa3cf2c7cdad0407e22538877",
+ "units_per_em": 2048,
+ "hhea": [1923, -577, 0],
+ "typo": [1923, -577, 0],
+ "win": [2068, 563],
+ "fsSelection": 160
+ },
+ "italic": {
+ "face": "Aptos Italic",
+ "source_file": "Aptos-Italic.ttf",
+ "face_index": 0,
+ "font_version": "Version 2.01;O365",
+ "sha256": "888909eceb9acd84157078cc097c11f8a94a34ff3bd3fe08194ce7866f5998d1",
+ "units_per_em": 2048,
+ "hhea": [1923, -577, 0],
+ "typo": [1923, -577, 0],
+ "win": [2068, 563],
+ "fsSelection": 129
+ },
+ "bold-italic": {
+ "face": "Aptos Bold Italic",
+ "source_file": "Aptos-Bold-Italic.ttf",
+ "face_index": 0,
+ "font_version": "Version 2.01;O365",
+ "sha256": "7d7ba35b867c5873274466c743a9812c7bca1a0828f137f7697ae311664f41b9",
+ "units_per_em": 2048,
+ "hhea": [1923, -577, 0],
+ "typo": [1923, -577, 0],
+ "win": [2068, 563],
+ "fsSelection": 161
+ }
+ },
+ "arial": {
+ "regular": {
+ "face": "Arial",
+ "source_file": "arial.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.80i",
+ "sha256": "15663c7e8495594c6136eb51b11983eb8f5bbcdd07bb2c327e0d1e83415b0f06",
+ "units_per_em": 2048,
+ "hhea": [1854, -434, 67],
+ "typo": [1491, -431, 307],
+ "win": [1854, 434],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Arial Bold",
+ "source_file": "arialbd.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.80i",
+ "sha256": "b018b20bd6392de9ad3c5f0a1dcd23ad1fdf94227652fd92541521c32d8e5fc1",
+ "units_per_em": 2048,
+ "hhea": [1854, -434, 67],
+ "typo": [1491, -431, 307],
+ "win": [1854, 434],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Arial Italic",
+ "source_file": "ariali.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.80i",
+ "sha256": "541466c87057d2f665fe190ec1e8011c82326ef9aaae0c318244db88b1ee63f5",
+ "units_per_em": 2048,
+ "hhea": [1854, -434, 67],
+ "typo": [1491, -425, 307],
+ "win": [1854, 434],
+ "fsSelection": 1
+ },
+ "bold-italic": {
+ "face": "Arial Bold Italic",
+ "source_file": "arialbi.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.80i",
+ "sha256": "399f00fe9cca7136639df72e976914c3713cbb321374e52def9ab5a10815904e",
+ "units_per_em": 2048,
+ "hhea": [1854, -434, 67],
+ "typo": [1491, -431, 307],
+ "win": [1854, 434],
+ "fsSelection": 33
+ }
+ },
+ "baskerville old face": {
+ "regular": {
+ "face": "Baskerville Old Face",
+ "source_file": "BaskervilleOldFace.ttf",
+ "face_index": 0,
+ "font_version": "Version 1.51",
+ "sha256": "529c972a6d5c1992c76e908255f655f98989b74b146058c90555af6d925a1715",
+ "units_per_em": 2048,
+ "hhea": [1536, -512, 0],
+ "typo": [1408, -366, 417],
+ "win": [1805, 531],
+ "fsSelection": 64
+ }
+ },
+ "braggadocio": {
+ "regular": {
+ "face": "Braggadocio",
+ "source_file": "Braggadocio.ttf",
+ "face_index": 0,
+ "font_version": "Version 1.52",
+ "sha256": "ae0e2bd920b20bcface2cb063f401cfd71551c4c3cb616210c59f7b50aa89a7e",
+ "units_per_em": 2048,
+ "hhea": [1587, -313, 0],
+ "typo": [1587, -313, 291],
+ "win": [2021, 455],
+ "fsSelection": 64
+ }
+ },
+ "calibri": {
+ "regular": {
+ "face": "Calibri",
+ "source_file": "Calibri.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.20;O365",
+ "sha256": "ea801e1f869b55464339058b1d4263d07cc074a18e20aa3ee1d07901423dee53",
+ "units_per_em": 2048,
+ "hhea": [1950, -550, 0],
+ "typo": [1536, -512, 452],
+ "win": [1950, 550],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Calibri Bold",
+ "source_file": "Calibrib.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.20;O365",
+ "sha256": "ac1cf97565de97cdc322228d875dc18c1131656c5138173e2c6d8ac7a37aa7f2",
+ "units_per_em": 2048,
+ "hhea": [1950, -550, 0],
+ "typo": [1536, -512, 452],
+ "win": [1950, 550],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Calibri Italic",
+ "source_file": "Calibrii.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.20;O365",
+ "sha256": "38e28b619448710314a298dd66305a3b8f494a854f19d40aa18b9872e61911fe",
+ "units_per_em": 2048,
+ "hhea": [1950, -550, 0],
+ "typo": [1536, -512, 452],
+ "win": [1950, 550],
+ "fsSelection": 1
+ },
+ "bold-italic": {
+ "face": "Calibri Bold Italic",
+ "source_file": "Calibriz.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.20;O365",
+ "sha256": "77117338878fefc82770d27303bcca90e900f2ef59a0a87d294b7744ec158b5b",
+ "units_per_em": 2048,
+ "hhea": [1950, -550, 0],
+ "typo": [1536, -512, 452],
+ "win": [1950, 550],
+ "fsSelection": 33
+ }
+ },
+ "cambria": {
+ "regular": {
+ "face": "Cambria",
+ "source_file": "Cambria.ttc",
+ "face_index": 0,
+ "font_version": "Version 6.90i",
+ "sha256": "ca2a527ab14967b1c7170a97329ed29f38af51b71c8c2073d89d1c055de22de1",
+ "units_per_em": 2048,
+ "hhea": [1946, -455, 0],
+ "typo": [1593, -455, 353],
+ "win": [1946, 455],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Cambria Bold",
+ "source_file": "Cambriab.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.90i",
+ "sha256": "5f686e13ff1b0f4616d6f3e24bd4b916df671cfb44397f7ddfba3ee03eeee10a",
+ "units_per_em": 2048,
+ "hhea": [1946, -455, 0],
+ "typo": [1593, -455, 353],
+ "win": [1946, 455],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Cambria Italic",
+ "source_file": "Cambriai.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.90i",
+ "sha256": "926b632b6ad114075c083539e3db300accdfac3afe2eabbec3e7e4792f3526ec",
+ "units_per_em": 2048,
+ "hhea": [1946, -455, 0],
+ "typo": [1593, -455, 353],
+ "win": [1946, 455],
+ "fsSelection": 1
+ },
+ "bold-italic": {
+ "face": "Cambria Bold Italic",
+ "source_file": "Cambriaz.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.90i",
+ "sha256": "dd7fc00fe4c8bd7755788d30632c16c81769f37459b0c9c2813c9c3ff3447c8a",
+ "units_per_em": 2048,
+ "hhea": [1946, -455, 0],
+ "typo": [1593, -455, 353],
+ "win": [1946, 455],
+ "fsSelection": 33
+ }
+ },
+ "candara": {
+ "regular": {
+ "face": "Candara",
+ "source_file": "Candara.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.61i",
+ "sha256": "31ef1a249923a19f1cb676e57b9873bdb83f5bb42baf9c6ad9d03906663da294",
+ "units_per_em": 2048,
+ "hhea": [1484, -564, 452],
+ "typo": [1484, -564, 452],
+ "win": [1950, 550],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Candara Bold",
+ "source_file": "Candarab.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.61i",
+ "sha256": "678afaf43e51a054c4c1c9908a86a3870d38b21f30b83751cc9210c56e7f1d39",
+ "units_per_em": 2048,
+ "hhea": [1484, -564, 452],
+ "typo": [1484, -564, 452],
+ "win": [1950, 550],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Candara Italic",
+ "source_file": "Candarai.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.61i",
+ "sha256": "b4179708cd7819a5d65680823b7f97e1b98a16c611f391c1d6162b53818b8ee3",
+ "units_per_em": 2048,
+ "hhea": [1484, -564, 452],
+ "typo": [1484, -564, 452],
+ "win": [1950, 550],
+ "fsSelection": 1
+ },
+ "bold-italic": {
+ "face": "Candara Bold Italic",
+ "source_file": "Candaraz.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.61i",
+ "sha256": "c2384d57476426c17186dcd2580a176c92e6857fde70525314aa90745a5b8a42",
+ "units_per_em": 2048,
+ "hhea": [1484, -564, 452],
+ "typo": [1484, -564, 452],
+ "win": [1950, 550],
+ "fsSelection": 33
+ }
+ },
+ "consolas": {
+ "regular": {
+ "face": "Consolas",
+ "source_file": "Consola.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.32i",
+ "sha256": "b1dc8633f1cca6a74b84a26e04d61dad05cb8151ee094964fdd30d4852386a6b",
+ "units_per_em": 2048,
+ "hhea": [1521, -527, 350],
+ "typo": [1521, -527, 350],
+ "win": [1884, 514],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Consolas Bold",
+ "source_file": "Consolab.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.32i",
+ "sha256": "ee7e1ee08ad5cc2e292f77aebb7fdd8b11ddb58d3968707e850d94168554d67e",
+ "units_per_em": 2048,
+ "hhea": [1521, -527, 350],
+ "typo": [1521, -527, 350],
+ "win": [1884, 514],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Consolas Italic",
+ "source_file": "Consolai.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.32i",
+ "sha256": "ad1158c5608b2f0f03a7e78e0181626ddebb6c49bd2385141027e2e827ca8f6a",
+ "units_per_em": 2048,
+ "hhea": [1521, -527, 350],
+ "typo": [1521, -527, 350],
+ "win": [1884, 514],
+ "fsSelection": 1
+ },
+ "bold-italic": {
+ "face": "Consolas Bold Italic",
+ "source_file": "Consolaz.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.32i",
+ "sha256": "fddcbcd483d3f60781b68fa74f763e20c0858570e81090ac8af62b460aa8f838",
+ "units_per_em": 2048,
+ "hhea": [1521, -527, 350],
+ "typo": [1521, -527, 350],
+ "win": [1884, 514],
+ "fsSelection": 33
+ }
+ },
+ "constantia": {
+ "regular": {
+ "face": "Constantia",
+ "source_file": "Constan.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.90i",
+ "sha256": "86448f9e0ce99376786556b1486417b25acd8da96d81bb8ee8ccd15b3135ea83",
+ "units_per_em": 2048,
+ "hhea": [1538, -510, 452],
+ "typo": [1538, -510, 452],
+ "win": [1950, 550],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Constantia Bold",
+ "source_file": "Constanb.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.90i",
+ "sha256": "dfd6df0556d9cb531d464ba8392bd711c4481383d6fab27532c60516c2f08411",
+ "units_per_em": 2048,
+ "hhea": [1538, -510, 452],
+ "typo": [1538, -510, 452],
+ "win": [1950, 550],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Constantia Italic",
+ "source_file": "Constani.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.90i",
+ "sha256": "4924d9ef2babc00ea43e2a87aa53a1b5315634d428d7fb367ec23687b9f997cf",
+ "units_per_em": 2048,
+ "hhea": [1538, -510, 452],
+ "typo": [1538, -510, 452],
+ "win": [1950, 550],
+ "fsSelection": 1
+ },
+ "bold-italic": {
+ "face": "Constantia Bold Italic",
+ "source_file": "Constanz.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.90i",
+ "sha256": "75757b4f00b30f80667ea5e1f25e42a33dee4572be41d697c8a8c2d514ec7648",
+ "units_per_em": 2048,
+ "hhea": [1538, -510, 452],
+ "typo": [1538, -510, 452],
+ "win": [1950, 550],
+ "fsSelection": 33
+ }
+ },
+ "dengxian": {
+ "regular": {
+ "face": "DengXian Regular",
+ "source_file": "Deng.ttf",
+ "face_index": 0,
+ "font_version": "Version 1.21",
+ "sha256": "b975b088200b56452b0cba317b0735ea457ee0eaac3b92ed927b6f0ec20d7568",
+ "units_per_em": 2048,
+ "hhea": [1659, -475, 0],
+ "typo": [1659, -475, 0],
+ "win": [1659, 475],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "DengXian Bold",
+ "source_file": "Dengb.ttf",
+ "face_index": 0,
+ "font_version": "Version 1.21",
+ "sha256": "be80e1246047a6489a2573c6426519c7cfe0d08c1669dd81c43bb67d39482a19",
+ "units_per_em": 2048,
+ "hhea": [1659, -475, 0],
+ "typo": [1659, -475, 0],
+ "win": [1659, 475],
+ "fsSelection": 32
+ }
+ },
+ "fangsong": {
+ "regular": {
+ "face": "FangSong",
+ "source_file": "Fangsong.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.01i",
+ "sha256": "d6d75adf4be24d51bbf08f7208359bfe7bdf6ec70806bbb9873412ba4e696f75",
+ "units_per_em": 256,
+ "hhea": [220, -36, 36],
+ "typo": [220, -36, 36],
+ "win": [220, 36],
+ "fsSelection": 64
+ }
+ },
+ "garamond": {
+ "regular": {
+ "face": "Garamond",
+ "source_file": "GARA.ttf",
+ "face_index": 0,
+ "font_version": "Version 2.40;O365",
+ "sha256": "c66e667b08b85b2058ccc75ccc6549157b96e2589fb5e534e80c1dd3a19496dc",
+ "units_per_em": 2048,
+ "hhea": [1765, -539, 0],
+ "typo": [1339, -539, 313],
+ "win": [1765, 539],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Garamond Bold",
+ "source_file": "GARABD.ttf",
+ "face_index": 0,
+ "font_version": "Version 2.40;O365",
+ "sha256": "1e568efed9d0c68f0ecd349ea9770d2df339eadbc1a625e188a3b4411d9c033c",
+ "units_per_em": 2048,
+ "hhea": [1765, -539, 0],
+ "typo": [1339, -539, 313],
+ "win": [1765, 539],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Garamond Italic",
+ "source_file": "GARAIT.ttf",
+ "face_index": 0,
+ "font_version": "Version 2.40;O365",
+ "sha256": "0e5a5b226790f997d79b354fd0a44832752b6ec265c7b148a318b2d12b582e73",
+ "units_per_em": 2048,
+ "hhea": [1765, -539, 0],
+ "typo": [1339, -539, 313],
+ "win": [1765, 539],
+ "fsSelection": 1
+ },
+ "bold-italic": {
+ "face": "Garamond Bold Italic",
+ "source_file": "GARABDIT.ttf",
+ "face_index": 0,
+ "font_version": "Version 1.00;O365",
+ "sha256": "272dce3ca72f1ca16fdb21b7faef7ffdd8878911e8709ec94d7d6eac1bdcdf76",
+ "units_per_em": 2048,
+ "hhea": [1765, -539, 0],
+ "typo": [1339, -539, 313],
+ "win": [1765, 539],
+ "fsSelection": 33
+ }
+ },
+ "georgia": {
+ "regular": {
+ "face": "Georgia",
+ "source_file": "/System/Library/Fonts/Supplemental/Georgia.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.00x-4",
+ "sha256": "4f54eb299fccea7f103edeb0d92437359bfd4441811d53222b82b335369f6218",
+ "units_per_em": 2048,
+ "hhea": [1878, -449, 0],
+ "typo": [1549, -444, 198],
+ "win": [1878, 449],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Georgia Bold",
+ "source_file": "/System/Library/Fonts/Supplemental/Georgia Bold.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.00x-4",
+ "sha256": "1cfa9abd55be746c798c22ef4eba88fce82257934897404be2dae53ed0a4142a",
+ "units_per_em": 2048,
+ "hhea": [1878, -449, 0],
+ "typo": [1549, -444, 198],
+ "win": [1878, 449],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Georgia Italic",
+ "source_file": "/System/Library/Fonts/Supplemental/Georgia Italic.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.00x-4",
+ "sha256": "7758840cacb7382db65aa038e9fd1194d077ba9b55fe748f9cfb196d2773ac4e",
+ "units_per_em": 2048,
+ "hhea": [1878, -449, 0],
+ "typo": [1549, -444, 198],
+ "win": [1878, 449],
+ "fsSelection": 1
+ },
+ "bold-italic": {
+ "face": "Georgia Bold Italic",
+ "source_file": "/System/Library/Fonts/Supplemental/Georgia Bold Italic.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.00x-4",
+ "sha256": "a2036878f47d0da1765869a8747cfb0079b6125776675bad352468b59ca4493d",
+ "units_per_em": 2048,
+ "hhea": [1878, -449, 0],
+ "typo": [1549, -444, 198],
+ "win": [1878, 449],
+ "fsSelection": 33
+ }
+ },
+ "kaiti": {
+ "regular": {
+ "face": "KaiTi",
+ "source_file": "Kaiti.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.01i",
+ "sha256": "483c7cdec7874dcc6c39d278c367c512a1b909b34d2776fd72c2a941fc3cfd2e",
+ "units_per_em": 256,
+ "hhea": [220, -36, 36],
+ "typo": [220, -36, 36],
+ "win": [220, 36],
+ "fsSelection": 64
+ }
+ },
+ "malgun gothic": {
+ "regular": {
+ "face": "Malgun Gothic",
+ "source_file": "malgun.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.67",
+ "sha256": "a476b34af18296df7d6e61b786affa451b845d7c9c05aadd9423569330251e66",
+ "units_per_em": 2048,
+ "hhea": [2229, -495, 0],
+ "typo": [1638, -410, 0],
+ "win": [2229, 495],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Malgun Gothic Bold",
+ "source_file": "malgunbd.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.60",
+ "sha256": "2bfad2b9a709caa70c4131d1c8ffb526dea53a996fd4f94b022c57ba77709825",
+ "units_per_em": 2048,
+ "hhea": [2229, -495, 0],
+ "typo": [1638, -410, 0],
+ "win": [2229, 495],
+ "fsSelection": 32
+ }
+ },
+ "meiryo": {
+ "regular": {
+ "face": "Meiryo",
+ "source_file": "meiryo.ttc",
+ "face_index": 0,
+ "font_version": "Version 6.30",
+ "sha256": "7207c466d70d897ab21489063f47eee03be6929c351e60845698c5ab4ae16b48",
+ "units_per_em": 2048,
+ "hhea": [2171, -901, 0],
+ "typo": [1798, -250, 1024],
+ "win": [2171, 901],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Meiryo Bold",
+ "source_file": "meiryob.ttc",
+ "face_index": 0,
+ "font_version": "Version 6.30",
+ "sha256": "b2dd42329222da79d8b9a42446b9fa55f44a517b7f5ab17660fcc77b6431aae6",
+ "units_per_em": 2048,
+ "hhea": [2171, -901, 0],
+ "typo": [1798, -250, 1024],
+ "win": [2171, 901],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Meiryo Italic",
+ "source_file": "meiryo.ttc",
+ "face_index": 1,
+ "font_version": "Version 6.30",
+ "sha256": "7207c466d70d897ab21489063f47eee03be6929c351e60845698c5ab4ae16b48",
+ "units_per_em": 2048,
+ "hhea": [2171, -901, 0],
+ "typo": [1798, -250, 1024],
+ "win": [2171, 901],
+ "fsSelection": 1
+ },
+ "bold-italic": {
+ "face": "Meiryo Bold Italic",
+ "source_file": "meiryob.ttc",
+ "face_index": 1,
+ "font_version": "Version 6.30",
+ "sha256": "b2dd42329222da79d8b9a42446b9fa55f44a517b7f5ab17660fcc77b6431aae6",
+ "units_per_em": 2048,
+ "hhea": [2171, -901, 0],
+ "typo": [1798, -250, 1024],
+ "win": [2171, 901],
+ "fsSelection": 33
+ }
+ },
+ "meiryo ui": {
+ "regular": {
+ "face": "Meiryo UI",
+ "source_file": "meiryo.ttc",
+ "face_index": 2,
+ "font_version": "Version 6.30",
+ "sha256": "7207c466d70d897ab21489063f47eee03be6929c351e60845698c5ab4ae16b48",
+ "units_per_em": 2048,
+ "hhea": [2171, -430, 0],
+ "typo": [1798, -250, 1024],
+ "win": [2171, 430],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Meiryo UI Bold",
+ "source_file": "meiryob.ttc",
+ "face_index": 2,
+ "font_version": "Version 6.30",
+ "sha256": "b2dd42329222da79d8b9a42446b9fa55f44a517b7f5ab17660fcc77b6431aae6",
+ "units_per_em": 2048,
+ "hhea": [2171, -430, 0],
+ "typo": [1798, -250, 1024],
+ "win": [2171, 430],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Meiryo UI Italic",
+ "source_file": "meiryo.ttc",
+ "face_index": 3,
+ "font_version": "Version 6.30",
+ "sha256": "7207c466d70d897ab21489063f47eee03be6929c351e60845698c5ab4ae16b48",
+ "units_per_em": 2048,
+ "hhea": [2171, -430, 0],
+ "typo": [1798, -250, 1024],
+ "win": [2171, 430],
+ "fsSelection": 1
+ },
+ "bold-italic": {
+ "face": "Meiryo UI Bold Italic",
+ "source_file": "meiryob.ttc",
+ "face_index": 3,
+ "font_version": "Version 6.30",
+ "sha256": "b2dd42329222da79d8b9a42446b9fa55f44a517b7f5ab17660fcc77b6431aae6",
+ "units_per_em": 2048,
+ "hhea": [2171, -430, 0],
+ "typo": [1798, -250, 1024],
+ "win": [2171, 430],
+ "fsSelection": 33
+ }
+ },
+ "microsoft jhenghei": {
+ "regular": {
+ "face": "Microsoft JhengHei",
+ "source_file": "MSJH.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.10i",
+ "sha256": "d7c8314856d7a7b3cc669d9cf27ffa15b5412af2863af90a79f88f75d105f78f",
+ "units_per_em": 2048,
+ "hhea": [2203, -521, 0],
+ "typo": [1823, -225, 0],
+ "win": [2203, 521],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Microsoft JhengHei Bold",
+ "source_file": "MSJHBD.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.10i",
+ "sha256": "12e60fa2d50ed03279d63bddf48b19a1d41a479f30162603aaec89b6d25d6e7e",
+ "units_per_em": 2048,
+ "hhea": [2203, -521, 0],
+ "typo": [1823, -225, 0],
+ "win": [2203, 521],
+ "fsSelection": 32
+ }
+ },
+ "microsoft yahei": {
+ "regular": {
+ "face": "Microsoft YaHei",
+ "source_file": "msyh.ttc",
+ "face_index": 0,
+ "font_version": "Version 6.30",
+ "sha256": "3084f1f88369af6bf9989c909024164d953d1e38d08734f05f28ef24b2f9d577",
+ "units_per_em": 2048,
+ "hhea": [2167, -536, 0],
+ "typo": [1663, -519, 9],
+ "win": [2167, 536],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Microsoft YaHei Bold",
+ "source_file": "msyhbd.ttc",
+ "face_index": 0,
+ "font_version": "Version 6.30",
+ "sha256": "519309b7ab0479c4dc3ace5e291de5a8702175be5586e165bc810267bd4619a5",
+ "units_per_em": 2048,
+ "hhea": [2167, -536, 0],
+ "typo": [1663, -519, 9],
+ "win": [2167, 536],
+ "fsSelection": 32
+ }
+ },
+ "microsoft yahei light": {
+ "regular": {
+ "face": "Microsoft YaHei Light",
+ "source_file": "msyhl.ttc",
+ "face_index": 0,
+ "font_version": "Version 6.24",
+ "sha256": "f25f39a6d56ec6d1b356254dd776219d71b7e6f3584b3ec1b83aab0ceb08881a",
+ "units_per_em": 2048,
+ "hhea": [2210, -514, 0],
+ "typo": [1655, -519, 9],
+ "win": [2080, 536],
+ "fsSelection": 256
+ }
+ },
+ "microsoft yahei ui": {
+ "regular": {
+ "face": "Microsoft YaHei UI",
+ "source_file": "msyh.ttc",
+ "face_index": 1,
+ "font_version": "Version 6.30",
+ "sha256": "3084f1f88369af6bf9989c909024164d953d1e38d08734f05f28ef24b2f9d577",
+ "units_per_em": 2048,
+ "hhea": [2080, -521, 0],
+ "typo": [1663, -519, 9],
+ "win": [2080, 521],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Microsoft YaHei UI Bold",
+ "source_file": "msyhbd.ttc",
+ "face_index": 1,
+ "font_version": "Version 6.30",
+ "sha256": "519309b7ab0479c4dc3ace5e291de5a8702175be5586e165bc810267bd4619a5",
+ "units_per_em": 2048,
+ "hhea": [2080, -521, 0],
+ "typo": [1663, -519, 9],
+ "win": [2080, 521],
+ "fsSelection": 32
+ }
+ },
+ "ms gothic": {
+ "regular": {
+ "face": "MS Gothic",
+ "source_file": "msgothic.ttc",
+ "face_index": 0,
+ "font_version": "Version 5.30",
+ "sha256": "dc68e70dce920b8fc279e56ee86a67950d192d02506515f848dd4d0d12e1bde9",
+ "units_per_em": 256,
+ "hhea": [220, -36, 0],
+ "typo": [220, -36, 0],
+ "win": [220, 36],
+ "fsSelection": 64
+ }
+ },
+ "ms mincho": {
+ "regular": {
+ "face": "MS Mincho",
+ "source_file": "msmincho.ttc",
+ "face_index": 0,
+ "font_version": "Version 5.30",
+ "sha256": "9c2edfd189157477cdbe60bfe85bad7cda4ae27bd66cd269288a07a50dcb2a85",
+ "units_per_em": 256,
+ "hhea": [220, -36, 0],
+ "typo": [220, -36, 0],
+ "win": [220, 36],
+ "fsSelection": 64
+ }
+ },
+ "ms pgothic": {
+ "regular": {
+ "face": "MS PGothic",
+ "source_file": "msgothic.ttc",
+ "face_index": 2,
+ "font_version": "Version 5.30",
+ "sha256": "dc68e70dce920b8fc279e56ee86a67950d192d02506515f848dd4d0d12e1bde9",
+ "units_per_em": 256,
+ "hhea": [220, -36, 0],
+ "typo": [220, -36, 0],
+ "win": [220, 36],
+ "fsSelection": 64
+ }
+ },
+ "ms pmincho": {
+ "regular": {
+ "face": "MS PMincho",
+ "source_file": "msmincho.ttc",
+ "face_index": 1,
+ "font_version": "Version 5.30",
+ "sha256": "9c2edfd189157477cdbe60bfe85bad7cda4ae27bd66cd269288a07a50dcb2a85",
+ "units_per_em": 256,
+ "hhea": [220, -36, 0],
+ "typo": [220, -36, 0],
+ "win": [220, 36],
+ "fsSelection": 64
+ }
+ },
+ "ms ui gothic": {
+ "regular": {
+ "face": "MS UI Gothic",
+ "source_file": "msgothic.ttc",
+ "face_index": 1,
+ "font_version": "Version 5.30",
+ "sha256": "dc68e70dce920b8fc279e56ee86a67950d192d02506515f848dd4d0d12e1bde9",
+ "units_per_em": 256,
+ "hhea": [220, -36, 0],
+ "typo": [220, -36, 0],
+ "win": [220, 36],
+ "fsSelection": 64
+ }
+ },
+ "segoe ui": {
+ "regular": {
+ "face": "Segoe UI",
+ "source_file": "~/Library/Group Containers/UBF8T346G9.Office/FontCache/4/CloudFonts/Segoe UI/41119599467.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.67;O365",
+ "sha256": "fcb0c4655a6bc4fd3e9fef00d5c90622e27710914cb1471e6b04c420bf489ded",
+ "units_per_em": 2048,
+ "hhea": [2210, -514, 0],
+ "typo": [1491, -431, 269],
+ "win": [2210, 514],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Segoe UI Bold",
+ "source_file": "~/Library/Group Containers/UBF8T346G9.Office/FontCache/4/CloudFonts/Segoe UI/48155170935.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.67;O365",
+ "sha256": "38444a06583e8e7a0669700ae55a018265491a101326d4e8c3fa32f704789829",
+ "units_per_em": 2048,
+ "hhea": [2210, -514, 0],
+ "typo": [1491, -431, 269],
+ "win": [2210, 514],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Segoe UI Italic",
+ "source_file": "~/Library/Group Containers/UBF8T346G9.Office/FontCache/4/CloudFonts/Segoe UI/41405981916.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.66;O365",
+ "sha256": "e1e3532a02226c950a3b004ca3750ef9f8311e5ca6d9f1f700945e5f5aee155b",
+ "units_per_em": 2048,
+ "hhea": [2210, -514, 0],
+ "typo": [1491, -431, 269],
+ "win": [2210, 514],
+ "fsSelection": 1
+ }
+ },
+ "simhei": {
+ "regular": {
+ "face": "SimHei",
+ "source_file": "SimHei.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.03i",
+ "sha256": "ef70e6bba293c9d30bdeb0dba2dd6019cceacbfddab3fb0c550ff14d9127c813",
+ "units_per_em": 256,
+ "hhea": [220, -36, 36],
+ "typo": [220, -36, 36],
+ "win": [220, 36],
+ "fsSelection": 64
+ }
+ },
+ "simsun": {
+ "regular": {
+ "face": "SimSun",
+ "source_file": "Simsun.ttc",
+ "face_index": 0,
+ "font_version": "Version 5.21",
+ "sha256": "05068fa1acae212120dcc7e98c884b174a6eca252a636b4b64030235473ec27e",
+ "units_per_em": 256,
+ "hhea": [220, -36, 36],
+ "typo": [220, -36, 36],
+ "win": [220, 36],
+ "fsSelection": 64
+ }
+ },
+ "stencil": {
+ "regular": {
+ "face": "Stencil",
+ "source_file": "Stencil.ttf",
+ "face_index": 0,
+ "font_version": "Version 1.52",
+ "sha256": "5d53b38fa8ff33d15676cdcd78b261681bfda861c449b4f7ddfd7574a5c11e18",
+ "units_per_em": 2048,
+ "hhea": [1490, -558, 0],
+ "typo": [1365, 0, 683],
+ "win": [1860, 567],
+ "fsSelection": 64
+ }
+ },
+ "stzhongsong": {
+ "regular": {
+ "face": "STZhongsong",
+ "source_file": "STZHONGS.ttf",
+ "face_index": 0,
+ "font_version": "Version 1.02",
+ "sha256": "be40ef56c9b9aefcf042c7602d673a46c06017a27d21ce020886e7acf24b18c3",
+ "units_per_em": 1000,
+ "hhea": [1007, -318, 0],
+ "typo": [800, -200, 144],
+ "win": [912, 225],
+ "fsSelection": 64
+ }
+ },
+ "tahoma": {
+ "regular": {
+ "face": "Tahoma",
+ "source_file": "tahoma.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.98;O365",
+ "sha256": "97e995a383dfb7afd2378297c0c2ce8862190f83f943a1222663871b7860892f",
+ "units_per_em": 2048,
+ "hhea": [2049, -423, 0],
+ "typo": [1566, -423, 59],
+ "win": [2049, 423],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Tahoma Bold",
+ "source_file": "tahomabd.ttf",
+ "face_index": 0,
+ "font_version": "Version 6.98;O365",
+ "sha256": "01b32af2fba9b28cebb2031bbcbbecab1762a6221a426a133104ebad373ea29b",
+ "units_per_em": 2048,
+ "hhea": [2049, -423, 0],
+ "typo": [1566, -423, 59],
+ "win": [2049, 423],
+ "fsSelection": 32
+ }
+ },
+ "times new roman": {
+ "regular": {
+ "face": "Times New Roman",
+ "source_file": "times.ttf",
+ "face_index": 0,
+ "font_version": "Version 7.00;O365",
+ "sha256": "e77f429f5cde743c30216c2d5917706d09ddd938990f4f5ae98bfd4b5c7d0495",
+ "units_per_em": 2048,
+ "hhea": [1825, -443, 0],
+ "typo": [1420, -442, 307],
+ "win": [1825, 443],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Times New Roman Bold",
+ "source_file": "timesbd.ttf",
+ "face_index": 0,
+ "font_version": "Version 7.00;O365",
+ "sha256": "3750f5d563d062ed8c4e2a0516da3374b8fbcdedee0608e107efd97ded80bcae",
+ "units_per_em": 2048,
+ "hhea": [1825, -443, 0],
+ "typo": [1387, -442, 307],
+ "win": [1825, 443],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Times New Roman Italic",
+ "source_file": "timesi.ttf",
+ "face_index": 0,
+ "font_version": "Version 7.00;O365",
+ "sha256": "f957cbaf4af5b52260462b486dd10a01507184dc39cdbbb3364e428b800b37e6",
+ "units_per_em": 2048,
+ "hhea": [1825, -443, 0],
+ "typo": [1422, -442, 307],
+ "win": [1825, 443],
+ "fsSelection": 1
+ },
+ "bold-italic": {
+ "face": "Times New Roman Bold Italic",
+ "source_file": "timesbi.ttf",
+ "face_index": 0,
+ "font_version": "Version 7.00;O365",
+ "sha256": "baad72fc175225bd00e60ce280841131ba8a170be3646901d38a9855ff1bdabc",
+ "units_per_em": 2048,
+ "hhea": [1825, -443, 0],
+ "typo": [1387, -442, 307],
+ "win": [1825, 443],
+ "fsSelection": 33
+ }
+ },
+ "trebuchet ms": {
+ "regular": {
+ "face": "Trebuchet MS",
+ "source_file": "/System/Library/Fonts/Supplemental/Trebuchet MS.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.00x",
+ "sha256": "ff1d49fde63aabd7f4fc7cd0a80ac7cdb1b9540058988fcbb64d7c23639a7386",
+ "units_per_em": 2048,
+ "hhea": [1923, -455, 0],
+ "typo": [1510, -420, 0],
+ "win": [1923, 455],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Trebuchet MS Bold",
+ "source_file": "/System/Library/Fonts/Supplemental/Trebuchet MS Bold.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.00x",
+ "sha256": "c7df0daa11665420461614fc22682c687852b2e1cf5c6ff9188096f5d2a8d0b2",
+ "units_per_em": 2048,
+ "hhea": [1923, -455, 0],
+ "typo": [1510, -420, 0],
+ "win": [1923, 455],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Trebuchet MS Italic",
+ "source_file": "/System/Library/Fonts/Supplemental/Trebuchet MS Italic.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.00x",
+ "sha256": "15012b4dfe5470d0f8b75d98b38c461cf81b295485061e1382dc30030c00f2cd",
+ "units_per_em": 2048,
+ "hhea": [1923, -455, 0],
+ "typo": [1510, -420, 0],
+ "win": [1923, 455],
+ "fsSelection": 1
+ },
+ "bold-italic": {
+ "face": "Trebuchet MS Bold Italic",
+ "source_file": "TrebuchetMSBoldItalic.ttf",
+ "face_index": 0,
+ "font_version": "Version 1.26",
+ "sha256": "40ec9117f62ee2b10a4ebd74d57f085e9730df73dbbcaa4ded3d99b7cdbd19a4",
+ "units_per_em": 2048,
+ "hhea": [1923, -455, 0],
+ "typo": [1510, -420, 0],
+ "win": [1923, 455],
+ "fsSelection": 33
+ }
+ },
+ "verdana": {
+ "regular": {
+ "face": "Verdana",
+ "source_file": "Verdana.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.02",
+ "sha256": "aef25c78eaf9cb243f62508ed5a373bb98918fe880a63b3e17ea0b123270175c",
+ "units_per_em": 2048,
+ "hhea": [2059, -430, 0],
+ "typo": [1566, -423, 202],
+ "win": [2059, 430],
+ "fsSelection": 64
+ },
+ "bold": {
+ "face": "Verdana Bold",
+ "source_file": "Verdana Bold.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.02",
+ "sha256": "bba4571a7cc83c0ccc8b96035e2b165526946b1d45baf73d1b402c65ed48de62",
+ "units_per_em": 2048,
+ "hhea": [2059, -430, 0],
+ "typo": [1566, -423, 202],
+ "win": [2059, 430],
+ "fsSelection": 32
+ },
+ "italic": {
+ "face": "Verdana Italic",
+ "source_file": "Verdana Italic.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.02",
+ "sha256": "ff503224a9c81914bfedbafe4d79246bd133ebcfad5b0ffc0cd9ebe18e96f9fb",
+ "units_per_em": 2048,
+ "hhea": [2059, -430, 0],
+ "typo": [1566, -423, 202],
+ "win": [2059, 430],
+ "fsSelection": 1
+ },
+ "bold-italic": {
+ "face": "Verdana Bold Italic",
+ "source_file": "Verdana Bold Italic.ttf",
+ "face_index": 0,
+ "font_version": "Version 5.02",
+ "sha256": "51644512b8e60d007c5c9fd17b9114364722124433bd3c6bb6166916aa9f863b",
+ "units_per_em": 2048,
+ "hhea": [2059, -430, 0],
+ "typo": [1566, -423, 202],
+ "win": [2059, 430],
+ "fsSelection": 33
+ }
+ },
+ "yu gothic": {
+ "regular": {
+ "face": "Yu Gothic Regular",
+ "source_file": "YuGothR.ttc",
+ "face_index": 0,
+ "font_version": "Version 1.85",
+ "sha256": "109b8dcaa475799278a8ca84fd5aeb94fa4fdbf7ee24f226e3de27e0e0c8a103",
+ "units_per_em": 2048,
+ "hhea": [1802, -455, 1024],
+ "typo": [1802, -246, 1024],
+ "win": [2017, 619],
+ "fsSelection": 0
+ },
+ "bold": {
+ "face": "Yu Gothic Bold",
+ "source_file": "YuGothB.ttc",
+ "face_index": 0,
+ "font_version": "Version 1.85",
+ "sha256": "39a1b42e01f83dc08e8ae0a455fb72fe7dbfb6fea65f8cf4e8a941ea683607fb",
+ "units_per_em": 2048,
+ "hhea": [1802, -455, 1024],
+ "typo": [1802, -246, 1024],
+ "win": [2024, 612],
+ "fsSelection": 32
+ }
+ },
+ "yu gothic ui": {
+ "regular": {
+ "face": "Yu Gothic UI Regular",
+ "source_file": "YuGothM.ttc",
+ "face_index": 1,
+ "font_version": "Version 1.85",
+ "sha256": "2b586ca104b51a4ebc8beab1ed99acfa4cd0cfdf38bcb60f6b86841d9cd47854",
+ "units_per_em": 2048,
+ "hhea": [2210, -514, 0],
+ "typo": [1491, -431, 269],
+ "win": [2210, 514],
+ "fsSelection": 0
+ },
+ "bold": {
+ "face": "Yu Gothic UI Bold",
+ "source_file": "YuGothB.ttc",
+ "face_index": 1,
+ "font_version": "Version 1.85",
+ "sha256": "39a1b42e01f83dc08e8ae0a455fb72fe7dbfb6fea65f8cf4e8a941ea683607fb",
+ "units_per_em": 2048,
+ "hhea": [2210, -514, 0],
+ "typo": [1491, -431, 269],
+ "win": [2210, 514],
+ "fsSelection": 32
+ }
+ }
+ }
+}
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/text_baseline.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/text_baseline.py
new file mode 100644
index 00000000..da330d15
--- /dev/null
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/text_baseline.py
@@ -0,0 +1,127 @@
+#!/usr/bin/env python3
+"""
+PPT Master - DrawingML Text Baseline
+
+Estimate the first baseline of ordinary top-anchored DrawingML text from
+bundled font metrics. See scripts/docs/svg-pipeline.md for the rendering scope.
+
+Usage:
+ Import drawingml_text_baseline_offset from the DrawingML converter.
+
+Examples:
+ offset = drawingml_text_baseline_offset(runs, fonts, default_size=40)
+
+Dependencies:
+ None (only uses standard library and sibling modules)
+"""
+
+from __future__ import annotations
+
+import json
+from fractions import Fraction
+from functools import lru_cache
+from pathlib import Path
+from typing import Any
+
+from .text_properties import parse_project_font_weight
+from .utils import (
+ FONT_PX_TO_HUNDREDTHS_PT,
+ font_px_to_hpt,
+ is_cjk_char,
+ parse_font_family,
+ primary_font_family,
+)
+
+
+@lru_cache(maxsize=1)
+def _font_metrics() -> dict[str, Any]:
+ with Path(__file__).with_name('font_metrics.json').open(encoding='utf-8') as handle:
+ return json.load(handle)['families']
+
+
+def _ascent_ratio(family: str, weight: str, style: str) -> Fraction:
+ faces = _font_metrics().get(primary_font_family(family), {})
+ bold = parse_project_font_weight(weight).value
+ face_style = 'bold' if bold else 'regular'
+ if style == 'italic':
+ face_style = 'bold-italic' if bold else 'italic'
+ # A synthesized italic keeps its real bold face when one is available.
+ # Unknown fonts use a fixed ratio, independent of installed fonts.
+ metrics = (
+ faces.get(face_style)
+ or (faces.get('bold') if bold else None)
+ or faces.get('regular')
+ )
+ if metrics is None:
+ return Fraction(4, 5)
+ source = 'typo' if metrics['fsSelection'] & 128 else 'win'
+ ascent, descent = metrics[source][:2]
+ return Fraction(ascent, ascent + abs(descent))
+
+
+def _whole_points(value: Fraction) -> int:
+ rounded = value + Fraction(1, 2)
+ return rounded.numerator // rounded.denominator
+
+
+def drawingml_text_baseline_offset(
+ runs: list[dict[str, Any]],
+ default_fonts: dict[str, str],
+ *,
+ default_size: float,
+ line_spacing_px: float | None = None,
+ line_spacing_ratio: float = 1.0,
+ language: str | None = None,
+) -> float:
+ """Return the first baseline's distance from a zero-inset frame top in px.
+
+ Call only for ordinary text, without native math or baseline shifts.
+ Runs describe the first visual line. Importers may supply resolved
+ ``font_faces`` to retain the original DrawingML script slots. Font sizes
+ and explicit line spacing use the same quantization as the emitted XML.
+ """
+ ascent = descent = largest_size = Fraction(0)
+ for run in runs:
+ if run.get('_line_break'):
+ break
+ text = str(run.get('text', ''))
+ if not text:
+ continue
+ size = Fraction(font_px_to_hpt(run.get('font_size', default_size)), 100)
+ fonts = run.get('font_faces') or (
+ parse_font_family(str(run['font_family']), language)
+ if run.get('font_family') else default_fonts
+ )
+ families = {fonts['ea'] if is_cjk_char(ch) else fonts['latin'] for ch in text}
+ for family in families:
+ ratio = _ascent_ratio(
+ family,
+ str(run.get('font_weight', '400')),
+ str(run.get('font_style', 'normal')),
+ )
+ ascent = max(ascent, size * ratio)
+ descent = max(descent, size * (1 - ratio))
+ largest_size = max(largest_size, size)
+
+ if not largest_size:
+ return 0.0
+ natural_height = Fraction(6, 5) * largest_size
+ baseline = natural_height * ascent / (ascent + descent)
+ if line_spacing_px is not None or line_spacing_ratio != 1.0:
+ spacing = natural_height * Fraction(str(line_spacing_ratio))
+ if line_spacing_px is not None:
+ spacing = Fraction(round(line_spacing_px * FONT_PX_TO_HUNDREDTHS_PT), 100)
+ # The compatible layout rounds fixed spacing before choosing its
+ # branch: 57.6pt becomes 58pt even when natural height is 57.6pt.
+ # Percentage spacing keeps its natural-height semantics.
+ spacing = Fraction(_whole_points(spacing))
+ minimum_baseline = Fraction(3, 4) * spacing
+ baseline = (
+ max(minimum_baseline, spacing - (natural_height - baseline))
+ if spacing <= natural_height else minimum_baseline
+ )
+
+ # PowerPoint's compatible layout rounds the first-line offset to whole
+ # points. Rational arithmetic preserves half-point ties (e.g. SimSun 64px)
+ # without float epsilons or Python round()'s ties-to-even behavior.
+ return float(_whole_points(baseline) * Fraction(4, 3))
diff --git a/skills/ppt-master/scripts/tests/test_native_export_guards.py b/skills/ppt-master/scripts/tests/test_native_export_guards.py
index d8100127..c845a024 100644
--- a/skills/ppt-master/scripts/tests/test_native_export_guards.py
+++ b/skills/ppt-master/scripts/tests/test_native_export_guards.py
@@ -435,8 +435,10 @@ class NativeExportGuardTests(unittest.TestCase):
self.assertEqual(len(group.findall('p:sp', NS)), 2)
frame = group.find('p:grpSpPr/a:xfrm', NS)
self.assertEqual(frame.get('rot'), '5400000')
- self.assertEqual(frame.find('a:off', NS).attrib, {'x': '487680', 'y': '1468755'})
- self.assertEqual(frame.find('a:chOff', NS).attrib, {'x': '944880', 'y': '981075'})
+ # Arial 20px has a native baseline offset of 15pt (20px), so the
+ # text child starts at y=100 before the group rotates around (100,120).
+ self.assertEqual(frame.find('a:off', NS).attrib, {'x': '516255', 'y': '1468755'})
+ self.assertEqual(frame.find('a:chOff', NS).attrib, {'x': '944880', 'y': '952500'})
self.assertFalse(group.findall('p:sp/p:spPr/a:xfrm[@rot]', NS))
def test_single_rect_matrix_matches_direct_geometry_and_skew_stays_rejected(self) -> None:
diff --git a/skills/ppt-master/scripts/tests/test_text_baseline.py b/skills/ppt-master/scripts/tests/test_text_baseline.py
new file mode 100644
index 00000000..2ed92d96
--- /dev/null
+++ b/skills/ppt-master/scripts/tests/test_text_baseline.py
@@ -0,0 +1,338 @@
+#!/usr/bin/env python3
+"""
+PPT Master - Native Text Baseline Regression Tests
+
+Check exported frame positions against PowerPoint-rendered baseline samples.
+Fixtures are self-contained and never read installed fonts.
+
+Usage:
+ python3 -m unittest tests.test_text_baseline
+
+Examples:
+ Run the module from the scripts directory.
+
+Dependencies:
+ Standard library and the local SVG-to-PPTX converter.
+"""
+
+from __future__ import annotations
+
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+from xml.etree import ElementTree as ET
+
+
+SCRIPTS_DIR = Path(__file__).resolve().parents[1]
+if str(SCRIPTS_DIR) not in sys.path:
+ sys.path.insert(0, str(SCRIPTS_DIR))
+
+from svg_to_pptx.drawingml.converter import convert_svg_to_slide_shapes # noqa: E402
+
+
+NS = {
+ 'a': 'http://schemas.openxmlformats.org/drawingml/2006/main',
+ 'm': 'http://schemas.openxmlformats.org/officeDocument/2006/math',
+ 'p': 'http://schemas.openxmlformats.org/presentationml/2006/main',
+}
+EMU_PER_PX = 9525
+
+
+class TextBaselineTests(unittest.TestCase):
+ def setUp(self) -> None:
+ temporary = tempfile.TemporaryDirectory()
+ self.addCleanup(temporary.cleanup)
+ self.root = Path(temporary.name)
+ self.svg_path = self.root / '01_baseline.svg'
+
+ def _export(self, body: str, *, text_flow: str = 'split') -> ET.Element:
+ self.svg_path.write_text(
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 720">'
+ f'{body}</svg>',
+ encoding='utf-8',
+ )
+ xml, *_rest = convert_svg_to_slide_shapes(
+ self.svg_path, resource_root=self.root, text_flow=text_flow,
+ )
+ return ET.fromstring(xml)
+
+ def _assert_top(self, shape: ET.Element, expected_px: float) -> None:
+ offset = shape.find('p:spPr/a:xfrm/a:off', NS)
+ self.assertIsNotNone(offset)
+ self.assertAlmostEqual(
+ int(offset.get('y')), expected_px * EMU_PER_PX, delta=1,
+ )
+
+ def _single_shape(self, slide: ET.Element) -> ET.Element:
+ shapes = slide.findall('.//p:sp', NS)
+ self.assertEqual(len(shapes), 1)
+ return shapes[0]
+
+ def test_default_spacing_uses_each_fonts_rendered_baseline(self) -> None:
+ # Mac PowerPoint 16.113.2: observed offsets rounded to the native pt grid.
+ samples = (
+ ('Arial', 38.6666666667),
+ ('Calibri', 37.3333333333),
+ ('SimSun', 41.3333333333),
+ ('SimHei', 41.3333333333),
+ ('Microsoft YaHei', 38.6666666667),
+ )
+ for family, baseline_offset in samples:
+ with self.subTest(family=family):
+ slide = self._export(
+ f'<text x="100" y="200" font-size="40" '
+ f'font-family="{family}">Hgpq</text>'
+ )
+ shape = self._single_shape(slide)
+ self._assert_top(shape, 200 - baseline_offset)
+ self.assertIsNone(shape.find('.//a:lnSpc', NS))
+ body = shape.find('p:txBody/a:bodyPr', NS)
+ self.assertEqual(body.get('tIns'), '0')
+ self.assertEqual(body.get('anchor'), 't')
+
+ def test_font_metric_fields_distinguish_windows_and_typographic_metrics(self) -> None:
+ for family, size, expected_offset in (
+ ('Candara', 40, 37.3333333333),
+ ('Aptos', 80, 73.3333333333),
+ ('Segoe UI', 24, 24.0),
+ ):
+ with self.subTest(family=family):
+ slide = self._export(
+ f'<text x="100" y="200" font-size="{size}" '
+ f'font-family="{family}">Hgpq</text>'
+ )
+ self._assert_top(self._single_shape(slide), 200 - expected_offset)
+
+ def test_half_point_baseline_rounds_up(self) -> None:
+ # The rendered 64 px SimSun sample resolves a 49.5 pt offset to 50 pt.
+ slide = self._export(
+ '<text x="100" y="200" font-size="64" font-family="SimSun">Hgpq</text>'
+ )
+ self._assert_top(self._single_shape(slide), 133.3333333333)
+
+ def test_family_alias_and_unknown_family_have_deterministic_positions(self) -> None:
+ for family in ('微软雅黑', 'Noto Sans SC', 'Unlisted Baseline Test Font'):
+ with self.subTest(family=family):
+ slide = self._export(
+ f'<text x="100" y="200" font-size="40" '
+ f'font-family="{family}">Hgpq</text>'
+ )
+ self._assert_top(self._single_shape(slide), 161.3333333333)
+
+ def test_larger_font_size_controls_mixed_size_line_in_either_order(self) -> None:
+ for sizes, expected_top in (
+ ((20, 40), 161.3333333333),
+ ((40, 20), 161.3333333333),
+ ((24, 64), 138.6666666667),
+ ((64, 24), 138.6666666667),
+ ):
+ with self.subTest(sizes=sizes):
+ slide = self._export(
+ '<text x="100" y="200" font-size="20" font-family="Microsoft YaHei">'
+ f'<tspan font-size="{sizes[0]}">Hg</tspan>'
+ f'<tspan font-size="{sizes[1]}">pq</tspan></text>'
+ )
+ shape = self._single_shape(slide)
+ self._assert_top(shape, expected_top)
+ self.assertEqual(len(shape.findall('.//a:r', NS)), 2)
+
+ def test_mixed_scripts_use_both_active_font_faces(self) -> None:
+ for text in ('Hg中文pq', '中文Hgpq'):
+ with self.subTest(text=text):
+ slide = self._export(
+ '<text x="100" y="200" font-size="40" '
+ f'font-family="Calibri, SimSun">{text}</text>'
+ )
+ self._assert_top(self._single_shape(slide), 161.3333333333)
+
+ def test_unused_east_asian_font_does_not_affect_latin_baseline(self) -> None:
+ slide = self._export(
+ '<text x="100" y="200" font-size="40" '
+ 'font-family="Calibri, SimSun">Hgpq</text>'
+ )
+ self._assert_top(self._single_shape(slide), 162.6666666667)
+
+ def test_mixed_font_runs_share_position_regardless_of_order(self) -> None:
+ runs = (
+ '<tspan font-family="Calibri">Hg</tspan>',
+ '<tspan font-family="SimSun">中文</tspan>',
+ )
+ for ordered_runs in (runs, runs[::-1]):
+ with self.subTest(runs=ordered_runs):
+ slide = self._export(
+ '<text x="100" y="200" font-size="40">'
+ + ''.join(ordered_runs) + '</text>'
+ )
+ self._assert_top(self._single_shape(slide), 161.3333333333)
+
+ def test_preserved_lines_follow_fixed_spacing_baseline_transition(self) -> None:
+ samples = (
+ (40, '45.3333333333333', '3400', 164.0),
+ (40, '48', '3600', 161.3333333333),
+ (40, '49.3333333333333', '3700', 162.6666666667),
+ # PowerPoint rounds 57.6 pt fixed spacing to 58 pt before choosing
+ # the baseline branch, while the stored OOXML retains 5760.
+ (64, '76.8', '5760', 141.3333333333),
+ )
+ for size, dy, spacing, expected_top in samples:
+ with self.subTest(size=size, dy=dy):
+ slide = self._export(
+ f'<text x="100" y="200" font-size="{size}" font-family="Microsoft YaHei">'
+ '<tspan x="100" dy="0">第一行</tspan>'
+ f'<tspan x="100" dy="{dy}">第二行</tspan></text>',
+ text_flow='preserve',
+ )
+ shape = self._single_shape(slide)
+ self._assert_top(shape, expected_top)
+ self.assertEqual(
+ [node.get('val') for node in shape.findall('.//a:lnSpc/a:spcPts', NS)],
+ [spacing],
+ )
+ self.assertEqual(len(shape.findall('.//a:br', NS)), 1)
+ break_properties = shape.find('.//a:br/a:rPr', NS)
+ self.assertIsNotNone(break_properties)
+ self.assertEqual(break_properties.get('sz'), '4800' if size == 64 else '3000')
+ self.assertEqual(
+ break_properties.find('a:latin', NS).get('typeface'), 'Microsoft YaHei',
+ )
+ self.assertEqual(
+ break_properties.find('a:ea', NS).get('typeface'), 'Microsoft YaHei',
+ )
+
+ def test_split_lines_each_use_their_own_default_spacing_baseline(self) -> None:
+ slide = self._export(
+ '<text x="100" y="200" font-size="40" font-family="Microsoft YaHei">'
+ '<tspan x="100" dy="0">第一行</tspan>'
+ '<tspan x="100" dy="48">第二行</tspan></text>'
+ )
+ shapes = slide.findall('.//p:sp', NS)
+ self.assertEqual(len(shapes), 2)
+ for shape, expected_top in zip(shapes, (161.3333333333, 209.3333333333)):
+ self._assert_top(shape, expected_top)
+ self.assertIsNone(shape.find('.//a:lnSpc', NS))
+
+ def test_larger_later_line_does_not_move_first_visual_line(self) -> None:
+ slide = self._export(
+ '<text x="100" y="200" font-size="40" font-family="Microsoft YaHei">'
+ '<tspan x="100" dy="0">第一行</tspan>'
+ '<tspan x="100" dy="48" font-size="64">第二行</tspan></text>',
+ text_flow='preserve',
+ )
+ shape = self._single_shape(slide)
+ self._assert_top(shape, 161.3333333333)
+ self.assertEqual(
+ [run.get('sz') for run in shape.findall('.//a:rPr', NS)],
+ ['3000', '4800'],
+ )
+ self.assertEqual(
+ [spacing.get('val') for spacing in shape.findall('.//a:lnSpc/a:spcPts', NS)],
+ ['3600', '3600'],
+ )
+
+ def test_relative_group_font_size_is_resolved_once_for_baseline(self) -> None:
+ # Text-bearing group transforms reject scale; inherited em sizes are
+ # the supported public converter path for this effective-size check.
+ slide = self._export(
+ '<g font-size="20">'
+ '<text x="100" y="200" font-size="2em" font-family="Microsoft YaHei">'
+ 'Hgpq</text></g>'
+ )
+ shape = self._single_shape(slide)
+ self._assert_top(shape, 161.3333333333)
+ self.assertEqual(shape.find('.//a:rPr', NS).get('sz'), '3000')
+
+ def test_extracted_bullet_size_does_not_move_the_text_baseline(self) -> None:
+ for marker_size in (40, 80):
+ with self.subTest(marker_size=marker_size):
+ slide = self._export(
+ '<text x="100" y="200" font-size="40" font-family="Calibri">'
+ '<tspan x="100" dy="0">'
+ f'<tspan font-size="{marker_size}">• </tspan>First</tspan>'
+ '<tspan x="100" dy="48">Second</tspan></text>',
+ text_flow='preserve',
+ )
+ shape = self._single_shape(slide)
+ self._assert_top(shape, 162.6666666667)
+ paragraph = shape.find('.//a:pPr', NS)
+ self.assertIsNotNone(paragraph.find('a:buSzTx', NS))
+ self.assertIsNotNone(paragraph.find('a:buFontTx', NS))
+ self.assertEqual(paragraph.find('a:buChar', NS).get('char'), '•')
+ self.assertEqual(
+ [run.get('sz') for run in shape.findall('.//a:r/a:rPr', NS)],
+ ['3000', '3000'],
+ )
+ self.assertEqual(shape.find('.//a:br/a:rPr', NS).get('sz'), '3000')
+ self.assertEqual(
+ [text.text for text in shape.findall('.//a:t', NS)],
+ ['First', 'Second'],
+ )
+
+ def test_missing_bold_italic_metrics_fall_back_to_the_bold_face(self) -> None:
+ # Yu Gothic bundles regular and bold, but no italic metrics; synthetic
+ # italic must preserve the selected weight's baseline rather than reset it.
+ offsets = {}
+ for weight, style in (('400', 'normal'), ('bold', 'normal'), ('bold', 'italic')):
+ slide = self._export(
+ '<text x="100" y="200" font-size="140" font-family="Yu Gothic" '
+ f'font-weight="{weight}" font-style="{style}">Hgpq</text>'
+ )
+ shape = self._single_shape(slide)
+ offsets[weight, style] = shape.find('p:spPr/a:xfrm/a:off', NS).get('y')
+ run = shape.find('.//a:rPr', NS)
+ self.assertEqual(run.get('b'), '1' if weight == 'bold' else None)
+ self.assertEqual(run.get('i'), '1' if style == 'italic' else None)
+ self.assertNotEqual(offsets['400', 'normal'], offsets['bold', 'normal'])
+ self.assertEqual(offsets['bold', 'normal'], offsets['bold', 'italic'])
+
+ def test_mixed_size_frame_contains_the_larger_fonts_line_height(self) -> None:
+ slide = self._export(
+ '<text x="100" y="200" font-size="20" font-family="Microsoft YaHei">'
+ '<tspan font-size="20">Hg</tspan><tspan font-size="64">pq</tspan></text>'
+ )
+ shape = self._single_shape(slide)
+ self._assert_top(shape, 138.6666666667)
+ height_px = int(shape.find('p:spPr/a:xfrm/a:ext', NS).get('cy')) / EMU_PER_PX
+ # A 64 px run needs its 76.8 px natural line, even when its parent is 20 px.
+ self.assertGreaterEqual(height_px, 76.8)
+ self.assertEqual(
+ [run.get('sz') for run in shape.findall('.//a:rPr', NS)],
+ ['1500', '4800'],
+ )
+
+ def test_super_and_subscript_keep_existing_shifted_run_positioning(self) -> None:
+ for shift, drawingml_shift in (('super', '30000'), ('sub', '-25000')):
+ with self.subTest(shift=shift):
+ slide = self._export(
+ '<text x="100" y="200" font-size="40" font-family="Microsoft YaHei">'
+ f'Hg<tspan baseline-shift="{shift}">2</tspan>pq</text>'
+ )
+ shape = self._single_shape(slide)
+ self._assert_top(shape, 166)
+ self.assertEqual(
+ [run.get('baseline') for run in shape.findall('.//a:rPr', NS)
+ if run.get('baseline') is not None],
+ [drawingml_shift],
+ )
+
+ def test_exact_imported_frame_preserves_frame_and_inset_reconstruction(self) -> None:
+ slide = self._export(
+ '<text x="100" y="200" font-size="40" font-family="Microsoft YaHei" '
+ 'data-pptx-frame="80 100 500 200">Hgpq</text>'
+ )
+ shape = self._single_shape(slide)
+ self._assert_top(shape, 100)
+ self.assertEqual(
+ shape.find('p:spPr/a:xfrm/a:ext', NS).attrib,
+ {'cx': '4762500', 'cy': '1905000'},
+ )
+ self.assertEqual(shape.find('p:txBody/a:bodyPr', NS).get('tIns'), '628650')
+
+ def test_inline_formula_retains_native_math_positioning(self) -> None:
+ slide = self._export(
+ '<text x="100" y="200" font-size="40" font-family="Microsoft YaHei">'
+ 'Hg<tspan data-pptx-inline-formula="x">x</tspan>pq</text>'
+ )
+ shape = self._single_shape(slide)
+ self._assert_top(shape, 166)
+ self.assertIsNotNone(shape.find('.//m:oMath', NS))
diff --git a/skills/ppt-master/scripts/tests/test_text_baseline_metadata.py b/skills/ppt-master/scripts/tests/test_text_baseline_metadata.py
new file mode 100644
index 00000000..96d45cf5
--- /dev/null
+++ b/skills/ppt-master/scripts/tests/test_text_baseline_metadata.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python3
+"""
+PPT Master - Imported Text Baseline Metadata Regression Tests
+
+Keep the imported baseline convention through text flattening and the
+authoring projection used when rebuilding native shapes.
+
+Usage:
+ python3 -m unittest tests.test_text_baseline_metadata
+
+Examples:
+ Run this module from the scripts directory.
+
+Dependencies:
+ Standard library and the local SVG authoring tools.
+"""
+
+from __future__ import annotations
+
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+from xml.etree import ElementTree as ET
+
+
+SCRIPTS_DIR = Path(__file__).resolve().parents[1]
+if str(SCRIPTS_DIR) not in sys.path:
+ sys.path.insert(0, str(SCRIPTS_DIR))
+
+from svg_authoring_view import project_svg_batch # noqa: E402
+from svg_finalize.flatten_tspan import flatten_text_with_tspans # noqa: E402
+
+
+SVG = "http://www.w3.org/2000/svg"
+BASELINE_ATTR = "data-pptx-text-baseline"
+
+
+class TextBaselineMetadataTests(unittest.TestCase):
+ def test_split_and_preserved_rows_keep_the_imported_baseline_version(self) -> None:
+ for merge_paragraphs in (False, True):
+ with self.subTest(merge_paragraphs=merge_paragraphs):
+ tree = ET.ElementTree(ET.fromstring(
+ f'<svg xmlns="{SVG}" viewBox="0 0 1280 720">'
+ '<text x="100" y="200" font-family="Calibri" font-size="40" '
+ f'{BASELINE_ATTR}="metrics-v1">'
+ '<tspan x="100" dy="0">First</tspan>'
+ '<tspan x="100" dy="48">Second</tspan></text></svg>'
+ ))
+ flatten_text_with_tspans(
+ tree,
+ merge_paragraphs=merge_paragraphs,
+ preserve_line_breaks=merge_paragraphs,
+ )
+ texts = list(tree.getroot().iter(f"{{{SVG}}}text"))
+ self.assertEqual(len(texts), 1 if merge_paragraphs else 2)
+ self.assertEqual(
+ [text.get(BASELINE_ATTR) for text in texts],
+ ["metrics-v1"] * len(texts),
+ )
+
+ def test_split_legacy_rows_do_not_acquire_a_new_baseline_version(self) -> None:
+ tree = ET.ElementTree(ET.fromstring(
+ f'<svg xmlns="{SVG}" viewBox="0 0 1280 720">'
+ '<text x="100" y="200" font-size="40">'
+ '<tspan x="100" dy="0">First</tspan>'
+ '<tspan x="100" dy="48">Second</tspan></text></svg>'
+ ))
+ flatten_text_with_tspans(tree)
+ texts = list(tree.getroot().iter(f"{{{SVG}}}text"))
+ self.assertEqual(len(texts), 2)
+ self.assertTrue(all(text.get(BASELINE_ATTR) is None for text in texts))
+
+ def test_semantic_projection_keeps_the_first_paragraphs_baseline_version(self) -> None:
+ with tempfile.TemporaryDirectory() as temporary:
+ root = Path(temporary)
+ source = root / "source.svg"
+ output_dir = root / "authoring"
+ output = output_dir / "source.svg"
+ source.write_text(
+ f'<svg xmlns="{SVG}" viewBox="0 0 1280 720">'
+ '<g id="shape-1" data-pptx-object="shape" data-pptx-prst="rect" '
+ 'data-pptx-frame="80 100 500 200">'
+ '<rect data-pptx-part="geometry" data-pptx-object="shape" '
+ 'data-pptx-prst="rect" data-pptx-frame="80 100 500 200" '
+ 'x="80" y="100" width="500" height="200" fill="none"/>'
+ '<text x="100" y="140" font-family="Calibri" font-size="20" '
+ f'{BASELINE_ATTR}="metrics-v1">First</text>'
+ '<text x="100" y="180" font-family="Calibri" font-size="20" '
+ f'{BASELINE_ATTR}="metrics-v1">Second</text></g></svg>',
+ encoding="utf-8",
+ )
+ project_svg_batch(
+ [(source, output)], root, output_dir,
+ force=False, projection_kind="flat",
+ )
+ projected = ET.parse(output).getroot()
+ texts = list(projected.iter(f"{{{SVG}}}text"))
+ self.assertEqual(len(texts), 1)
+ self.assertEqual(texts[0].get(BASELINE_ATTR), "metrics-v1")
+ self.assertEqual(texts[0].get("data-pptx-text-model"), "paragraphs")
diff --git a/skills/ppt-master/scripts/tests/test_text_baseline_roundtrip.py b/skills/ppt-master/scripts/tests/test_text_baseline_roundtrip.py
new file mode 100644
index 00000000..eb4943ae
--- /dev/null
+++ b/skills/ppt-master/scripts/tests/test_text_baseline_roundtrip.py
@@ -0,0 +1,338 @@
+#!/usr/bin/env python3
+"""
+PPT Master - Text Baseline Round-trip Regression Tests
+
+Exercise the public DrawingML importer and SVG exporter with self-contained
+text fixtures, including edited native shapes with preserved frames.
+
+Usage:
+ python3 -m unittest tests.test_text_baseline_roundtrip
+
+Examples:
+ Run the module from the scripts directory.
+
+Dependencies:
+ Standard library and the local PPT Master conversion modules.
+"""
+
+from __future__ import annotations
+
+import io
+import sys
+import tempfile
+import unittest
+import zipfile
+from contextlib import redirect_stderr, redirect_stdout
+from pathlib import Path
+from xml.etree import ElementTree as ET
+from xml.sax.saxutils import escape
+
+
+SCRIPTS_DIR = Path(__file__).resolve().parents[1]
+if str(SCRIPTS_DIR) not in sys.path:
+ sys.path.insert(0, str(SCRIPTS_DIR))
+
+from authoring_roundtrip import materialize_flat_authoring_roundtrip # noqa: E402
+from pptx_to_svg.converter import ConvertOptions, convert_pptx_to_svg # noqa: E402
+from pptx_to_svg.emu_units import Xfrm # noqa: E402
+from pptx_to_svg.txbody_to_svg import convert_txbody # noqa: E402
+from svg_to_pptx.drawingml.converter import convert_svg_to_slide_shapes # noqa: E402
+from svg_to_pptx.pptx_package.builder import create_pptx_with_native_svg # noqa: E402
+
+
+NS = {
+ 'a': 'http://schemas.openxmlformats.org/drawingml/2006/main',
+ 'p': 'http://schemas.openxmlformats.org/presentationml/2006/main',
+ 's': 'http://www.w3.org/2000/svg',
+}
+EMU_PER_PX = 9525
+
+
+def _run(text: str, family: str = 'Microsoft YaHei', size_hpt: int = 3000) -> str:
+ return (
+ f'<a:r><a:rPr sz="{size_hpt}"><a:latin typeface="{family}"/>'
+ f'<a:ea typeface="{family}"/><a:cs typeface="{family}"/>'
+ f'</a:rPr><a:t>{escape(text)}</a:t></a:r>'
+ )
+
+
+def _txbody(
+ runs: str,
+ *,
+ spacing_hpt: int | None = None,
+ spacing_pct: int | None = None,
+ top_inset: int = 0,
+) -> ET.Element:
+ spacing = (
+ f'<a:lnSpc><a:spcPts val="{spacing_hpt}"/></a:lnSpc>'
+ if spacing_hpt is not None else ''
+ )
+ if spacing_pct is not None:
+ spacing = f'<a:lnSpc><a:spcPct val="{spacing_pct}"/></a:lnSpc>'
+ return ET.fromstring(
+ f'<p:txBody xmlns:a="{NS["a"]}" xmlns:p="{NS["p"]}">'
+ f'<a:bodyPr anchor="t" wrap="none" lIns="0" tIns="{top_inset}" rIns="0" bIns="0"/>'
+ f'<a:lstStyle/><a:p><a:pPr>{spacing}</a:pPr>{runs}</a:p></p:txBody>'
+ )
+
+
+class TextBaselineRoundtripTests(unittest.TestCase):
+ def setUp(self) -> None:
+ temporary = tempfile.TemporaryDirectory()
+ self.addCleanup(temporary.cleanup)
+ self.root = Path(temporary.name)
+ self.svg_path = self.root / '01_source.svg'
+
+ def _write_svg(self, body: str) -> None:
+ self.svg_path.write_text(
+ f'<svg xmlns="{NS["s"]}" viewBox="0 0 1280 720">{body}</svg>',
+ encoding='utf-8',
+ )
+
+ def _export(self, body: str, *, text_flow: str = 'split') -> ET.Element:
+ self._write_svg(body)
+ xml, *_rest = convert_svg_to_slide_shapes(
+ self.svg_path, resource_root=self.root, text_flow=text_flow,
+ )
+ return ET.fromstring(xml)
+
+ def _text_shape(self, slide: ET.Element) -> ET.Element:
+ shapes = [shape for shape in slide.findall('.//p:sp', NS)
+ if shape.find('p:txBody', NS) is not None]
+ self.assertEqual(len(shapes), 1)
+ return shapes[0]
+
+ def _import(self, body: ET.Element, frame: Xfrm | None = None) -> ET.Element:
+ result = convert_txbody(
+ body, frame or Xfrm(x=80, y=100, w=600, h=300), None,
+ )
+ root = ET.fromstring(f'<svg xmlns="{NS["s"]}">{result.svg}</svg>')
+ self.assertTrue(root.findall('s:text', NS))
+ return root
+
+ def _import_shape(self, shape: ET.Element) -> ET.Element:
+ offset = shape.find('p:spPr/a:xfrm/a:off', NS)
+ extent = shape.find('p:spPr/a:xfrm/a:ext', NS)
+ frame = Xfrm(
+ x=int(offset.get('x')) / EMU_PER_PX,
+ y=int(offset.get('y')) / EMU_PER_PX,
+ w=int(extent.get('cx')) / EMU_PER_PX,
+ h=int(extent.get('cy')) / EMU_PER_PX,
+ )
+ return self._import(shape.find('p:txBody', NS), frame)
+
+ def _assert_baseline(self, imported: ET.Element, expected: float) -> ET.Element:
+ text = imported.find('s:text', NS)
+ self.assertAlmostEqual(float(text.get('y')), expected, delta=0.000001)
+ self.assertEqual(text.get('data-pptx-text-baseline'), 'metrics-v1')
+ return text
+
+ def test_native_single_lines_use_their_fonts_baseline_and_top_inset(self) -> None:
+ for family, size_hpt, offset in (
+ ('Arial', 3000, 38.6666666667),
+ ('Calibri', 3000, 37.3333333333),
+ ('SimSun', 3000, 41.3333333333),
+ ('SimHei', 3000, 41.3333333333),
+ ('Microsoft YaHei', 3000, 38.6666666667),
+ ('Segoe UI', 1800, 24.0),
+ ):
+ with self.subTest(family=family):
+ body = _txbody(_run('Hgpq', family, size_hpt), top_inset=7 * EMU_PER_PX)
+ self._assert_baseline(self._import(body), 107 + offset)
+
+ def test_native_fixed_spacing_uses_the_first_visual_lines_size(self) -> None:
+ samples = (
+ (3000, 3400, 36.0, 45.3333333333),
+ (3000, 3600, 38.6666666667, 48.0),
+ (3000, 3700, 37.3333333333, 49.3333333333),
+ (4800, 5760, 58.6666666667, 76.8),
+ )
+ for size_hpt, spacing, offset, advance in samples:
+ with self.subTest(size=size_hpt, spacing=spacing):
+ runs = (
+ _run('First', size_hpt=size_hpt)
+ + f'<a:br><a:rPr sz="{size_hpt}"/></a:br>'
+ + _run('Second', size_hpt=4800)
+ )
+ text = self._assert_baseline(
+ self._import(_txbody(runs, spacing_hpt=spacing)), 100 + offset,
+ )
+ advances = [float(span.get('dy')) for span in text.iter(f'{{{NS["s"]}}}tspan')
+ if span.get('dy') is not None]
+ self.assertEqual(len(advances), 1)
+ self.assertAlmostEqual(advances[0], advance, delta=0.000001)
+
+ def test_native_mixed_fonts_and_sizes_share_the_entire_lines_baseline(self) -> None:
+ samples = (
+ _run('Hg', 'Calibri') + _run('中文', 'SimSun'),
+ _run('中文', 'SimSun') + _run('Hg', 'Calibri'),
+ _run('Hg', size_hpt=1500) + _run('pq', size_hpt=3000),
+ _run('Hg', size_hpt=3000) + _run('pq', size_hpt=1500),
+ )
+ for runs in samples:
+ with self.subTest(runs=runs):
+ self._assert_baseline(self._import(_txbody(runs)), 138.6666666667)
+
+ def test_percentage_spacing_remains_relative_to_the_natural_line_height(self) -> None:
+ samples = (
+ ('Microsoft YaHei', 3000, 50000, 18.6666666667, 24.0),
+ ('Arial', 3000, 100000, 38.6666666667, 48.0),
+ ('Calibri', 3000, 100000, 37.3333333333, 48.0),
+ ('SimSun', 3000, 100000, 41.3333333333, 48.0),
+ ('Microsoft YaHei', 3000, 100000, 38.6666666667, 48.0),
+ ('Microsoft YaHei', 3000, 150000, 54.6666666667, 72.0),
+ # 100% retains the natural 57.6 pt line height. Unlike spcPts=5760,
+ # it does not first snap to 58 pt and choose the fixed-spacing branch.
+ ('Microsoft YaHei', 4800, 100000, 61.3333333333, 76.8),
+ )
+ for family, size, percent, offset, advance in samples:
+ with self.subTest(family=family, size=size, percent=percent):
+ runs = (
+ _run('First', family, size)
+ + f'<a:br><a:rPr sz="{size}"/></a:br>'
+ + _run('Second', family, size)
+ )
+ text = self._assert_baseline(
+ self._import(_txbody(runs, spacing_pct=percent)), 100 + offset,
+ )
+ spans = [span for span in text.iter(f'{{{NS["s"]}}}tspan')
+ if span.get('dy') is not None]
+ self.assertEqual(len(spans), 1)
+ self.assertAlmostEqual(float(spans[0].get('dy')), advance, delta=0.000001)
+
+ def test_local_line_spacing_choice_overrides_the_inherited_choice(self) -> None:
+ samples = (
+ ('spcPct', 100000, 'spcPts', 2000, 138.6666666667, 48.0),
+ ('spcPts', 3400, 'spcPct', 150000, 136.0, 45.3333333333),
+ ('spcPts', 0, 'spcPct', 150000, 100.0, 0.0),
+ )
+ for local_kind, local_value, inherited_kind, inherited_value, baseline, advance in samples:
+ with self.subTest(local_kind=local_kind, local_value=local_value):
+ runs = _run('First') + '<a:br><a:rPr sz="3000"/></a:br>' + _run('Second')
+ body = _txbody(runs)
+ body.find('a:p/a:pPr', NS).append(ET.fromstring(
+ f'<a:lnSpc xmlns:a="{NS["a"]}">'
+ f'<a:{local_kind} val="{local_value}"/></a:lnSpc>'
+ ))
+ body.find('a:lstStyle', NS).append(ET.fromstring(
+ f'<a:lvl1pPr xmlns:a="{NS["a"]}"><a:lnSpc>'
+ f'<a:{inherited_kind} val="{inherited_value}"/>'
+ '</a:lnSpc></a:lvl1pPr>'
+ ))
+ text = self._assert_baseline(self._import(body), baseline)
+ spans = [span for span in text.iter(f'{{{NS["s"]}}}tspan')
+ if span.get('dy') is not None]
+ self.assertEqual(len(spans), 1)
+ self.assertAlmostEqual(float(spans[0].get('dy')), advance, delta=0.000001)
+
+ def test_later_shifted_paragraph_keeps_the_whole_body_on_legacy_baselines(self) -> None:
+ body = _txbody(_run('First'))
+ shifted_paragraph = ET.fromstring(f'<a:p xmlns:a="{NS["a"]}">{_run("Raised")}</a:p>')
+ shifted_paragraph.find('a:r/a:rPr', NS).set('baseline', '30000')
+ body.append(shifted_paragraph)
+ imported = self._import(body)
+ texts = imported.findall('s:text', NS)
+ self.assertEqual(len(texts), 2)
+ self.assertAlmostEqual(float(texts[0].get('y')), 134.0)
+ self.assertTrue(all(text.get('data-pptx-text-baseline') is None for text in texts))
+
+ def test_svg_to_native_to_svg_restores_the_authored_first_baseline(self) -> None:
+ samples = [
+ (f'<text x="100" y="200" font-family="{family}" font-size="40">Hgpq</text>', 'split')
+ for family in ('Arial', 'Calibri', 'SimSun', 'SimHei', 'Microsoft YaHei')
+ ]
+ samples.extend((
+ ('<text x="100" y="200" font-family="Calibri, SimSun" font-size="40">'
+ 'Hg中文pq</text>', 'split'),
+ ('<text x="100" y="200" font-family="Microsoft YaHei" font-size="20">'
+ '<tspan>Hg</tspan><tspan font-size="40">pq</tspan></text>', 'split'),
+ ('<text x="100" y="200" font-family="Microsoft YaHei" font-size="40">'
+ '<tspan x="100" dy="0">First</tspan>'
+ '<tspan x="100" dy="45.3333333333333">Second</tspan></text>', 'preserve'),
+ ('<text x="100" y="200" font-family="Microsoft YaHei" font-size="64">'
+ '<tspan x="100" dy="0">First</tspan>'
+ '<tspan x="100" dy="76.8">Second</tspan></text>', 'preserve'),
+ ))
+ for svg, flow in samples:
+ with self.subTest(svg=svg):
+ shape = self._text_shape(self._export(svg, text_flow=flow))
+ self._assert_baseline(self._import_shape(shape), 200)
+
+ def test_imported_text_with_exact_frame_reconstructs_insets_without_drift(self) -> None:
+ body = _txbody(_run('Hgpq'), top_inset=66 * EMU_PER_PX)
+ frame = Xfrm(x=80, y=100, w=500, h=200)
+ imported = self._import(body, frame)
+ for edited_text in ('Edited', 'Again'):
+ text = imported.find('s:text', NS)
+ self.assertEqual(text.get('data-pptx-text-baseline'), 'metrics-v1')
+ text.set('data-pptx-frame', '80 100 500 200')
+ text.find('s:tspan', NS).text = edited_text
+ shape = self._text_shape(self._export(ET.tostring(text, encoding='unicode')))
+ self.assertEqual(
+ shape.find('p:spPr/a:xfrm/a:off', NS).attrib,
+ {'x': '762000', 'y': '952500'},
+ )
+ self.assertEqual(
+ shape.find('p:spPr/a:xfrm/a:ext', NS).attrib,
+ {'cx': '4762500', 'cy': '1905000'},
+ )
+ self.assertAlmostEqual(
+ int(shape.find('p:txBody/a:bodyPr', NS).get('tIns')),
+ 628650, delta=1,
+ )
+ imported = self._import_shape(shape)
+
+ def test_legacy_unmarked_svg_keeps_its_existing_exact_frame_insets(self) -> None:
+ shape = self._text_shape(self._export(
+ '<text x="100" y="200" font-family="Microsoft YaHei" font-size="40" '
+ 'data-pptx-frame="80 100 500 200">Legacy</text>'
+ ))
+ self.assertEqual(shape.find('p:spPr/a:xfrm/a:off', NS).get('y'), '952500')
+ self.assertEqual(shape.find('p:txBody/a:bodyPr', NS).get('tIns'), '628650')
+
+ def test_real_imported_workspace_preserves_frame_after_text_edit(self) -> None:
+ self._write_svg(
+ '<text x="100" y="200" font-family="Microsoft YaHei" font-size="40" '
+ 'data-pptx-frame="80 100 500 200">Hgpq</text>'
+ )
+ source = self.root / 'source.pptx'
+ workspace = self.root / 'workspace'
+ with redirect_stdout(io.StringIO()), redirect_stderr(io.StringIO()):
+ success = create_pptx_with_native_svg(
+ [self.svg_path], source, resource_root=self.root, pptx_structure='flat',
+ use_compat_mode=False, transition=None, workers=1, verbose=False,
+ )
+ self.assertTrue(success)
+ convert_pptx_to_svg(
+ source, workspace, ConvertOptions(inheritance_mode='both', roundtrip=True),
+ )
+ with zipfile.ZipFile(source) as package:
+ original = self._text_shape(ET.fromstring(package.read('ppt/slides/slide1.xml')))
+ authoring_dir = workspace / 'authoring-svg-flat'
+ authored = authoring_dir / 'slide_01.svg'
+ document = ET.parse(authored)
+ text = document.getroot().find('.//s:text', NS)
+ self.assertIsNotNone(text)
+ self.assertEqual(text.get('data-pptx-text-baseline'), 'metrics-v1')
+ content = next(node for node in text.iter() if node.text == 'Hgpq')
+ content.text = 'Edited'
+ document.write(authored, encoding='utf-8', xml_declaration=True)
+ with redirect_stdout(io.StringIO()), redirect_stderr(io.StringIO()):
+ materialized = materialize_flat_authoring_roundtrip(
+ workspace, authoring_dir, workspace / 'materialized',
+ )
+ xml, *_rest = convert_svg_to_slide_shapes(
+ materialized.svg_files[0], resource_root=workspace, text_flow='preserve',
+ )
+ rebuilt = self._text_shape(ET.fromstring(xml))
+ self.assertEqual([node.text for node in rebuilt.findall('.//a:t', NS)], ['Edited'])
+ for child in ('a:off', 'a:ext'):
+ self.assertEqual(
+ rebuilt.find(f'p:spPr/a:xfrm/{child}', NS).attrib,
+ original.find(f'p:spPr/a:xfrm/{child}', NS).attrib,
+ )
+ for inset in ('lIns', 'tIns', 'rIns', 'bIns'):
+ self.assertAlmostEqual(
+ int(rebuilt.find('p:txBody/a:bodyPr', NS).get(inset)),
+ int(original.find('p:txBody/a:bodyPr', NS).get(inset)), delta=1,
+ )