summaryrefslogtreecommitdiffstats
path: root/libass/ass_shaper.c
Commit message (Collapse)AuthorAgeFilesLines
* Use FriBiDi 1.x API when availableKhaled Hosny2019-09-261-0/+22
| | | | This allows making use of the updated UBA in Unicode 6.3 and up.
* cache: remove level of indirection in glyph metrics valueDr.Smile2019-05-201-21/+21
|
* cache: construct cache values only from corresponding keysDr.Smile2019-05-191-32/+41
| | | | | | | | | | | | | | | | | | | | This commit forces construction of cache values using only data available in its companion keys. That ensures logical correctness: keys are guaranteed to have all the necessary data, and prevents accidental collisions. Most fixes of cache logic correspond to minor problem when rendering is done with double parameter but cache key stores its approximate fixed-point representation. The only serious problem is missing scale of clip drawing. Also this commit removes unused scale parameters from glyph metrics cache key. Due to missing scale clip shapes that differed only in scale treated by cache system as identical. That can lead to incorrect reuse of cached bitmap of different scale instead of correct one. The only hack left is in glyph metrics cache with its unicode >= VERTICAL_LOWER_BOUND check.
* ass_set_fonts: empty cache as wellRodger Combs2017-10-221-0/+7
|
* shaper: fix reallocationGrigori Goronzy2016-10-041-0/+1
| | | | | | | | Update the variable that tracks the allocated size. This potentially improves performance and avoid some side effects, which lead to undefined behavior in some cases. Fixes fuzzer test case id:000051,sig:11,sync:fuzzer3,src:004221.
* cache: fix ownership tracking issues of ASS_FontDr.Smile2016-07-161-0/+1
|
* cache: keep ref_count of all active objects nonzeroDr.Smile2016-06-301-25/+29
|
* cache: replace size_func with parameter in ass_cache_commit()Dr.Smile2016-06-301-2/+2
|
* cache: remove ass_cache_cancel(), cache failures insteadDr.Smile2016-06-301-15/+17
|
* cache: switch to gradual cache clearingDr.Smile2016-06-301-9/+8
| | | | | | | | | | | Advantages over the old algorithm consist of the following. * There are no glitches due to full cache clearing. Items are arranged into linked list ordered by time of last use. Only the oldest items get deleted at the clearing event. * Each item now keeps track of number of references. Referenced cache values are immune to clearing. * Reduced amount of total cache memory for the same performance. * Reduced number of memory allocations per cache item.
* shaper: drop RTL base direction for RTL font encodingsGrigori Goronzy2016-06-101-8/+4
| | | | | | | | VSFilter uses LTR base direction even if Arabic or Hebrew font encodings are used, so do the same. This resolves some reordering issues. Fixes #224.
* Fully fix compilation with MSVC/ICLOleg Oshmyan2015-09-171-0/+1
| | | | | | | | | As before, this does not add any build system support: a config.h file and a project must still be manually created (or the compiler can be run manually instead of using a project). Signed-off-by: Grigori Goronzy <greg@kinoho.net> Signed-off-by: Oleg Oshmyan <chortos@inbox.lv>
* ass_shaper: raise shaper info log levelwm42015-09-071-1/+1
| | | | | MSGL_V is usually for far noisier messages, such as those printed per subtitle event.
* Custom font matching and font sourcesGrigori Goronzy2015-07-101-1/+1
| | | | | | | Implement a simple font sorter (FontSelector) and an interface to deal with multiple font sources (FontProvider). Unfinished business, but works for the most part. Currently the only implemented FontProvider uses fontconfig.
* shaper: purge outdated commentGrigori Goronzy2015-05-241-2/+2
| | | | | HarfBuzz has been able to disable fallback kerning since commit 038c98f6. Add some more useful docstrings instead.
* More malloc checkingwm42014-11-201-12/+32
| | | | | | | | Don't crash if running out of memory when allocating per-glyph data during shaping. Also some fixes to initialization. The caller of ass_fontconfig.c/match_fullname() actually handles a NULL return value correctly.
* shaper: add FriBidi error handlingGrigori Goronzy2014-05-291-5/+15
| | | | | | It is unlikely, but FriBidi might not process a string correctly, and we should handle that. Tested by making it fail always. This should also fix some compiler warnings.
* shaper: fix nasty sign bug in font functionsGrigori Goronzy2014-03-171-1/+1
| | | | Fixes issue #68.
* Fix limits.h includesGrigori Goronzy2014-02-171-0/+1
| | | | These were missing in several places. Fixes #50.
* shaper: use global features correctlyGrigori Goronzy2014-01-291-5/+5
| | | | | | | start/end of feature tags is unsigned, so use the proper constant to signal to HarfBuzz that these features are global. This allows HarfBuzz to cache shape plans, and that can considerably speed up shaping, especially if many small runs need to be shaped.
* shaper: rewrite and simplify harfbuzz shapingGrigori Goronzy2014-01-291-73/+72
| | | | | | Rewrite the core of the harfbuzz shaping function. Gets rid of the MAX_RUNS limit of runs per line and reuses a single hb_buffer_t, which should be more efficient.
* Combine bitmaps before applying blur and shadow11rcombs2014-01-251-3/+26
|
* Fix missing pointer dereference in 1636a551Oleg Oshmyan2014-01-141-1/+1
|
* shaper: disable ligatures for non-zero \fspOleg Oshmyan2014-01-081-7/+20
|
* shaper: actually correctly handle @font advanceOleg Oshmyan2014-01-071-6/+11
| | | | | | | | | | The code was confusing glyph index and Unicode codepoint. 256df617 attempted a fix but merely moved the wrong code. Fixes Google Code issue #94. Vertical ligatures are possibly still broken, but horizontal ligatures and non-ligatures are correct now.
* Added ass_font_index_magic to fix char indexes in weird encodings11rcombs2013-12-061-3/+3
|
* ass_shaper: changing scale_x/y starts a new glyph runwm42013-09-261-0/+2
| | | | | Since font_size is usually normalized to 256, scale_x/y has to be used for this purpose.
* Fix Hinting againwm42013-09-261-8/+5
| | | | | | | | | | | | Commit 05eb520 missed some duplicated bits in ass_shaper.c. <wm4> oh crap <zgreg> oh crap indeed Instead of duplicating the logic in ass_shaper.c, just change the glyphs before they even get into processing. This way, all code reading the font size etc. is affected. This essentially reverts commit c207000c, because it's not needed anymore.
* Fix fribidi include pathwm42013-07-171-2/+0
| | | | | The old include statement works only by coincidence, and will actually break the build on certain setups.
* Remove unused variableswm42013-06-221-2/+1
|
* shaper: proper script/language handlingGrigori Goronzy2013-03-041-4/+170
| | | | | | | | | | | | | | | | | | | | | 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.
* shaper: correctly handle @font advanceGrigori Goronzy2013-03-031-3/+6
| | | | | | The code was confusing glyph index and unicode codepoint index. Fixes issue 94.
* shaper: add hack to workaround grid-fittingGrigori Goronzy2012-10-161-6/+8
| | | | | This complements commit 7af780, which didn't correctly apply the hack to the advance/position as calculated by the shaper.
* Revert "shaper: add UCDN support"Grigori Goronzy2012-10-151-13/+0
| | | | | | | | This reverts commit 840ce4c2d9381e340c3239d104933fea85fff3e5. Harfbuzz added UCDN support much quicker than I thought and the latest release 0.9.5 contains UCDN already, so we don't need it in libass anymore.
* shaper: improve skipping of zero-width charactersGrigori Goronzy2012-10-011-13/+25
| | | | | | The list was somewhat incomplete. Add what's important and left, and disable removal if HarfBuzz is used. HarfBuzz removes these characters now by itself. Refactor a little into a separate function.
* shaper: add UCDN supportGrigori Goronzy2012-10-011-0/+13
| | | | | | Add explicit support for UCDN, without relying on any HarfBuzz integration. This finally allows easy usage of HarfBuzz without glib, ICU, or some other big bloated library!
* shaper: allow font encoding -1 for neutral base directionGrigori Goronzy2012-10-011-2/+5
|
* shaper: always use LTR base direction by defaultGrigori Goronzy2012-10-011-4/+2
| | | | | | | | | | Unfortunately, VSFilter always assumes LTR base direction. All existing Arabic subtitles have been designed with that in mind. This causes various issues, for instance punctuation placed at the wrong side of a line. We have no other choice than to use the same braindead always-LTR assumption (except if overridden by the font encoding property).
* shaper: fix control character filteringGrigori Goronzy2012-05-191-1/+2
| | | | | | | | Correct off-by-one error and add 0x200c-0x200f range. This range is compromised of explicit direction and join marks. Fixes issue 54 Fixes issue 55
* harfbuzz: adjust to API changeGrigori Goronzy2011-09-241-1/+1
|
* harfbuzz: adjust to hb_buffer_t API changeGrigori Goronzy2011-08-291-1/+2
|
* harfbuzz: fix vertical advanceGrigori Goronzy2011-08-251-0/+5
| | | | | Make sure to use vertical advance under the right conditions - vertical font selected, requested glyph is non-latin.
* Add compile time switch for HarfBuzz supportGrigori Goronzy2011-08-081-38/+71
| | | | | | | | | | | | | 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-5/+29
| | | | | | | 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.
* Remove a bunch of debug printf callsGrigori Goronzy2011-08-041-34/+1
| | | | Shaping works well now, they aren't needed anymore.
* Support language hint in the Script Info sectionGrigori Goronzy2011-08-011-0/+13
| | | | | | 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.
* harfbuzz: cache glyph metricsGrigori Goronzy2011-07-291-4/+221
| | | | | | HarfBuzz' FreeType font functions do not cache anything and call FT_Load_Glyph all the time, which can be slow. Add a cache for metrics and use it with custom font functions.
* Axe misleading comment, reordering works fineGrigori Goronzy2011-07-251-2/+0
|
* Disable reordering of non-spacing marksGrigori Goronzy2011-07-251-1/+1
| | | | | | | | FriBidi's line reordering algorithm reorders non-spacing marks (diacritics, etc.) to come after the base character by default. This doesn't work particularly well with our layout model and leads to wrongly positioned marks in some cases with HarfBuzz and all cases with FriBidi shaping.
* Don't extend face runs as much as possibleGrigori Goronzy2011-07-221-5/+0
| | | | This leads to fewer shaping runs, but has many unwanted side effects.
* Update HarfBuzz' font metricsGrigori Goronzy2011-07-221-0/+16
|
* Remove unused variableGrigori Goronzy2011-07-161-2/+0
|
* shaper: fix run-specific font sizeGrigori Goronzy2011-07-161-1/+2
| | | | | Make sure to set the font size for every run, as needed, to get metrics (advance/offset) for the right size.
* Cache HarfBuzz fontsGrigori Goronzy2011-07-151-3/+36
| | | | | | Add a new opaque data structure to store shaper-specific font data in an ASS_Font. At the moment, this is used for caching HarfBuzz fonts, to reduce allocation and font initialization overhead.
* Use the "font encoding" property as a base direction hintGrigori Goronzy2011-07-151-3/+34
| | | | | | | | | | 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.
* Add kerning toggle for HarfBuzz shapingGrigori Goronzy2011-07-131-0/+10
| | | | | Make the "Kerning" track property toggle the OpenType feature "kern". The old TrueType kerning code won't come back.
* Enable vert/vkna features for @font vertical textGrigori Goronzy2011-07-131-1/+44
| | | | | | Set up a feature list and toggles these features as needed. The "vert" feature enables vertical glyph variants in general, while "vkna" additionally enables vertical variants for Kana.
* Introduce ASS_Shaper objectGrigori Goronzy2011-07-131-67/+174
| | | | | | 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-7/+7
| | | | | Handle advance of clusters correctly, fix drawings, calculate run direction correctly, fix y offset sign.
* Support glyph clusters of multiple glyphsGrigori Goronzy2011-07-111-6/+46
| | | | | | | | | 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-5/+78
| | | | | | | | 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.
* Hook up FriBidi's simple Arabic shaperGrigori Goronzy2011-07-101-9/+12
| | | | | Use FriBidi's shaper not only for mirroring, but also for simplified Arabic shaping.
* shaper: always use neutral base directionGrigori Goronzy2011-07-081-1/+2
|
* shaper: print version info stringGrigori Goronzy2011-07-061-0/+9
|
* Provisional bidi and shaping supportGrigori Goronzy2011-07-061-0/+115
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.