summaryrefslogtreecommitdiff
path: root/pango/pangofc-fontmap.c
Commit message (Collapse)AuthorAgeFilesLines
* fc: Avoid extra copies of family namesMatthias Clasen2022-08-271-6/+19
| | | | | | | | When we create a PangoFcFont from an FcPattern, we know that the pattern will live as long as the font and the font description we create at the same time. So there is no need to copy the strings we get out of the pattern.
* fc: Notify :n-items when neededlistmodel-propertiesMatthias Clasen2022-06-101-0/+2
| | | | | Notify :n-items when reloading the configuration, since that may change the number of families.
* Drop uses of pango_coverage_ref/unrefMatthias Clasen2022-01-101-3/+3
| | | | Just use g_object_ref/unref.
* tracing: Fix the definesMatthias Clasen2021-12-251-6/+18
| | | | | | | | We want to define pango_trace_mark to nothing. This reveals that we've never compiled these calls out before, and there are some warnings to be fixed in that case.
* fc: CleanupMatthias Clasen2021-12-181-1/+0
| | | | | | Stop using fcfont->matrix. This is just a redundant copy of the matrix that is already available in the font key. Just use that.
* fc: Drop unnecessary ifdefsMatthias Clasen2021-11-081-27/+11
| | | | We are requiring a new enough fontconfig now.
* fc: Implement the other casing variantsMatthias Clasen2021-11-071-5/+66
| | | | | | Pass all the PangoVariant values through the FcPattern by translating them into suitable OpenType features in the pattern.
* fc: Implement PANGO_VARIANT_SMALL_CAPSMatthias Clasen2021-11-051-0/+21
| | | | | | | Arrange for PANGO_VARIANT_SMALL_CAPS to be translated into the OpenType feature smcp=1 and back. This makes small caps survive a roundtrip from font description to font and back.
* Fix a typoMatthias Clasen2021-10-231-1/+1
|
* fcfont: CosmeticsMatthias Clasen2021-08-281-1/+1
| | | | Remove a few duplicated lines and typos.
* fcfontmap: Silence compiler warningsMatthias Clasen2021-08-221-0/+2
|
* font-desc: Use local volatile double values to store sizesMarco Trevisan (TreviƱo)2021-07-211-1/+7
| | | | | | | | | | | | | | | | | | | | Under i386 multiplying double and integer values and cast it to integer may end up to compute the wrong value when only 387 FPU is used, because the temporary value will be stored in a register whose precision isn't good enough. And so, some multiplications which are expected to produce an integer, will actually return a truncated value, that will be eventually floored. An example is 1.2 * 12800 that is clearly 15360.0, but will produce 15359 when casted to int in the said i386 environment. So use a temporary double variable to ensure that we do this computation in the double scope, before casting to int. And this will avoid using the said register, even when using more aggressive optimizations (as per marking the local variable volatile). Fixes: https://gitlab.gnome.org/GNOME/pango/-/issues/580
* Quiet a compiler warningMatthias Clasen2021-07-101-4/+6
| | | | | Another case where using a GPtrArray instead of a GArray of pointers is nicer.
* Remove an obsolete version checkMatthias Clasen2021-07-101-3/+0
| | | | | We require harbuzz to be at least 2.0.0 for a while now. No need to check that version at runtime.
* fontconfig: Ignore woff fontswoff-offMatthias Clasen2021-07-091-1/+9
| | | | | | | | harfbuzz creates a face, but doesn't seem to find any glyphs in woff fonts, so filter them out. Sadly, fontfonfig does not have useful format information about this, so we need to crudely filter by filename.
* Use an enum instead of numeric values for fc_initializedFederico Mena Quintero2021-07-011-5/+16
|
* Use atomic reference counting for PangoFcPatternsFederico Mena Quintero2021-07-011-18/+3
| | | | | | | There was a data race in accessing the ref_count of this struct; now with g_atomic_rc_box it's done properly across threads. Fixes https://gitlab.gnome.org/GNOME/pango/-/issues/571
* Extract function to free the contents of a PangoFcPatternsFederico Mena Quintero2021-07-011-7/+14
|
* fc: Drop a broken optimizationdrop-broken-optimizationMatthias Clasen2021-07-011-3/+0
| | | | | | | | | We were trying to cut short the wait for FcInit in pango_fc_font_map_set_config. But there was a thinko: while it is true that the fontmap which had set_config called on it does not need to wait for FcInit anymore, other threads fontmaps still do. Instead of making this more complicated, just drop the optimization.
* Clarify docs of pango_fc_fontmap_get_configget-config-docsMatthias Clasen2021-07-011-1/+2
| | | | | | | The return value is owned by Pango. transfer=none doesn't really work for non-GObject types, so just spell it out. Fixes: #572
* docs: Reduce redundancydocs-cleanupsMatthias Clasen2021-05-201-1/+1
| | | | | | Remove a boatload of "or %NULL" from nullable parameters and return values. gi-docgen generates suitable text from the annotation that we don't need to duplicate.
* fc: Don't use GTask for threadingfix-lilypond-leakMatthias Clasen2021-05-101-31/+24
| | | | | | | | | | GTask requires a running mainloop, otherwise we end up leaking task objects and their associated data. This is not a problem in GTK applications, but it does show up in batch operation, such as with lilypond. To avoid this problem, use plain threads.
* Add some NULL checksadd-null-checkdsMatthias Clasen2021-05-091-1/+2
| | | | | | | Originally suggested by Philipp Withnall in https://bugzilla.gnome.org/show_bug.cgi?id=778655 Fixes: #268
* Fix hangs that people have observedfix-deadlocks2Matthias Clasen2021-03-311-2/+1
| | | | | | | We were erroneously setting fc_initialized back to 1 in one place. But now 1 means 'wait for the FcInit thread that is already underway. Setting it to 2 restores the intention.
* Revert "Merge branch 'fix-deadlocks' into 'master'"revert-1fedc11aMatthias Clasen2021-03-311-1/+2
| | | This reverts merge request !309
* Fix hangs that people have observedfix-deadlocksMatthias Clasen2021-03-311-2/+1
| | | | | | | We were erroneously setting fc_initialized back to 1 in one place. But now 1 means 'wait for the FcInit thread that is already underway. Setting it to 2 restores the intention.
* Only initialize fontconfig oncefcinit-onceMatthias Clasen2021-03-271-13/+25
| | | | | | | When multiple fontmaps are created in quick succession, we would send off a thread to call FcInit for each one of them, which is not really necessary. Just do it once.
* Use g_memdup2()memdup2Matthias Clasen2021-03-181-2/+2
| | | | | The g_memdup() function is replaced by a safer version in newer versions of GLib.
* Fix placement of marks in upright vertical text.Tavmjong Bah2021-03-171-3/+2
|
* pangofc: Tweak docsMatthias Clasen2021-03-111-34/+47
| | | | Convert link syntax and add summaries.
* docs: Port PangoFc apis to the new doc formatMatthias Clasen2021-03-111-78/+81
| | | | | | Replace gtk-doc'isms and use gi-docgen links instead. Cross-gir links are still an open issue.
* docs: Replace lots of vestigial xml markupMatthias Clasen2021-03-111-10/+2
| | | | | We want to use pure markdown, since docbook is going away as the intermediate format.
* fc: Fix an ordering issuefontmap-thread-fixMatthias Clasen2021-02-241-0/+7
| | | | | | | | | | | | | With the recently introduced threading for fontconfig calls, we introduced an ordering issue where the fontmap may die before an outstanding thread returns, and then the code that unrefs the pattern object tries to remove it from the fontmap cache. Prevent that by giving each thread a strong ref on the fontmap while it runs. Fixes: #537
* fontconfig: Add some trace marksspeed-up-format-filteringMatthias Clasen2021-02-221-3/+41
| | | | | Add sysprof marks around the expensive fontconfig calls, and for when we are waiting on them.
* Move FcInit call to a threadMatthias Clasen2021-02-221-0/+50
| | | | | | | | | | With a big fontconfig configuration, FcInit takes some time (60-100ms on my system). Doing this work off the main thread can potentially avoid blocking other work. To take advantage of this, GTK calls pango_cairo_font_map_get_default() early to initiate the creation of a fontmap, thereby triggering the FcInit() call.
* Move FcFontMatch and FcFontSort calls to a threadMatthias Clasen2021-02-221-35/+152
| | | | | | | | | | fontconfig is thread-safe, so we can do calls that can take several milliseconds to complete in a thread. This patch does that for FcFontSetMatch and FcFontSetSort. It is a win, at least for FcFontSetSort, since it reduces the time that the main thread spends in pango_fc_patterns_get_font_pattern for i > 0 from around 10 to 6 milliseconds.
* Use FcFontSetList instead of FcFontListMatthias Clasen2021-02-221-5/+6
| | | | | | | We have filtered-by-format lists of fonts available now, so we should use them to ensure we always operate on the same set of fonts. Also, fix another case of passing NULL for the config.
* fc: Only do filtering by format onceMatthias Clasen2021-02-221-23/+58
| | | | | | The fontconfig configuration changes rarely, so we can avoid unnecessary work by only doing the filtering by supported formats once, and keeping the result.
* Use the right FcConfig for FcFontListfix-FcConfig-usesMatthias Clasen2021-02-221-1/+1
| | | | | | | | | Passing NULL for a config argument in a fontconfig api means we are using the default configuration, which may be different from the one the fontmap is supposed to be using. Fix an instance of this in pango_fc_face_list_sizes.
* Use the right FcConfig for FcRenderPrepareMatthias Clasen2021-02-221-1/+1
| | | | | | | | | Passing NULL for a config argument in a fontconfig api means we are using the default configuration, which may be different from the one the fontmap is supposed to be using. Fix an instance of this in pango_fc_fontset_load_next_font.
* Fix pango_font_describe for Emoji fontsMatthias Clasen2021-01-241-1/+18
| | | | | | | | | | | We are using the size from the FcPattern. For scalable bitmap fonts, this has been scaled to match the requested pixel size. To make a font description that can be turned back into a FcPattern and roundtrip successfully, we need to undo that scaling. Thankfully, fontconfig leaves the pixelsizefixupfactor in the pattern, so it is easy to do. Fixes: #530
* fontconfig: Try harder to find a default faceregular-faceMatthias Clasen2020-11-061-8/+23
| | | | | | | | | | | | Fonts are amazing, and not in a good way. My system has fonts with 0, 1, 2 "Regular" faces. It also has fonts where the "Regular" face is, in fact, bold. So, we need to work even harder to return a reasonable face when asked about the default. We already make a determination of faces that we consider 'regular' when we create the faces initially. Just keep that information for later reuse.
* fontconfig: Try harder to return a default faceMatthias Clasen2020-11-051-3/+7
| | | | | | | | | pango_font_family_get_face() is documented as nullable, so we are technically within our rights to return NULL, but that is unexpected when passing NULL to get the default face, and the family has faces. So, try a little harder by returning the first face if we don't find a face with the name "Regular".
* fc: Sort faces of a familysort-facesMatthias Clasen2020-09-211-0/+28
| | | | | | Make pango_font_family_list_faces() return faces sorted by slant and weight. This makes the font chooser look much less random.
* Merge branch 'ch/83' into 'master'Matthias Clasen2020-09-181-0/+25
|\ | | | | | | | | | | | | Add pango_fc_font_map_set_default_substitute Closes #83 See merge request GNOME/pango!191
| * add pango_fc_font_map_set_default_substituteCaleb Hearon2020-06-131-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | added: pango_fc_font_map_set_default_substitute pango_fc_font_map_default_substitute_changed deprecated: pango_ft2_font_map_set_default_substitute pango_ft2_font_map_changed pango_xft_font_map_set_default_substitute pango_xft_font_map_changed Now PangoCairoFcFontMap will call what is passed to pango_fc_font_map_set_default_substitute when it is time. The deprecated functions make calls to the parent (FC) class now. The user-supplied callbacks are executed in the exact same places as before.
* | pangofc: Add pango_fc_font_get_languagespreferred-languagesMatthias Clasen2020-09-181-1/+55
| | | | | | | | | | | | | | This really belongs into PangoFont, but we're out of room in the PangoFontClass struct for vfuncs, so this will have to remain backend-specific functionality for now.
* | Remove leftover debug codeMatthias Clasen2020-08-231-2/+0
| | | | | | | | | | This #if snuck in as part of efa66e7b634050ef3. No need to keep it around.
* | Don't call FcFontSetSort twiceMatthias Clasen2020-08-151-7/+12
| | | | | | | | | | | | We can do the format filtering on the unsorted font lists. Sorting the same list twice may be fast, but there's still some setup overhead.
* | Speed up font format filteringMatthias Clasen2020-08-151-1/+4
| | | | | | | | | | We were needlessly duplicating patters when we could have just referenced them.