Commit Graph

184 Commits

Author SHA1 Message Date
Hajime Hoshi
f2180a5dc5 text/v2: rename SizeInPoints -> SizeInPixels 2023-11-15 13:14:36 +09:00
Hajime Hoshi
4694b78d54 text/v2: refactoring 2023-11-15 12:34:02 +09:00
Hajime Hoshi
5354ccc44f examples/2048: use text/v2
Also, this changes fixes a bug in (*text/v2.GoTextFace).Metrics.

Updates #2454
2023-11-15 12:28:39 +09:00
Hajime Hoshi
fe35180b78 text/v2: implement GoTextFace
Closes #675
Updates #2143
Updates #2454
2023-11-15 03:40:45 +09:00
Hajime Hoshi
46600b42f9 text/v2: swap the arguments of Advance for consistency 2023-11-15 03:18:23 +09:00
Hajime Hoshi
2b46a77e39 text/v2: replace Rune and IndexInBytes with Start/EndIndexInBytes in Glyph
The relationships between runes and glyphs are n:m in general,
then Rune is not enough. Let Glyph have a range of a string.

Updates #2454
2023-11-14 01:38:45 +09:00
Hajime Hoshi
ea1d9dde4e text/v2: add LayoutOptions
Now AppendGlyphs can treat multiple lines and alignments.
2023-11-13 23:47:37 +09:00
Hajime Hoshi
4a84f3697c text/v2: refactoring: simplify implementation 2023-11-13 13:24:39 +09:00
Hajime Hoshi
29fe3f6d21 text/v2: refactoring: don't consider origin's posotion for the subpixel offset Y 2023-11-13 02:44:09 +09:00
Hajime Hoshi
e4f9d854d2 Revert "text/v2: don't consider subpixels in Y direction in StdFace"
This reverts commit 38a0449b44.

Reason: the rendering result has changed unexpectedly
2023-11-13 02:41:38 +09:00
Hajime Hoshi
38a0449b44 text/v2: don't consider subpixels in Y direction in StdFace 2023-11-13 02:24:49 +09:00
Hajime Hoshi
a645fbb2b0 text/v2: refactoring 2023-11-13 02:16:17 +09:00
Hajime Hoshi
9735687d3e text/v2: refactoring 2023-11-13 01:31:25 +09:00
Hajime Hoshi
7c40b5f922 text/v2: bug fix: fix a semantically wrong calculation
Updates #2454
2023-11-12 21:04:39 +09:00
Hajime Hoshi
3f180b2165 text/v2: bug fix: StdFace was never released
StdFace was used as a cache key, then these are never released.

This change fixes this issue by adding faceCacheKey and use it as
a cache key.

Updates #498
2023-11-12 18:49:46 +09:00
Hajime Hoshi
77f3b57d1f text/v2: bug fix: the offset should be added at the end of each iteration
Updates #2454
Updates #2528
2023-11-12 17:37:36 +09:00
Hajime Hoshi
b05c272499 text/v2: add CacheGlyphs
Updates #2454
Updates #2528
2023-11-12 17:35:01 +09:00
Hajime Hoshi
b8b8b16098 all: add text/v2
This change adds some basic APIs incuding StdFace.

GoTextFace will be added later.

