Commit Graph

98 Commits

Author SHA1 Message Date
Jeff Young 9eaa5f90e0 Replace larger text bboxes now that we're not using them for knockouts.
(cherry picked from commit 570978fa7f)
2023-06-06 11:19:41 +01:00
Jeff Young f3c5c458c6 Formatting.
(cherry picked from commit 6b0bff2f4f)
2023-06-06 11:19:41 +01:00
Jeff Young 45c7490180 Outline font performance improvements.
1) Don't fracture font glyphs when generating them; we're going
   to fracture during triangulation anyway.
2) Don't check for self-intersection when deciding to fracture.
   It costs nearly as much as the fracture does.
3) Cache drawing sheet text.
4) Use the current font when checking for cache validity.
5) Parallelize glyph triangulation.
6) Don't invalidate bounding box caches when offset by {0,0}
7) Use the glyph cache when generating text effective shape.
8) Short-circuit NormalizeJustification() if its center/center.
9) Don't triangulate for GuessSelectionCandidates()
10) Avoid sqrt whenever possible.
11) Pre-allocate bezier and SHAPE_LINE_CHAIN buffers.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14303

(cherry picked from commit 4ed267394a)
2023-06-04 20:57:14 +01:00
Seth Hillbrand d5bd1f5aea Cleanup text alignment between version 6 and 7
Version 7 text alignment changed subtly for stroke fonts from version 6.
Additionally, the output has been different between screen and plotting,
leading to offset text in plotted output relative to the text shown on
screen.

This introduces a fudge factor in FONT::getLinePositions to correct the
offset in the plotting output relative to v6.

This also changes the SCH_PAINTER and PCB_PAINTER to correct the
relative offsets between GAL and PLOTTER classes.  The source of these
offsets is atm unclear.

Fixes https://gitlab.com/kicad/code/kicad/issues/14755

(cherry picked from commit 0de24bfd59)
2023-05-17 15:29:49 -07:00
Seth Hillbrand 81be16d058 Adjust stroke font output to match v6 output
Many minor tweaks were added that changed the output of the stroke font
from v5/v6.  These offsets changed the gerber output expected.  This
reverts the changes to something much closer to the v6 output.  It is
not pixel-perfect but gets very close on most texts.

Fixes https://gitlab.com/kicad/code/kicad/issues/14609

(cherry picked from commit 72267cf9b0)
2023-05-12 12:53:32 -07:00
Jeff Young e3adc76a72 Rewrite linebreaking algorithm.
Previous version was overly simplistic to deal correctly
with multiple spaces or textruns not separated by spaces.

Fixes https://gitlab.com/kicad/code/kicad/issues/14683
2023-05-05 22:32:03 +01:00
Jeff Young e8a9485d5e Markup fixes.
1) allow escape sequences inside markup sequences
2) keep overbar when inside nested markup
3) always place overbar at full height, not sub/superscript height

Fixes https://gitlab.com/kicad/code/kicad/issues/14553

Fixes https://gitlab.com/kicad/code/kicad/issues/13449
2023-04-17 17:52:11 +01:00
Jeff Young 2d9bcb6e4f Select correct face from a .ttc file.
Fixes https://gitlab.com/kicad/code/kicad/issues/13314

(cherry picked from commit 7b3e01ce52)
2023-03-14 11:56:33 +00:00
Seth Hillbrand 5aba9b539f Revert font spacing/tabs to the v6 model
While convoluted, this model matches as best we have found so far, the
alignment with scintilla.  The spacing is character size for N-1 of the
characters in the 4-space tab stops.  The final character is sized for
the actual space character in the stroke font (0.761905)

Fixes https://gitlab.com/kicad/code/kicad/issues/13791

(cherry picked from commit bce402a01c)
2023-03-06 16:23:06 -08:00
Jeff Young b2241dca72 Adjust stroke font baseline offset to better match 6.0.
Fixes https://gitlab.com/kicad/code/kicad/issues/13886

(cherry picked from commit 4bb508eacf)
2023-02-26 21:59:43 +00:00
Seth Hillbrand f927c15adf Prevent mutex deadlock
The overbar function in outline fonts recursively calls the text
function which already owns the lock.  To avoid this, we have an
unlocked variant that is wrapped by the exposed text function

