Commit Graph

70 Commits

Author SHA1 Message Date
Idriss Fekir 0f32312e26 widgets: Fix error on text color selection
Resolves #11003

GeglColor defaults to NULL rather than black like
GimpRGB. When selecting text with two or more colors
in the total selection, this causes NULL to be passed
to gimp_color_button_set_color () which throws an error.
This patch resolves the issue by setting GeglColor to
black if it's NULL before the call.
2024-03-06 06:37:13 -05:00
Jehan 47c1cb8504 app: use GeglColor in GimpTextBuffer and GimpTextTag.
It's actually not enough to get proper colors for inner text tags. The
main color is correct, but color for subtext is currently not managed.
This must be fixed.
2024-02-11 23:28:04 +01:00
Jehan 916d032f67 app, libgimp*, plug-ins: GimpColorButton now space-invaded.
The invasion extended to some core widgets too, in particular GimpColorPanel (a
subclass of GimpColorButton). There was quite a lot of code depending on these
widgets.
2024-02-11 23:28:03 +01:00
Jehan e992ca3e51 app, libgimp, pdb, plug-ins: GimpText* using GeglColor.
One of the big improvement in this commit is that text layers are now much
better at space accuracy. They were already space-aware, yet rendered as sRGB u8
only before being converted to the image's space. It means that text layers had
the following limitations:

* Any color out of sRGB gamut were trimmed.
* Precision was always 8-bit (even if the image was high-bit depth).

Now GimpTextLayout keeps track of its source space (for RGB and CMYK only, this
won't be as easy when we will support more backend, since Cairo has only RGB
support for image data) and the image TRC (in case it bypasses the color space's
TRB) and it draws within this gamut and space.
It means first that we are not limited to sRGB colors; we will draw text main
color in the full image gamut, with still 2 remaining limitations:

* Unbounded colors are impossible because Pango format (to color text) uses
  hexadecimal (so even with half/float images, you can't draw out-of-gamut text
  unfortunately).
* Main color precision is still 8-bit, yet a tiny bit better than before as we
  at least follow TRC (so we avoid some of the precision loss when converting,
  even though the bit-depth is still the biggest loss).

The outline color on the other hand is drawn through Cairo API entirely, in
float. This means that the outline color will now be without any precision loss.

Note that this depends on CAIRO_FORMAT_RGBA128F which is only available since
Cairo 1.17.2 which is not in Debian bookworm (our current baseline for GIMP
3.0). It means that the old precision will still happen with older Cairo
version, as determined by #if code at compilation.
2024-02-11 23:28:02 +01:00
Idriss Fekir a966297498 Port GimpText to GimpFont
In GimpText, The font used to be stored as a string containing its name,
Now, it is stored as a GimpFont object, which makes more sense and makes
operations on fonts easier (such as serialization).
2023-09-12 14:23:40 +00:00
Idriss Fekir 5972d8d97f Implement support for custom fonts
Remap font names to unique generated names
so that pango sees them.

keep the font name for display and the internal
name for everything else.

* Fonts are still broken When exporting to pdf

* Not sure if xcf files would be usable on other systems
maybe use hash of psname internally instead

* Not sure if plug-ins using text layer work correctly
(do they use internal font name or the actual name?)
2023-07-25 21:16:04 +02:00
Jehan 2748dfe83c app: fix coding style for and factorize MR !269.
Fixing broken coding style and factorize the code to avoid redundant
calls, in a separate commit as the contributor hasn't responded for
nearly 2 years. Also no need to get the character count as -1 offset is
equivalent to point after last character (or alternatively we could have
used gtk_text_buffer_get_end_iter()).

I had raised some more questions on a possible better implementation (or
maybe not), but since the discussion never happened, let's just push
as-is. It still improves things and the whole text editor should be
revamped some day anyway.

