Commit graph

27 commits

Author SHA1 Message Date
jp9000 53eb817d43 text-freetype2: Defer loading of plugin until source created
Helps significantly boost initialization time.
2016-11-14 17:34:45 -08:00
jp9000 5af1a2b5bb text-freetype2: Deprecate on windows 2016-09-14 16:59:46 -07:00
jp9000 bc9d68e2ad text-freetype2: Do not set default text 2016-06-27 03:18:48 -07:00
jp9000 42305f1c98 text-freetype2: Don't draw anything if no text to draw
Under certain circumstances (when there's no text and a filter is
applied for example) the freetype 2 text source would still draw.
2016-04-22 08:23:44 -07:00
Jim 32358ba636 Merge pull request #518 from hwdro/TFT-A8
text-freetype2: Use GS_A8 type glyphs texture
2016-03-24 01:23:55 -07:00
jp9000 9a54b61df6 text-freetype2: Mark ft2 text source as custom draw
Fixes a bug where the first effect filter on the freetype2 text source
wouldn't be properly applied
2016-03-20 21:40:37 -07:00
hwdro e0592beab3 text-freetype2: Use GS_A8 type glyphs texture
Since glyphs are rendered by FT as 8-bit gray levels bitmaps, it would
be a waste of memory to cache glyphs in a RGBA texture.
2016-03-10 15:23:42 +02:00
jp9000 667768b96b text-freetype2: Fix garbled rendering if face changed
When using a text file with the source and the font face is changed, it
would cause it to fail to update the glyphs and text accordingly.  It
would trigger an error jump at line 392 of text-freetype2.c, ultimately
resulting in the text to render garbled after that.

How to reproduce:
Set the source to get text from a file, then just change the font face
(but not the size or anything else).
2015-10-05 16:31:35 -07:00
Copy Liu c4f5769df4 text-freetype2: Refresh glype cache after file update
When updating text from file periodically, newer glyphs that weren't
already cached would not end up being rendered.  This fixes the issue by
calling cache_glyphs after the file has been updated.

How to reproduce the original issue:
Set a text-freetype2 source to load an english-only text file.  Then
overwrite the text in the file with non-english characters.  The
non-english characters will then fail to render.

Reported at https://obsproject.com/mantis/view.php?id=336

Closes jp9000/obs-studio#481
2015-10-05 16:00:06 -07:00
jp9000 e91f5384b4 text-freetype2: Cache data to reduce load time
This caches the font list data to a file to minimize load times.  Font
data will be refreshed when any font files are added/removed, based upon
a checksum of the font file names and dates (if available).
2015-10-04 21:16:31 -07:00
jp9000 6285a47726 (API Change) libobs: Pass type data to get_name callbacks
API changed from:
obs_source_info::get_name(void)
obs_output_info::get_name(void)
obs_encoder_info::get_name(void)
obs_service_info::get_name(void)

API changed to:
obs_source_info::get_name(void *type_data)
obs_output_info::get_name(void *type_data)
obs_encoder_info::get_name(void *type_data)
obs_service_info::get_name(void *type_data)

This allows the type data to be used when getting the name of the
object (useful for plugin wrappers primarily).

NOTE: Though a parameter was added, this is backward-compatible with
older plugins due to calling convention.  The new parameter will simply
be ignored by older plugins, and the stack (if used) will be cleaned up
by the caller.
2015-09-16 09:21:12 -07:00
jp9000 fdcb27230c text-freetype2: Add translation for source name 2015-07-06 21:28:40 -07:00
Manuel Kroeber 8a55f3bda7 text-freetype2: Fix bug 0000151
Fix bug 0000151: File loading not properly handled.

Link to bug: https://obsproject.com/mantis/view.php?id=151

A newly selected font is not loaded properly if "read from file" is
active without a valid file.  Old error handling lead to random memory
being displayed.

Closes Pull Request #390

(message edited by Jim)
2015-03-01 23:39:13 -08:00
Palana 94a93abb2b (API Change) Pass data to get_properties when possible 2014-10-01 15:39:57 +02:00
jp9000 c9df41c1e2 (API Change) Remove pointers from all typedefs
Typedef pointers are unsafe.  If you do:
typedef struct bla *bla_t;
then you cannot use it as a constant, such as: const bla_t, because
that constant will be to the pointer itself rather than to the
underlying data.  I admit this was a fundamental mistake that must
be corrected.

All typedefs that were pointer types will now have their pointers
removed from the type itself, and the pointers will be used when they
are actually used as variables/parameters/returns instead.

This does not break ABI though, which is pretty nice.
2014-09-25 21:48:11 -07:00
jp9000 8d76f940c6 Add null pointer check for text file
Apparently there was no check for a null pointer file name.
2014-09-02 18:22:44 -07:00
jp9000 ab4efe4dd1 text-freetype2: Fix null poitner dereference 2014-08-26 10:20:13 -07:00
jp9000 07d099bd1e text-freetype2: Localize text file path filter 2014-08-25 09:10:29 -07:00
jp9000 938b7c4395 text-freetype2: Fix 'text file' property filter
The text file filter accidentally said "All font files (*.txt)" instead
of saying "Text files (*.txt)".  Probably just a mistake from a
copy&paste.
2014-08-25 08:46:47 -07:00
jp9000 d95d20aa46 text-freetype2: Avoid spamming the log
When polling the file for changes, if the file doesn't exist, avoid
repeating the message over and over again that it couldn't find the
file.
2014-08-24 16:59:02 -07:00
jp9000 4ec0861481 text-freetype2: Avoid memory leak
Doing just return could cause it to bypass the font_obj cleanup
2014-08-24 16:58:28 -07:00
jp9000 50b80925e3 text-freetype2: Check if using file with from_file 2014-08-24 16:56:34 -07:00
jp9000 93d9317b7d text-freetype2: Fix issues with text file loading 2014-08-24 16:38:37 -07:00
jp9000 ec4016cafd Use better default fonts
On windows, Arial is probably one of the most commonly used.  Mac,
Helvetica.  The rest, Sans Serif.
2014-08-24 08:43:28 -07:00
jp9000 0fca88dde9 Do not draw text from file if file not found 2014-08-24 08:31:03 -07:00
jp9000 7f0ae838d7 Add system font lookup for mac/windows
This changes the font plugin from using a font file to using a specific
installed system font, which is searched for on each specific system and
associated with the font file.  It now uses a font property instead of a
path property, and font size has been removed because the font property
now handles that.

When the module is first loaded, it will build up a list of system fonts
in order to be usable by Freetype.  It was quite painful to program this
because font files can contain multiple localized versions of their face
names, and then there was the issue where windows likes to mangle
custom style types to the font name.  Regardless, it all seems to have
worked out pretty well.

Minor issues:
- Truetype/Opentype fonts sometimes do not automatically have
  italic and/or bold styles available, it seems that the system applies
  transformations manually in those cases.  We don't do this yet,
  however, so right now a user might select a font with italic/bold
  only to discover that italic/bold doesn't always work.  Not entirely
  sure what to do about this yet.  There's probably a freetype function
  to do something like that somehow,

This also requires that iconv be used for non-windows systems to be able
to look up localized font names within font files.  Windows will use
the win32 API and code page IDs to translate font names.
2014-08-19 02:11:37 -07:00
paibox e1611b431c Merge Freetype text plugin 2014-08-18 00:14:02 -07:00