Skip to content

Commit

Permalink
Add baseline to font measurement (#2320)
Browse files Browse the repository at this point in the history
* Firstly lets fix the precision of text sizes
* Add information about baseline to text measurement
* Update RichText to realign lines where the baseline varies across the row
  • Loading branch information
andydotxyz committed Jul 27, 2021
1 parent dbd4284 commit f80990b
Show file tree
Hide file tree
Showing 537 changed files with 6,423 additions and 6,295 deletions.
Binary file modified canvas/testdata/text/layout_long_center_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified canvas/testdata/text/layout_long_leading_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified canvas/testdata/text/layout_long_trailing_large.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified canvas/testdata/text/layout_long_trailing_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified canvas/testdata/text/layout_short_center_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified canvas/testdata/text/layout_short_leading_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified canvas/testdata/text/layout_short_trailing_large.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified canvas/testdata/text/layout_short_trailing_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions cmd/fyne_settings/settings/appearance.go
Expand Up @@ -118,7 +118,7 @@ func (s *Settings) createPreview() image.Image {
th = theme.DarkTheme()
}

cache.ResetSvg() // reset icon cache
cache.ResetThemeCaches() // reset icon cache
fyne.CurrentApp().Settings().(overrideTheme).OverrideTheme(th, s.fyneSettings.PrimaryColor)

empty := widget.NewLabel("")
Expand All @@ -136,7 +136,7 @@ func (s *Settings) createPreview() image.Image {
time.Sleep(canvas.DurationShort)
img := c.Capture()

cache.ResetSvg() // ensure we re-create the correct cached assets
cache.ResetThemeCaches() // ensure we re-create the correct cached assets
fyne.CurrentApp().Settings().(overrideTheme).OverrideTheme(oldTheme, oldColor)
return img
}
Expand Down
20 changes: 10 additions & 10 deletions container/testdata/apptabs/desktop/change_content_change_hidden.xml
@@ -1,20 +1,20 @@
<canvas size="150x150">
<content>
<widget size="150x150" type="*container.AppTabs">
<container size="150x37">
<container size="150x37">
<widget size="57x37" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="41x21">Test1</text>
<container size="150x36">
<container size="150x36">
<widget size="56x36" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="40x20">Test1</text>
</widget>
<widget pos="61,0" size="57x37" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="41x21">Test2</text>
<widget pos="60,0" size="56x36" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="40x20">Test2</text>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,37" size="150x4"/>
<rectangle fillColor="primary" pos="0,37" size="57x4"/>
<widget pos="0,41" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x21">Text3</text>
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" size="56x4"/>
<widget pos="0,40" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x20">Text3</text>
</widget>
</widget>
</content>
Expand Down
@@ -1,20 +1,20 @@
<canvas size="150x150">
<content>
<widget size="150x150" type="*container.AppTabs">
<container size="150x37">
<container size="150x37">
<widget size="57x37" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="41x21">Test1</text>
<container size="150x36">
<container size="150x36">
<widget size="56x36" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="40x20">Test1</text>
</widget>
<widget pos="61,0" size="57x37" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="41x21">Test2</text>
<widget pos="60,0" size="56x36" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="40x20">Test2</text>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,37" size="150x4"/>
<rectangle fillColor="primary" pos="0,37" size="57x4"/>
<widget pos="0,41" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x21">Text3</text>
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" size="56x4"/>
<widget pos="0,40" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x20">Text3</text>
</widget>
</widget>
</content>
Expand Down
20 changes: 10 additions & 10 deletions container/testdata/apptabs/desktop/change_content_initial.xml
@@ -1,20 +1,20 @@
<canvas size="150x150">
<content>
<widget size="150x150" type="*container.AppTabs">
<container size="150x37">
<container size="150x37">
<widget size="57x37" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="41x21">Test1</text>
<container size="150x36">
<container size="150x36">
<widget size="56x36" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="40x20">Test1</text>
</widget>
<widget pos="61,0" size="57x37" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="41x21">Test2</text>
<widget pos="60,0" size="56x36" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="40x20">Test2</text>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,37" size="150x4"/>
<rectangle fillColor="primary" pos="0,37" size="57x4"/>
<widget pos="0,41" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x21">Text1</text>
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" size="56x4"/>
<widget pos="0,40" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x20">Text1</text>
</widget>
</widget>
</content>
Expand Down
@@ -1,20 +1,20 @@
<canvas size="150x150">
<content>
<widget size="150x150" type="*container.AppTabs">
<container size="150x37">
<container size="150x37">
<widget size="28x37" type="*container.tabButton">
<container size="150x36">
<container size="150x36">
<widget size="28x36" type="*container.tabButton">
<image pos="4,8" rsc="cancelIcon" size="iconInlineSize" themed="primary"/>
</widget>
<widget pos="32,0" size="28x37" type="*container.tabButton">
<widget pos="32,0" size="28x36" type="*container.tabButton">
<image pos="4,8" rsc="confirmIcon" size="iconInlineSize"/>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,37" size="150x4"/>
<rectangle fillColor="primary" pos="0,37" size="28x4"/>
<widget pos="0,41" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x21">Text1</text>
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" size="28x4"/>
<widget pos="0,40" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x20">Text1</text>
</widget>
</widget>
</content>
Expand Down
@@ -1,20 +1,20 @@
<canvas size="150x150">
<content>
<widget size="150x150" type="*container.AppTabs">
<container size="150x37">
<container size="150x37">
<widget size="28x37" type="*container.tabButton">
<container size="150x36">
<container size="150x36">
<widget size="28x36" type="*container.tabButton">
<image pos="4,8" rsc="cancelIcon" size="iconInlineSize" themed="primary"/>
</widget>
<widget pos="32,0" size="28x37" type="*container.tabButton">
<widget pos="32,0" size="28x36" type="*container.tabButton">
<image pos="4,8" rsc="confirmIcon" size="iconInlineSize"/>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,37" size="150x4"/>
<rectangle fillColor="primary" pos="0,37" size="28x4"/>
<widget pos="0,41" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x21">Text1</text>
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" size="28x4"/>
<widget pos="0,40" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x20">Text1</text>
</widget>
</widget>
</content>
Expand Down
16 changes: 8 additions & 8 deletions container/testdata/apptabs/desktop/change_icon_initial.xml
@@ -1,20 +1,20 @@
<canvas size="150x150">
<content>
<widget size="150x150" type="*container.AppTabs">
<container size="150x37">
<container size="150x37">
<widget size="28x37" type="*container.tabButton">
<container size="150x36">
<container size="150x36">
<widget size="28x36" type="*container.tabButton">
<image pos="4,8" rsc="cancelIcon" size="iconInlineSize" themed="primary"/>
</widget>
<widget pos="32,0" size="28x37" type="*container.tabButton">
<widget pos="32,0" size="28x36" type="*container.tabButton">
<image pos="4,8" rsc="confirmIcon" size="iconInlineSize"/>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,37" size="150x4"/>
<rectangle fillColor="primary" pos="0,37" size="28x4"/>
<widget pos="0,41" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x21">Text1</text>
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" size="28x4"/>
<widget pos="0,40" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x20">Text1</text>
</widget>
</widget>
</content>
Expand Down
20 changes: 10 additions & 10 deletions container/testdata/apptabs/desktop/change_label_change_selected.xml
@@ -1,20 +1,20 @@
<canvas size="150x150">
<content>
<widget size="150x150" type="*container.AppTabs">
<container size="150x37">
<container size="150x37">
<widget size="63x37" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="47x21">New 1</text>
<container size="150x36">
<container size="150x36">
<widget size="62x36" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="46x20">New 1</text>
</widget>
<widget pos="67,0" size="57x37" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="41x21">Test2</text>
<widget pos="66,0" size="56x36" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="40x20">Test2</text>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,37" size="150x4"/>
<rectangle fillColor="primary" pos="0,37" size="63x4"/>
<widget pos="0,41" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x21">Text1</text>
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" size="62x4"/>
<widget pos="0,40" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x20">Text1</text>
</widget>
</widget>
</content>
Expand Down
@@ -1,20 +1,20 @@
<canvas size="150x150">
<content>
<widget size="150x150" type="*container.AppTabs">
<container size="150x37">
<container size="150x37">
<widget size="63x37" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="47x21">New 1</text>
<container size="150x36">
<container size="150x36">
<widget size="62x36" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="46x20">New 1</text>
</widget>
<widget pos="67,0" size="63x37" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="47x21">New 2</text>
<widget pos="66,0" size="62x36" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="46x20">New 2</text>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,37" size="150x4"/>
<rectangle fillColor="primary" pos="0,37" size="63x4"/>
<widget pos="0,41" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x21">Text1</text>
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" size="62x4"/>
<widget pos="0,40" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x20">Text1</text>
</widget>
</widget>
</content>
Expand Down
20 changes: 10 additions & 10 deletions container/testdata/apptabs/desktop/change_label_initial.xml
@@ -1,20 +1,20 @@
<canvas size="150x150">
<content>
<widget size="150x150" type="*container.AppTabs">
<container size="150x37">
<container size="150x37">
<widget size="57x37" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="41x21">Test1</text>
<container size="150x36">
<container size="150x36">
<widget size="56x36" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="40x20">Test1</text>
</widget>
<widget pos="61,0" size="57x37" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="41x21">Test2</text>
<widget pos="60,0" size="56x36" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="40x20">Test2</text>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,37" size="150x4"/>
<rectangle fillColor="primary" pos="0,37" size="57x4"/>
<widget pos="0,41" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x21">Text1</text>
<rectangle fillColor="shadow" pos="0,36" size="150x4"/>
<rectangle fillColor="primary" pos="0,36" size="56x4"/>
<widget pos="0,40" size="150x109" type="*widget.Label">
<text pos="8,8" size="134x20">Text1</text>
</widget>
</widget>
</content>
Expand Down
20 changes: 10 additions & 10 deletions container/testdata/apptabs/desktop/dynamic_appended.xml
@@ -1,20 +1,20 @@
<canvas size="300x150">
<content>
<widget size="300x150" type="*container.AppTabs">
<container size="300x37">
<container size="300x37">
<widget size="57x37" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="41x21">Test1</text>
<container size="300x36">
<container size="300x36">
<widget size="56x36" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="40x20">Test1</text>
</widget>
<widget pos="61,0" size="57x37" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="41x21">Test2</text>
<widget pos="60,0" size="56x36" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="40x20">Test2</text>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,37" size="300x4"/>
<rectangle fillColor="primary" pos="0,37" size="57x4"/>
<widget pos="0,41" size="300x109" type="*widget.Label">
<text pos="8,8" size="284x21">Text 1</text>
<rectangle fillColor="shadow" pos="0,36" size="300x4"/>
<rectangle fillColor="primary" pos="0,36" size="56x4"/>
<widget pos="0,40" size="300x109" type="*widget.Label">
<text pos="8,8" size="284x20">Text 1</text>
</widget>
</widget>
</content>
Expand Down
@@ -1,17 +1,17 @@
<canvas size="300x150">
<content>
<widget size="300x150" type="*container.AppTabs">
<container size="300x37">
<container size="300x37">
<widget size="57x37" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="41x21">Test2</text>
<container size="300x36">
<container size="300x36">
<widget size="56x36" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="40x20">Test2</text>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,37" size="300x4"/>
<rectangle fillColor="primary" pos="0,37" size="57x4"/>
<widget pos="0,41" size="300x109" type="*widget.Label">
<text pos="8,8" size="284x21">Text 2</text>
<rectangle fillColor="shadow" pos="0,36" size="300x4"/>
<rectangle fillColor="primary" pos="0,36" size="56x4"/>
<widget pos="0,40" size="300x109" type="*widget.Label">
<text pos="8,8" size="284x20">Text 2</text>
</widget>
</widget>
</content>
Expand Down
@@ -1,26 +1,26 @@
<canvas size="300x150">
<content>
<widget size="300x150" type="*container.AppTabs">
<container size="300x37">
<container size="300x37">
<widget size="57x37" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="41x21">Test2</text>
<container size="300x36">
<container size="300x36">
<widget size="56x36" type="*container.tabButton">
<text alignment="center" bold color="primary" pos="8,8" size="40x20">Test2</text>
</widget>
<widget pos="61,0" size="57x37" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="41x21">Test3</text>
<widget pos="60,0" size="56x36" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="40x20">Test3</text>
</widget>
<widget pos="122,0" size="57x37" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="41x21">Test4</text>
<widget pos="121,0" size="56x36" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="40x20">Test4</text>
</widget>
<widget pos="183,0" size="57x37" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="41x21">Test5</text>
<widget pos="181,0" size="56x36" type="*container.tabButton">
<text alignment="center" bold pos="8,8" size="40x20">Test5</text>
</widget>
</container>
</container>
<rectangle fillColor="shadow" pos="0,37" size="300x4"/>
<rectangle fillColor="primary" pos="0,37" size="57x4"/>
<widget pos="0,41" size="300x109" type="*widget.Label">
<text pos="8,8" size="284x21">Text 2</text>
<rectangle fillColor="shadow" pos="0,36" size="300x4"/>
<rectangle fillColor="primary" pos="0,36" size="56x4"/>
<widget pos="0,40" size="300x109" type="*widget.Label">
<text pos="8,8" size="284x20">Text 2</text>
</widget>
</widget>
</content>
Expand Down

0 comments on commit f80990b

Please sign in to comment.