The MR commit (i.e. previous commit) fixes the specific case when
changing font size with no text selected (changing the size of the whole
text).
2022-03-25 22:09:10 +01:00
houda 2c3e62d926 Allow editing text size when using the editor window 2022-03-25 22:09:10 +01:00
Lukas Oberhuber e41250394d gimptextstyleeditor: Fix crash on exit
Messages were being sent to editor after editor had been destroyed. This
stops that.
2021-12-22 12:58:32 +00:00
Ell 8954d1f386 libgimpwidgets, app, plug-ins: use GimpSpinButton everywhere
Replace all direct uses of GtkSpinButton with GimpSpinButton, so
that its modified behavior extends to all our spin buttons.
2019-03-09 07:28:52 -05:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Michael Natterer 80997a8646 Remove most GTK_ADJUSTMENT() and (GtkAdjutment *) casts
they are obsolete in GTK+ 3.x because GtkAdjustment cannot be passed
around as GtkObject any longer, GtkObject is gone.
2018-06-24 18:15:16 +02:00
Michael Natterer 5ee48e9ef3 app: undeprecate GimpTextStyleEditor, and set a CSS name for themeing 2018-06-18 00:59:11 +02:00
Michael Natterer e88fb8e9c7 app: remove all old font management code, switch to GimpFontFactory[View]
Biggest change in this commit is reordering stuff in GimpContext
because GimpFont is now a first class citizen.
2018-06-03 01:27:06 +02:00
Simon Budig 72e63887ba libgimpwidgets: convert GimpSizeEntry to a GtkGrid. 2018-05-20 21:06:32 +02:00
Michael Natterer 822a7228c4 Bug 794221 - Recently used colors on text don't get added to the color history
Add signal GimpTextBuffer::color-applied which is emitted when text is
inserted or when color is applied to a span of text.

In GimpTextTool, connect to the signal and update the global color
history.

Unrelated: rename gimp_text_tag_get_color() to get_fg_color() and add
boolean return values to get_fg_color() and get_fg_color() which
indicates if a color is set on the tag at all. This ended up unneeded
in the fix but is an improvement regardless.
2018-03-23 14:19:01 +01:00
Michael Natterer 539927ebfa app: replace all g_assert() by the newly added gimp_assert()
which is just a #define to g_assert for now, but can now easily be
turned into something that does some nicer debugging using our new
stack trace infrastructure. This commit also reverts all constructed()
functions to use assert again.
2018-02-11 22:23:10 +01:00
Michael Natterer 0cb3e75f79 app: use a lot of g_clear_object() and g_clear_pointer()
More than 2000 lines of code less in app/, instead of

if (instance->member)
  {
    g_object_unref/g_free/g_whatever (instance->member);
    instance->member = NULL;
  }

we now simply use

g_clear_object/pointer (&instance->member);
2017-07-15 18:42:44 +02:00
Michael Natterer dda54c1df8 Deprecate stock items for good and change all icon defines to GIMP_ICON_*
Try to sort all GIMP_ICON_* defines into FDO categories like in
https://specifications.freedesktop.org/icon-naming-spec/latest/ar01s04.html

Add defines for all icons we override, rename some icons to their FDO
standard names, and mark the ones we duplicate with a comment so we
don't forget to rename those to standard names in 3.0.
2017-03-05 16:01:59 +01:00
Jehan 6c674e973c app, libgimp*, plug-ins, icons: revert icon names into freedesktop...
... standard icon names and GTK+ icon names as second choice.
We should only use GIMP specific icon names as last resort, when there
is no standard or GTK+ names dedicated to the function.
This is made possible thanks to commit 3cc77b0.

s/gimp-document-recent/document-open-recent/
s/gimp-indent/format-indent-more/
s/gimp-next/go-next/
s/gimp-previous/go-previous/
s/gimp-save/document-save/
s/gimp-save-as/document-save-as/
s/gimp-revert/document-revert/
s/gimp-open/document-open/
s/gimp-document-recent/document-open-recent/
s/gimp-quit/window-close/ ou s/gimp-quit/application-exit/
s/gimp-warning/dialog-warning/
s/gimp-edit-clear/edit-clear/

s/gimp-justify-.*/gtk-justify-.*/
s/gimp-font/gtk-select-font/
s/gimp-color-palette/gtk-select-color/
s/gimp-cancel/gtk-cancel/
2016-09-03 15:49:29 +02:00
klausstaedtler 312691312d icons: Bug 759904
add
gimp-shred

patch: replace "edit-clear" by "gimp-shred" (or GIMP_STOCK_SHRED)

