Commit Graph

274 Commits (master)

Author SHA1 Message Date
Olli Wang 4e42b6c659 Fixes memory leaks due to not releasing font images properly. 2022-03-28 00:42:30 +08:00
Olli Wang 2615db02e5 Fixes stbtt implemention.
This commit fixes the issue mentioned by 0b37350df7 (r63095702)
2022-01-09 12:30:49 +08:00
Olli Wang 0b37350df7 Fixes FreeType errors when dealing with multiple NVGcontext objects.
Originally there is only a shared `FT_Library` object. However, if we create multiple `NVGcontext` objects and as soon as we delete one, the shared `FT_Library` object will be released, too. And that would cause a problem for the rest of `NVGcontext` objects.
2021-12-03 00:23:26 +08:00
Nat! ba85215f10
Update fontstash.h
* change call order in `fonsDeleteInternal` so that free memory isn't passed to `fons__tt_done`
2021-10-31 22:28:28 +01:00
Nat! 0bfd2c21cc New ci.yml. Build nanovg on every push on ubuntu.
Does not build examples (yet), due to technical
problems with the older ubuntu version being used
by github.
2020-12-25 16:43:36 +01:00
Nat! 0faac6f91a less whitespace 2020-12-21 10:59:15 +01:00
Nat! 621e0b8d35 Fixed text vanishing when the transform is vertically flipped 2020-12-20 12:45:20 +01:00
Dominus Iniquitatis fb785932a0
Single-byte typo fix 2020-11-05 04:56:25 +03:00
Mikko Mononen a90ccc20cc
Merge pull request #588 from d4tocchini/freetype-hint-fix
fix for freetype glyph loading
2020-10-01 14:16:13 +03:00
D4 30b9f3e047 Squashed wonky FT kerning via FT_Load_Glyph flag FT_LOAD_TARGET_LIGHT 2020-10-01 00:47:50 -07:00
My Name 4c7eb2f63d Added a preprocessor definition to disable the use of stb_image + Added CMakeLists 2020-09-15 11:41:34 +09:00
Geoff 52265fe278
Fixed Signed/Unsigned Comparison Warning
In Visual Studio 17, I get warnings related to these variables:
````
fontstash.h(241): warning C4018: '<': signed/unsigned mismatch
fontstash.h(242): warning C4018: '<': signed/unsigned mismatch
````

