Commit graph

99 commits

Author SHA1 Message Date
William Wilgus
a749a95840 font.c cleanup
find_font_index can use font_filename_matches_loaded_id()

font_path_to_glyph_path doesn't need strcat

Change-Id: I8d1d36a68abbc700078d651eed930035641b6240
2023-02-15 23:02:36 -05:00
William Wilgus
ff98a54cd9 font.c return false if id is out of range instead of NULL
forgot to change this to match the bool return

Change-Id: I2cc6dc985b07f2bc0ae493b060aff6105f329097
2023-02-15 01:27:50 -05:00
William Wilgus
91c8633e8c [BugFix] font.c filename was movable
stupid bug on my part font_filename was pointing to a movable
alloc therefore that data could be moved out from under the returned pointer

instead pin the internal calls to core_get_data and
remove font_filename in favor of a function that checks if a
filename matches the loaded font as this was all it was used for anyway

Change-Id: Iebb47ffe3f81aa9d5e3968975f26d64283633ffc
2023-02-15 01:15:59 -05:00
William Wilgus
c955d93075 font.c dynamic path name
only alloc enough space for the path  instead of a fixed buffer

round up the path buffer size to slightly more thna the longest
common path length to reduce reallocations

Change-Id: I51b8b17584d6a905ea3a66a7c38b7b1b9da2e786
2023-01-30 23:36:34 -05:00
Aidan MacDonald
1e9ad3ca0d Remove buflib allocation names, part two
Remove allocation names from the buflib API and fix up all callers.

Change-Id: I3df922e258d5f0d711d70e72b56b4ed634fb0f5a
2023-01-13 10:32:54 +00:00
Aidan MacDonald
879888b158 Avoid using buflib names for storing font paths
Naming your allocations is more of a debugging feature; it's a
bad idea to abuse this feature for storing some random string.
The font code does exactly that to remember the path used to
load a font, and it's the only code that uses buflib names in
this way.

Store the path inside the font allocation instead as a regular
char array. For simplicity it's MAX_PATH sized, so this'll use
a bit more memory than the buflib name method, maybe 1-2 KiB if
a few fonts are loaded.

Change-Id: Ie286a1a273d6477af9e5d3f76e0534b62f72e8f7
2023-01-13 04:54:05 -05:00
William Wilgus
f6c719d7ec replace strlcpy with strmemccpy
replace applicable calls to strlcpy with calls to strmemccpy
which null terminates on truncation

in theory the strmemccpy calls should be slightly faster since they
don't traverse the rest of the source string on truncation
but I seriously doubt there is too much of that going on in the code base

Change-Id: Ia0251514e36a6242bbf3f03c5e0df123aba60ed2
2022-11-14 23:56:16 -05:00
William Wilgus
c756a8a89d make splash split on control characters
splits on spaces also considers \r\n\f\v\t as mandatory breaks

I'm still working on the strptokspn function
my goal is to use it directly rather than storing the matched char
and modifying the source string with \0 in order to tokenize the output
--Done

Change-Id: I7f378b5b9c4df8f10899b9a55a98950afb3931dc
2022-11-12 06:22:16 -05:00
Aidan MacDonald
1718cf5f8a Convert a number of allocations to use buflib pinning
Several places in the codebase implemented an ad-hoc form of pinning;
they can be converted to use buflib pinning instead.

Change-Id: I4450be007e80f6c9cc9f56c2929fa4b9b85ebff3
2022-10-16 14:50:39 +01:00
William Wilgus
12ef045fdf move buflib_free invalid handle check to the function
allow buflib_free to check for invalid or already freed handles
within the function -- remove all the invalid handle guards thru core_free

