Commit Graph

125 Commits

Author SHA1 Message Date
Jeff Young 98f4e60b90 Contour cache must be sensitive to size.
(While we scale the contours afterwards, font hint
data is size-sensitive so the contours are already
size-specific.)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18014
2024-05-15 23:36:57 +01:00
Jeff Young 05cdd44404 Don't assume all glyphs are outline with an outline font.
Underline and overbar may be stroke glyphs.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17478
2024-03-18 22:21:01 +00:00
Jeff Young e7abeb3c38 Cleanup. 2024-02-24 20:05:51 +00:00
Jeff Young ffa6adec96 Add a cache for TrueType contours and triangulation data.
Also returns minimumSegmentLength to its former value as
it doesn't appear to be required to fix
https://gitlab.com/kicad/code/kicad/-/issues/11463.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/16568
(cherry picked from commit 162e8962f7)
2024-02-23 16:53:29 +01:00
Jeff Young 1ff36f23b8 Clean up stale TODOs. 2024-02-05 15:49:57 +00:00
Jeff Young de634c6f3e Generate tofu if we fail to decompose outline font glyph. 2024-02-05 15:49:57 +00:00
Jeff Young a28f092b67 Don't cover STL types. 2024-02-05 15:49:57 +00:00
Jeff Young 8410a5e685 Coding conventions and cleanup. 2024-01-23 16:03:25 +00:00
Jeff Young 047b5f8b18 Cache for wxLocale::IsAvailable(). 2024-01-17 16:13:53 +00:00
Seth Hillbrand 42e02552ac Make outline font min segment length configurable
This was hard coded at 10IU, which was way too small for pcbnew and
still too small for schematic editor.  Instead, we set a default of 50
and allow the user to adjust (smaller for less powerful machines)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16568
2024-01-11 18:30:00 -08:00
Marek Roszko be21c689e8 Change the __except to use the exception result codes 2024-01-05 21:03:43 -05:00
Marek Roszko 05cbfc6aca Add Windows SEH to catch fontconfig/freetype font read faults
Related https://gitlab.com/kicad/code/kicad/-/issues/16484
2024-01-05 15:23:00 -05:00
Jeff Young 68cbb820a7 performance efficiencies 2023-12-18 17:20:34 +00:00
Alex Shvartzkop b108e7058b Fix bad outline font glyphs when ligatures apply. 2023-11-18 07:59:46 +03:00
Jeff Young 1b6048b6d5 Handle non-binary font weights.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14502
2023-11-05 14:21:13 +00:00
Marek Roszko 050f812f5e Move fontconfig to kicommon for now to de-duplicate the font cache 2023-09-24 22:58:18 -04:00
Marek Roszko 22b733209d Fail GAL on its header leaking audit
Maybe we should rethink directly accessing GAL so much, but at least 600 files didn't need GAL leaked into them due to view_overlay.h
2023-09-18 19:52:27 -04:00
jean-pierre charras 931401b5be Fix a compil issue (missing header) and a minor compil warning 2023-09-14 08:44:09 +02:00
Marek Roszko 5b9aab9070 fontconfig.cpp doesn't need pgm_base.h 2023-09-13 23:14:50 -04:00
Marek Roszko 11de95778b Unwrap the FROM_UTF8 macro in favor of direct function
The extern just gets annoying to try to export the func later. We also yeet TO_UTF8 to string_utils.h for parity.
2023-09-09 00:10:57 -04:00
Marek Roszko f45d61ef18 OUTLINE_FONT does not need Pgm() or settings or EDA_TEXT 2023-09-06 22:12:59 -04:00
Marek Roszko 53bf7b71c6 Don't call FcInitLoadConfigAndFonts after FcInit() already happened
We are only the default global FcConfig created by calling FcInitLoadConfigAndFonts inside FcInit().
Calling FcInitLoadConfigAndFonts does nothing but creating another FcConfig option that never gets disposed or used because we use the FcConfig functions with null
2023-08-26 13:53:43 -04:00
Marek Roszko 25967b4a0f Fix font map cache access creating invalid entries (and crashes) 2023-08-26 09:24:47 -04:00
Jeff Young 778213ba8f LEGACY_FACTOR was upside-down.
(Should be 1.68/1.61, not 1.61/1.68.)
2023-08-07 14:01:58 +01:00
Jeff Young 5e112ca78e ADDED: parameterize font metrics and allow customization of overbar height. 2023-08-06 20:57:41 +01:00
Jeff Young 570978fa7f Replace larger text bboxes now that we're not using them for knockouts. 2023-05-28 18:17:24 +01:00
Jeff Young 6b0bff2f4f Formatting. 2023-05-27 22:46:02 +01:00
Jeff Young 4ed267394a 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
2023-05-27 01:35:40 +01:00
Jeff Young 6e127829f8 Cleanup formating and includes. 2023-05-26 18:44:33 +01:00
Seth Hillbrand 0de24bfd59 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
2023-05-17 13:33:49 -07:00
Seth Hillbrand 72267cf9b0 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
2023-05-12 12:40:41 -07:00
Jeff Young 995388fb71 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:40 +01:00
Jeff Young 7e5fedef6a 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:56:54 +01:00
Wayne Stambaugh 28776f5745 Text attributes object improvements.
* Add compare method to COLOR4D object.
* Add unit test to validate COLOR4D comparison method.
* Add missing color test in text attribute comparison method.
* Add unit test for text attribute object.
* Remove unnecessary headers from text attribute header.
* Move text attribute code into separate source file.
2023-03-29 12:53:45 -04:00
Jeff Young 7b3e01ce52 Select correct face from a .ttc file.
Fixes https://gitlab.com/kicad/code/kicad/issues/13314
2023-03-13 18:29:55 +00:00
Jon Evans 7b3fd2113c Improve sheet rendering performance
- Cache font markup parsing
- Cache SCH_SYMBOL::GetOrientation
- Don't construct new strings each time in GetDefaultFieldName
2023-03-05 17:41:46 -05:00
Seth Hillbrand bce402a01c 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
2023-02-24 17:15:57 -08:00
Jeff Young 4bb508eacf Adjust stroke font baseline offset to better match 6.0.
Fixes https://gitlab.com/kicad/code/kicad/issues/13886
2023-02-24 12:44:55 +00:00
Seth Hillbrand 81256c0fa4 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
2023-02-23 14:59:59 -08:00
Marek Roszko 39e69a3d29 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
2023-02-21 20:26:41 -05:00
Mark Roszko 7b4abb1f7b FT_Face is also not thread, protect getTextAsGlyphs 2023-02-17 14:39:52 +00:00
Marek Roszko 65d5b34da3 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.
2023-02-17 07:26:52 -05:00
Marek Roszko e8e407dfba 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
2023-02-13 20:09:05 -05: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