Making them unsigned fixes it.
2020-03-20 09:51:00 +01:00
Mikko Mononen 426aa3f149 Fix for #570: round glyph positions to pixels using floor 2020-03-18 23:11:00 +02:00
Mikko Mononen bff4734a9a
Merge pull request #567 from olilarkin/fix-webgl-warning
Bind a dummy texture in setUniforms when compiling with emscripten
2020-03-11 23:12:37 +02:00
Oli Larkin 35dbc98160 modify to use dummy texture even without emscripten 2020-03-10 21:27:36 +00:00
Mikko Mononen e281ffcabd Fixed nvgTextBreakLines returning bad minx
- nvgTextBreakLines: wordMinX was relative to rowStartX, which caused
problems when rowStartX change on line break, but wordMinX was still
relative to the previous rowStartX
- fixed font size on perf graphs
- made demo to use row minx/maxx instead of row->width
- fixed demo hover distance
2020-03-07 23:01:56 +02:00
Oli Larkin 3e986cdf4b call glnvg__renderCreateTexture() in glnvg__renderCreate 2020-03-05 22:10:53 +00:00
Oli Larkin d98041b4ee Bind a dummy texture in setUniforms when compiling with emscripten
fixes the WebGL error "RENDER WARNING: there is no texture bound to the unit 0"" in Chrome
2020-03-02 23:18:05 +00:00
Mikko Mononen db50e12d03
Merge pull request #563 from olliwang/linegap
Fixes the issue that line gap may ruin the text layout.
2020-02-28 12:49:06 +02:00
Mikko Mononen 492df633f1
Merge pull request #560 from olliwang/font
Support for resetting fallback fonts.
2020-02-28 12:06:32 +02:00
Olli Wang c519ae578b Support for resetting fallback fonts.
This commit adds `nvgResetFallbackFontsId()` and `nvgResetFallbackFonts()` functions for resetting fallback fonts.
2020-02-28 17:59:48 +08:00
Olli Wang 528dc4efb5 Fixes the issue that line gap may ruin the text layout. 2020-02-28 17:34:04 +08:00
Oli Larkin 5a006cdca4 Pass fringe parameter to renderTriangles, fixes bad clipping of text on high DPI screens 2020-02-26 12:12:31 +00:00
Olli Wang 8851f025e4 Support for loading a certain font face from a font file.
This commit allows loading a certain font face from a font collection file such as TTC.
2020-02-20 13:23:33 +08:00
Olli Wang 69e1a47511 Fixes the issue that font size is inconsistent.
This commit fixes the issue that font size is inconsistent between different font files. `stb_truetype.h` is also updated to the latest version to support additional font types such as OpenType fonts.
2020-02-10 17:06:58 +08:00
Kenny Sharma 97fc85668f Fix compile issue for missing { in fontstash.h 2018-09-27 11:55:31 -07:00
Olli Wang 9b27dc3894 Fixes memory leaks of freetype.
This commit fixes the issue that freetype library isn’t released in `fonsDeleteInternal()` and causes memory leaks.
2018-09-27 17:51:38 +08:00
Olli Wang e7154e104e Fixes the bug that gl may fail to draw fringes.
This commit fixes the bug that `glnvg__convexFill()` tried to draw fringes depending on whether `NVG_ANTIALIAS` is set. However, #386 adds `nvgShapeAntiAlias()` for chaning anti-alias state explicitly, and `glnvg__convexFill()` would cause error If the anti-alias state is disabled.
2018-09-09 22:27:03 +08:00
Mikko Mononen cfa175a0b9
Merge pull request #392 from satoren/crash_on_32bit_platform
Fix example crash on 32bit platform
2018-09-02 11:36:06 +03:00
Olli Wang 83da90e1c8 Forces autohint when loading glyph using FreeType.
This commit adds the `FT_LOAD_FORCE_AUTOHINT` parameter to `FT_Load_Glyph()` to fix wonky characters.
2018-07-27 18:07:45 +08:00
Olli Wang 8d1b1e7d15 Fixes text corruption on atlas rebuild.
This commit fixes #494.
2018-07-16 13:44:48 +08:00
Mikko Mononen 6fa3b3d519
Merge pull request #477 from olliwang/size
Fixes the type of view size.
2018-04-30 10:45:42 +03:00
Olli Wang 6b6e3a5246 Fixes the type of view size.
This commit changes the type of the view size accepted by `nvgRenderFrame()` from `int` to `float` so it matches the type defined in `GLNVGcontext`. This would prevent a framebuffer missing a pixel in final rendering result.
2018-04-27 07:27:31 +08:00
Mikko Mononen 30a943cb9c Merge remote-tracking branch 'origin/master' 2018-04-18 00:02:34 +03:00
Mikko Mononen dfa31dfba2 Fix for #471
- disable stroke AA gradient when not using AA
2018-04-18 00:02:16 +03:00
JonathanS 6ce863cc57 Use GLES2 glTex[Sub]Image2D code paths also for GL2 2018-03-29 22:07:56 +02:00
Gavin Howard 5022b370e4
Mark devicePixelRatio unused in glnvg_renderViewport 2017-12-18 16:13:16 -07:00
Mikko Mononen 364911b596
Merge pull request #431 from olliwang/font
Resets font atlas when it is full.
2017-11-06 22:49:32 +02:00
Olli Wang 645861c804 Renders glyph’s bitmap data on demand.
This commit updates font stash to render glyph's bitmap data on demand. This change is intended to fix the issue that `nvgTextBounds()` may return an unreliable result when font atlas is full. This situation usually happens when auto scaling a large font text to fit a small rectangle.

The `fons__getGlyph()` function now accepts a new parameter indicating whether bitmap data is optional, and only `nvgText()` requires it. All of `nvgTextGlyphPositions()`, `nvgTextBreakLines()`, `nvgTextBounds()` and `nvgTextBoxBounds()` functions are changed to work without glyph’s bitmap data.
2017-11-06 21:03:33 +08:00
Andrew Belt 448af072d6 Only apply fallback if GL_DEPTH24_STENCIL8 is defined 2017-09-23 10:32:17 -04:00
Andrew Belt bfd5d11f27 Merge branch 'master' of https://github.com/memononen/nanovg 2017-09-22 14:24:25 -04:00
Andrew Belt ee6b7346cc Add GL_DEPTH24_STENCIL8 as a fallback when creating render buffer object
for nvgluCreateFramebuffer
2017-09-22 14:22:48 -04:00
Joshua Ashton ac6a656898 Fix MSVC 2017 compiler warning 2017-09-05 14:42:27 +01:00
Dag Ågren b124bbbaf5 Fix implicit conversion warning. 2017-09-03 01:32:00 +03:00
Dag Ågren 3b54182b02 Remove unused variable. 2017-09-03 01:22:50 +03:00
satoren c7f70787c9 Fix crash on 32bit platform 2017-07-27 19:18:58 +09:00
Mikko Mononen 4f1c6d302a Fix for #391
Fixed return value of nvgText to be the position after the rendered
string, also fixed scaling of the value.
2017-07-26 21:11:45 +03:00
Mikko Mononen 30e1c98175 Merge pull request #386 from olliwang/flags
Allows to turn on/off antialias for shapes.
2017-07-12 07:44:28 +03:00
Olli Wang 17321202da Allows to turn on/off antialias for shapes.
This commit adds a new `nvgShapeAntiAlias()` function for turning on/off antialias for specific shapes.
2017-07-12 12:40:02 +08:00
Olli Wang f87cdf1041 Prevents uploading unused vertices to GPU.
This commit fixes the bug that `glnvg__renderFill()` allocates unused quad vertices for `GLNVG_CONVEXFILL`, which causes unused vertices uploaded to the GPU.

Besides, the quad for the `GLNVG_FILL` type is changed to drawn by `GL_TRIANGLE_STRIP` instead of `GL_TRIANGLES` so two more vertices can be reduced per quad.

In one of my test case, I need to paste an image to a framebuffer about 5,000 times, and this change would reduce the total number of uploaded vertices from `52,106` to `22,476`. It is good for FPS and battery consumption.
2017-07-12 03:54:55 +08:00