Fixes https://gitlab.com/kicad/code/kicad/issues/14015


(cherry picked from commit 81256c0fa4)
2023-02-25 13:44:18 +00:00
Salvador E. Tropea b21e65fc5f Fix compatibility with wxWidgets 3.0.x
- Use CanonicalName when GetCanonicalWithRegion() isn't available
2023-02-22 19:23:55 +00:00
Marek Roszko fd4a0dbedf Fix up handling of font names available in multiple names
ttf fonts can declare multiple language names. Many by default opt to just declare one and not tag it any particular language.
However, there are CJK languages that typically leverage this function the most. They'll tag both a "en" and a cjk lang family name in CJK characters.

To be as user friendly as possible, we need to display said fonts in the CJK languages if KiCad to set to such a locale.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14011


(cherry picked from commit 39e69a3d29)
2023-02-22 01:27:09 +00:00
Mark Roszko 62337f75b8 FT_Face is also not thread, protect getTextAsGlyphs
(cherry picked from commit 7b4abb1f7b)
2023-02-17 15:17:11 +00:00
Marek Roszko 4d4fdfff70 freetype is not thread safe, zone filler can trigger multi-thread access
sentry KICAD-B1

https://freetype.org/freetype2/docs/reference/ft2-base_interface.html
[Since 2.5.6] In multi-threaded applications it is easiest to use one FT_Library object per thread.
In case this is too cumbersome, a single FT_Library object across threads is possible also, as long as a mutex lock is used around FT_New_Face and FT_Done_Face.


(cherry picked from commit 65d5b34da3)
2023-02-17 15:17:02 +00:00
Marek Roszko a48eace90a It's not impossible for the font face to fail loading
LoadFont()'s only usage already checked for nullptr to fallback, let's actually return nullptr on a failed load

Fixes sentry KICAD-8Z
Make the cause of sentry KICAD-95


(cherry picked from commit e8e407dfba)
2023-02-14 01:09:56 +00:00
Seth Hillbrand bcc1e28bab Fix Windows build error
bc Microsoft owns all the words
2023-01-25 16:45:04 -08:00
Seth Hillbrand 33bef16376 Simplify the winding calculation
This algorithm is more robust against points and cheaper to execute.
2023-01-25 13:13:38 -08:00
Seth Hillbrand cf52bfcc55 Handle missing Bold/Ital outline fonts
If the font face doesn't include a Bold or Italic version, we still want
to display the font as bold/italic, so we fake it with freetype.

This also prevents recurring error messages where the outline font warns
about "substitutes" within the same font family.

Also allows variants on the weight descriptor to be used without
throwing a substitution warning

Fixes https://gitlab.com/kicad/code/kicad/issues/13654
2023-01-25 13:13:38 -08:00
Marek Roszko 0ff32d20cd wxS more things 2023-01-22 09:41:42 -05:00
Marek Roszko ac94995f70 Some more wxS 2023-01-16 19:07:50 -05:00
Jeff Young aeb0d1d887 Use a more reliable conversion to UTF8.
Fixes https://gitlab.com/kicad/code/kicad/issues/12722

Fixes https://gitlab.com/kicad/code/kicad/issues/13313
2023-01-07 13:13:13 +00:00
Jeff Young 6d73d9a08e Split another couple of hairs in the never-ending "how big is a font".
Fixes https://gitlab.com/kicad/code/kicad/issues/13009

