summaryrefslogtreecommitdiffstats
path: root/libass/ass_font.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix OS/2 usWinDescent/usWinAscent for quirky fontsGrigori Goronzy2013-07-061-3/+4
| | | | | | | | Some fonts stuff a signed, negative value into this unsigned field. This usually causes very small and wrongly positioned rendering. Also handle usWinAscent similarly, just in case. Fixes issue #106.
* Fix fix_freetype_strokerOleg Oshmyan2012-12-281-5/+5
| | | | | | | | | | | | The first point in a countour is not allowed to be a cubic control point, which is sometimes violated by blindly reversing a countour, producing the following errors: [ass] FT_Stroker_ParseOutline failed, error: 20 [ass] Failed to rasterize glyph: 1 To avoid this, let the first point remain the first and only reverse the order of the remaining points.
* vertical: improve glyph positioningGrigori Goronzy2011-08-251-2/+8
| | | | | | | | | | | | It is a bit crazy, but for vertical layout the sTypoAscender and sTypoDescender fields of the OS/2 table are supposed to be used for determining the size of the ideographic EM box [1], so that glyphs can be centered on the baseline more neatly. With this change, vertical layout should be completely equal to VSFilter. [1] http://www.microsoft.com/typography/otspec150/os2.htm#sta
* harfbuzz: fix vertical advanceGrigori Goronzy2011-08-251-2/+0
| | | | | Make sure to use vertical advance under the right conditions - vertical font selected, requested glyph is non-latin.
* Hack: return a valid face index even if no glyph is foundGrigori Goronzy2011-07-171-0/+2
| | | | | Temporary fix for a crash when a font face doesn't actually contain the glyph that fontconfig reports. Needs a real solution.
* Fix crash with FreeType's updated strokerGrigori Goronzy2011-07-171-7/+26
| | | | | | The new revision of the stroker in FreeType doesn't like the way contours are zero-filled to disable them. It's not particularly clean anyway, so rewrite the whole outline instead.
* Set requested font face correctlyGrigori Goronzy2011-07-161-1/+1
|
* shaper: fix run-specific font sizeGrigori Goronzy2011-07-161-5/+3
| | | | | 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-0/+4
| | | | | | 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.
* Revert @font ascender/descender hackGrigori Goronzy2011-07-151-3/+0
| | | | | | | | | This was introduced with commit e051ab. After re-evaluation, it seems to be rather wrong. Windows appears to use the same ascender as horizontal rendering, except for the first line. We don't have this special handling of the first line, but apart from that, everything is similar to Windows now. Verified with a couple of popular CJK fonts, such as MS Mincho, Meiryo, etc.
* HarfBuzz shaping supportGrigori Goronzy2011-07-111-8/+16
| | | | | | | | 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-20/+40
| | | | | | | | | | | 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.
* Clean up includesGrigori Goronzy2011-06-211-2/+0
|
* Convert outline processing and caching from glyphs to bare outlinesGrigori Goronzy2011-06-201-0/+19
| | | | | | | | | 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.
* Stroker: process outlines directlyGrigori Goronzy2011-06-131-19/+19
|
* Much improved cache/hashmap implementationGrigori Goronzy2011-06-071-3/+3
| | | | | | | | - less code, cleaner - decoupled from ASS_Library - better data encapsulation - simpler interface - avoids a nasty hack
* Improved "last resort" charmap matchingGrigori Goronzy2011-04-091-5/+6
| | | | | | | | After font reselection, loop through all charmaps if no glyph can't be found until we hopefully find one that works. If we get here at all, the font is seriously broken, so this is unlikely to harm anything. This improves the last resort charmap fallback introduced in 96057d.
* Relicense to ISCGrigori Goronzy2010-09-281-12/+10
| | | | | | In hope to make libass as useful as possible, relicense libass to ISC, a simplified 2-clause BSD license. All contributors who provided non-trivial changes have granted their permission for this.
* Get rid of NULL checks for freeGrigori Goronzy2010-08-091-2/+1
| | | | | The useless "if (foo) free(foo)" idiom is all over the place, just get rid of it finally...
* POSIX compliance: add strings.h include where appropriateGrigori Goronzy2010-08-071-0/+1
| | | | | strcasecmp/strncasecmp needs strings.h according to POSIX, so add this include where these occur.
* Fall back to first charmap as last resortGrigori Goronzy2010-08-011-0/+8
| | | | | | If we're already after the font reselection stage and a glyph cannot be found in a font, try again with the first charmap as a last resort. This is needed for old "symbol" fonts, for example.
* Add fixups for various font defectsGrigori Goronzy2010-06-261-0/+127
| | | | | | | | Reverse "outside" contours with wrong winding correction, require that a contour is "inside" for considering its removal; Move this hack into ass_font.c, where it belongs. Initial patch by uau.
* Fix ascender/descender scalingGrigori Goronzy2010-05-171-1/+1
| | | | Partially reverts 162a735b6b2dba13022f96db42a3f153cf28033e.
* Use first Windows charmap as fallbackGrigori Goronzy2010-04-181-2/+13
| | | | | | Extend the charmap selection heuristics to select the first Windows charmap if no Unicode charmap is found. Fixes one particular font, FGP楷書体NT-M, and possibly others.
* Support multiple faces per attachment correctlyGrigori Goronzy2010-04-171-1/+1
| | | | | | | | Store the real font face id instead of using 0 all the time and use the real font face id for font lookup as well. This makes font attachments with multiple faces work correctly. Thanks to ubitux and uau!
* Simplify: FreeType glyph load flagsGrigori Goronzy2010-04-111-2/+2
|
* Use vertical ascender only for rotated glyphsGrigori Goronzy2010-04-111-1/+1
|
* Completely disable transforms when loading a glyphGrigori Goronzy2010-04-111-0/+1
| | | | Might save a few cycles.
* Do not rotate glyphs below lower bound (GDI)Grigori Goronzy2010-04-111-31/+20
| | | | | | GDI does not use vertical writing for glyphs below a certain unicode codepoint. To make this work correctly, refactor glyph transformations a bit.
* Calculate vertical layout ascender/descenderGrigori Goronzy2010-04-111-0/+3
| | | | | Calculate ascender for rotated glyphs from the maximum advance width. Works OK usually, but screws up with fonts that miss this information.
* Basic @font supportGrigori Goronzy2010-04-111-5/+28
| | | | | | Do not skip '@' at the start of a font name in styles; detect '@' at font name start and set a new attribute in ASS_Font accordingly. Rotate affected glyphs after loading and calculate a suitable advance.
* Ignore global advance width unconditionallyGrigori Goronzy2010-04-101-5/+5
| | | | | | | | | | Some (arguably) broken CJK fonts claim to have a fixed advance width, but they actually use two different widths for half-width and full-width characters. Even worse, some use proportional width. This can cause problems under certain circumstances. A big project (Cairo) uses a FreeType load flag to ignore the global advance width for such fonts, so I assume it can be used safely. Let's do it just like them.
* Remove support for freetype < 2.2.1Grigori Goronzy2010-01-081-9/+0
| | | | | Get rid of compatibility #ifdefs and some code to support very old versions of freetype. libass now requires at least version 2.2.1.
* Render NBSP (\h) as normal spaceGrigori Goronzy2009-09-161-0/+3
| | | | | | Many fonts don't have a non-breaking space (NBSP) character and this can cause problems when these glyphs are substituted. Render them like a regular space.
* Improve and fix outline strikerGrigori Goronzy2009-08-151-10/+31
| | | | | | Exit early if no striking is needed; make sure to strike in reverse direction for non-truetype font and use the usual return value convention (0 == no errors).
* Add glyph emboldening fallbackGrigori Goronzy2009-08-121-0/+22
| | | | | | | Fallback to embolden manually with FreeType in case a bold face was requested, but no bold variant is available. The glyphs are slightly emboldened (much less than FT_GlyphSlot_Embolden would do) and the metrics are not touched at all.
* Rename typedefs (breaks API)Grigori Goronzy2009-08-061-22/+22
| | | | | | Rename all typedefs from the convention foo_bar_t, which can possibly conflict with POSIX types, to FooBar (and ASS_FooBar for public API typedefs). Fix formatting and stray comments while at it.
* Remove shift vector in ass_render_eventGrigori Goronzy2009-07-251-2/+4
| | | | | | | The shift is not calculated when fetching a glyph anymore. Instead, it is calculated right before rasterizing a glyph. Remove the shift vector and make get_outline_glyph, the glyph cache and ass_font_set_transform work without supplying a shift vector.
* Check for table availability when striking a glyphGrigori Goronzy2009-07-201-2/+2
| | | | | | | | The glyph striker (underline/strike-through) did not check for table availability, possibly accessing a NULL pointer. Change this to only strike the glyph if the table with the appropriate information is available. Currently there is no fallback for fonts without the required information.
* Font metrics: prefer OS/2 table for ascender/descenderGrigori Goronzy2009-07-201-4/+10
| | | | | | If possible, use ascender/descender from the OS/2 TTF table. This is another try to get libass to match VSFilter in regard to vertical font metrics.
* Tweak font metrics to match Windows GDIGrigori Goronzy2009-07-171-2/+3
| | | | | Try to change ascender/descender calculation to be more compatible with Windows GDI and consequently, VSFilter.
* Message callback funtionalityGrigori Goronzy2009-07-111-13/+19
| | | | | | | | | | | Introduce functionality for providing a message callback that is used for passing messages to the controlling application instead of simply printing them to standard output. The function pointer to the callback is stored in the ass_library_t instance. ass_msg needs access to it, so in many places the library instance needs to be passed around now. The default behavior is the old one: messages of MSGL_INFO or lower are printed to the standard output, prefixed with "[ass]".
* Replace string defines with real stringsGrigori Goronzy2009-07-111-13/+12
| | | | | | Instead of referencing string defines from help_mp.h, use the strings directly in ass_msg. Consequently, help_mp.h is useless and can be deleted.
* Support for underline and strikethroughGrigori Goronzy2009-07-071-1/+85
| | | | | | | | | | | | | | | | | Add support for the underline (\u) and strikethrough/strikeout (\s) properties. This is a bit tricky, since FreeType doesn't offer any method of adding the lines, so you have to draw them yourself. libass uses various information from TrueType tables to get position and size of the lines, does a few simple consistency checks (some fonts might be broken) and if everything is alright, adds new contours for the lines. Sometimes, rendering errors can occur: - Currently, kerning isn't taken into account, which means the lines can overlap a little, leading to small optical glitches. - Some (broken) fonts use the wrong winding direction. In this case, the FreeType stroker will only consider the added lines to be "outside" and only stroke the line instead of the whole glyph.
* Fix strdup() string leaksGrigori Goronzy2009-06-271-0/+3
| | | | | On two occassions strings where strdup()'ed but never freed. Fix these two small memory leaks.
* Include ass_utils.h instead of mputils.hGrigori Goronzy2009-06-271-1/+0
|
* Cosmetics: fix a few remaining declarationsGrigori Goronzy2009-06-271-1/+1
| | | | | Fix formatting of a few remaining declarations missed in the first cleanup.
* Rename mp_msg to ass_msgGrigori Goronzy2009-06-271-8/+8
|
* Reindent all source code.greg2009-06-201-242/+266
| | | | | | | | | | | | | | | Reindent complete source code (*.c, *.h) with indent, the exact command line being: indent -kr -i4 -bap -nut -l76 *.c *.h From now on, new code should use (more or less) K&R style, only spaces and no tabs, 4 spaces indent width. Avoid long lines. Fix function declaration pointer spacing. Remove spaces that were added to many function declarations by indent, like some_func(foo_t * bar). Fix indenting of macros in ass.c
* Remove cache globals; move cache data into a separate cache_store structgreg2009-06-191-3/+3
| | | | that is part of ass_renderer.
* Add a missing check for a NULL return value.eugeni2009-06-161-0/+2
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29367 b3059339-0415-0410-9bf9-f77b7e298cf2
* whitespace cosmetics: Remove all trailing whitespace.diego2009-05-131-9/+9
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29305 b3059339-0415-0410-9bf9-f77b7e298cf2
* Treat -font/-subfont as Fontconfig pattern in libass.eugeni2009-03-081-1/+2
| | | | | | Patch by Adrian Stutz (adrian sttz ch). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28895 b3059339-0415-0410-9bf9-f77b7e298cf2
* Rename font-related preprocessor directives.diego2008-08-071-1/+1
| | | | | | | Switch them from a HAVE_ to a CONFIG_ prefix. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27425 b3059339-0415-0410-9bf9-f77b7e298cf2
* Speak of libass instead of MPlayer in the libass license headers.diego2008-05-141-4/+4
| | | | | | | | We already use LIBASS_ prefixes for the multiple inclusion guards. Thus libass can be considered separate enough to warrant this. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26770 b3059339-0415-0410-9bf9-f77b7e298cf2
* Use standard license header.diego2008-05-131-16/+18
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26755 b3059339-0415-0410-9bf9-f77b7e298cf2
* Do not try to guess font metrics based on its bounding box.eugeni2008-01-121-8/+2
| | | | | | | | | It was originally a workaround for fonts with bad ascender/descender values, but it breaks display of some otherwise valid fonts (bugzilla 987), so reverted. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25688 b3059339-0415-0410-9bf9-f77b7e298cf2
* Cosmetics: fix indentation after last commit.eugeni2007-10-251-6/+6
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24856 b3059339-0415-0410-9bf9-f77b7e298cf2
* Check return value of add_face.eugeni2007-10-251-0/+2
| | | | | | | | | This fixes segfault when reselecting fonts and the new font could not be loaded (because of a bad font file, or too many font faces already loaded). Patch by Glen Nakamura, glen at imodulo dot com. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24855 b3059339-0415-0410-9bf9-f77b7e298cf2
* Don't apply windows-like font scaling if hhea or os2 tables contain invalideugeni2007-08-031-2/+6
| | | | | | | metrics. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24003 b3059339-0415-0410-9bf9-f77b7e298cf2
* Workaround for fonts with zero ascender/descender in horizontal header.eugeni2007-08-031-0/+20
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24002 b3059339-0415-0410-9bf9-f77b7e298cf2
* Factor out common code from ass_font_new and ass_font_reselect.eugeni2007-08-031-58/+46
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24001 b3059339-0415-0410-9bf9-f77b7e298cf2
* More simple and correct font reselection.eugeni2007-08-031-11/+3
| | | | | | | | | Since ass_font_t contains a list of font faces, there is no need to select the face with maximum charset coverage each time. It is enough to select any face with the required glyph. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24000 b3059339-0415-0410-9bf9-f77b7e298cf2
* Fix #if condition.eugeni2007-05-201-1/+1
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23358 b3059339-0415-0410-9bf9-f77b7e298cf2
* FT_Request_Size does not exist in FreeType 2.1.*. Fallback to FT_Set_Char_Size.eugeni2007-05-201-0/+4
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23357 b3059339-0415-0410-9bf9-f77b7e298cf2
* Correct font size in libass.eugeni2007-05-191-5/+26
| | | | | | | | | Values from TrueType OS/2 table are used to reproduce VSFilter behaviour. Magic 0.8 multiplier and scaling for the fractional part of font size are not needed anymore. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23346 b3059339-0415-0410-9bf9-f77b7e298cf2
* Support fractional font sizes.eugeni2007-05-141-6/+8
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23318 b3059339-0415-0410-9bf9-f77b7e298cf2
* Limit ass_font_set_transform to nonrotating transformations.eugeni2007-05-141-12/+18
| | | | | | | | Rotations are not needed here (they are performed in transform3d) and they disable autohinter. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23317 b3059339-0415-0410-9bf9-f77b7e298cf2
* In ass_font_new, allocate temporary ass_font_t on stack and return the pointereugeni2007-05-031-19/+17
| | | | | | | | | | | to cache-owned copy. This fixes leaked ass_font_t struct. Without this, font pointers obtained from ass_font_new() and ass_font_cache_find() were different, and bitmaps rendered with the first one could not be located in the cache later. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23230 b3059339-0415-0410-9bf9-f77b7e298cf2
* Add -ass-hinting option for setting font hinting method.eugeni2007-04-271-2/+10
| | | | | | | | | It is possible to separately configure hinting for scaled and unscaled osd. The default is native hinter for unscaled osd (only vo_gl at this point), no hinting for vf_ass. git-svn-id: svn://svn.m