Change-Id: Ibdcbc82760fc93b674c42283fca420d94907df8e
2022-10-15 09:26:58 -04:00
Solomon Peachy
bc416ff590 misc: Only include rbpaths.h and string-extra.h in places that need it
(Don't include rbpaths.h in settings.h, or string-extra.h in rbpaths.h)

Build-tested on rocker, erosq, mini2g, nano2g,
                xduoox3, clipzip, dx50, and uisim

Change-Id: If32e9c9910f5c8247a655cb64522b84d6d7ccbb5
2021-04-10 12:08:12 -04:00
Aidan MacDonald
aacb0811d9 Rename symbols of FiiO M3K Linux-based port
Mainly a straight replacement of FIIO_M3K -> FIIO_M3K_LINUX.

Change-Id: Id07c84f8150991d1b6851540c2c3f8f67e3f12c2
2021-02-27 23:53:28 +00:00
Solomon Peachy
2a471e288c New port: AIGO EROS Q / EROS K
The Q and K have a slightly different case, but the hardware under the
shell is completely identical.

These models are rebadged versions:

 * Hifiwalker H2   (== Q)
 * AGPTek H3       (== K)
 * Surfans F20     (== K)

Other notes:

  * Significant improvements in the shared Hiby-platform launcher/loader
    * SD card can theoretically be hot-swapped now
    * Support external USB mass storage!
  * Some consolidation of Hiby-platform targets
  * Some consolidation of plugin keymaps

Todo/known issues:

 * Keymaps need to be gone over properly
 * Convert to HAVE_SCROLLWHEEL?

Change-Id: I5a8a4f22c38a5b69392ca7c0a8ad8c4e07d9523c
2020-10-11 16:37:17 -04:00
Amaury Pouly
1d121e8c08 Initial commit for the Sony NWZ linux port
SUPPORTED SERIES:
- NWZ-E450
- NWZ-E460
- NWZ-E470
- NWZ-E580
- NWZ-A10

NOTES:
- bootloader makefile convert an extra font to be installed alongside the bootloader
  since sysfont is way too small
- the toolsicon bitmap comes from the Oxygen iconset
- touchscreen driver is untested

TODO:
- implement audio routing driver (pcm is handled by pcm-alsa)
- fix playback: it crashes on illegal instruction in DEBUG builds
- find out why the browser starts at / instead of /contents
- implement radio support
- implement return to OF for usb handling
- calibrate battery curve (NB: of can report a battery level on a 0-5 scale but
  probabl don't want to use that ?)
- implement simulator build (we need a nice image of the player)
- figure out if we can detect jack removal

POTENTIAL TODOS:
- try to build a usb serial gadget and gdbserver

Change-Id: Ic77d71e0651355d47cc4e423a40fb64a60c69a80
2017-09-05 21:42:12 +02:00
Thomas Martitz
37be80a1a5 fonts: Fix regression(s) caused by c23ce62.
The builtin sysfont does not have an associated buflib_alloc_data
(because it's builtin right?). font_get_{width,bits} accessed a field of
it for all fonts which crashed on some systems but not on mine.
Solution: Move this field to struct font directly.

The cache size calculated was also busted.

Fixes FS#12944 and most likely FS#12938.

Change-Id: I32303c4335a12a6c421fdca34f7ece851aac12ca
2014-01-26 14:01:48 +01:00
Thomas Martitz
08d9b7fca5 Fix red. Screw those last-minute changes :\
Change-Id: I12666e98114e490a13023af7149fc37147d4e864
2014-01-16 10:31:15 +01:00
Thomas Martitz
01b28ea725 font: Fix crash due to uninitialized field.
Change-Id: If2fafb15a9998eebb2936e819507758e003abe30
2014-01-16 10:21:18 +01:00
Thomas Martitz
c23ce62829 fonts: Do not unload completely on USB.
The font engine can now perform cache lookups even if the font file is
closed, if the font was disabled with the new font_disable_all() function.
It is highly probable that the lookup succeeds but in the cache-miss case
a blank, full-width glyph will be returned.

Change-Id: I3c97e747d2a0ba30c7b495c6118c9f029d265b56
2014-01-15 23:37:39 +01:00
Thomas Martitz
281d1fadb3 Do not include kernel.h in system.h.
system.h doesn't need it on its own and this change makes it less
dependant on Rockbox internals.

Change-Id: I4e1e4108a52a7b599627a829204eb82b392fc6d6
2014-01-05 19:35:23 +01:00
Bertrik Sikken
d023bf0f5d Fix checks on buflib allocated handles (0 is not a valid handle value)
Change-Id: I8fdc5a59a5062f40a431cd49971390e21631b8ec
2012-06-10 17:15:47 +02:00
Michael Sevakis
da6cebb6b0 Use buflib for the allocation of voice PCM resources.
Buffers are not allocated and thread is not created until the first
call where voice is required.

Adds a different callback (sync_callback) to buflib so that other
sorts of synchonization are possible, such as briefly locking-out the
PCM callback for a buffer move. It's sort of a messy addition but it
is needed so voice decoding won't have to be stopped when its buffer
is moved.

Change-Id: I4d4d8c35eed5dd15fb7ee7df9323af3d036e92b3
2012-05-02 17:22:28 -04:00
Bertrik Sikken
cb972abc48 Another round of making local functions static
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31384 a1c6a512-1295-4272-9138-f99709370657
2011-12-20 20:35:28 +00:00
Boris Gjenero
694502a965 Fix FS#12423 : Rockbox access to /.rockbox/fonts after usb_enable(true). This fixes entry into USB mode on the Archos Recorder V2 and possibly also other targets using a USB to IDE bridge chip. Fred Bauer found this removes the need for a workaround in glyph_cache_save(). I'm including his patch which removes the workaround.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31155 a1c6a512-1295-4272-9138-f99709370657
2011-12-06 00:58:01 +00:00
Frank Gevaerts
6e664f49b1 Guard font functions against invalid font ids. These arguably should never be passed, but this prevents freezes. Fixes FS#12400
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31075 a1c6a512-1295-4272-9138-f99709370657
2011-11-27 15:36:03 +00:00
Frank Gevaerts
dfd5d0684a Actually make glyph_cache_save static instead of just claiming it should be
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31074 a1c6a512-1295-4272-9138-f99709370657
2011-11-27 15:28:16 +00:00
Frank Gevaerts
e5a3c26c1d glyph_cache_save should be static
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31073 a1c6a512-1295-4272-9138-f99709370657
2011-11-27 15:24:53 +00:00
Fred Bauer
95a828bcdb Fix parameter order in font_load_in_memory(). FS#12395.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31033 a1c6a512-1295-4272-9138-f99709370657
2011-11-20 17:49:47 +00:00
Fred Bauer
ea7a89606c FS#12293 Global default glyph setting in System > Limits > Glyphs To Cache. Defaults to 250. This saves a lot of RAM while still allowing non-English users to have adequate glyph coverage.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31031 a1c6a512-1295-4272-9138-f99709370657
2011-11-19 23:34:26 +00:00
Jonathan Gordon
f19f3efb07 Redo r30826 (and hopefully not reintroduce font issues) which cleans up the font API. FONT_UI is deprecated, use screens[screen].getuifont() instead (and .setuifont() to set it after a font has been loaded)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30932 a1c6a512-1295-4272-9138-f99709370657
2011-11-08 10:09:33 +00:00
Bertrik Sikken
e71750b7a3 Make local functions and variables static where possible
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30897 a1c6a512-1295-4272-9138-f99709370657
2011-11-03 23:32:49 +00:00
Fred Bauer
e299eb3ea3 Add functions font_set_ui() and font_get_ui(). The font returned by FONT_UI used to be fixed at zero but since buflib-fonts (r30589) can be different, depending on the order of loads and unloads. Fixes broken behavoir in virtual keyboard (FS#12336), lyrics player (FS#12306), and hopefully, FS#12337
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30826 a1c6a512-1295-4272-9138-f99709370657
2011-10-22 17:13:33 +00:00
Dominik Riebeling
c032b9d083 Add empty font_lock() for bootloaders to fix builds.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30817 a1c6a512-1295-4272-9138-f99709370657
2011-10-21 20:15:26 +00:00
Fred Bauer
04a015dde0 Provide font_lock(). Font_get_bits() or ..width() may have to read glyph cache misses from disk so provide a means to lock the buflib memory during the wait.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30814 a1c6a512-1295-4272-9138-f99709370657
2011-10-21 18:05:52 +00:00
Fred Bauer
8c9017211e Faster cached font loading. FS#12333
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30769 a1c6a512-1295-4272-9138-f99709370657
2011-10-17 13:17:04 +00:00
Fred Bauer
100974162d FS:12299 Font glyph cache is no longer saved. Each font will now have its own glyph cache file with the extension '.gc' Includes a temporary fix that delays saving the file to prevent the creation of multiple gc files with same name. Mostly JD Gordon's code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30760 a1c6a512-1295-4272-9138-f99709370657
2011-10-16 13:18:46 +00:00
Fred Bauer
08979ba835 Fix yellow
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30753 a1c6a512-1295-4272-9138-f99709370657
2011-10-14 20:42:14 +00:00
Fred Bauer
de3e2e7efc Remove font_reset() which tried to fetch font *pfs from uninitiaized buflib_allocations. Change handle locking to track number of locks applied. Remove some duplicated code from internal_load_font()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30752 a1c6a512-1295-4272-9138-f99709370657
2011-10-14 20:35:52 +00:00
Fred Bauer
ee7de145f1 Don't make font available via buflib_allocations[] until fully loaded
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30750 a1c6a512-1295-4272-9138-f99709370657
2011-10-14 14:04:27 +00:00
Thomas Martitz
5783505b99 Add two macros for char*-based pointer arithmetic and use it in font.c
This fixes errornous pointer addition (+ on a short*), which crashed in some situation.
Fixes FS#12317 and should hopefully get the clips booting again.

Thanks to Jonathan Gordon for spotting the bad pointer arithmetic.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30724 a1c6a512-1295-4272-9138-f99709370657
2011-10-07 19:29:18 +00:00
Björn Stenberg
725ed0ad3f Only alloc if necessary. Patch by Jonathan Gordon.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30716 a1c6a512-1295-4272-9138-f99709370657
2011-10-05 11:44:22 +00:00
Thomas Martitz
1125c39ea8 Don't leak file descriptor.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30619 a1c6a512-1295-4272-9138-f99709370657
2011-09-29 05:42:20 +00:00
Fred Bauer
205ef12b9d font_load(): Reduce font memory allocation to the font's file size if less than MAX_FONT_SIZE
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30618 a1c6a512-1295-4272-9138-f99709370657
2011-09-29 03:15:27 +00:00
Fred Bauer
117ebdb28c Do not move NULL pointers in buflibmove_callback(). Fixes some skin crashes when changing themes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30610 a1c6a512-1295-4272-9138-f99709370657
2011-09-27 01:02:34 +00:00
Fred Bauer
01b36e889c glyph_bytes() should pad to an even number
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30606 a1c6a512-1295-4272-9138-f99709370657
2011-09-26 18:13:34 +00:00
Thomas Martitz
586288cba1 Fix typos. Should have test compiled at least once :\
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30604 a1c6a512-1295-4272-9138-f99709370657
2011-09-25 20:19:54 +00:00
Thomas Martitz
6af8a579c7 Fonts/buflib: The lru cache base poitner needs to be updated as well in the move callback.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30603 a1c6a512-1295-4272-9138-f99709370657
2011-09-25 20:18:45 +00:00
Jonathan Gordon
83cfbf4e51 Allow fonts to use smaller buffers than the default size. use font_load_ex() to speficiy the buffer size. If the font is already loaded with a smaller buffer it will be reloaded to use the new size. Also fix an issue where handles would get lost if fonts fail to load in skins
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30592 a1c6a512-1295-4272-9138-f99709370657
2011-09-24 14:52:16 +00:00
Jonathan Gordon
aa0f4a4bbe FS#12273 - use buflib for font storage. thanks to the testers :)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30589 a1c6a512-1295-4272-9138-f99709370657
2011-09-24 13:19:34 +00:00
Thomas Martitz
9edd6d4ee9 Anti-Aliased Fonts support.
This enables Rockbox to render anti-aliased fonts using an alpha blending method.
The input font bitmaps are 4bit, i.e. 4x larger, but the metadata size stays the same.

A tool, convttf, for converting ttf fonts directly to the Rockbox fnt format is provided.
It has a useful help output, but the parameter that works best is -c1 or -c2 (2 for larger font sizes).

Flyspray: FS#8961
Author: Initial work by Jonas Hurrelmann, further work by Fred Bauer, Andrew Mahone, Teruaki Kawashima and myself.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29523 a1c6a512-1295-4272-9138-f99709370657
2011-03-05 18:36:51 +00:00
Michael Sparmann
751303c2ac iPod Classic CE-ATA Support (Part 1 of 4: Cacheline align some statically allocated sector buffers)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29444 a1c6a512-1295-4272-9138-f99709370657
2011-02-27 22:44:30 +00:00