Skip to content

Port GimpText to GimpFont and fix font serialization/deserialization in xcf files

Idriss Fekir requested to merge user062/gimp:gimpfont_in_gimptext into master

After MR !1011 (merged), In order for xcf files saving/loading to work properly when containing a text layer, font info has to be inserted in the xcf file, so that when loading the file, the proper font can be picked.

Quoting @Jehan:

  • Create a GIMP_CONFIG_PROP_FONT (which is basically a normal property which contains GIMP_CONFIG_PARAM_FLAGS meaning that a property is serializable).

  • Update GimpText so that "font" is a GimpFont (using the now created GIMP_CONFIG_PROP_FONT) and fix the various calls making use of this property.

  • Once this is done your XCF will contain a parasite using fully featured font info. Except that it's not readable until you also implement deserialization which should deserialize all the above fields and search if any font exist which match these.

  • So now you got it right: you can save and load a XCF file with proper font… except it won't work with old XCF and we don't want to break compatibility! So you need to add a layer of compatibility by modifying the deserialization code to handle both old and new serialized contents. If it's the old syntax, just search for a font with a given name as "best guess". With new syntax, you can do better and search more accurately.

  • (De)Serialize fonts in the pango markup.

Edited by Idriss Fekir

Merge request reports

Loading