Fixes https://gitlab.com/kicad/code/kicad/issues/13115
2022-12-12 17:37:17 +00:00
Jeff Young 740e193871 Increase bounding box of stroke text and the leader box of all text.
Fixes https://gitlab.com/kicad/code/kicad/issues/13009
2022-11-27 15:27:30 +00:00
Jeff Young 387f1214f0 Add some heuristics to guess a better font overbar offset.
Fixes https://gitlab.com/kicad/code/kicad/issues/13010
2022-11-26 17:26:20 +00:00
Ian McInerney 1683e552f7 Add/fix some variable initializations 2022-09-25 00:48:38 +01:00
dsa-t bd8b737c44 GAL: Do better job at reserving vertices. 2022-09-14 16:07:47 +00:00
jean-pierre charras bde2d388f1 Fix a very serious memory leak in OUTLINE_FONT::getTextAsGlyphs(). 2022-09-13 17:55:12 +02:00
Jeff Young 9188838e50 RIP EDA_RECT. 2022-08-31 23:57:24 +01:00
Jeff Young 560dc7d2b6 Underline for hypertext rollovers. 2022-08-27 23:58:13 +01:00
Seth Hillbrand 7a8b188569 Fix Sentry crash for font loads
We cache newstroke loading, but if we have threaded loads, we might ask
multiple threads to load the newstroke font at the same time.  This
causes conflicts in the vector allocations->crashes
2022-08-23 09:51:20 -07:00
jean-pierre charras 32551cf1ea minor coding style fix. 2022-07-31 18:35:37 +02:00
jean-pierre charras 993c446fdf Fix some warnings detected by PVS-STUDIO (most are not used vars) 2022-07-25 18:23:52 +02:00
jean-pierre charras 9f38fa43cd Fix some minor compil and Coverity warnings. 2022-06-05 11:44:49 +02:00
Jeff Young 38e5faf21b Overhaul bitmap text for performance.
Also adjusts metrics to better match stroke font.

Also removes text-halo highlighting as it's too expensive to re-render
when the zoom changes.

Fixes https://gitlab.com/kicad/code/kicad/issues/11460
2022-05-14 20:09:54 +01:00
Jeff Young 47e002a33d Add font to status bar for text objects. 2022-04-26 18:52:53 +01:00
Jeff Young 662c1ce88f Improve outline font overbar metrics. 2022-04-26 12:52:29 +01:00
Jeff Young 9b6a10fa6a Fix mirrored overbars.
Also fixes a bug that we'd render too many glyphs when some glyphs
were combined.  (To test, render "text" in Apple Chancery.  The opening
"te" is combined into a ligature after which we render an extra 't' at
the end.

Fixes https://gitlab.com/kicad/code/kicad/issues/11441
2022-04-23 14:21:12 +01:00
Jeff Young fb1e1aec9a Add tab processing for outline fonts. 2022-04-20 12:00:19 +01:00
Jeff Young 37a2ee7d03 Replace tab processing that got lost in move to new font engine.
Fixes https://gitlab.com/kicad/code/kicad/issues/11123
2022-04-20 00:06:34 +01:00
Jeff Young 659e61355c Adjust text spacing a bit more so 6.0 boards are more likely to pass DRC. 2022-03-30 16:32:24 +01:00
Jeff Young 4424865577 Make sure spaces at start of line get accounted for.
Fixes https://gitlab.com/kicad/code/kicad/issues/11276
2022-03-30 16:32:23 +01:00
Jeff Young 6a3c5b6e0e Adjust bottom- and centre-aligned linespacing to better match 6.0.
Fixes https://gitlab.com/kicad/code/kicad/issues/11269
2022-03-29 19:31:02 +01:00
Ola Rinta-Koski 6196f2bdf0 Version info: report all font libraries 2022-03-07 14:01:37 +00:00
Jeff Young 98f4b1d16c Make gcc (or linux?) happy. 2022-02-26 22:56:10 +00:00
Jeff Young 941d7f94ad Use safer UTF8 conversion routines to prevent crashes.
Fixes https://gitlab.com/kicad/code/kicad/issues/10982
2022-02-26 19:03:00 +00:00
Jeff Young d1b8b68c68 No need to partition font glyph triangulation. 2022-02-15 19:19:02 +00:00
Ola Rinta-Koski 44c93e48e9 Markup parser fix: subscript/superscript/overbar handling 2022-02-08 18:50:53 +00:00
Jeff Young 5ce559176d Overhaul the font metrics calcs for overbar, italics and bboxes. 2022-02-07 17:36:40 +00:00
jean-pierre charras 2485648a54 Fix typo in a copy/paste and a minor compil warning 2022-02-07 17:32:19 +01:00