summaryrefslogtreecommitdiffstats
path: root/libass/ass_render.c
Commit message (Collapse)AuthorAgeFilesLines
* Don't overwrite user-defined aspect ratio settingswm42013-03-291-2/+13
| | | | | | | | | | | | | | | | | | | | | ass_set_storage_size() overwrote the user-defined aspect ratio set with ass_set_aspect_ratio(). Change it so that if ass_set_aspect_ratio() is used, the ass_set_storage_size() parameters are not used for any aspect ratio calculations. (The storage size is still used for calculating the blur scale.) This simplifies the code as well, because the aspect ratio is now centrally calculated in ass_start_frame(). Update the doxygen. Make it clear that ass_set_storage_size() will be used for aspect ratio calculation, unless ass_set_aspect_ratio() is used. Also mention what libass actually does with the dar and sar parameters: it uses them to calculate a pixel aspect ratio, nothing else. Explicitly allow resetting the storage size with w=h=0. Document that it's allowed to remove the user defined aspect ratio by setting a pixel aspedct ratio of 0. See issue 6.
* Add type field to ASS_Image structwm42013-03-201-9/+13
| | | | Patch by chrisburel, posted on Google code issue 31.
* shaper: proper script/language handlingGrigori Goronzy2013-03-041-2/+1
| | | | | | | | | | | | | | | | | | | | | Determine script for each character and use this as an additional property for splitting up the text into runs. Characters of Common or Inherited script assume the script of the preceding character. If that is not possible (First character(s) in a run are Common/Inherited, for instance), a backwards scan is done so they can assume the script of the following character. Additionally, determine default language in case no override is set. This simply maps a language to a script, if a language exists that is mostly representative for a given script. Pango's mapping has been adapted. This helps with fonts that don't have OpenType features set up for default script/language pairs. It's also considered to be right approach by most people, and might help with correct OpenType rendering in some other cases. Fixes issue 85.
* Add ass_set_storage_size and fix related scaling issuesOleg Oshmyan2013-03-031-2/+7
| | | | | | | | \blur radius is not scaled from script to storage resolution but is scaled from storage to display resolution. The same applies to borders and shadows if ScaledBorderAndShadow is "no". (If it is "yes", borders and shadows are scaled from script to display resolution just like before.)
* Scale border size with user font size coefficientwm42013-01-111-0/+1
|
* Add Blur field to ASS_Stylewm42013-01-111-1/+1
| | | | | Useful when applications specify the style manually for non-ASS subtitles.
* Use glyph properties instead of renderer state in draw_opaque_boxOleg Oshmyan2012-12-281-7/+7
| | | | | | | scale_x, scale_y and hspacing should be read from the GlyphInfo of the glyph the box is based on, not from render_priv->state. The values in the renderer state are affected by override tags specified after this glyph, so they are irrelevant.
* Properly render opaque box shadows even when there is no borderOleg Oshmyan2012-12-281-3/+3
| | | | | | | | | | | | Even if the border size is zero, the shadow is supposed to be a copy of a hypothetical border: when border_style is 1, this coincides with the borderless glyph, but when border_style is 3, the shadow must be an opaque box. Opaque box borders are now generated regardless of border size being non-zero, and outline_to_bitmap3 gets a new flag indicating whether it should discard the border (after generating a shadow from it).
* Removes an useless warning message.Xidorn Quan2012-12-141-5/+0
| | | | | | Function "outline_to_bitmap" gives a warning itself when it returns NULL, so it is useless to print an addition warning for checking its return value.
* shaper: add hack to workaround grid-fittingGrigori Goronzy2012-10-161-1/+2
| | | | | This complements commit 7af780, which didn't correctly apply the hack to the advance/position as calculated by the shaper.
* Fix change detection in a rare caseGrigori Goronzy2012-10-011-1/+5
| | | | | | | | | If an empty track is passed to ass_render_frame, always set the change detection value to 2 (content and positions changed). This is acceptable in both the case that the previous call resulted in images (obviously) and in the case that the previous call resulted in no images (in that case the change detection result doesn't actually matter).
* Fix change detection when cache is clearedwm42012-10-011-0/+6
| | | | | | | | | | | check_cache_limits() clears the image list. If all subtitles disappear right in the frame the cache has been cleared, ass_detect_change() will see two empty image lists (old - not empty, but cleared, new - empty), and signal to the application that there was no change. As result, media players which rely on the change detection will keep displaying the last subtitle until the next subtitle event. This bug was found by uau and has been reported on IRC in February.
* Add ass_set_line_position() API function for subtitle positionwm42012-10-011-3/+12
| | | | | | | | This allows users to change the vertical position of normal subtitles. MPlayer has such a feature as -sub-pos option using its internal subtitle renderer. Bump LIBASS_VERSION to indicate the API addition.
* Fix \fay when used with multiline subswm42012-09-291-0/+1
| | | | | | | | | When \fay tag is applied to a multiline sub, it causes subsequent lines of the sub to be offset vertically as if it was rendered next to the previous line (not below). Patch by Hector Martin <hector@marcansoft.com>, with an additional correction related to libass issue #46.
* Fix issues with shearing in combination with scalingwm42012-09-291-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two problems. First, the shearing tags (\fay and \fax) misbehave when used with scaling tags (\fscx and \fscy). We have to compensate for the scaling in either direction when shearing, because the shearing is applied after scaling. VSFilter, which by definition has the correct behavior, does it the other way around. Second, libass doesn't scale smoothly when small font sizes are involved. These can come either from downscaling (e.g. make the mplayer window smaller than the video with a video output like gl or vdpau), or from setting the font size manually. In these cases, the font size passed to freetype get very low, so that rounding errors or size adjustments due to hinting or other pixel grid fitting add up. The result is text rendered in the wrong size, or "pulsating" text if the font size depends on animated parameters. This is worsened by the practice found in subtitle scripts to use tag combinations like "\fscy2500\fs2" to get more precision for controlling font size (needed because VSFilter doesn't read fractional scale values). We solve the second issue by always requesting a constant font size from freetype, and then scaling the resulting glyph to the desired size. This seems to disable freetype's glyph fitting issue. The caveat is that it (obviously) also disables hinting, which may result in worse text quality. However, the combination of applying \fs and \fscx tags, and animating them, seems to leave no other choice. This fixes libass issue #46 (hopefully).
* Terminate drawings immediately on a \p0 tagwm42012-09-291-5/+32
| | | | | | | | | | | | | | | | The parsing code allowed override tags after \p0 to affect the drawing. This is incorrect. Finish the drawing object as soon as \p0 is encountered instead. This requires moving the code executing the style overrides from get_next_char() in ass_parse.c to the main render loop in ass_renderer.c, because we have to re-enter the rendering loop inside of a tag. The old code was simply executing all tags until a new character could be returned to the renderer loop, mutating up the state (RenderContext fields) for the drawing after the drawing was closed, but before it was rendered. This fixes libass issue #47.
* Fix resetting border style with \rSTYLEwm42012-09-291-4/+6
| | | | | | | | | With \rSTYLE, it is possible to change the border style within the same subtitle event. You can do this by setting a different BorderStyle value in the newly requested style. VSFilter handles this as expected, while libass uses a single border style for the whole subtitle event. This fixes libass issue #56.
* Refactor and fix border generationGrigori Goronzy2012-04-211-1/+3
| | | | | Make sure to update the border appropriately in the second pass, after parsing.
* Support \rSTYLENAME syntaxGrigori Goronzy2012-03-111-20/+23
| | | | | This allows to reset to a certain style, instead of the default style for the current line. For some reason, this was completely missing.
* Letter spacing is a per-cluster propertyGrigori Goronzy2011-10-031-1/+2
| | | | | | | | Layout refactoring broke letter spacing and always used the last valid spacing specified for the whole line, which is of course wrong. Letter-spacing is an inline property and can be different for each glyph cluster. Add that property to GlyphInfo and use it to fix this regression.
* Remove unused code for bitmap runsGrigori Goronzy2011-09-251-58/+0
| | | | They are going to be reintroduced later.
* Fix x coordinates with PAR correction and left borderGrigori Goronzy2011-08-291-1/+2
| | | | | This is a bit hacky, but I'm planning to rewrite positioning in a much cleaner way. Addresses GC issue #27.
* Fix drawing leak on cache hitGrigori Goronzy2011-08-291-3/+6
| | | | This was introduced by the new cache code.
* Nicer initialization messagesGrigori Goronzy2011-08-221-5/+3
| | | | | Adjust the renderer initialization messages and get rid of a rather useless message, FreeType headers version.
* opaque box: avoid unnecessary outline copyGrigori Goronzy2011-08-221-2/+1
| | | | | | It's faster and easier to just create a new outline, than to copy it, free it, and create a new one. The old glyph-based code needed to do this since it's not possible to create a glyph "from scratch".
* Fix and simplify opaque box borderGrigori Goronzy2011-08-221-15/+14
| | | | | | Make sure to pass the correct advance and ascender/descender to the opaque box creation function. We can also simplify this a bit as we do not need to check if it's a glyph or drawing anymore.
* Deterministic bitmap loadingGrigori Goronzy2011-08-151-62/+61
| | | | This is similar to the earlier change, but for bitmaps.
* Deterministic outline glyph loadingGrigori Goronzy2011-08-101-39/+34
| | | | | Make sure to always load and process outlines the same way, no matter if cached or not.
* Add compile time switch for HarfBuzz supportGrigori Goronzy2011-08-081-0/+4
| | | | | | | | | | | | | Now that it's possible to switch shapers at runtime, it also becomes a lot easier to disable them at compile time. Add ifdefs and build system changes so that HarfBuzz can be safely disabled. It's autodetected now and enabled if available. This shuffles a bit of code around, but there are no functional changes. Note that FriBidi remains mandatory for the time being, but this shouldn't pose any problems, since it is a small and very portable library without any special dependencies.
* Runtime shaper selectionGrigori Goronzy2011-08-081-27/+25
| | | | | | | Add an API call, ass_set_shaper, and infrastructure to make shapers selectable at runtime. Currently, this allows to switch between two shapers: a SIMPLE shaper that maps to FriBidi and a COMPLEX shaper that maps to HarfBuzz.
* Adjust italic to non-italic style spacingGrigori Goronzy2011-08-061-4/+2
| | | | | | | | | | Previously, the space added was quite a lot, since it was calculated so that it would be enough to accommodate a heavily FreeType-slanted glyph in the worst case. In many cases this was too much spacing, especially if the italic font was only slightly angled. The new fix simply ensures that the glyph is inside the bounds of the advance.
* Support language hint in the Script Info sectionGrigori Goronzy2011-08-011-0/+2
| | | | | | Parse a hint in the form "Language: xx" with xx being an ISO 639-1 language code, and pass it to HarfBuzz. This can be useful to render scripts with language-specific character variants.
* Fix line counting and breakingGrigori Goronzy2011-07-171-5/+6
| | | | | | | | | Make sure to increment the line counter only if the offset of the new line is actually legal and inside the bounds of the text size. Fixes random crashes in case the last symbol of the line is a break. git-blame says it's Evgeniys fault, it wasn't caused by the recent layout changes.
* shaper: fix run-specific font sizeGrigori Goronzy2011-07-161-4/+4
| | | | | Make sure to set the font size for every run, as needed, to get metrics (advance/offset) for the right size.
* Use the "font encoding" property as a base direction hintGrigori Goronzy2011-07-151-0/+3
| | | | | | | | | | ASS specifies a "font encoding", both in the styles as well as with the \fe override tag. This font encoding is very Windows-specific and libass doesn't use it for charmap matching or anything like that. However, it can be useful for hinting the base direction of text. Make Hebrew and Arabic encodings switch to RTL base direction, other languages to LTR and use neutral base direction for the autodetect setting.
* Restore italic to non-italic transition layout fixGrigori Goronzy2011-07-131-16/+14
|
* Disable currently unused bitmap run codeGrigori Goronzy2011-07-131-0/+2
|
* Add kerning toggle for HarfBuzz shapingGrigori Goronzy2011-07-131-1/+2
| | | | | Make the "Kerning" track property toggle the OpenType feature "kern". The old TrueType kerning code won't come back.
* Fix layout with fsp/fay features enabledGrigori Goronzy2011-07-131-3/+6
|
* Introduce ASS_Shaper objectGrigori Goronzy2011-07-131-42/+8
| | | | | | Encapsulate all data related to shaping into this new object and migrate all shaping-related code to it. The object is long-living; arrays are allocated only once and then grown as needed.
* Various small fixes to HarfBuzz renderingGrigori Goronzy2011-07-121-17/+23
| | | | | Handle advance of clusters correctly, fix drawings, calculate run direction correctly, fix y offset sign.
* Support glyph clusters of multiple glyphsGrigori Goronzy2011-07-111-100/+152
| | | | | | | | | Sometimes a glyph cluster resolves to multiple glyphs, for example when diacritics are used with Arabic script. This doesn't map well to the list of glyphs expected by libass. Extend the glyph list to a list of singly-linked glyph clusters of glyphs and adapt the renderer to support this.
* HarfBuzz shaping supportGrigori Goronzy2011-07-111-20/+45
| | | | | | | | Split up text into runs with the same direction, font face and font size, shape these runs with HarfBuzz and reorder accordingly. This noticeably improves Arabic shaping and should make shaping for many other scripts work. HarfBuzz also does kerning for Latin text.
* Separate glyph font face matching and glyph loadingGrigori Goronzy2011-07-111-2/+6
| | | | | | | | | | | Split up ass_font_get_glyph into two functions: one function matches checks the fonts for support of the requested codepoint and returns a face_index and glyph_index to later load the glyph, with a second function. This approach is very useful for shaping, which needs to be done on runs with the same font face and font size and changes the glyph_index.
* Fix bitmap cacheGrigori Goronzy2011-07-101-2/+3
| | | | | | Pass the *complete* hash key to the cache handling functions, not only the outline-specific subkey. This mistake completely stopped the cache from actually working and resulted in great slowdown!
* Reorder positions for "Banner" effect textGrigori Goronzy2011-07-101-32/+36
| | | | | | Events that use the "Banner" effect have different wrapping/breaking handling (none at all, to be exact) and need special treatment to make reordering work.
* Redesign horizontal alignment calculations for bidiGrigori Goronzy2011-07-091-18/+7
| | | | | | | The line alignment code determined the first and last glyph in a line and calculated the distance from that. This is rather arcane and doesn't easily work with bidi. Redesign the algorithm to simply add together all individual character widths instead.
* Fix coordinates after repositioningGrigori Goronzy2011-07-081-2/+11
|
* shaper: print version info stringGrigori Goronzy2011-07-061-0/+2
|
* Provisional bidi and shaping supportGrigori Goronzy2011-07-061-14/+64
| | | | | | | | | | | | | | Adds fully working bidirectional text and simple shaping support. The following works: - bidirectional text according to the Unicode Bidirectional Algorithm - simple shaper for mirrored forms (brackets, etc.) according to rule L4 of the Unicode Bidirectional Algorithm - reordering into visual order with correct line wrapping However, the implementation certainly needs efficiency improvements (caching, less malloc'ing), a proper shaper (HarfBuzz) needs to be hooked up and various bugs with karaoke and positioning need to be fixed.
* Separate event parsing and layoutGrigori Goronzy2011-07-041-127/+133
| | | | | | Split up the combined event parsing and layout loop into two passes. State information needed for layout are duplicated in GlyphInfo structures.
* Introduce bitmap runsGrigori Goronzy2011-07-041-0/+62
| | | | | | | | Prepare for run-based rendering. In the parser, increment a run id according to relevant style changes (color, border, shadow, etc.) to mark the points where a new bitmap needs to be started. Modify the line wrapper to increment the run ids of each glyph after a break. Add functions to calculate the render size of runs for rasterization.
* Fix: VSFilter compat: don't render shadow when glyph/border invisibleGrigori Goronzy2011-07-041-1/+1
| | | | | | Use the alpha channel, not the red channel. Fixes commit f92830. Original patch by lachs0r.
* Cache ascender/descenderGrigori Goronzy2011-07-011-19/+10
| | | | | | Cache ascender/descender so they don't have to be queried every frame for every glyph. This also makes it possible to more uniformly handle drawings and glyphs.
* Fix stride support in vector clipsGrigori Goronzy2011-06-271-1/+1
|
* cache: unified bitmap cacheGrigori Goronzy2011-06-271-33/+24
| | | | | | Similarly to the glyph cache, subclass the bitmap cache to allow both outline bitmaps and clipping mask bitmaps to coexist in the same cache in a much cleaner way.
* cache: use outline-bitmap hierarchy to slim down bitmap hash keyGrigori Goronzy2011-06-271-26/+17
| | | | | | | | The bitmap hash key duplicated a lot of information the glyph hash key already saves. The subclassing introduced recently complicates this even more. Modify the hash key to utilize a pointer to the glyph hash value instead, which is faster and more flexible. Make sure to always empty the bitmap cache when the glyph cache is emptied.
* cache: unified outline cache for glyphs/drawingsGrigori Goronzy2011-06-271-21/+26
| | | | | | | | | Glyphs and drawings have wildly different hash keys. Subclass the hash keys of glyphs and drawings in a new, unified outline cache. This also fixes some issues with drawings in the glyph cache. Now, the textual description of the drawing is included in the key (the hash value isn't really good enough, especially not fnv32) and the baseline offset is saved as well.
* bitmap: add strideGrigori Goronzy2011-06-261-8/+8
| | | | | Add stride support to the basic bitmap type used for low-level rasterization.
* Use bare outlines for drawingsGrigori Goronzy2011-06-201-16/+8
| | | | | | | This finally gets rid of the nasty hack that manipulated a glyph we somehow got from FreeType. Simplifies drawing handling a bit and decouples drawing code from all font handling and related (fontconfig, etc.) code.
* Convert outline processing and caching from glyphs to bare outlinesGrigori Goronzy2011-06-201-70/+73
| | | | | | | | | This introduces functions to use and copy pointered outline objects easily and uses these instead of glyphs everywhere. Previously the glyph cache was abused for caching vector clipping masks, but this isn't possible anymore (nor desirable), thus vector clipping cache has been disabled for the moment.
* Convert to high-level rasterizer parts to outlinesGrigori Goronzy2011-06-151-7/+9
| | | | | This covers rasterization, filtering and blending for one render item.
* Stroker: process outlines directlyGrigori Goronzy2011-06-131-21/+34
|
* Fix whitespace trimmingGrigori Goronzy2011-06-111-8/+9
|</