gimp/app/actions/documents-commands.c:                                    "edit-clear",
gimp/gimp/app/actions/edit-actions.c:  { "edit-undo-clear", "edit-clear",
gimp/app/actions/documents-actions.c:  { "documents-clear", "edit-clear",
gimp/app/dialogs/preferences-dialog.c:  button = prefs_button_add ("edit-clear", shred

add
gimp-edit-clear

patch: replace "edit-clear" by "gimp-edit-clear" (or GIMP_STOCK_EDIT_CLEAR)

gimp/app/actions/text-editor-actions.c:  { "text-editor-clear", "edit-clear",
gimp/app/actions/edit-actions.c:  { "edit-clear", "edit-clear",
gimp/app/actions/error-console-actions.c:  { "error-console-clear", "edit-clear",
gimp/app/actions/text-tool-actions.c:  { "text-tool-clear", "edit-clear",
gimp/app/widgets/gimptextstyleeditor.c:  image = gtk_image_new_from_icon_name ("edit-clear", GTK_ICON_SIZE_MENU);
gimp/app/dialogs/preferences-dialog.c:  button = prefs_button_add ("edit-clear",


patch
gimpicons.c
gimpicons.h

update
icon-list.mk
2016-06-10 13:50:45 +02:00
Michael Natterer ace40d125d Bug 735891 - color areas in the color picker info window are half transparent
Add code to GimpOverlayChild which can render arbitrary children of
the widget fully opaque, ignoring the configured opacity.

Add gimp_widget_get,set_fully_opaque() which gets/sets a per-widget
boolean flag to trigger that code.

Set the color picker's and the text tool style widget's color areas to
fully opaque.
2015-10-27 21:41:32 +01:00
Michael Natterer 981abdffe1 app: the icon's name is format-text-strikethrough not format-edit-strikethrough 2014-05-16 20:47:41 +02:00
Michael Natterer 65a65947d9 app, libgimp: replace GTK_STOCK_FOO by icon names
unless it's a stock ID used for an action button, will address that
later.
2014-05-11 22:49:22 +02:00
Michael Natterer 0d2d1c3752 app: port most of app's GUI from stock IDs to icon names
There is still quite some stock ID rendering around, stay tuned...
2014-05-07 15:30:38 +02:00
Jehan 53d2059bd8 Bug 417704: font name for missing font is given in the font entry's help message.
When a font is missing, the name of the expected font will be displayed in the
help message through the text style editor with an explanatory message.
2013-05-17 20:59:46 +09:00
Michael Natterer 804313bbec Bug 694417 - GIMP Segmentation Faults (Segfault, Crash) after Changing Color...
Don't pass a NULL pointer to gimp_text_buffer_get_font_tag() because
it is dereferenced in a call to strcmp().

gimp_context_get_font_name() returns NULL when the selected text
includes spans with different fonts. Add the same special handling for
spans with inconsistent sizes too, and add comments that we should
have the same for the color.

Original patch from Massimo Valentini.
2013-04-21 17:51:08 +02:00
Jehan 20c86f821d Bug 689523: data bootstrap initial values in the text style editor at construction.
This was causing first a visual issue where the style editor UI would
show no default font/size/style at instanciation, but even a crash
when the user would change the font size or style (bold, italic...)
from this UI before selecting a font or writing a text.
2012-12-12 12:36:24 +09:00
Michael Natterer 908f727f0a Chain up unconditionally in GObject::constructed()
It's supported since GLib 2.28.
2012-11-12 21:51:22 +01:00
Michael Natterer f71afd245f app: remove redundant code from the last commit 2012-11-10 00:07:23 +01:00
Michael Natterer abd2e78bdf Bug 683011 - Text tool discards text attributes in the on-canvas dialog...
When font, size or color were changed, set the text buffer's current
insert_tags just as we already do for the bold, italic etc. toggle
buttons.  Changed gimp_text_style_editor_list_tags() to also return
the tags for font, size or color.
2012-11-09 23:06:45 +01:00
Massimo Valentini a29c096614 app: initialize also GimpRGB's alpha component
Conditional jump or move depends on uninitialised value(s)
==29000==    at 0x4C33CBC: gimp_color_area_set_color (gimp/libgimpwidgets/gimpcolorarea.c:425)
==29000==    by 0x4C3505B: gimp_color_button_set_color (gimp/libgimpwidgets/gimpcolorbutton.c:642)
==29000==    by 0x5DA5BE: gimp_text_style_editor_set_color (gimp/app/widgets/gimptextstyleeditor.c:700)
==29000==    by 0x5DB0D4: gimp_text_style_editor_update_idle (gimp/app/widgets/gimptextstyleeditor.c:1090)
==29000==    by 0x57E9E95: gdk_threads_dispatch (gtk-2-24/gdk/gdk.c:512)

Steps to reproduce:

<Ctrl>N <Enter> T
click on canvas
type something

select the text entered and change its color using
the color button from the text style editor
2012-03-13 20:44:47 +01:00
Michael Natterer 2414301799 Review the last few commits and apply some style fanaticism
some completely unrelated,
2012-02-07 20:36:55 +01:00
Massimo Valentini 39368a410d plugged memory leaks 2012-02-07 17:32:02 +01:00
Michael Natterer dcf84f3910 app: set the correct resolution on the text style overlay's size entry 2011-12-03 23:56:51 +01:00
Michael Natterer 3e336199b9 app: use gtk_box_new() 2011-09-30 11:29:11 +02:00
Michael Natterer a90961ef4a app: make GimpTextStyleEditor look a bit nicer
Add some spacing and move the color button to the bottom.
2011-03-21 01:00:37 +01:00
Michael Natterer 6d97fd3887 app: use a size entry instead of a spinbutton in GimpTextStyleEditor
so it's finally clear what unit the text size has.
2011-03-20 12:37:01 +01:00
Michael Natterer 140c9aae91 Bug 625273 - Insert Font and font-size into the Texteditor's Menubar
If the cursor position (or the current selection), doesn't contain any
font, font-size or color tags, display the default values from the
GimpText object instead of "nothing". Still display nothing if the
selection contains different fonts, sizes or colors.
2011-03-18 22:13:34 +01:00
Michael Natterer ecbfb4a9e8 app: add a GimpText property and construct param to GimpTextStyleEditor
which will be used to get default values from.
2011-03-18 21:16:53 +01:00
Michael Natterer 90058cded7 app: add missing tooltips in the text style overlay widget 2011-03-14 13:05:30 +01:00
Michael Natterer 4186d0114f app: add comment to improve readability 2011-01-20 20:26:34 +01:00
Michael Natterer 202124c438 app: implement GObject::constructed() instead of ::constructor() 2011-01-14 09:38:46 +01:00
Michael Natterer b9a7c121a4 app: don't inherit from GtkHBox or GtkVBox
Instead, inherit from GtkBox directly and set the orientation in
init().  Replace more gtk_container_add() by gtk_box_pack_start() in
the reparented classes.
2010-10-30 15:44:46 +02:00
Michael Natterer 68b380fa4e app: forgot to check for "color_differs" for breaking out of a loop
Shouldn't change anything, just be slightly faster in some cases.
2010-10-02 19:51:49 +02:00
Michael Natterer 81cfb44047 app: use a GimpColorPanel not a GimpColorButton in the text style editor
so we get proper color previews in the popup menu.
2010-09-29 21:14:51 +02:00
Michael Natterer bfce429d24 app: some minor fixes in GimpTextStyleEditor
- initialize all of the color strust in init().
- simplify font_changed().
2010-09-02 00:42:59 +02:00
Michael Natterer ad819263af Bug 620674 - Adding support for multi-colored text layer
Apply slightly modified patch from Barak Itkin that adds colors for
text spans plus GUI to edit these colors.
2010-09-02 00:20:04 +02:00
Michael Natterer 67ba62154e app: fix and improve text style overlay keyboard interaction
- app/widgets/gimptextstyleeditor.c: don't block all key events so
  they can reach the canvas.

- app/display/gimpdisplayshell-callbacks.c: instead, ignore canvas key
  events when the canvas has no focus.

This fixes navigating out of the text style editor with TAB, moving
focus to the canvas. I have no clue why navigating *between* the
widgets in the style editor doesn't work.
2010-05-12 19:00:18 +02:00
Michael Natterer a6b2d102f3 app: add utility functions for getting GtkTextTag properties
and also #define the names of the properties we (ab)use, so we don't
have to use magic strings all over the place, and we don't have to use
g_object_get() either.
2010-04-03 18:04:50 +02:00