Updates #2454
2023-11-12 17:04:25 +09:00
Hajime Hoshi
1d4c210ff2 text: update comments 2023-11-12 00:20:47 +09:00
Hajime Hoshi
ca24a411bb text: update comments 2023-11-11 20:22:30 +09:00
Hajime Hoshi
82f2319020 internal/hook: rename hooks -> hook 2023-10-06 13:58:00 +09:00
Hajime Hoshi
911cf0c48c text: deprecate BoundString
After we found a correct definition of the term 'dot', BoundString seems
less useful than expected. In order to adjust the position of a text, we
should use a face's Metrics and a string's advance (font.MeasureString).
2023-06-10 19:21:04 +09:00
Hajime Hoshi
0918877344 text: update comments 2023-06-02 00:46:07 +09:00
Hajime Hoshi
11e79f3b51 text: update comments 2023-05-30 17:50:08 +09:00
Hajime Hoshi
f446288e0c update bitmapfont to v3 2023-05-30 11:17:36 +09:00
Hajime Hoshi
baea6d47ee text: cache Kern values
Closes #2673
2023-05-28 23:23:43 +09:00
Hajime Hoshi
e374ca0ac3 text: refactoring: introduce faceWithCache 2023-05-28 22:54:07 +09:00
Hajime Hoshi
8864ce1291 all: update comments 2023-02-07 12:05:43 +09:00
Pierre Curto
04170d628f
text: fix typos and add fields to struct initializers (#2556)
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2023-01-28 00:14:37 +09:00
Hajime Hoshi
f054a7634a ebiten: deprecate (*Image).Size
Closes #2351
2023-01-20 01:26:37 +09:00
Pierre Curto
abd293fae6
text, vector: fix typos and redundant casts (#2537) 2023-01-13 03:28:41 +09:00
Hajime Hoshi
6f4cb04ebb
text: make CacheGlyphs create all the sub-pixel variations (#2530)
Before this change, CacheGlyphs created only necessary glyphs wihtout
considering variations by sub-pixels in X direction. This was sometimes
unexpected when a user might want to prepare glyph cache with a string
including all the letters, instead of actual texts.

This change makes CacheGlyphs create all the sub-pixel variations of
the given runes.

Updates #2469
Closes #2528
2023-01-07 23:22:55 +09:00
Hajime Hoshi
a042af98b1 text: improve rendering quality with HintingVertical
When HintingVertical is used, the interval between two glyphs is not
quantized (i.e. not a whole pixel). The text package didn't consider
this situation.

This change improves the quality by using more various glyph images
with 1/4 pixels granularity in vertical direction.

Closes #2469
2022-11-25 16:45:37 +09:00
Hajime Hoshi
56788cf8d9 text: give offest to getGlyphImage
Now getGlyphImage can focus on rendering and doesn't have to calculate
offsets.
2022-11-25 16:15:16 +09:00
Hajime Hoshi
b9b78b5b44 text: update comments 2022-11-24 18:22:32 +09:00
Hajime Hoshi
003474152c text: add comments about positioning 2022-11-23 22:35:02 +09:00
Hajime Hoshi
156c34a316 ebiten: separate a package for ColorM: colorm
Closes #2171
2022-11-08 23:50:04 +09:00
Hajime Hoshi
2610c148e4 text: typo 2022-09-14 14:41:22 +09:00
Hajime Hoshi
f923250a65 ebiten: typo 2022-08-21 20:02:53 +09:00
Hajime Hoshi
33da481d60 text: refactoring
Updates #1992
2022-08-13 00:28:41 +09:00
Hajime Hoshi
0217ed0544 ebiten: add WritePixels replacing ReplacePixels
Closes #2236
2022-08-08 03:50:27 +09:00
mattn
2bacecca24
fix typos (#2227) 2022-08-03 22:40:39 +09:00
mattn
3cd0daac67
go generate ./... with Go 1.19 (#2228) 2022-08-03 20:48:02 +09:00
Hajime Hoshi
04d1dbb263 text: update comments
Updates #1992
2022-04-04 02:55:15 +09:00
Hajime Hoshi
e05cfdb00a text: update comments about BoundsString
The way in which space characters are treated is exactly same as
golang.org/x/image/font's `BoundsString`.

Updates #1992
2022-04-04 01:56:32 +09:00
Hajime Hoshi
98b8fbe2df text: English
Updates #2047
2022-04-02 19:00:13 +09:00
Hajime Hoshi
7cee60f00f text: add a comment about Glyph.Image
Updates #2047
2022-04-02 18:59:25 +09:00
Hajime Hoshi
e687865c8c ebiten: add ColorM.ScaleWithColor
Updates #1944
2022-01-10 17:36:46 +09:00
Hajime Hoshi
732b125349 text: Add AppendGlyphs and Glyphs
Closes #1767
Closes #1871
2021-11-12 02:31:53 +09:00
Hajime Hoshi
3eb444f211 text: Refactoring 2021-11-12 00:17:51 +09:00
r3vit
57c45a13e4
Remove dot imports from tests - Remove dot imports (#1837)
Closes #1824
2021-10-02 19:58:48 +09:00
Hajime Hoshi
4509f2aee4 text: Add FaceWithLineHeight
Closes #1760
2021-09-12 22:56:14 +09:00
nanoslayer
e52a933506
text: Fix nil pointer dereference in drawGlyph (#1732)
drawGlyph can panic when provided with a nil *ebiten.DrawImageOptions
reference. Check that the pointer is not nil before dereferencing.
2021-07-28 03:20:35 +09:00
Hajime Hoshi
6efe7cbb8b text: Fix comments 2021-07-27 17:38:34 +09:00
Hajime Hoshi
656d9dccc0 text: Add DrawWithOptions
Closes #1461
2021-07-27 17:36:21 +09:00
Hajime Hoshi
040fcd930f Revert "Revert 2 commits using ColorM cache"
This reverts commit dd7a8bc497.

Reason: DrawTriangles worked fine for the reporter's purpose.

Updates #1655
2021-05-30 15:17:11 +09:00
Hajime Hoshi
dd7a8bc497 Revert 2 commits using ColorM cache
This reverts commit 87c8625692.
This reverts commit a6dd6196b4.

Reason: Performance regression (#1655)

Closes #1655
2021-05-30 03:10:00 +09:00
Hajime Hoshi
a716edc713 text: Add explanation about cache limit 2021-04-27 02:36:33 +09:00
Hajime Hoshi
3f97386d8e text: Improve the comment 2021-04-27 02:28:52 +09:00
Hajime Hoshi
cdf700ed84 text: Improve the comments 2021-04-27 02:20:10 +09:00
Hajime Hoshi
c5c12cbf68 text: Improve the comment 2021-04-27 01:59:39 +09:00
Hajime Hoshi
4f6ad4e60b text: Update comments 2021-04-24 03:27:56 +09:00
Hajime Hoshi
a6dd6196b4 internal/affine: Cache scaling ColorM for heuristic optimization
Closes #1474
2021-01-28 02:23:22 +09:00
Hajime Hoshi
c8454bdfed text: Integrate emptyGlyphs and glyphImageCache to reduce runtine.mapaccess2 2021-01-05 13:12:46 +09:00
Hajime Hoshi
927c477d2b text: Change getGlyphImages to getGlyphImage to avoid allocating slices 2021-01-05 12:21:41 +09:00
Hajime Hoshi
cd779b678a text: Add comments 2020-11-03 20:35:55 +09:00
Hajime Hoshi
c70ebdc697 text: Misspelling 2020-11-03 19:54:51 +09:00
Hajime Hoshi
2d9e2a0483 text: Add CacheGlyphs
Fixes #1413
2020-11-03 17:12:51 +09:00
Hajime Hoshi
ec6821b1e1 text: Refactoring 2020-11-03 16:36:10 +09:00
Hajime Hoshi
5ec05ed79d text: Cleaning up the cache after the rendering finishes
Before this fix, cleaning up the cache happens during making glyph
images, and this can be problematic when the text includes more
glyphs than the cache limit.

After this fix, Draw allows to have more glyph cache than the limit
temporarily.
2020-11-03 15:58:35 +09:00
Hajime Hoshi
a046700ae1 text: Remove the optimization for GopherJS 2020-10-07 01:13:31 +09:00
Hajime Hoshi
1b816eb249 ebiten: Remove the error returning value from NewImageFromImage
Updates #1380
2020-10-06 01:03:33 +09:00
Hajime Hoshi
c6053bcf14 ebiten: Remove the error returning value from NewImage
Updates #1380
2020-10-06 00:48:56 +09:00
Hajime Hoshi
54da0d9763 ebiten: Remove the returning value from (*Image).DrawImage
Updates #1380
2020-10-06 00:21:17 +09:00
Hajime Hoshi
fe97e7b0a5 ebiten: Remove the filter argument from NewImage and NewImageFromImage
Updates #503
2020-10-05 01:40:44 +09:00
Hajime Hoshi
bf515bb594 Update version to v2.0.0-alpha 2020-10-04 04:30:40 +09:00
Hajime Hoshi
c08f47f445 text: Bug fix: Draw didn't work correctly with non-integer glyph bounds
Fixes #1377
2020-10-03 23:04:50 +09:00
Hajime Hoshi
c1be079ae9 text: Bug fix: Treat negative kernings correctly
Fixes #1378
2020-10-03 20:02:29 +09:00
Hajime Hoshi
f189404370 text: Update bitmapfont to v2 2020-09-23 22:59:46 +09:00
Hajime Hoshi
0699ca193c text: Improve comments 2020-07-30 00:54:57 +09:00
Hajime Hoshi
481c160c2a text: Replace MeasureString with BoundString
Fixes #1272
2020-07-30 00:51:10 +09:00
Hajime Hoshi
bb3a4cda22 text: Fix comments 2020-07-30 00:21:51 +09:00
Hajime Hoshi
35d1c8ae7a text: Improve documentations
Updates #1271
2020-07-30 00:02:35 +09:00
Hajime Hoshi
911750c4a6 text: Add comments 2020-07-20 23:47:46 +09:00
Hajime Hoshi
780465b702 ebitenutil: Cache ColorM and reuse them at DrawRect
Fixes #1221
2020-06-29 22:35:28 +09:00
Hajime Hoshi
3d7c102472 shaderir: Add func params 2020-05-13 23:31:17 +09:00
Peter Wunder
abc2801ff1
text: Add MeasureString method (#1152)
(sorta-kinda continuation from #1151)

This PR adds a MeasureString(string, font.Face) method next to the Draw() method in Ebiten's
text package. It should work with any supported font.Face, even "non-standard" faces like
those produced by packages like https://github.com/AndreKR/multiface. MeasureString's code
was adapted from the Draw method, so it's just as reliable.
2020-05-13 18:03:39 +09:00
Hajime Hoshi
47d5c3b5e1 Add testing package 2020-04-01 18:10:48 +09:00
Zachary Burkett
bb60818e8d
Add linebreak support to text.Draw (#1075)
Closes #1074
2020-02-12 23:15:57 +09:00
Hajime Hoshi
4a9a7f936d Make go vet a little happier on macOS
Updates #889
2019-07-22 20:16:22 +09:00
Hajime Hoshi
710f56531f graphics: Experimental: (*image.Image).SubImage
Fixes #722
2018-10-28 02:19:14 +09:00
Hajime Hoshi
fe4f12fa6f text: Fix style 2018-08-27 23:42:17 +09:00
Hajime Hoshi
1c088dc8b6 text: Use bitmapfont package for testing 2018-08-19 20:16:57 +09:00
Hajime Hoshi
d752408da3 Fix comments not to use the term 'this function' 2018-07-15 01:04:46 +09:00
Hajime Hoshi
92631e64ed Remove internal/sync
nosync package for GopherJS is problematic since nosync's mutex
assumes that Lock call is never duplicated, which is not true in
actual applications.

See also #603.
2018-05-09 23:41:08 +09:00
Hajime Hoshi
81dfc13b21 text: Remove duplicated glyphs 2018-04-28 22:50:45 +09:00
Hajime Hoshi
be3d529767 text: Bug fix: one image should be used for multiple glyphs (#535) 2018-04-26 02:41:01 +09:00
Hajime Hoshi
6caebc2310 text: Avoid creating 0-sized image 2018-04-26 02:11:45 +09:00
Hajime Hoshi
059bab0b13 text: Optimization: reduce ColorM calc 2018-04-23 22:42:38 +09:00
Hajime Hoshi
5257e6f9a7 text: Unify draw calls for multiple runes (#535) 2018-04-23 22:15:45 +09:00