summaryrefslogtreecommitdiffstats
path: root/libass/ass_font.c
Commit message (Collapse)AuthorAgeFilesLines
* fontselect: coretext: allow selection based on PostScript nameStefano Pigozzi2015-07-101-2/+22
| | | | | | | | | | | Up until now fontselect used the face index to identify which font to load from a font collection. While this pretty convenient when using something freetype based like fontconfig, it seems to be somewhat freetype specific. CoreText uses the PostScript name as the unique identifier of a font. This commit allows to use that instead of the index to decide which face to open with FT_New_Face. To use the PostScript name the provider must return a -1 index and the PostScript name.
* Use streamed access for memory fontsGrigori Goronzy2015-07-101-6/+40
| | | | | This is faster in many cases, and more suitable for Windows' GetFontData function.
* Pass family name as path for memory fontsGrigori Goronzy2015-07-101-1/+1
| | | | | This is a bit nicer because we can actually see which physical font has been selected for a certain logical font.
* Memory font supportGrigori Goronzy2015-07-101-23/+8
| | | | | Allow memory fonts with the get_face_data callback. This feature is used for embedded fonts, but can be used by any font provider.
* Use TrueType font weight scaleGrigori Goronzy2015-07-101-1/+1
| | | | | | | | | | fontconfig uses an unusual scale from 0-215 for the font weight. It looks like it is somewhat derived from the typographic scale some font families use, but is still rather nonstandard. Nowadays the TrueType scale from 100-900 seems to be standard. CSS uses it, for example. However, most importantly, VSFilter also uses the TrueType scale. So let's use it in libass, too.
* Add glyph coverage map for embedded fontsGrigori Goronzy2015-07-101-1/+1
| | | | | | Introduce a simple glyph coverage map (created when the font is added) and use it for checking glyph coverage in font selection. This uses a simple linear search at the moment.
* Never add a face twice to an ASS_FontGrigori Goronzy2015-07-101-7/+16
| | | | | | Introduce a unique ID per font face and check it in add_face to make sure we never add a font face twice. This is useful in case the glyph coverage report is unreliable.
* Custom font matching and font sourcesGrigori Goronzy2015-07-101-17/+13
| | | | | | | 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.
* Fix bug in ASS_Outline intrastructureDr.Smile2015-01-221-34/+19
|
* Destroy harfbuzz faces before freetype facesBehdad Esfahbod2014-12-281-2/+2
| | | | | HarfBuzz faces reference the FreeType faces. Destroying FT faces first can cause crash in HB destruction code: https://bugs.freedesktop.org/show_bug.cgi?id=86300
* Replace FT_Outline with ASS_OutlineDr.Smile2014-11-231-18/+119
|
* Check some allocations in strike-through codewm42014-11-141-5/+10
|
* Fix limits.h includesGrigori Goronzy2014-02-171-0/+1
| | | | These were missing in several places. Fixes #50.
* Font metrics: FreeType falls back to sTypoAscender/DescenderOleg Oshmyan2014-02-111-4/+8
| | | | Fixes libass#8.
* Fix compilation with VC++ 2013Thomas Goyne2013-12-121-47/+32
| | | | | | | | | | | For whatever reason FT_Vector points[4] = { ... }; needs to come at the beginning of a scope. Since that block was duplicated, just extract it to a function. This does not include buildsystem support, so actually compiling with VC++ requires creating a project and supplying a config.h file. Signed-off-by: wm4 <wm4@nowhere>
* Added ass_font_index_magic to fix char indexes in weird encodings11rcombs2013-12-061-7/+22
|
* 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.